From fd6cbd5df172ae2c6fd54649783644b1eaabcdfc Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Fri, 5 May 2023 16:09:40 +0800 Subject: [PATCH] fix nonce error for debug trace api (#256) --- core/types/transaction.go | 2 ++ eth/api_tracer.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/core/types/transaction.go b/core/types/transaction.go index e551d23796..1a87a679a9 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -726,3 +726,5 @@ func (m Message) Gas() uint64 { return m.gasLimit } func (m Message) Nonce() uint64 { return m.nonce } func (m Message) Data() []byte { return m.data } func (m Message) CheckNonce() bool { return m.checkNonce } + +func (m *Message) SetNonce(nonce uint64) { m.nonce = nonce } diff --git a/eth/api_tracer.go b/eth/api_tracer.go index bddff0ccd3..b8c4661a91 100644 --- a/eth/api_tracer.go +++ b/eth/api_tracer.go @@ -471,6 +471,8 @@ func (api *PrivateDebugAPI) traceBlock(ctx context.Context, block *types.Block, } // Generate the next state snapshot fast without tracing msg, _ := tx.AsMessage(signer, balacne, block.Number()) + // Set nonce to fix issue #256 + msg.SetNonce(statedb.GetNonce(*tx.From())) vmctx := core.NewEVMContext(msg, block.Header(), api.eth.blockchain, nil) vmenv := vm.NewEVM(vmctx, statedb, XDCxState, api.config, vm.Config{})