Skip to content

Commit

Permalink
eth/tracers: check posa before statedb.Prepare in IntermiateRoots api
Browse files Browse the repository at this point in the history
Signed-off-by: wenbiao <[email protected]>
  • Loading branch information
rigsec committed Dec 10, 2021
1 parent 3eaba66 commit ce02ae5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions eth/tracers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ce02ae5

Please sign in to comment.