Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
d2b2523
Changed getRetiringFederation so it returns an optional
julianlen Dec 9, 2025
1e5a8f7
trimmed extra spaces
julianlen Dec 9, 2025
b469e1c
changed a test so it calls getRetiringFederation() once
julianlen Dec 9, 2025
6e16a2a
Added an exception in createMigrationTransaction for an empty retiri…
julianlen Dec 9, 2025
998002f
Deleted useless exception for when a Retiring Fed doesn't exist
julianlen Dec 11, 2025
820594c
renamed originWallet for retiringFederationWallet
julianlen Dec 11, 2025
0239341
deleted retiringFederationOptional and replaced it for a more functio…
julianlen Dec 11, 2025
2810d72
Changed in getFederationFromPublicKey how the retiring federation is …
julianlen Dec 11, 2025
254d2e5
improved messages
julianlen Dec 11, 2025
5521999
changed in getFlyoverFederationFromTxOutputs and getFederationFromTxO…
julianlen Dec 12, 2025
54547e7
renaming federation to retiringFederation in two places
julianlen Dec 12, 2025
a5d7660
extracted response codes in FederationSupportImpl
julianlen Dec 12, 2025
a3401c2
squash creation of fed and turning it optional
julianlen Dec 12, 2025
375510e
Added in FederationSupportImpl .ofNullable and changed imports so the…
julianlen Dec 12, 2025
4ad7973
changed getRetiringFederationWallet() so it returns an Optional
julianlen Dec 9, 2025
788f181
little refactor to avoid asserting if an optional is present
julianlen Dec 11, 2025
3354fb1
changed getRetiringFederationBtcUTXOs to replace the switch with an i…
julianlen Dec 9, 2025
a188de4
improved and fix comments
julianlen Dec 12, 2025
8a4a271
instead of throwing an exception in a test to fail if the optional is…
julianlen Dec 12, 2025
800458b
Merge pull request #3407 from rsksmart/getRetiringFederation-returnsO…
julianlen Dec 12, 2025
a601f1a
Merge pull request #3408 from rsksmart/getRetiringFederationWallet-re…
marcos-iov Dec 12, 2025
c14c88d
changed getActiveFederationBtcUTXOs to replace the switch with an if-…
julianlen Dec 15, 2025
f566223
Merge pull request #3421 from rsksmart/getActiveFederationBtcUTXOs-re…
marcos-iov Dec 16, 2025
46135ab
Moved isInMigrationAge to FederationSupport, added tests to check tha…
julianlen Dec 11, 2025
b6eabd1
unified networkParams to mainnet
julianlen Dec 11, 2025
b3696b2
added isPastMigrationAge to FederationSupport and deleted from Bridge…
julianlen Dec 12, 2025
0831af4
renaming for clarity
julianlen Dec 16, 2025
a9c99bb
changed isPastMigrationAge to isActiveFederationPastMigrationAge, del…
julianlen Dec 16, 2025
01d3657
moved retiring federation balance to migrateFunds
julianlen Dec 15, 2025
6cebcaf
changed the arguments logRetiringFederationBalance receives
julianlen Dec 15, 2025
115bb2a
changed logRetiringFederationBalance to be non-static
julianlen Dec 17, 2025
8484e3a
Merge pull request #3420 from rsksmart/migrateFunds-logs
marcos-iov Dec 17, 2025
5204365
extracted hasBalance variable
julianlen Dec 17, 2025
96d1d31
changed getActiveFederation().getAddress() to getActiveFederationAddr…
julianlen Dec 17, 2025
219cc03
Created the methods getMigrationAgeEnd and getMigrationAgeStart, dele…
julianlen Dec 17, 2025
5bce6b9
improved tests in FederationSupportImplTest
julianlen Dec 17, 2025
557f1c1
improved the log
julianlen Dec 17, 2025
cf854b8
fixed tiny typo
julianlen Dec 17, 2025
6b38534
make the activeFederation close to its use
julianlen Dec 17, 2025
8b21798
fixed log in isActiveFederationPastMigrationAge
julianlen Dec 17, 2025
7d4a317
improved FederationSupportImplTest
julianlen Dec 17, 2025
fc21874
Merge pull request #3418 from rsksmart/isInMigrationAge-refactor
marcos-iov Dec 17, 2025
9a99920
it avoids disconnect twice the btc transaction inputs, it is already …
julianlen Dec 16, 2025
0be5d16
Turn BuildResult in a Record class
julianlen Dec 17, 2025
f2c3369
Merge pull request #3422 from rsksmart/createMigrationTransaction-ret…
marcos-iov Dec 18, 2025
0c3ddef
turn getRetiringFederationThreshold to return an optional
julianlen Dec 19, 2025
24d4709
changed how FEDERATION_NON_EXISTENT is called so it follows the rest …
julianlen Dec 19, 2025
0ede66d
changed test names
julianlen Dec 19, 2025
f7f7545
extracted a variable to thresholdOptional
julianlen Dec 19, 2025
880dde3
Merge pull request #3425 from rsksmart/getRetiringFederationThrehsold…
marcos-iov Dec 19, 2025
386bb03
turn getRetiringFederationSize to return an optional
julianlen Dec 19, 2025
3484c74
fixed a comment and an useless empty line
julianlen Dec 19, 2025
2d49c16
changed how FEDERATION_NON_EXISTENT is called so it follows the rest …
julianlen Dec 19, 2025
c196617
changed test names
julianlen Dec 19, 2025
a98a45b
Merge pull request #3424 from rsksmart/getRetiringFederationSize-opti…
julianlen Dec 22, 2025
94f1ade
turn getRetiringFederationCreationTime to return an optional
julianlen Dec 19, 2025
4562171
rename getEpochTimeBasedOnActivation to getFederationCreationTimeEpoc…
julianlen Dec 22, 2025
408c03b
Merge pull request #3426 from rsksmart/getRetiringFederationCreationT…
julianlen Dec 22, 2025
d6b9f81
turn getRetiringFederationCreationBlockNumber to return an optional
julianlen Dec 19, 2025
a662892
fixed some tests
julianlen Dec 19, 2025
e17a688
Merge pull request #3427 from rsksmart/getRetiringFederationCreationB…
marcos-iov Dec 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 15 additions & 21 deletions rskj-core/src/main/java/co/rsk/peg/Bridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -849,14 +849,7 @@ public byte[] getFederatorPublicKeyOfType(Object[] args) throws VMException {
public Long getFederationCreationTime(Object[] args) {
logger.trace("getFederationCreationTime");
Instant activeFederationCreationTime = bridgeSupport.getActiveFederationCreationTime();

if (!activations.isActive(ConsensusRule.RSKIP419)) {
// Return the creation time in milliseconds from the epoch
return activeFederationCreationTime.toEpochMilli();
}

// Return the creation time in seconds from the epoch
return activeFederationCreationTime.getEpochSecond();
return getFederationCreationTimeEpochBasedOnActivation(activeFederationCreationTime);
}

public long getFederationCreationBlockNumber(Object[] args) {
Expand All @@ -880,13 +873,14 @@ public String getRetiringFederationAddress(Object[] args) {
public Integer getRetiringFederationSize(Object[] args) {
logger.trace("getRetiringFederationSize");

return bridgeSupport.getRetiringFederationSize();
return bridgeSupport.getRetiringFederationSize()
.orElseGet(FederationChangeResponseCode.FEDERATION_NON_EXISTENT::getCode);
}

public Integer getRetiringFederationThreshold(Object[] args) {
logger.trace("getRetiringFederationThreshold");

return bridgeSupport.getRetiringFederationThreshold();
return bridgeSupport.getRetiringFederationThreshold().orElseGet(FederationChangeResponseCode.FEDERATION_NON_EXISTENT::getCode);
}

public byte[] getRetiringFederatorPublicKey(Object[] args) {
Expand Down Expand Up @@ -929,13 +923,12 @@ public byte[] getRetiringFederatorPublicKeyOfType(Object[] args) throws VMExcept
public Long getRetiringFederationCreationTime(Object[] args) {
logger.trace("getRetiringFederationCreationTime");

Instant retiringFederationCreationTime = bridgeSupport.getRetiringFederationCreationTime();

if (retiringFederationCreationTime == null) {
// -1 is returned when no retiring federation
return -1L;
}
Optional<Instant> retiringFederationCreationTime = bridgeSupport.getRetiringFederationCreationTime();
return retiringFederationCreationTime.map(this::getFederationCreationTimeEpochBasedOnActivation)
.orElse((long) FederationChangeResponseCode.FEDERATION_NON_EXISTENT.getCode());
}

private Long getFederationCreationTimeEpochBasedOnActivation(Instant retiringFederationCreationTime) {
if (!activations.isActive(ConsensusRule.RSKIP419)) {
// Return the creation time in milliseconds from the epoch
return retiringFederationCreationTime.toEpochMilli();
Expand All @@ -947,7 +940,8 @@ public Long getRetiringFederationCreationTime(Object[] args) {

public long getRetiringFederationCreationBlockNumber(Object[] args) {
logger.trace("getRetiringFederationCreationBlockNumber");
return bridgeSupport.getRetiringFederationCreationBlockNumber();
return bridgeSupport.getRetiringFederationCreationBlockNumber()
.orElse((long) FederationChangeResponseCode.FEDERATION_NON_EXISTENT.getCode());
}

public Integer createFederation(Object[] args) {
Expand Down Expand Up @@ -1605,8 +1599,8 @@ public static BridgeMethods.BridgeMethodExecutor activeAndRetiringFederationOnly
return (self, args) -> {
boolean isFromActiveFed = BridgeUtils.isFromFederateMember(self.rskTx, self.bridgeSupport.getActiveFederation(), self.signatureCache);

Federation retiringFederation = self.bridgeSupport.getRetiringFederation();
boolean isFromRetiringFed = retiringFederation != null && BridgeUtils.isFromFederateMember(self.rskTx, retiringFederation, self.signatureCache);
Optional<Federation> retiringFederation = self.bridgeSupport.getRetiringFederation();
boolean isFromRetiringFed = retiringFederation.isPresent() && BridgeUtils.isFromFederateMember(self.rskTx, retiringFederation.get(), self.signatureCache);

if (!isFromActiveFed && !isFromRetiringFed) {
String errorMessage = String.format(
Expand All @@ -1625,8 +1619,8 @@ public static BridgeMethods.BridgeMethodExecutor activeRetiringAndProposedFedera
return (self, args) -> {
boolean isFromActiveFed = BridgeUtils.isFromFederateMember(self.rskTx, self.bridgeSupport.getActiveFederation(), self.signatureCache);

Federation retiringFederation = self.bridgeSupport.getRetiringFederation();
boolean isFromRetiringFed = retiringFederation != null && BridgeUtils.isFromFederateMember(self.rskTx, retiringFederation, self.signatureCache);
Optional<Federation> retiringFederation = self.bridgeSupport.getRetiringFederation();
boolean isFromRetiringFed = retiringFederation.isPresent() && BridgeUtils.isFromFederateMember(self.rskTx, retiringFederation.get(), self.signatureCache);

Optional<Federation> proposedFederation = self.bridgeSupport.getProposedFederation();
boolean isFromProposedFed = proposedFederation.isPresent() && BridgeUtils.isFromFederateMember(self.rskTx, proposedFederation.get(), self.signatureCache);
Expand Down
Loading
Loading