Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[context] enable delegate endorsement and refactor fresh account conversion at Tsunami height #4188

Merged
merged 1 commit into from
Mar 15, 2024
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
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.")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this log is tooooooo long, make debug not convenient

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
Loading