mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-11 14:33:52 +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"
|
"fmt"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"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"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/core/vm"
|
"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
|
// Execute all the transaction contained within the block concurrently
|
||||||
var (
|
var (
|
||||||
signer = types.MakeSigner(api.backend.ChainConfig(), block.Number())
|
signer = types.MakeSigner(api.backend.ChainConfig(), block.Number())
|
||||||
txs = block.Transactions()
|
txs, stateSyncPresent = api.getAllBlockTransactions(ctx, block)
|
||||||
deleteEmptyObjects = api.backend.ChainConfig().IsEIP158(block.Number())
|
deleteEmptyObjects = api.backend.ChainConfig().IsEIP158(block.Number())
|
||||||
)
|
)
|
||||||
|
|
||||||
blockCtx := core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), nil)
|
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())
|
message, _ := tx.AsMessage(signer, block.BaseFee())
|
||||||
txContext := core.NewEVMTxContext(message)
|
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
|
// Not sure if we need to do this
|
||||||
statedb.Prepare(tx.Hash(), indx)
|
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 {
|
if err != nil {
|
||||||
return &TxTraceResult{
|
return &TxTraceResult{
|
||||||
Error: err.Error(),
|
Error: err.Error(),
|
||||||
|
|
@ -115,7 +124,11 @@ func (api *API) traceBorBlock(ctx context.Context, block *types.Block, config *T
|
||||||
}
|
}
|
||||||
|
|
||||||
for indx, tx := range txs {
|
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
|
return res, nil
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue