Skip to content

Commit

Permalink
[context] enable delegate endorsement and refactor fresh account conv…
Browse files Browse the repository at this point in the history
…ersion at Tsunami height
  • Loading branch information
dustinxie committed Mar 14, 2024
1 parent 855d8ba commit e9d8a95
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
8 changes: 4 additions & 4 deletions action/protocol/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ type (
SharedGasWithDapp bool
CandidateRegisterMustWithStake bool
DisableDelegateEndorsement bool
SuicideTxLogMismatchPanic bool
RefactorFreshAccountConversion bool
SuicideTxLogMismatchPanic bool
}

// FeatureWithHeightCtx provides feature check functions.
Expand Down Expand Up @@ -261,10 +261,10 @@ func WithFeatureCtx(ctx context.Context) context.Context {
ExecutionSizeLimit32KB: !g.IsSumatra(height),
UseZeroNonceForFreshAccount: g.IsSumatra(height),
SharedGasWithDapp: g.IsToBeEnabled(height),
CandidateRegisterMustWithStake: !g.IsToBeEnabled(height),
DisableDelegateEndorsement: !g.IsToBeEnabled(height),
CandidateRegisterMustWithStake: !g.IsTsunami(height),
DisableDelegateEndorsement: !g.IsTsunami(height),
RefactorFreshAccountConversion: g.IsTsunami(height),
SuicideTxLogMismatchPanic: g.IsToBeEnabled(height),
RefactorFreshAccountConversion: g.IsToBeEnabled(height),
},
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ func TestProtocol_HandleCandidateEndorsement(t *testing.T) {
GasLimit: test.blkGasLimit,
})
cfg := deepcopy.Copy(genesis.Default).(genesis.Genesis)
cfg.ToBeEnabledBlockHeight = 1
cfg.TsunamiBlockHeight = 1
ctx = genesis.WithGenesisContext(ctx, cfg)
ctx = protocol.WithFeatureCtx(protocol.WithFeatureWithHeightCtx(ctx))
require.Equal(test.err, errors.Cause(p.Validate(ctx, act, sm)))
Expand Down
4 changes: 2 additions & 2 deletions action/protocol/staking/handler_candidate_selfstake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func initTestStateWithHeight(t *testing.T, ctrl *gomock.Controller, bucketCfgs [
candidates = append(candidates, cand)
}
cfg := deepcopy.Copy(genesis.Default).(genesis.Genesis)
cfg.ToBeEnabledBlockHeight = 1
cfg.TsunamiBlockHeight = 1
ctx := genesis.WithGenesisContext(context.Background(), cfg)
ctx = protocol.WithFeatureWithHeightCtx(ctx)
v, err := p.Start(ctx, sm)
Expand Down Expand Up @@ -432,7 +432,7 @@ func TestProtocol_HandleCandidateSelfStake(t *testing.T) {
GasLimit: test.blkGasLimit,
})
cfg := deepcopy.Copy(genesis.Default).(genesis.Genesis)
cfg.ToBeEnabledBlockHeight = 1
cfg.TsunamiBlockHeight = 1
ctx = genesis.WithGenesisContext(ctx, cfg)
ctx = protocol.WithFeatureCtx(protocol.WithFeatureWithHeightCtx(ctx))
require.Equal(test.err, errors.Cause(p.Validate(ctx, act, sm)))
Expand Down
24 changes: 12 additions & 12 deletions action/protocol/staking/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ func TestProtocol_HandleCandidateRegister(t *testing.T) {
GasLimit: test.blkGasLimit,
})
g := deepcopy.Copy(genesis.Default).(genesis.Genesis)
g.ToBeEnabledBlockHeight = 0
g.TsunamiBlockHeight = 0
ctx = genesis.WithGenesisContext(ctx, g)
ctx = protocol.WithFeatureCtx(protocol.WithFeatureWithHeightCtx(ctx))
require.Equal(test.err, errors.Cause(p.Validate(ctx, act, sm)))
Expand Down Expand Up @@ -1752,7 +1752,7 @@ func TestProtocol_HandleChangeCandidate_ClearPrevCandidateSelfStake(t *testing.T
r.NoError(err)
ctx := context.Background()
g := deepcopy.Copy(genesis.Default).(genesis.Genesis)
g.ToBeEnabledBlockHeight = 0
g.TsunamiBlockHeight = 0
ctx = genesis.WithGenesisContext(ctx, g)
ctx = protocol.WithActionCtx(ctx, protocol.ActionCtx{
Caller: identityset.Address(5),
Expand Down Expand Up @@ -1796,7 +1796,7 @@ func TestProtocol_HandleChangeCandidate_ClearPrevCandidateSelfStake(t *testing.T
r.NoError(err)
ctx := context.Background()
g := deepcopy.Copy(genesis.Default).(genesis.Genesis)
g.ToBeEnabledBlockHeight = 0
g.TsunamiBlockHeight = 0
ctx = genesis.WithGenesisContext(ctx, g)
ctx = protocol.WithActionCtx(ctx, protocol.ActionCtx{
Caller: identityset.Address(1),
Expand Down Expand Up @@ -1840,7 +1840,7 @@ func TestProtocol_HandleChangeCandidate_ClearPrevCandidateSelfStake(t *testing.T
r.NoError(err)
ctx := context.Background()
g := deepcopy.Copy(genesis.Default).(genesis.Genesis)
g.ToBeEnabledBlockHeight = 0
g.TsunamiBlockHeight = 0
ctx = genesis.WithGenesisContext(ctx, g)
ctx = protocol.WithActionCtx(ctx, protocol.ActionCtx{
Caller: identityset.Address(1),
Expand Down Expand Up @@ -2892,7 +2892,7 @@ func TestChangeCandidate(t *testing.T) {
r.NoError(err)
ctx := context.Background()
g := deepcopy.Copy(genesis.Default).(genesis.Genesis)
g.ToBeEnabledBlockHeight = 0
g.TsunamiBlockHeight = 0
ctx = genesis.WithGenesisContext(ctx, g)
ctx = protocol.WithActionCtx(ctx, protocol.ActionCtx{
Caller: identityset.Address(1),
Expand Down Expand Up @@ -2929,7 +2929,7 @@ func TestChangeCandidate(t *testing.T) {
r.NoError(err)
ctx := context.Background()
g := deepcopy.Copy(genesis.Default).(genesis.Genesis)
g.ToBeEnabledBlockHeight = 0
g.TsunamiBlockHeight = 0
ctx = genesis.WithGenesisContext(ctx, g)
ctx = protocol.WithActionCtx(ctx, protocol.ActionCtx{
Caller: identityset.Address(1),
Expand Down Expand Up @@ -2966,7 +2966,7 @@ func TestChangeCandidate(t *testing.T) {
r.NoError(err)
ctx := context.Background()
g := deepcopy.Copy(genesis.Default).(genesis.Genesis)
g.ToBeEnabledBlockHeight = 0
g.TsunamiBlockHeight = 0
ctx = genesis.WithGenesisContext(ctx, g)
ctx = protocol.WithActionCtx(ctx, protocol.ActionCtx{
Caller: identityset.Address(1),
Expand Down Expand Up @@ -3000,7 +3000,7 @@ func TestChangeCandidate(t *testing.T) {
r.NoError(err)
ctx := context.Background()
g := deepcopy.Copy(genesis.Default).(genesis.Genesis)
g.ToBeEnabledBlockHeight = 0
g.TsunamiBlockHeight = 0
ctx = genesis.WithGenesisContext(ctx, g)
ctx = protocol.WithActionCtx(ctx, protocol.ActionCtx{
Caller: identityset.Address(1),
Expand Down Expand Up @@ -3039,7 +3039,7 @@ func TestUnstake(t *testing.T) {
r.NoError(err)
ctx := context.Background()
g := deepcopy.Copy(genesis.Default).(genesis.Genesis)
g.ToBeEnabledBlockHeight = 0
g.TsunamiBlockHeight = 0
ctx = genesis.WithGenesisContext(ctx, g)
ctx = protocol.WithActionCtx(ctx, protocol.ActionCtx{
Caller: identityset.Address(1),
Expand Down Expand Up @@ -3076,7 +3076,7 @@ func TestUnstake(t *testing.T) {
r.NoError(err)
ctx := context.Background()
g := deepcopy.Copy(genesis.Default).(genesis.Genesis)
g.ToBeEnabledBlockHeight = 0
g.TsunamiBlockHeight = 0
ctx = genesis.WithGenesisContext(ctx, g)
ctx = protocol.WithActionCtx(ctx, protocol.ActionCtx{
Caller: identityset.Address(1),
Expand Down Expand Up @@ -3113,7 +3113,7 @@ func TestUnstake(t *testing.T) {
r.NoError(err)
ctx := context.Background()
g := deepcopy.Copy(genesis.Default).(genesis.Genesis)
g.ToBeEnabledBlockHeight = 0
g.TsunamiBlockHeight = 0
ctx = genesis.WithGenesisContext(ctx, g)
ctx = protocol.WithActionCtx(ctx, protocol.ActionCtx{
Caller: identityset.Address(1),
Expand Down Expand Up @@ -3147,7 +3147,7 @@ func TestUnstake(t *testing.T) {
r.NoError(err)
ctx := context.Background()
g := deepcopy.Copy(genesis.Default).(genesis.Genesis)
g.ToBeEnabledBlockHeight = 0
g.TsunamiBlockHeight = 0
ctx = genesis.WithGenesisContext(ctx, g)
ctx = protocol.WithActionCtx(ctx, protocol.ActionCtx{
Caller: identityset.Address(1),
Expand Down
2 changes: 1 addition & 1 deletion dispatcher/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func (d *IotxDispatcher) actionHandler() {
case a := <-d.actionChan:
d.handleActionMsg(a)
case <-d.quit:
log.L().Info("action handler is terminated.")
log.L().Debug("action handler is terminated.")
return
}
}
Expand Down
2 changes: 1 addition & 1 deletion e2etest/native_staking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ func TestNativeStaking(t *testing.T) {
cfg.Chain.EnableAsyncIndexWrite = false
cfg.Genesis.BootstrapCandidates = testInitCands
cfg.Genesis.FbkMigrationBlockHeight = 1
cfg.Genesis.ToBeEnabledBlockHeight = 0
cfg.Genesis.TsunamiBlockHeight = 0
cfg.Genesis.EndorsementWithdrawWaitingBlocks = 10

t.Run("test native staking", func(t *testing.T) {
Expand Down

0 comments on commit e9d8a95

Please sign in to comment.