Skip to content

Commit

Permalink
enabling features at Upernavik height (#4309)
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinxie authored Jun 27, 2024
1 parent 881fc5d commit 2cc95d7
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 18 deletions.
16 changes: 8 additions & 8 deletions action/protocol/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,14 @@ func WithFeatureCtx(ctx context.Context) context.Context {
CandidateRegisterMustWithStake: !g.IsTsunami(height),
DisableDelegateEndorsement: !g.IsTsunami(height),
RefactorFreshAccountConversion: g.IsTsunami(height),
SuicideTxLogMismatchPanic: g.IsToBeEnabled(height),
PanicUnrecoverableError: g.IsToBeEnabled(height),
CandidateIdentifiedByOwner: !g.IsToBeEnabled(height),
UseTxContainer: g.IsToBeEnabled(height),
LimitedStakingContract: !g.IsToBeEnabled(height),
MigrateNativeStake: g.IsToBeEnabled(height),
AddClaimRewardAddress: g.IsToBeEnabled(height),
EnforceLegacyEndorsement: !g.IsToBeEnabled(height),
SuicideTxLogMismatchPanic: g.IsUpernavik(height),
PanicUnrecoverableError: g.IsUpernavik(height),
CandidateIdentifiedByOwner: !g.IsUpernavik(height),
UseTxContainer: g.IsUpernavik(height),
LimitedStakingContract: !g.IsUpernavik(height),
MigrateNativeStake: g.IsUpernavik(height),
AddClaimRewardAddress: g.IsUpernavik(height),
EnforceLegacyEndorsement: !g.IsUpernavik(height),
},
)
}
Expand Down
4 changes: 2 additions & 2 deletions action/protocol/staking/endorsement_statemanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ func TestEndorsementStateReader_Status(t *testing.T) {
})
t.Run("status after Upernavik", func(t *testing.T) {
g := deepcopy.Copy(genesis.Default).(genesis.Genesis)
g.TsunamiBlockHeight = 1 // enable endorsement protocol at block 1
g.ToBeEnabledBlockHeight = 2 // enable endorsement protocol improvement at block 2
g.TsunamiBlockHeight = 1 // enable endorsement protocol at block 1
g.UpernavikBlockHeight = 2 // enable endorsement protocol improvement at block 2
ctx := protocol.WithBlockCtx(context.Background(), protocol.BlockCtx{BlockHeight: 2})
ctx = genesis.WithGenesisContext(ctx, g)
ctx = protocol.WithFeatureCtx(ctx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func TestProtocol_HandleCandidateTransferOwnership(t *testing.T) {
})
cfg := deepcopy.Copy(genesis.Default).(genesis.Genesis)
cfg.TsunamiBlockHeight = 1
cfg.ToBeEnabledBlockHeight = 1 // enable candidate owner transfer feature
cfg.UpernavikBlockHeight = 1 // enable candidate owner transfer feature
ctx = genesis.WithGenesisContext(ctx, cfg)
ctx = protocol.WithFeatureCtx(protocol.WithFeatureWithHeightCtx(ctx))
require.NoError(p.Validate(ctx, act, sm))
Expand Down
3 changes: 1 addition & 2 deletions action/protocol/staking/handler_stake_migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ func TestHandleStakeMigrate(t *testing.T) {
cfg.RedseaBlockHeight = 1
cfg.SumatraBlockHeight = 1
cfg.TsunamiBlockHeight = 1
cfg.UpernavikBlockHeight = 1000000 // not enabled
cfg.ToBeEnabledBlockHeight = 1 // enable CandidateIdentifiedByOwner feature
cfg.UpernavikBlockHeight = 2 // enable CandidateIdentifiedByOwner feature
}
initCfg(&cfg)

Expand Down
2 changes: 1 addition & 1 deletion blockchain/integrity/integrity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ func TestBlockchainHardForkFeatures(t *testing.T) {
cfg.Genesis.RedseaBlockHeight = 2
cfg.Genesis.SumatraBlockHeight = 2
cfg.Genesis.TsunamiBlockHeight = 3
cfg.Genesis.ToBeEnabledBlockHeight = 3
cfg.Genesis.UpernavikBlockHeight = 4
cfg.Genesis.InitBalanceMap[identityset.Address(27).String()] = unit.ConvertIotxToRau(10000000000).String()

ctx := context.Background()
Expand Down
7 changes: 3 additions & 4 deletions e2etest/native_staking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ func TestNativeStaking(t *testing.T) {
cfg.Genesis.FbkMigrationBlockHeight = 1
cfg.Genesis.TsunamiBlockHeight = 2
cfg.Genesis.EndorsementWithdrawWaitingBlocks = 10
cfg.Genesis.ToBeEnabledBlockHeight = 3 // enable CandidateIdentifiedByOwner feature
cfg.Genesis.UpernavikBlockHeight = 3 // enable CandidateIdentifiedByOwner feature

t.Run("test native staking", func(t *testing.T) {
testNativeStaking(cfg, t)
Expand Down Expand Up @@ -629,8 +629,7 @@ func TestCandidateTransferOwnership(t *testing.T) {
cfg.Genesis.RedseaBlockHeight = 1
cfg.Genesis.SumatraBlockHeight = 1
cfg.Genesis.TsunamiBlockHeight = 1
cfg.Genesis.UpernavikBlockHeight = 1000000 // not enabled
cfg.Genesis.ToBeEnabledBlockHeight = 1 // enable CandidateIdentifiedByOwner feature
cfg.Genesis.UpernavikBlockHeight = 2 // enable CandidateIdentifiedByOwner feature
return cfg
}
registerAmount, _ := big.NewInt(0).SetString("1200000000000000000000000", 10)
Expand Down Expand Up @@ -976,7 +975,7 @@ func TestCandidateTransferOwnership(t *testing.T) {
})
t.Run("new endorsement", func(t *testing.T) {
cfg := initCfg()
cfg.Genesis.ToBeEnabledBlockHeight = 6
cfg.Genesis.UpernavikBlockHeight = 6
cfg.Genesis.EndorsementWithdrawWaitingBlocks = 5
test := newE2ETest(t, cfg)
defer test.teardown()
Expand Down

0 comments on commit 2cc95d7

Please sign in to comment.