From f20c11bdfe1b5a366f4883f7bf2d55ca3409cb30 Mon Sep 17 00:00:00 2001 From: Dustin Xie Date: Wed, 19 Jun 2024 17:30:04 -0700 Subject: [PATCH] enabling features at Upernavik height --- action/protocol/context.go | 16 ++++++++-------- .../staking/endorsement_statemanager_test.go | 4 ++-- .../handler_candidate_transfer_ownership_test.go | 2 +- .../staking/handler_stake_migrate_test.go | 3 +-- blockchain/integrity/integrity_test.go | 2 +- e2etest/native_staking_test.go | 7 +++---- 6 files changed, 16 insertions(+), 18 deletions(-) diff --git a/action/protocol/context.go b/action/protocol/context.go index a8cfdcdff1..3e1375212a 100644 --- a/action/protocol/context.go +++ b/action/protocol/context.go @@ -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), }, ) } diff --git a/action/protocol/staking/endorsement_statemanager_test.go b/action/protocol/staking/endorsement_statemanager_test.go index 773199e204..11a3296ed9 100644 --- a/action/protocol/staking/endorsement_statemanager_test.go +++ b/action/protocol/staking/endorsement_statemanager_test.go @@ -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) diff --git a/action/protocol/staking/handler_candidate_transfer_ownership_test.go b/action/protocol/staking/handler_candidate_transfer_ownership_test.go index 35112bf9a4..7a4e6fde5d 100644 --- a/action/protocol/staking/handler_candidate_transfer_ownership_test.go +++ b/action/protocol/staking/handler_candidate_transfer_ownership_test.go @@ -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)) diff --git a/action/protocol/staking/handler_stake_migrate_test.go b/action/protocol/staking/handler_stake_migrate_test.go index c3c6557a7f..50aa61f4c9 100644 --- a/action/protocol/staking/handler_stake_migrate_test.go +++ b/action/protocol/staking/handler_stake_migrate_test.go @@ -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) diff --git a/blockchain/integrity/integrity_test.go b/blockchain/integrity/integrity_test.go index 799aa75535..cf21cb4dc3 100644 --- a/blockchain/integrity/integrity_test.go +++ b/blockchain/integrity/integrity_test.go @@ -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() diff --git a/e2etest/native_staking_test.go b/e2etest/native_staking_test.go index 7854265ff1..439cc3b725 100644 --- a/e2etest/native_staking_test.go +++ b/e2etest/native_staking_test.go @@ -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) @@ -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) @@ -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()