Skip to content

Commit 0689ede

Browse files
localnet: activate Bloom hardfork and bundled features at epoch 5 (#5077)
* localnet: activate Bloom hardfork and bundled features at epoch 5 * fix tests broken by localnet BloomEpoch bundling at epoch 5
1 parent 7ee7e4f commit 0689ede

4 files changed

Lines changed: 135 additions & 25 deletions

File tree

internal/chain/engine_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ func TestVerifyShardStateRejectsEmptyShardState(t *testing.T) {
110110
chain := makeFakeBlockChain()
111111
chain.superCommittee = shard.State{}
112112
header := makeFakeHeader()
113+
header.SetEpoch(big.NewInt(currentEpoch))
113114

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

463464
parent := blockfactory.NewTestHeader()
464465
parent.SetNumber(big.NewInt(doubleSignBlockNumber))
465-
parent.SetEpoch(big.NewInt(5))
466+
parent.SetEpoch(big.NewInt(4))
466467
parent.SetTime(big.NewInt(time.Now().Unix()))
467468
chain.currentBlock = *types.NewBlockWithHeader(parent)
468469
parent = chain.CurrentHeader()

internal/params/config.go

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -408,13 +408,13 @@ var (
408408
EIP155Epoch: big.NewInt(0),
409409
S3Epoch: big.NewInt(0),
410410
CrossTxEpoch: big.NewInt(0),
411-
CXMerkleProofReplayFixEpoch: big.NewInt(0),
412-
CXReceiptStateRollbackEpoch: big.NewInt(0),
411+
CXMerkleProofReplayFixEpoch: big.NewInt(5),
412+
CXReceiptStateRollbackEpoch: big.NewInt(5),
413413
MinCommissionPromoPeriod: big.NewInt(10),
414414
ReceiptLogEpoch: big.NewInt(0),
415415
PreStakingEpoch: big.NewInt(0),
416416
CrossLinkEpoch: big.NewInt(2),
417-
RejectShard0CrossLinkEpoch: big.NewInt(0),
417+
RejectShard0CrossLinkEpoch: big.NewInt(5),
418418
StakingEpoch: big.NewInt(2),
419419
QuickUnlockEpoch: big.NewInt(0),
420420
FiveSecondsEpoch: big.NewInt(0),
@@ -439,37 +439,38 @@ var (
439439
CrossShardXferPrecompileEpoch: big.NewInt(1),
440440
FeeCollectEpoch: big.NewInt(2),
441441
ValidatorCodeFixEpoch: big.NewInt(2),
442-
HIP30Epoch: EpochTBD,
442+
HIP30Epoch: big.NewInt(5),
443443
BlockGas30MEpoch: big.NewInt(0),
444444
MaxRateEpoch: EpochTBD,
445445
TopMaxRateEpoch: EpochTBD,
446446
LeaderRotationInternalValidatorsEpoch: big.NewInt(3),
447447
LeaderRotationExternalValidatorsEpoch: big.NewInt(3),
448448
HIP32Epoch: EpochTBD,
449-
AllowlistEpoch: EpochTBD,
450-
LeaderRotationV2Epoch: EpochTBD,
449+
AllowlistEpoch: big.NewInt(5),
450+
LeaderRotationV2Epoch: big.NewInt(5),
451451
DevnetExternalEpoch: EpochTBD,
452452
TestnetExternalEpoch: EpochTBD,
453-
TimestampValidationEpoch: big.NewInt(0),
454-
DuplicateCrossLinkEpoch: EpochTBD,
455-
ShardStateValidationEpoch: big.NewInt(0),
453+
TimestampValidationEpoch: big.NewInt(5),
454+
DuplicateCrossLinkEpoch: big.NewInt(5),
455+
ShardStateValidationEpoch: big.NewInt(5),
456456
IsOneSecondEpoch: big.NewInt(4),
457-
EIP2537PrecompileEpoch: EpochTBD,
458-
EIP1153TransientStorageEpoch: EpochTBD,
459-
EIP7939CLZEpoch: EpochTBD,
460-
EIP5656McopyEpoch: EpochTBD,
461-
EIP3855Epoch: EpochTBD,
462-
EIP3860Epoch: EpochTBD,
457+
EIP2537PrecompileEpoch: big.NewInt(5),
458+
EIP1153TransientStorageEpoch: big.NewInt(5),
459+
EIP7939CLZEpoch: big.NewInt(5),
460+
EIP5656McopyEpoch: big.NewInt(5),
461+
EIP3855Epoch: big.NewInt(5),
462+
EIP3860Epoch: big.NewInt(5),
463+
EIP6780Epoch: big.NewInt(5),
463464
PragueEpoch: EpochTBD,
464-
EIP8024Epoch: EpochTBD,
465-
ValidatorWrapperAddressBindEpoch: EpochTBD,
466-
SlashExternalStakeDenomFixEpoch: EpochTBD,
467-
RejectDuplicateSlashEvidenceEpoch: big.NewInt(0),
468-
SlashGroupOrderFixEpoch: big.NewInt(2),
469-
BLSProofBindEpoch: EpochTBD,
470-
SlashBallotSignerFixEpoch: big.NewInt(2),
471-
VerifyBeaconHeaderSlashEpoch: EpochTBD,
472-
BloomEpoch: EpochTBD,
465+
EIP8024Epoch: big.NewInt(5),
466+
ValidatorWrapperAddressBindEpoch: big.NewInt(5),
467+
SlashExternalStakeDenomFixEpoch: big.NewInt(5),
468+
RejectDuplicateSlashEvidenceEpoch: big.NewInt(5),
469+
SlashGroupOrderFixEpoch: big.NewInt(5),
470+
BLSProofBindEpoch: big.NewInt(5),
471+
SlashBallotSignerFixEpoch: big.NewInt(5),
472+
VerifyBeaconHeaderSlashEpoch: big.NewInt(5),
473+
BloomEpoch: big.NewInt(5),
473474
}
474475

475476
// AllProtocolChanges ...

internal/params/config_test.go

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,110 @@ func TestMainnetTBDFeaturesInactiveBeforeActivation(t *testing.T) {
6464
require.False(t, rules.IsEIP5656Mcopy)
6565
require.False(t, rules.IsCXReceiptStateRollback)
6666
}
67+
68+
func TestBloomEpochConfigured(t *testing.T) {
69+
require.Equal(t, big.NewInt(7420), TestnetChainConfig.BloomEpoch)
70+
require.Equal(t, big.NewInt(53508), PartnerChainConfig.BloomEpoch)
71+
require.Equal(t, big.NewInt(5), LocalnetChainConfig.BloomEpoch)
72+
73+
require.True(t, TestnetChainConfig.BloomEpoch.Cmp(maxEpoch(testnetBloomFeatureEpochs())) >= 0)
74+
require.True(t, PartnerChainConfig.BloomEpoch.Cmp(maxEpoch(devnetBloomFeatureEpochs())) >= 0)
75+
require.True(t, LocalnetChainConfig.BloomEpoch.Cmp(maxEpoch(localnetBloomFeatureEpochs())) >= 0)
76+
77+
for _, epoch := range localnetBloomFeatureEpochs() {
78+
require.Equal(t, big.NewInt(5), epoch)
79+
}
80+
}
81+
82+
func testnetBloomFeatureEpochs() []*big.Int {
83+
return []*big.Int{
84+
TestnetChainConfig.CXMerkleProofReplayFixEpoch,
85+
TestnetChainConfig.CXReceiptStateRollbackEpoch,
86+
TestnetChainConfig.TimestampValidationEpoch,
87+
TestnetChainConfig.SlashExternalStakeDenomFixEpoch,
88+
TestnetChainConfig.DuplicateCrossLinkEpoch,
89+
TestnetChainConfig.ShardStateValidationEpoch,
90+
TestnetChainConfig.RejectShard0CrossLinkEpoch,
91+
TestnetChainConfig.EIP2537PrecompileEpoch,
92+
TestnetChainConfig.EIP1153TransientStorageEpoch,
93+
TestnetChainConfig.EIP7939CLZEpoch,
94+
TestnetChainConfig.EIP5656McopyEpoch,
95+
TestnetChainConfig.EIP3855Epoch,
96+
TestnetChainConfig.EIP3860Epoch,
97+
TestnetChainConfig.EIP6780Epoch,
98+
TestnetChainConfig.EIP8024Epoch,
99+
TestnetChainConfig.RejectDuplicateSlashEvidenceEpoch,
100+
TestnetChainConfig.AllowlistEpoch,
101+
TestnetChainConfig.LeaderRotationV2Epoch,
102+
TestnetChainConfig.SlashGroupOrderFixEpoch,
103+
TestnetChainConfig.ValidatorWrapperAddressBindEpoch,
104+
TestnetChainConfig.BLSProofBindEpoch,
105+
TestnetChainConfig.SlashBallotSignerFixEpoch,
106+
TestnetChainConfig.VerifyBeaconHeaderSlashEpoch,
107+
}
108+
}
109+
110+
func devnetBloomFeatureEpochs() []*big.Int {
111+
return []*big.Int{
112+
PartnerChainConfig.CXMerkleProofReplayFixEpoch,
113+
PartnerChainConfig.CXReceiptStateRollbackEpoch,
114+
PartnerChainConfig.TimestampValidationEpoch,
115+
PartnerChainConfig.SlashExternalStakeDenomFixEpoch,
116+
PartnerChainConfig.DuplicateCrossLinkEpoch,
117+
PartnerChainConfig.ShardStateValidationEpoch,
118+
PartnerChainConfig.RejectShard0CrossLinkEpoch,
119+
PartnerChainConfig.EIP2537PrecompileEpoch,
120+
PartnerChainConfig.EIP1153TransientStorageEpoch,
121+
PartnerChainConfig.EIP7939CLZEpoch,
122+
PartnerChainConfig.EIP5656McopyEpoch,
123+
PartnerChainConfig.EIP3855Epoch,
124+
PartnerChainConfig.EIP3860Epoch,
125+
PartnerChainConfig.EIP6780Epoch,
126+
PartnerChainConfig.EIP8024Epoch,
127+
PartnerChainConfig.RejectDuplicateSlashEvidenceEpoch,
128+
PartnerChainConfig.LeaderRotationV2Epoch,
129+
PartnerChainConfig.SlashGroupOrderFixEpoch,
130+
PartnerChainConfig.ValidatorWrapperAddressBindEpoch,
131+
PartnerChainConfig.BLSProofBindEpoch,
132+
PartnerChainConfig.SlashBallotSignerFixEpoch,
133+
PartnerChainConfig.VerifyBeaconHeaderSlashEpoch,
134+
}
135+
}
136+
137+
func localnetBloomFeatureEpochs() []*big.Int {
138+
return []*big.Int{
139+
LocalnetChainConfig.CXMerkleProofReplayFixEpoch,
140+
LocalnetChainConfig.CXReceiptStateRollbackEpoch,
141+
LocalnetChainConfig.TimestampValidationEpoch,
142+
LocalnetChainConfig.SlashExternalStakeDenomFixEpoch,
143+
LocalnetChainConfig.DuplicateCrossLinkEpoch,
144+
LocalnetChainConfig.ShardStateValidationEpoch,
145+
LocalnetChainConfig.RejectShard0CrossLinkEpoch,
146+
LocalnetChainConfig.EIP2537PrecompileEpoch,
147+
LocalnetChainConfig.EIP1153TransientStorageEpoch,
148+
LocalnetChainConfig.EIP7939CLZEpoch,
149+
LocalnetChainConfig.EIP5656McopyEpoch,
150+
LocalnetChainConfig.EIP3855Epoch,
151+
LocalnetChainConfig.EIP3860Epoch,
152+
LocalnetChainConfig.EIP6780Epoch,
153+
LocalnetChainConfig.EIP8024Epoch,
154+
LocalnetChainConfig.RejectDuplicateSlashEvidenceEpoch,
155+
LocalnetChainConfig.AllowlistEpoch,
156+
LocalnetChainConfig.LeaderRotationV2Epoch,
157+
LocalnetChainConfig.SlashGroupOrderFixEpoch,
158+
LocalnetChainConfig.ValidatorWrapperAddressBindEpoch,
159+
LocalnetChainConfig.BLSProofBindEpoch,
160+
LocalnetChainConfig.SlashBallotSignerFixEpoch,
161+
LocalnetChainConfig.VerifyBeaconHeaderSlashEpoch,
162+
}
163+
}
164+
165+
func maxEpoch(epochs []*big.Int) *big.Int {
166+
max := epochs[0]
167+
for _, epoch := range epochs[1:] {
168+
if epoch.Cmp(max) > 0 {
169+
max = epoch
170+
}
171+
}
172+
return max
173+
}

staking/slash/double-sign_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ func TestVerifyRejectsExtraBallotSignerKeys(t *testing.T) {
8484
record := extraBallotSignerSlashRecord(t)
8585
sdb := defaultTestStateDB()
8686
chain := defaultFakeBlockChain()
87+
chain.config.SlashBallotSignerFixEpoch = big.NewInt(0)
8788

8889
err := Verify(chain, sdb, &record)
8990
if err == nil {

0 commit comments

Comments
 (0)