Skip to content

Commit

Permalink
consortium-v2: increase the nonce of sender before transaction execut…
Browse files Browse the repository at this point in the history
…ion (#434)

Currently, in system transaction we increase nonce after transaction execution
which is not consistent with normal transaction. This change does not require a
hardfork as:
- Nonce is not used when executing transaction in virtual machine
- Consortium-v2 is after Byzantium so we don't fall through the path to
  calculate root hash after transaction execution

Reference: bnb-chain/bsc#2185
  • Loading branch information
minh-bq committed Apr 5, 2024
1 parent a8bda75 commit 44ad3d9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion consensus/consortium/common/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ func ApplyTransaction(msg types.Message, opts *ApplyTransactOpts) (err error) {
*receivedTxs = (*receivedTxs)[1:]
}
opts.State.Prepare(expectedTx.Hash(), len(*txs))
opts.State.SetNonce(msg.From(), nonce+1)
gasUsed, err := applyMessage(opts.ApplyMessageOpts, expectedTx)
if err != nil {
failed = true
Expand Down Expand Up @@ -378,7 +379,6 @@ func ApplyTransaction(msg types.Message, opts *ApplyTransactOpts) (err error) {
receipt.BlockNumber = header.Number
receipt.TransactionIndex = uint(opts.State.TxIndex())
*receipts = append(*receipts, receipt)
opts.State.SetNonce(msg.From(), nonce+1)
return nil
}

Expand Down

0 comments on commit 44ad3d9

Please sign in to comment.