Skip to content

Commit

Permalink
consortium-v2: increase the nonce of sender before transaction execution
Browse files Browse the repository at this point in the history
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 72da4b0 commit aaedbc6
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 @@ -347,6 +347,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 @@ -376,7 +377,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 aaedbc6

Please sign in to comment.