Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion internal/chain/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ func TestVerifyShardStateRejectsEmptyShardState(t *testing.T) {
chain := makeFakeBlockChain()
chain.superCommittee = shard.State{}
header := makeFakeHeader()
header.SetEpoch(big.NewInt(currentEpoch))

encodedEmptyState, err := shard.EncodeWrapper(shard.State{}, false)
if err != nil {
Expand Down Expand Up @@ -462,7 +463,7 @@ func TestVerifyHeaderTimestampValidationBackwardCompatibleBeforeFork(t *testing.

parent := blockfactory.NewTestHeader()
parent.SetNumber(big.NewInt(doubleSignBlockNumber))
parent.SetEpoch(big.NewInt(5))
parent.SetEpoch(big.NewInt(4))
parent.SetTime(big.NewInt(time.Now().Unix()))
chain.currentBlock = *types.NewBlockWithHeader(parent)
parent = chain.CurrentHeader()
Expand Down
49 changes: 25 additions & 24 deletions internal/params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,13 +408,13 @@ var (
EIP155Epoch: big.NewInt(0),
S3Epoch: big.NewInt(0),
CrossTxEpoch: big.NewInt(0),
CXMerkleProofReplayFixEpoch: big.NewInt(0),
CXReceiptStateRollbackEpoch: big.NewInt(0),
CXMerkleProofReplayFixEpoch: big.NewInt(5),
CXReceiptStateRollbackEpoch: big.NewInt(5),
MinCommissionPromoPeriod: big.NewInt(10),
ReceiptLogEpoch: big.NewInt(0),
PreStakingEpoch: big.NewInt(0),
CrossLinkEpoch: big.NewInt(2),
RejectShard0CrossLinkEpoch: big.NewInt(0),
RejectShard0CrossLinkEpoch: big.NewInt(5),
StakingEpoch: big.NewInt(2),
QuickUnlockEpoch: big.NewInt(0),
FiveSecondsEpoch: big.NewInt(0),
Expand All @@ -439,37 +439,38 @@ var (
CrossShardXferPrecompileEpoch: big.NewInt(1),
FeeCollectEpoch: big.NewInt(2),
ValidatorCodeFixEpoch: big.NewInt(2),
HIP30Epoch: EpochTBD,
HIP30Epoch: big.NewInt(5),
BlockGas30MEpoch: big.NewInt(0),
MaxRateEpoch: EpochTBD,
TopMaxRateEpoch: EpochTBD,
LeaderRotationInternalValidatorsEpoch: big.NewInt(3),
LeaderRotationExternalValidatorsEpoch: big.NewInt(3),
HIP32Epoch: EpochTBD,
AllowlistEpoch: EpochTBD,
LeaderRotationV2Epoch: EpochTBD,
AllowlistEpoch: big.NewInt(5),
LeaderRotationV2Epoch: big.NewInt(5),
DevnetExternalEpoch: EpochTBD,
TestnetExternalEpoch: EpochTBD,
TimestampValidationEpoch: big.NewInt(0),
DuplicateCrossLinkEpoch: EpochTBD,
ShardStateValidationEpoch: big.NewInt(0),
TimestampValidationEpoch: big.NewInt(5),
DuplicateCrossLinkEpoch: big.NewInt(5),
ShardStateValidationEpoch: big.NewInt(5),
IsOneSecondEpoch: big.NewInt(4),
EIP2537PrecompileEpoch: EpochTBD,
EIP1153TransientStorageEpoch: EpochTBD,
EIP7939CLZEpoch: EpochTBD,
EIP5656McopyEpoch: EpochTBD,
EIP3855Epoch: EpochTBD,
EIP3860Epoch: EpochTBD,
EIP2537PrecompileEpoch: big.NewInt(5),
EIP1153TransientStorageEpoch: big.NewInt(5),
EIP7939CLZEpoch: big.NewInt(5),
EIP5656McopyEpoch: big.NewInt(5),
EIP3855Epoch: big.NewInt(5),
EIP3860Epoch: big.NewInt(5),
EIP6780Epoch: big.NewInt(5),
PragueEpoch: EpochTBD,
EIP8024Epoch: EpochTBD,
ValidatorWrapperAddressBindEpoch: EpochTBD,
SlashExternalStakeDenomFixEpoch: EpochTBD,
RejectDuplicateSlashEvidenceEpoch: big.NewInt(0),
SlashGroupOrderFixEpoch: big.NewInt(2),
BLSProofBindEpoch: EpochTBD,
SlashBallotSignerFixEpoch: big.NewInt(2),
VerifyBeaconHeaderSlashEpoch: EpochTBD,
BloomEpoch: EpochTBD,
EIP8024Epoch: big.NewInt(5),
ValidatorWrapperAddressBindEpoch: big.NewInt(5),
SlashExternalStakeDenomFixEpoch: big.NewInt(5),
RejectDuplicateSlashEvidenceEpoch: big.NewInt(5),
SlashGroupOrderFixEpoch: big.NewInt(5),
BLSProofBindEpoch: big.NewInt(5),
SlashBallotSignerFixEpoch: big.NewInt(5),
VerifyBeaconHeaderSlashEpoch: big.NewInt(5),
BloomEpoch: big.NewInt(5),
}

// AllProtocolChanges ...
Expand Down
107 changes: 107 additions & 0 deletions internal/params/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,110 @@ func TestMainnetTBDFeaturesInactiveBeforeActivation(t *testing.T) {
require.False(t, rules.IsEIP5656Mcopy)
require.False(t, rules.IsCXReceiptStateRollback)
}

func TestBloomEpochConfigured(t *testing.T) {
require.Equal(t, big.NewInt(7420), TestnetChainConfig.BloomEpoch)
require.Equal(t, big.NewInt(53508), PartnerChainConfig.BloomEpoch)
require.Equal(t, big.NewInt(5), LocalnetChainConfig.BloomEpoch)

require.True(t, TestnetChainConfig.BloomEpoch.Cmp(maxEpoch(testnetBloomFeatureEpochs())) >= 0)
require.True(t, PartnerChainConfig.BloomEpoch.Cmp(maxEpoch(devnetBloomFeatureEpochs())) >= 0)
require.True(t, LocalnetChainConfig.BloomEpoch.Cmp(maxEpoch(localnetBloomFeatureEpochs())) >= 0)

for _, epoch := range localnetBloomFeatureEpochs() {
require.Equal(t, big.NewInt(5), epoch)
}
}

func testnetBloomFeatureEpochs() []*big.Int {
return []*big.Int{
TestnetChainConfig.CXMerkleProofReplayFixEpoch,
TestnetChainConfig.CXReceiptStateRollbackEpoch,
TestnetChainConfig.TimestampValidationEpoch,
TestnetChainConfig.SlashExternalStakeDenomFixEpoch,
TestnetChainConfig.DuplicateCrossLinkEpoch,
TestnetChainConfig.ShardStateValidationEpoch,
TestnetChainConfig.RejectShard0CrossLinkEpoch,
TestnetChainConfig.EIP2537PrecompileEpoch,
TestnetChainConfig.EIP1153TransientStorageEpoch,
TestnetChainConfig.EIP7939CLZEpoch,
TestnetChainConfig.EIP5656McopyEpoch,
TestnetChainConfig.EIP3855Epoch,
TestnetChainConfig.EIP3860Epoch,
TestnetChainConfig.EIP6780Epoch,
TestnetChainConfig.EIP8024Epoch,
TestnetChainConfig.RejectDuplicateSlashEvidenceEpoch,
TestnetChainConfig.AllowlistEpoch,
TestnetChainConfig.LeaderRotationV2Epoch,
TestnetChainConfig.SlashGroupOrderFixEpoch,
TestnetChainConfig.ValidatorWrapperAddressBindEpoch,
TestnetChainConfig.BLSProofBindEpoch,
TestnetChainConfig.SlashBallotSignerFixEpoch,
TestnetChainConfig.VerifyBeaconHeaderSlashEpoch,
}
}

func devnetBloomFeatureEpochs() []*big.Int {
return []*big.Int{
PartnerChainConfig.CXMerkleProofReplayFixEpoch,
PartnerChainConfig.CXReceiptStateRollbackEpoch,
PartnerChainConfig.TimestampValidationEpoch,
PartnerChainConfig.SlashExternalStakeDenomFixEpoch,
PartnerChainConfig.DuplicateCrossLinkEpoch,
PartnerChainConfig.ShardStateValidationEpoch,
PartnerChainConfig.RejectShard0CrossLinkEpoch,
PartnerChainConfig.EIP2537PrecompileEpoch,
PartnerChainConfig.EIP1153TransientStorageEpoch,
PartnerChainConfig.EIP7939CLZEpoch,
PartnerChainConfig.EIP5656McopyEpoch,
PartnerChainConfig.EIP3855Epoch,
PartnerChainConfig.EIP3860Epoch,
PartnerChainConfig.EIP6780Epoch,
PartnerChainConfig.EIP8024Epoch,
PartnerChainConfig.RejectDuplicateSlashEvidenceEpoch,
PartnerChainConfig.LeaderRotationV2Epoch,
PartnerChainConfig.SlashGroupOrderFixEpoch,
PartnerChainConfig.ValidatorWrapperAddressBindEpoch,
PartnerChainConfig.BLSProofBindEpoch,
PartnerChainConfig.SlashBallotSignerFixEpoch,
PartnerChainConfig.VerifyBeaconHeaderSlashEpoch,
}
}

func localnetBloomFeatureEpochs() []*big.Int {
return []*big.Int{
LocalnetChainConfig.CXMerkleProofReplayFixEpoch,
LocalnetChainConfig.CXReceiptStateRollbackEpoch,
LocalnetChainConfig.TimestampValidationEpoch,
LocalnetChainConfig.SlashExternalStakeDenomFixEpoch,
LocalnetChainConfig.DuplicateCrossLinkEpoch,
LocalnetChainConfig.ShardStateValidationEpoch,
LocalnetChainConfig.RejectShard0CrossLinkEpoch,
LocalnetChainConfig.EIP2537PrecompileEpoch,
LocalnetChainConfig.EIP1153TransientStorageEpoch,
LocalnetChainConfig.EIP7939CLZEpoch,
LocalnetChainConfig.EIP5656McopyEpoch,
LocalnetChainConfig.EIP3855Epoch,
LocalnetChainConfig.EIP3860Epoch,
LocalnetChainConfig.EIP6780Epoch,
LocalnetChainConfig.EIP8024Epoch,
LocalnetChainConfig.RejectDuplicateSlashEvidenceEpoch,
LocalnetChainConfig.AllowlistEpoch,
LocalnetChainConfig.LeaderRotationV2Epoch,
LocalnetChainConfig.SlashGroupOrderFixEpoch,
LocalnetChainConfig.ValidatorWrapperAddressBindEpoch,
LocalnetChainConfig.BLSProofBindEpoch,
LocalnetChainConfig.SlashBallotSignerFixEpoch,
LocalnetChainConfig.VerifyBeaconHeaderSlashEpoch,
}
}

func maxEpoch(epochs []*big.Int) *big.Int {
max := epochs[0]
for _, epoch := range epochs[1:] {
if epoch.Cmp(max) > 0 {
max = epoch
}
}
return max
}
1 change: 1 addition & 0 deletions staking/slash/double-sign_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func TestVerifyRejectsExtraBallotSignerKeys(t *testing.T) {
record := extraBallotSignerSlashRecord(t)
sdb := defaultTestStateDB()
chain := defaultFakeBlockChain()
chain.config.SlashBallotSignerFixEpoch = big.NewInt(0)

err := Verify(chain, sdb, &record)
if err == nil {
Expand Down