mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
if the txhash is set and is not the first tx then vmConf.Tracer call will trigger panic
This commit is contained in:
parent
077ebb5a89
commit
4d66cf49bc
1 changed files with 7 additions and 9 deletions
|
|
@ -34,6 +34,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/core"
|
"github.com/ethereum/go-ethereum/core"
|
||||||
"github.com/ethereum/go-ethereum/core/rawdb"
|
"github.com/ethereum/go-ethereum/core/rawdb"
|
||||||
"github.com/ethereum/go-ethereum/core/state"
|
"github.com/ethereum/go-ethereum/core/state"
|
||||||
|
"github.com/ethereum/go-ethereum/core/tracing"
|
||||||
"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"
|
||||||
"github.com/ethereum/go-ethereum/eth/tracers/logger"
|
"github.com/ethereum/go-ethereum/eth/tracers/logger"
|
||||||
|
|
@ -788,7 +789,7 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block
|
||||||
// Prepare the transaction for un-traced execution
|
// Prepare the transaction for un-traced execution
|
||||||
var (
|
var (
|
||||||
msg, _ = core.TransactionToMessage(tx, signer, block.BaseFee())
|
msg, _ = core.TransactionToMessage(tx, signer, block.BaseFee())
|
||||||
vmConf vm.Config
|
tracer *tracing.Hooks
|
||||||
dump *os.File
|
dump *os.File
|
||||||
writer *bufio.Writer
|
writer *bufio.Writer
|
||||||
err error
|
err error
|
||||||
|
|
@ -808,23 +809,20 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block
|
||||||
|
|
||||||
// Swap out the noop logger to the standard tracer
|
// Swap out the noop logger to the standard tracer
|
||||||
writer = bufio.NewWriter(dump)
|
writer = bufio.NewWriter(dump)
|
||||||
vmConf = vm.Config{
|
tracer = logger.NewJSONLogger(&logConfig, writer)
|
||||||
Tracer: logger.NewJSONLogger(&logConfig, writer),
|
|
||||||
EnablePreimageRecording: true,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Execute the transaction and flush any traces to disk
|
// Execute the transaction and flush any traces to disk
|
||||||
statedb.SetTxContext(tx.Hash(), i)
|
statedb.SetTxContext(tx.Hash(), i)
|
||||||
if vmConf.Tracer.OnTxStart != nil {
|
if tracer != nil && tracer.OnTxStart != nil {
|
||||||
vmConf.Tracer.OnTxStart(evm.GetVMContext(), tx, msg.From)
|
tracer.OnTxStart(evm.GetVMContext(), tx, msg.From)
|
||||||
}
|
}
|
||||||
vmRet, err := core.ApplyMessage(evm, msg, new(core.GasPool).AddGas(msg.GasLimit))
|
vmRet, err := core.ApplyMessage(evm, msg, new(core.GasPool).AddGas(msg.GasLimit))
|
||||||
if vmConf.Tracer.OnTxEnd != nil {
|
if tracer != nil && tracer.OnTxEnd != nil {
|
||||||
var receipt *types.Receipt
|
var receipt *types.Receipt
|
||||||
if err == nil {
|
if err == nil {
|
||||||
receipt = &types.Receipt{GasUsed: vmRet.UsedGas}
|
receipt = &types.Receipt{GasUsed: vmRet.UsedGas}
|
||||||
}
|
}
|
||||||
vmConf.Tracer.OnTxEnd(receipt, err)
|
tracer.OnTxEnd(receipt, err)
|
||||||
}
|
}
|
||||||
if writer != nil {
|
if writer != nil {
|
||||||
writer.Flush()
|
writer.Flush()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue