Skip to content

Commit

Permalink
debug_traceCallMany: lost ibs.Reset() (#12593)
Browse files Browse the repository at this point in the history
for #12589
  • Loading branch information
AskAlexSharov authored Nov 4, 2024
1 parent e46cc43 commit 143e3ec
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions turbo/jsonrpc/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ func (api *PrivateDebugAPIImpl) TraceCallMany(ctx context.Context, bundles []Bun
return err
}

st := state.New(stateReader)
ibs := state.New(stateReader)

header := block.Header()

Expand All @@ -521,15 +521,15 @@ func (api *PrivateDebugAPIImpl) TraceCallMany(ctx context.Context, bundles []Bun

blockCtx = core.NewEVMBlockContext(header, getHash, api.engine(), nil /* author */, chainConfig)
// Get a new instance of the EVM
evm = vm.NewEVM(blockCtx, txCtx, st, chainConfig, vm.Config{Debug: false})
evm = vm.NewEVM(blockCtx, txCtx, ibs, chainConfig, vm.Config{Debug: false})
signer := types.MakeSigner(chainConfig, blockNum, block.Time())
rules := chainConfig.Rules(blockNum, blockCtx.Time)

// Setup the gas pool (also for unmetered requests)
// and apply the message.
gp := new(core.GasPool).AddGas(math.MaxUint64).AddBlobGas(math.MaxUint64)
for idx, txn := range replayTransactions {
st.SetTxContext(idx)
ibs.SetTxContext(idx)
msg, err := txn.AsMessage(*signer, block.BaseFee(), rules)
if err != nil {
stream.WriteNil()
Expand All @@ -543,13 +543,13 @@ func (api *PrivateDebugAPIImpl) TraceCallMany(ctx context.Context, bundles []Bun
stream.WriteNil()
return err
}
_ = st.FinalizeTx(rules, state.NewNoopWriter())
_ = ibs.FinalizeTx(rules, state.NewNoopWriter())

}

// after replaying the txns, we want to overload the state
if config.StateOverrides != nil {
err = config.StateOverrides.Override(evm.IntraBlockState().(*state.IntraBlockState))
err = config.StateOverrides.Override(ibs)
if err != nil {
stream.WriteNil()
return err
Expand All @@ -561,6 +561,7 @@ func (api *PrivateDebugAPIImpl) TraceCallMany(ctx context.Context, bundles []Bun
stream.WriteArrayStart()
// first change blockContext
blockHeaderOverride(&blockCtx, bundle.BlockOverride, overrideBlockHash)
ibs.Reset()
for txnIndex, txn := range bundle.Transactions {
if txn.Gas == nil || *(txn.Gas) == 0 {
txn.Gas = (*hexutil.Uint64)(&api.GasCap)
Expand All @@ -572,7 +573,6 @@ func (api *PrivateDebugAPIImpl) TraceCallMany(ctx context.Context, bundles []Bun
return err
}
txCtx = core.NewEVMTxContext(msg)
ibs := evm.IntraBlockState().(*state.IntraBlockState)
ibs.SetTxContext(txnIndex)
err = transactions.TraceTx(ctx, msg, blockCtx, txCtx, evm.IntraBlockState(), config, chainConfig, stream, api.evmCallTimeout)
if err != nil {
Expand Down

0 comments on commit 143e3ec

Please sign in to comment.