mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 23:26:44 +00:00
chg : support state-sync in newcli server debugBorBlock
This commit is contained in:
parent
ee18b3cd18
commit
bfd4f3e74e
1 changed files with 19 additions and 6 deletions
|
|
@ -5,6 +5,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/consensus/bor/statefull"
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
|
|
@ -68,14 +69,14 @@ func (api *API) traceBorBlock(ctx context.Context, block *types.Block, config *T
|
|||
|
||||
// Execute all the transaction contained within the block concurrently
|
||||
var (
|
||||
signer = types.MakeSigner(api.backend.ChainConfig(), block.Number())
|
||||
txs = block.Transactions()
|
||||
deleteEmptyObjects = api.backend.ChainConfig().IsEIP158(block.Number())
|
||||
signer = types.MakeSigner(api.backend.ChainConfig(), block.Number())
|
||||
txs, stateSyncPresent = api.getAllBlockTransactions(ctx, block)
|
||||
deleteEmptyObjects = api.backend.ChainConfig().IsEIP158(block.Number())
|
||||
)
|
||||
|
||||
blockCtx := core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), nil)
|
||||
|
||||
traceTxn := func(indx int, tx *types.Transaction) *TxTraceResult {
|
||||
traceTxn := func(indx int, tx *types.Transaction, borTx bool) *TxTraceResult {
|
||||
message, _ := tx.AsMessage(signer, block.BaseFee())
|
||||
txContext := core.NewEVMTxContext(message)
|
||||
|
||||
|
|
@ -88,7 +89,15 @@ func (api *API) traceBorBlock(ctx context.Context, block *types.Block, config *T
|
|||
// Not sure if we need to do this
|
||||
statedb.Prepare(tx.Hash(), indx)
|
||||
|
||||
execRes, err := core.ApplyMessage(vmenv, message, new(core.GasPool).AddGas(message.Gas()))
|
||||
var execRes *core.ExecutionResult
|
||||
|
||||
if borTx {
|
||||
callmsg := prepareCallMessage(message)
|
||||
execRes, err = statefull.ApplyBorMessage(*vmenv, callmsg)
|
||||
} else {
|
||||
execRes, err = core.ApplyMessage(vmenv, message, new(core.GasPool).AddGas(message.Gas()))
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return &TxTraceResult{
|
||||
Error: err.Error(),
|
||||
|
|
@ -115,7 +124,11 @@ func (api *API) traceBorBlock(ctx context.Context, block *types.Block, config *T
|
|||
}
|
||||
|
||||
for indx, tx := range txs {
|
||||
res.Transactions = append(res.Transactions, traceTxn(indx, tx))
|
||||
if stateSyncPresent && indx == len(txs)-1 {
|
||||
res.Transactions = append(res.Transactions, traceTxn(indx, tx, true))
|
||||
} else {
|
||||
res.Transactions = append(res.Transactions, traceTxn(indx, tx, false))
|
||||
}
|
||||
}
|
||||
|
||||
return res, nil
|
||||
|
|
|
|||
Loading…
Reference in a new issue