Skip to content

Commit

Permalink
special handling for genesis block not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinxie committed Apr 10, 2023
1 parent 270b507 commit 0594a62
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions state/factory/workingset.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,15 +333,10 @@ func (ws *workingSet) validateNonce(ctx context.Context, blk *block.Block) error
}
appendActionIndex(accountNonceMap, caller.String(), selp.Nonce())
}

// Special handling for genesis block
if blk.Height() == 0 {
return nil
}
return ws.checkNonceContinuity(ctx, accountNonceMap)
}

func (ws *workingSet) validateNonce2(ctx context.Context, blk *block.Block) error {
func (ws *workingSet) validateNonceSkipSystemAction(ctx context.Context, blk *block.Block) error {
accountNonceMap := make(map[string][]uint64)
for _, selp := range blk.Actions {
if action.IsSystemAction(selp) {
Expand All @@ -358,11 +353,6 @@ func (ws *workingSet) validateNonce2(ctx context.Context, blk *block.Block) erro
}
accountNonceMap[srcAddr] = append(accountNonceMap[srcAddr], selp.Nonce())
}

// Special handling for genesis block
if blk.Height() == 0 {
return nil
}
return ws.checkNonceContinuity(ctx, accountNonceMap)
}

Expand Down Expand Up @@ -546,7 +536,7 @@ func updateReceiptIndex(receipts []*action.Receipt) {

func (ws *workingSet) ValidateBlock(ctx context.Context, blk *block.Block) error {
if protocol.MustGetFeatureCtx(ctx).SkipSystemActionNonce {
if err := ws.validateNonce2(ctx, blk); err != nil {
if err := ws.validateNonceSkipSystemAction(ctx, blk); err != nil {
return errors.Wrap(err, "failed to validate nonce")
}
} else {
Expand Down

0 comments on commit 0594a62

Please sign in to comment.