From ce02ae51a919e6d96e2f23c6c4db010fdaae11a5 Mon Sep 17 00:00:00 2001 From: wenbiao Date: Fri, 10 Dec 2021 21:20:29 +0800 Subject: [PATCH] eth/tracers: check posa before statedb.Prepare in IntermiateRoots api Signed-off-by: wenbiao --- eth/tracers/api.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/eth/tracers/api.go b/eth/tracers/api.go index d63e13d1d0..5835ff8215 100644 --- a/eth/tracers/api.go +++ b/eth/tracers/api.go @@ -532,6 +532,17 @@ func (api *API) IntermediateRoots(ctx context.Context, hash common.Hash, config txContext = core.NewEVMTxContext(msg) vmenv = vm.NewEVM(vmctx, txContext, statedb, chainConfig, vm.Config{}) ) + + if posa, ok := api.backend.Engine().(consensus.PoSA); ok { + if isSystem, _ := posa.IsSystemTransaction(tx, block.Header()); isSystem { + balance := statedb.GetBalance(consensus.SystemAddress) + if balance.Cmp(common.Big0) > 0 { + statedb.SetBalance(consensus.SystemAddress, big.NewInt(0)) + statedb.AddBalance(vmctx.Coinbase, balance) + } + } + } + statedb.Prepare(tx.Hash(), block.Hash(), i) if _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.Gas())); err != nil { log.Warn("Tracing intermediate roots did not complete", "txindex", i, "txhash", tx.Hash(), "err", err)