Skip to content

Commit

Permalink
[workingset] use processWithCorrectOrder() always
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinxie committed Dec 26, 2024
1 parent 36a8913 commit 4492eaf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 48 deletions.
2 changes: 0 additions & 2 deletions action/protocol/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ type (
SufficentBalanceGuarantee bool
EnableCancunEVM bool
UnfoldContainerBeforeValidate bool
CorrectValidationOrder bool
UnstakedButNotClearSelfStakeAmount bool
EnableNewTxTypes bool
VerifyNotContainerBeforeRun bool
Expand Down Expand Up @@ -310,7 +309,6 @@ func WithFeatureCtx(ctx context.Context) context.Context {
SufficentBalanceGuarantee: g.IsVanuatu(height),
EnableCancunEVM: g.IsVanuatu(height),
UnfoldContainerBeforeValidate: g.IsVanuatu(height),
CorrectValidationOrder: g.IsVanuatu(height),
UnstakedButNotClearSelfStakeAmount: !g.IsVanuatu(height),
EnableNewTxTypes: g.IsVanuatu(height),
VerifyNotContainerBeforeRun: g.IsVanuatu(height),
Expand Down
48 changes: 2 additions & 46 deletions state/factory/workingset.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,10 +504,7 @@ func (ws *workingSet) checkNonceContinuity(ctx context.Context, accountNonceMap
}

func (ws *workingSet) Process(ctx context.Context, actions []*action.SealedEnvelope) error {
if protocol.MustGetFeatureCtx(ctx).CorrectValidationOrder {
return ws.processWithCorrectOrder(ctx, actions)
}
return ws.process(ctx, actions)
return ws.processWithCorrectOrder(ctx, actions)
}

func (ws *workingSet) processWithCorrectOrder(ctx context.Context, actions []*action.SealedEnvelope) error {
Expand Down Expand Up @@ -565,41 +562,6 @@ func (ws *workingSet) processWithCorrectOrder(ctx context.Context, actions []*ac
return ws.finalize()
}

func (ws *workingSet) process(ctx context.Context, actions []*action.SealedEnvelope) error {
if err := ws.validate(ctx); err != nil {
return err
}

reg := protocol.MustGetRegistry(ctx)
for _, act := range actions {
ctxWithActionContext, err := withActionCtx(ctx, act)
if err != nil {
return err
}
for _, p := range reg.All() {
if validator, ok := p.(protocol.ActionValidator); ok {
if err := validator.Validate(ctxWithActionContext, act.Envelope, ws); err != nil {
return err
}
}
}
}
for _, p := range reg.All() {
if pp, ok := p.(protocol.PreStatesCreator); ok {
if err := pp.CreatePreStates(ctx, ws); err != nil {
return err
}
}
}

receipts, err := ws.runActions(ctx, actions)
if err != nil {
return err
}
ws.receipts = receipts
return ws.finalize()
}

func (ws *workingSet) generateSystemActions(ctx context.Context) ([]action.Envelope, error) {
reg := protocol.MustGetRegistry(ctx)
postSystemActions := []action.Envelope{}
Expand Down Expand Up @@ -841,13 +803,7 @@ func (ws *workingSet) ValidateBlock(ctx context.Context, blk *block.Block) error
return err
}
}
var err error
if protocol.MustGetFeatureCtx(ctx).CorrectValidationOrder {
err = ws.processWithCorrectOrder(ctx, blk.RunnableActions().Actions())
} else {
err = ws.process(ctx, blk.RunnableActions().Actions())
}
if err != nil {
if err := ws.processWithCorrectOrder(ctx, blk.RunnableActions().Actions()); err != nil {
log.L().Error("Failed to update state.", zap.Uint64("height", ws.height), zap.Error(err))
return err
}
Expand Down

0 comments on commit 4492eaf

Please sign in to comment.