Skip to content

Commit

Permalink
Update testnet validation period duration and activation age
Browse files Browse the repository at this point in the history
  • Loading branch information
julia-zack committed Jan 2, 2025
1 parent e32131c commit a85f772
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ public Instant getGenesisFederationCreationTime() {
public long getValidationPeriodDurationInBlocks() { return validationPeriodDurationInBlocks; }

public long getFederationActivationAge(ActivationConfig.ForBlock activations) {
return activations.isActive(ConsensusRule.RSKIP383) ? federationActivationAge : federationActivationAgeLegacy;
if (!activations.isActive(ConsensusRule.RSKIP383)) {
return federationActivationAgeLegacy;
}

return federationActivationAge;
}

public long getFundsMigrationAgeSinceActivationBegin() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import co.rsk.bitcoinj.core.NetworkParameters;
import co.rsk.peg.vote.AddressBasedAuthorizer;
import org.bouncycastle.util.encoders.Hex;
import org.ethereum.config.blockchain.upgrades.ActivationConfig;
import org.ethereum.config.blockchain.upgrades.ConsensusRule;
import org.ethereum.crypto.ECKey;

import java.time.ZonedDateTime;
Expand Down Expand Up @@ -35,7 +37,7 @@ private FederationTestNetConstants() {
).map(hex -> ECKey.fromPublicOnly(Hex.decode(hex))).collect(Collectors.toList()));
federationChangeAuthorizer = new AddressBasedAuthorizer(federationChangeAuthorizedKeys, AddressBasedAuthorizer.MinimumRequiredCalculation.MAJORITY);

validationPeriodDurationInBlocks = 80L;
validationPeriodDurationInBlocks = 2000L;

federationActivationAgeLegacy = 60L;
federationActivationAge = 120L;
Expand All @@ -61,4 +63,19 @@ private FederationTestNetConstants() {
public static FederationTestNetConstants getInstance() {
return INSTANCE;
}

@Override
public long getFederationActivationAge(ActivationConfig.ForBlock activations) {
if (!activations.isActive(ConsensusRule.RSKIP383)) {
return federationActivationAgeLegacy;
}

if (!activations.isActive(ConsensusRule.RSKIP419)) {
return federationActivationAge;
}

// after lovell, we have to consider the activation age
// to be more blocks than the validation period duration
return validationPeriodDurationInBlocks + 400L;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.stream.Stream;
import org.bouncycastle.util.encoders.Hex;
import org.ethereum.config.blockchain.upgrades.ActivationConfig;
import org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest;
import org.ethereum.config.blockchain.upgrades.ConsensusRule;
import org.ethereum.crypto.ECKey;
import org.junit.jupiter.params.ParameterizedTest;
Expand Down Expand Up @@ -115,7 +116,7 @@ void getValidationPeriodDuration(FederationConstants constants, long expectedDur
private static Stream<Arguments> validationPeriodDurationArgs() {
return Stream.of(
Arguments.of(MAINNET, 16000L),
Arguments.of(TESTNET, 80L),
Arguments.of(TESTNET, 2000L),
Arguments.of(REGTEST, 125L)
);
}
Expand All @@ -130,22 +131,26 @@ private static Stream<Arguments> fedActivationAgeAndActivationArgs() {
long fedActivationAgeLegacyMainnet = 18500L;
long fedActivationAgeLegacyTestnet = 60L;
long fedActivationAgeLegacyRegtest = 10L;
ActivationConfig.ForBlock activationsPreRSKIP383 = mock(ActivationConfig.ForBlock.class);
when(activationsPreRSKIP383.isActive(ConsensusRule.RSKIP383)).thenReturn(false);
ActivationConfig.ForBlock activationsPreRSKIP383 = ActivationConfigsForTest.hop401().forBlock(0L);

long fedActivationAgeMainnet = 40320L;
long fedActivationAgeTestnet = 120L;
long fedActivationAgeRegtest = 150L;
ActivationConfig.ForBlock activationsPostRSKIP383 = mock(ActivationConfig.ForBlock.class);
when(activationsPostRSKIP383.isActive(ConsensusRule.RSKIP383)).thenReturn(true);
ActivationConfig.ForBlock activationsPostRSKIP383PreRSKIP419 = ActivationConfigsForTest.fingerroot500().forBlock(0L);

long fedActivationAgeTestnetPostLovell = 2400L;
ActivationConfig.ForBlock activationsPostRSKIP419 = ActivationConfigsForTest.all().forBlock(0L);

return Stream.of(
Arguments.of(MAINNET, activationsPreRSKIP383, fedActivationAgeLegacyMainnet),
Arguments.of(TESTNET, activationsPreRSKIP383, fedActivationAgeLegacyTestnet),
Arguments.of(REGTEST, activationsPreRSKIP383, fedActivationAgeLegacyRegtest),
Arguments.of(MAINNET, activationsPostRSKIP383, fedActivationAgeMainnet),
Arguments.of(TESTNET, activationsPostRSKIP383, fedActivationAgeTestnet),
Arguments.of(REGTEST, activationsPostRSKIP383, fedActivationAgeRegtest)
Arguments.of(MAINNET, activationsPostRSKIP383PreRSKIP419, fedActivationAgeMainnet),
Arguments.of(TESTNET, activationsPostRSKIP383PreRSKIP419, fedActivationAgeTestnet),
Arguments.of(REGTEST, activationsPostRSKIP383PreRSKIP419, fedActivationAgeRegtest),
Arguments.of(MAINNET, activationsPostRSKIP419, fedActivationAgeMainnet),
Arguments.of(TESTNET, activationsPostRSKIP419, fedActivationAgeTestnetPostLovell),
Arguments.of(REGTEST, activationsPostRSKIP419, fedActivationAgeRegtest)
);
}

Expand Down

0 comments on commit a85f772

Please sign in to comment.