From 8b71cee589716dd43c74c5e3237feae0fc201c59 Mon Sep 17 00:00:00 2001 From: Andrew Ashikhmin <34320705+yperbasis@users.noreply.github.com> Date: Wed, 2 Oct 2024 15:32:06 +0200 Subject: [PATCH] Move bor_fee_log from core to polygon (#12176) Cherry pick #10810 --- accounts/abi/bind/backends/simulated.go | 9 +- cmd/rpcdaemon/cli/config.go | 17 ++++ consensus/aura/aura.go | 9 ++ consensus/clique/clique.go | 16 +++- consensus/consensus.go | 14 ++++ consensus/ethash/ethash.go | 11 ++- consensus/merge/merge.go | 9 ++ core/evm.go | 60 ++++---------- core/state_transition.go | 83 ++++--------------- core/vm/evmtypes/evmtypes.go | 48 ++++++++++- core/vm/runtime/env.go | 3 +- .../internal/tracetest/calltrace_test.go | 7 +- .../internal/tracetest/prestate_test.go | 3 +- eth/tracers/tracers_test.go | 8 +- polygon/bor/bor.go | 48 +++++++++++ core/bor_fee_log.go => polygon/bor/fee_log.go | 63 +------------- polygon/tracer/trace_bor_state_sync_txn.go | 9 +- turbo/adapter/ethapi/api.go | 7 +- turbo/jsonrpc/eth_call.go | 6 +- turbo/jsonrpc/eth_receipts.go | 2 +- turbo/jsonrpc/otterscan_api.go | 3 +- turbo/jsonrpc/overlay_api.go | 5 +- turbo/jsonrpc/trace_adhoc.go | 6 +- turbo/jsonrpc/trace_adhoc_test.go | 3 +- turbo/jsonrpc/trace_filtering.go | 4 +- turbo/transactions/call.go | 4 +- turbo/transactions/tracing.go | 5 +- 27 files changed, 254 insertions(+), 208 deletions(-) rename core/bor_fee_log.go => polygon/bor/fee_log.go (55%) diff --git a/accounts/abi/bind/backends/simulated.go b/accounts/abi/bind/backends/simulated.go index 1f822ca40d3..2614fc3aada 100644 --- a/accounts/abi/bind/backends/simulated.go +++ b/accounts/abi/bind/backends/simulated.go @@ -48,6 +48,7 @@ import ( "github.com/ledgerwatch/erigon/core/state" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/core/vm" + "github.com/ledgerwatch/erigon/core/vm/evmtypes" "github.com/ledgerwatch/erigon/event" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/turbo/services" @@ -510,7 +511,7 @@ func (b *SimulatedBackend) PendingCodeAt(ctx context.Context, contract libcommon return b.pendingState.GetCode(contract), nil } -func newRevertError(result *core.ExecutionResult) *revertError { +func newRevertError(result *evmtypes.ExecutionResult) *revertError { reason, errUnpack := abi.UnpackRevert(result.Revert()) err := errors.New("execution reverted") if errUnpack == nil { @@ -548,7 +549,7 @@ func (b *SimulatedBackend) CallContract(ctx context.Context, call ethereum.CallM if blockNumber != nil && blockNumber.Cmp(b.pendingBlock.Number()) != 0 { return nil, errBlockNumberUnsupported } - var res *core.ExecutionResult + var res *evmtypes.ExecutionResult if err := b.m.DB.View(context.Background(), func(tx kv.Tx) (err error) { s := state.New(b.m.NewStateReader(tx)) res, err = b.callContract(ctx, call, b.pendingBlock, s) @@ -640,7 +641,7 @@ func (b *SimulatedBackend) EstimateGas(ctx context.Context, call ethereum.CallMs b.pendingState.SetTxContext(libcommon.Hash{}, libcommon.Hash{}, len(b.pendingBlock.Transactions())) // Create a helper to check if a gas allowance results in an executable transaction - executable := func(gas uint64) (bool, *core.ExecutionResult, error) { + executable := func(gas uint64) (bool, *evmtypes.ExecutionResult, error) { call.Gas = gas snapshot := b.pendingState.Snapshot() @@ -694,7 +695,7 @@ func (b *SimulatedBackend) EstimateGas(ctx context.Context, call ethereum.CallMs // callContract implements common code between normal and pending contract calls. // state is modified during execution, make sure to copy it if necessary. -func (b *SimulatedBackend) callContract(_ context.Context, call ethereum.CallMsg, block *types.Block, statedb *state.IntraBlockState) (*core.ExecutionResult, error) { +func (b *SimulatedBackend) callContract(_ context.Context, call ethereum.CallMsg, block *types.Block, statedb *state.IntraBlockState) (*evmtypes.ExecutionResult, error) { const baseFeeUpperLimit = 880000000 // Ensure message is initialized properly. if call.GasPrice == nil { diff --git a/cmd/rpcdaemon/cli/config.go b/cmd/rpcdaemon/cli/config.go index 3962ab4cc46..f886a58e5ec 100644 --- a/cmd/rpcdaemon/cli/config.go +++ b/cmd/rpcdaemon/cli/config.go @@ -54,6 +54,7 @@ import ( "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/state" "github.com/ledgerwatch/erigon/core/types" + "github.com/ledgerwatch/erigon/core/vm/evmtypes" "github.com/ledgerwatch/erigon/eth/ethconfig" "github.com/ledgerwatch/erigon/node" "github.com/ledgerwatch/erigon/node/nodecfg" @@ -993,6 +994,22 @@ func (e *remoteConsensusEngine) Initialize(config *chain.Config, chain consensus e.engine.Initialize(config, chain, header, state, syscall, logger) } +func (e *remoteConsensusEngine) GetTransferFunc() evmtypes.TransferFunc { + if err := e.validateEngineReady(); err != nil { + panic(err) + } + + return e.engine.GetTransferFunc() +} + +func (e *remoteConsensusEngine) GetPostApplyMessageFunc() evmtypes.PostApplyMessageFunc { + if err := e.validateEngineReady(); err != nil { + panic(err) + } + + return e.engine.GetPostApplyMessageFunc() +} + func (e *remoteConsensusEngine) VerifyHeader(_ consensus.ChainHeaderReader, _ *types.Header, _ bool) error { panic("remoteConsensusEngine.VerifyHeader not supported") } diff --git a/consensus/aura/aura.go b/consensus/aura/aura.go index a280182d845..b27b1740ffb 100644 --- a/consensus/aura/aura.go +++ b/consensus/aura/aura.go @@ -36,6 +36,7 @@ import ( "github.com/ledgerwatch/erigon/consensus/ethash" "github.com/ledgerwatch/erigon/core/state" "github.com/ledgerwatch/erigon/core/types" + "github.com/ledgerwatch/erigon/core/vm/evmtypes" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/erigon/rpc" ) @@ -1219,6 +1220,14 @@ func (c *AuRa) ExecuteSystemWithdrawals(withdrawals []*types.Withdrawal, syscall return err } +func (c *AuRa) GetTransferFunc() evmtypes.TransferFunc { + return consensus.Transfer +} + +func (c *AuRa) GetPostApplyMessageFunc() evmtypes.PostApplyMessageFunc { + return nil +} + /* // extracts the empty steps from the header seal. should only be called when there are 3 fields in the seal // (i.e. header.number() >= self.empty_steps_transition). diff --git a/consensus/clique/clique.go b/consensus/clique/clique.go index c1db6cd439e..7c9a91c88ee 100644 --- a/consensus/clique/clique.go +++ b/consensus/clique/clique.go @@ -28,17 +28,15 @@ import ( "sync" "time" - "github.com/ledgerwatch/erigon-lib/common/hexutil" - "github.com/ledgerwatch/erigon-lib/kv/dbutils" - "github.com/goccy/go-json" lru "github.com/hashicorp/golang-lru/arc/v2" - "github.com/ledgerwatch/erigon/turbo/services" "github.com/ledgerwatch/log/v3" "github.com/ledgerwatch/erigon-lib/chain" libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutil" "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/dbutils" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/debug" @@ -46,11 +44,13 @@ import ( "github.com/ledgerwatch/erigon/core/state" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/core/types/accounts" + "github.com/ledgerwatch/erigon/core/vm/evmtypes" "github.com/ledgerwatch/erigon/crypto" "github.com/ledgerwatch/erigon/crypto/cryptopool" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/erigon/rpc" + "github.com/ledgerwatch/erigon/turbo/services" ) const ( @@ -643,3 +643,11 @@ func (c *Clique) snapshots(latest uint64, total int) ([]*Snapshot, error) { return res, nil } + +func (c *Clique) GetTransferFunc() evmtypes.TransferFunc { + return consensus.Transfer +} + +func (c *Clique) GetPostApplyMessageFunc() evmtypes.PostApplyMessageFunc { + return nil +} diff --git a/consensus/consensus.go b/consensus/consensus.go index 8807827510b..a2b9176acc5 100644 --- a/consensus/consensus.go +++ b/consensus/consensus.go @@ -25,8 +25,10 @@ import ( "github.com/ledgerwatch/erigon-lib/chain" libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon/core/state" "github.com/ledgerwatch/erigon/core/types" + "github.com/ledgerwatch/erigon/core/vm/evmtypes" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/erigon/rpc" ) @@ -125,6 +127,10 @@ type EngineReader interface { CalculateRewards(config *chain.Config, header *types.Header, uncles []*types.Header, syscall SystemCall, ) ([]Reward, error) + GetTransferFunc() evmtypes.TransferFunc + + GetPostApplyMessageFunc() evmtypes.PostApplyMessageFunc + // Close terminates any background threads, DB's etc maintained by the consensus engine. Close() error } @@ -194,3 +200,11 @@ type PoW interface { // Hashrate returns the current mining hashrate of a PoW consensus engine. Hashrate() float64 } + +// Transfer subtracts amount from sender and adds amount to recipient using the given Db +func Transfer(db evmtypes.IntraBlockState, sender, recipient libcommon.Address, amount *uint256.Int, bailout bool) { + if !bailout { + db.SubBalance(sender, amount) + } + db.AddBalance(recipient, amount) +} diff --git a/consensus/ethash/ethash.go b/consensus/ethash/ethash.go index ef2840371de..ef8d64c8852 100644 --- a/consensus/ethash/ethash.go +++ b/consensus/ethash/ethash.go @@ -33,11 +33,12 @@ import ( "github.com/edsrzf/mmap-go" "github.com/hashicorp/golang-lru/v2/simplelru" - "github.com/ledgerwatch/erigon/consensus/ethash/ethashcfg" "github.com/ledgerwatch/erigon/common/debug" cmath "github.com/ledgerwatch/erigon/common/math" "github.com/ledgerwatch/erigon/consensus" + "github.com/ledgerwatch/erigon/consensus/ethash/ethashcfg" + "github.com/ledgerwatch/erigon/core/vm/evmtypes" "github.com/ledgerwatch/erigon/rpc" "github.com/ledgerwatch/log/v3" ) @@ -573,3 +574,11 @@ func (ethash *Ethash) APIs(chain consensus.ChainHeaderReader) []rpc.API { func SeedHash(block uint64) []byte { return seedHash(block) } + +func (ethash *Ethash) GetTransferFunc() evmtypes.TransferFunc { + return consensus.Transfer +} + +func (ethash *Ethash) GetPostApplyMessageFunc() evmtypes.PostApplyMessageFunc { + return nil +} diff --git a/consensus/merge/merge.go b/consensus/merge/merge.go index 1b69945ed97..3a047d48c7e 100644 --- a/consensus/merge/merge.go +++ b/consensus/merge/merge.go @@ -16,6 +16,7 @@ import ( "github.com/ledgerwatch/erigon/consensus/misc" "github.com/ledgerwatch/erigon/core/state" "github.com/ledgerwatch/erigon/core/types" + "github.com/ledgerwatch/erigon/core/vm/evmtypes" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rpc" "github.com/ledgerwatch/log/v3" @@ -340,6 +341,14 @@ func (s *Merge) APIs(chain consensus.ChainHeaderReader) []rpc.API { return s.eth1Engine.APIs(chain) } +func (s *Merge) GetTransferFunc() evmtypes.TransferFunc { + return s.eth1Engine.GetTransferFunc() +} + +func (s *Merge) GetPostApplyMessageFunc() evmtypes.PostApplyMessageFunc { + return s.eth1Engine.GetPostApplyMessageFunc() +} + func (s *Merge) Close() error { return s.eth1Engine.Close() } diff --git a/core/evm.go b/core/evm.go index 3421f8a9a45..d03158f4f0e 100644 --- a/core/evm.go +++ b/core/evm.go @@ -22,7 +22,6 @@ import ( "github.com/holiman/uint256" - "github.com/ledgerwatch/erigon-lib/chain" libcommon "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon/consensus" @@ -62,23 +61,27 @@ func NewEVMBlockContext(header *types.Header, blockHashFunc func(n uint64) libco } var transferFunc evmtypes.TransferFunc - if engine != nil && engine.Type() == chain.BorConsensus { - transferFunc = BorTransfer + var postApplyMessageFunc evmtypes.PostApplyMessageFunc + if engine != nil { + transferFunc = engine.GetTransferFunc() + postApplyMessageFunc = engine.GetPostApplyMessageFunc() } else { - transferFunc = Transfer + transferFunc = consensus.Transfer + postApplyMessageFunc = nil } return evmtypes.BlockContext{ - CanTransfer: CanTransfer, - Transfer: transferFunc, - GetHash: blockHashFunc, - Coinbase: beneficiary, - BlockNumber: header.Number.Uint64(), - Time: header.Time, - Difficulty: new(big.Int).Set(header.Difficulty), - BaseFee: &baseFee, - GasLimit: header.GasLimit, - PrevRanDao: prevRandDao, - ExcessBlobGas: excessBlobGas, + CanTransfer: CanTransfer, + Transfer: transferFunc, + GetHash: blockHashFunc, + PostApplyMessage: postApplyMessageFunc, + Coinbase: beneficiary, + BlockNumber: header.Number.Uint64(), + Time: header.Time, + Difficulty: new(big.Int).Set(header.Difficulty), + BaseFee: &baseFee, + GasLimit: header.GasLimit, + PrevRanDao: prevRandDao, + ExcessBlobGas: excessBlobGas, } } @@ -130,30 +133,3 @@ func GetHashFn(ref *types.Header, getHeader func(hash libcommon.Hash, number uin func CanTransfer(db evmtypes.IntraBlockState, addr libcommon.Address, amount *uint256.Int) bool { return !db.GetBalance(addr).Lt(amount) } - -// Transfer subtracts amount from sender and adds amount to recipient using the given Db -func Transfer(db evmtypes.IntraBlockState, sender, recipient libcommon.Address, amount *uint256.Int, bailout bool) { - if !bailout { - db.SubBalance(sender, amount) - } - db.AddBalance(recipient, amount) -} - -// BorTransfer transfer in Bor -func BorTransfer(db evmtypes.IntraBlockState, sender, recipient libcommon.Address, amount *uint256.Int, bailout bool) { - // get inputs before - input1 := db.GetBalance(sender).Clone() - input2 := db.GetBalance(recipient).Clone() - - if !bailout { - db.SubBalance(sender, amount) - } - db.AddBalance(recipient, amount) - - // get outputs after - output1 := db.GetBalance(sender).Clone() - output2 := db.GetBalance(recipient).Clone() - - // add transfer log - AddTransferLog(db, sender, recipient, amount, input1, input2, output1, output2) -} diff --git a/core/state_transition.go b/core/state_transition.go index 3f0649e9a44..59c3f43e9ff 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -96,41 +96,6 @@ type Message interface { IsFree() bool } -// ExecutionResult includes all output after executing given evm -// message no matter the execution itself is successful or not. -type ExecutionResult struct { - UsedGas uint64 // Total used gas but include the refunded gas - Err error // Any error encountered during the execution(listed in core/vm/errors.go) - ReturnData []byte // Returned data from evm(function result or data supplied with revert opcode) -} - -// Unwrap returns the internal evm error which allows us for further -// analysis outside. -func (result *ExecutionResult) Unwrap() error { - return result.Err -} - -// Failed returns the indicator whether the execution is successful or not -func (result *ExecutionResult) Failed() bool { return result.Err != nil } - -// Return is a helper function to help caller distinguish between revert reason -// and function return. Return returns the data after execution if no error occurs. -func (result *ExecutionResult) Return() []byte { - if result.Err != nil { - return nil - } - return libcommon.CopyBytes(result.ReturnData) -} - -// Revert returns the concrete revert reason if the execution is aborted by `REVERT` -// opcode. Note the reason can be nil if no data supplied with revert opcode. -func (result *ExecutionResult) Revert() []byte { - if result.Err != vm.ErrExecutionReverted { - return nil - } - return libcommon.CopyBytes(result.ReturnData) -} - // IntrinsicGas computes the 'intrinsic gas' for a message with the given data. func IntrinsicGas(data []byte, accessList types2.AccessList, isContractCreation bool, isHomestead, isEIP2028, isEIP3860 bool) (uint64, error) { // Zero and non-zero bytes are priced differently @@ -180,7 +145,7 @@ func NewStateTransition(evm *vm.EVM, msg Message, gp *GasPool) *StateTransition // `refunds` is false when it is not required to apply gas refunds // `gasBailout` is true when it is not required to fail transaction if the balance is not enough to pay gas. // for trace_call to replicate OE/Parity behaviour -func ApplyMessage(evm *vm.EVM, msg Message, gp *GasPool, refunds bool, gasBailout bool) (*ExecutionResult, error) { +func ApplyMessage(evm *vm.EVM, msg Message, gp *GasPool, refunds bool, gasBailout bool) (*evmtypes.ExecutionResult, error) { return NewStateTransition(evm, msg, gp).TransitionDb(refunds, gasBailout) } @@ -338,15 +303,11 @@ func (st *StateTransition) preCheck(gasBailout bool) error { // // However if any consensus issue encountered, return the error directly with // nil evm execution result. -func (st *StateTransition) TransitionDb(refunds bool, gasBailout bool) (*ExecutionResult, error) { +func (st *StateTransition) TransitionDb(refunds bool, gasBailout bool) (*evmtypes.ExecutionResult, error) { coinbase := st.evm.Context.Coinbase - var input1 *uint256.Int - var input2 *uint256.Int - if st.isBor { - input1 = st.state.GetBalance(st.msg.From()).Clone() - input2 = st.state.GetBalance(coinbase).Clone() - } + senderInitBalance := st.state.GetBalance(st.msg.From()).Clone() + coinbaseInitBalance := st.state.GetBalance(coinbase).Clone() // First check this message satisfies all consensus rules before // applying the message. The rules include these clauses @@ -446,30 +407,22 @@ func (st *StateTransition) TransitionDb(refunds bool, gasBailout bool) (*Executi st.state.AddBalance(*burntContractAddress, burnAmount) } } - if st.isBor { - // Deprecating transfer log and will be removed in future fork. PLEASE DO NOT USE this transfer log going forward. Parameters won't get updated as expected going forward with EIP1559 - // add transfer log - output1 := input1.Clone() - output2 := input2.Clone() - AddFeeTransferLog( - st.state, - - msg.From(), - coinbase, - - amount, - input1, - input2, - output1.Sub(output1, amount), - output2.Add(output2, amount), - ) + + result := &evmtypes.ExecutionResult{ + UsedGas: st.gasUsed(), + Err: vmerr, + Reverted: vmerr == vm.ErrExecutionReverted, + ReturnData: ret, + SenderInitBalance: senderInitBalance, + CoinbaseInitBalance: coinbaseInitBalance, + FeeTipped: amount, + } + + if st.evm.Context.PostApplyMessage != nil { + st.evm.Context.PostApplyMessage(st.state, msg.From(), coinbase, result) } - return &ExecutionResult{ - UsedGas: st.gasUsed(), - Err: vmerr, - ReturnData: ret, - }, nil + return result, nil } func (st *StateTransition) refundGas(refundQuotient uint64) { diff --git a/core/vm/evmtypes/evmtypes.go b/core/vm/evmtypes/evmtypes.go index 9d1e4c9d92e..e838a907685 100644 --- a/core/vm/evmtypes/evmtypes.go +++ b/core/vm/evmtypes/evmtypes.go @@ -21,7 +21,8 @@ type BlockContext struct { // Transfer transfers ether from one account to the other Transfer TransferFunc // GetHash returns the hash corresponding to n - GetHash GetHashFunc + GetHash GetHashFunc + PostApplyMessage PostApplyMessageFunc // Block information Coinbase common.Address // Provides information for COINBASE @@ -46,14 +47,59 @@ type TxContext struct { BlobHashes []common.Hash // Provides versioned blob hashes for BLOBHASH } +// ExecutionResult includes all output after executing given evm +// message no matter the execution itself is successful or not. +type ExecutionResult struct { + UsedGas uint64 // Total used gas but include the refunded gas + Err error // Any error encountered during the execution(listed in core/vm/errors.go) + Reverted bool // Whether the execution was aborted by `REVERT` + ReturnData []byte // Returned data from evm(function result or data supplied with revert opcode) + SenderInitBalance *uint256.Int + CoinbaseInitBalance *uint256.Int + FeeTipped *uint256.Int +} + +// Unwrap returns the internal evm error which allows us for further +// analysis outside. +func (result *ExecutionResult) Unwrap() error { + return result.Err +} + +// Failed returns the indicator whether the execution is successful or not +func (result *ExecutionResult) Failed() bool { return result.Err != nil } + +// Return is a helper function to help caller distinguish between revert reason +// and function return. Return returns the data after execution if no error occurs. +func (result *ExecutionResult) Return() []byte { + if result.Err != nil { + return nil + } + return common.CopyBytes(result.ReturnData) +} + +// Revert returns the concrete revert reason if the execution is aborted by `REVERT` +// opcode. Note the reason can be nil if no data supplied with revert opcode. +func (result *ExecutionResult) Revert() []byte { + if !result.Reverted { + return nil + } + return common.CopyBytes(result.ReturnData) +} + type ( // CanTransferFunc is the signature of a transfer guard function CanTransferFunc func(IntraBlockState, common.Address, *uint256.Int) bool + // TransferFunc is the signature of a transfer function TransferFunc func(IntraBlockState, common.Address, common.Address, *uint256.Int, bool) + // GetHashFunc returns the nth block hash in the blockchain // and is used by the BLOCKHASH EVM op code. GetHashFunc func(uint64) common.Hash + + // PostApplyMessageFunc is an extension point to execute custom logic at the end of core.ApplyMessage. + // It's used in Bor for AddFeeTransferLog. + PostApplyMessageFunc func(ibs IntraBlockState, sender common.Address, coinbase common.Address, result *ExecutionResult) ) // IntraBlockState is an EVM database for full state querying. diff --git a/core/vm/runtime/env.go b/core/vm/runtime/env.go index e83dc6d9843..14489a78dd7 100644 --- a/core/vm/runtime/env.go +++ b/core/vm/runtime/env.go @@ -17,6 +17,7 @@ package runtime import ( + "github.com/ledgerwatch/erigon/consensus" "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/core/vm" "github.com/ledgerwatch/erigon/core/vm/evmtypes" @@ -30,7 +31,7 @@ func NewEnv(cfg *Config) *vm.EVM { blockContext := evmtypes.BlockContext{ CanTransfer: core.CanTransfer, - Transfer: core.Transfer, + Transfer: consensus.Transfer, GetHash: cfg.GetHashFn, Coinbase: cfg.Coinbase, BlockNumber: cfg.BlockNumber.Uint64(), diff --git a/eth/tracers/internal/tracetest/calltrace_test.go b/eth/tracers/internal/tracetest/calltrace_test.go index 1ace9cafaf5..788ea60a510 100644 --- a/eth/tracers/internal/tracetest/calltrace_test.go +++ b/eth/tracers/internal/tracetest/calltrace_test.go @@ -34,6 +34,7 @@ import ( "github.com/ledgerwatch/erigon-lib/common/hexutility" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/math" + "github.com/ledgerwatch/erigon/consensus" "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/core/vm" @@ -135,7 +136,7 @@ func testCallTracer(tracerName string, dirPath string, t *testing.T) { signer := types.MakeSigner(test.Genesis.Config, uint64(test.Context.Number), uint64(test.Context.Time)) context := evmtypes.BlockContext{ CanTransfer: core.CanTransfer, - Transfer: core.Transfer, + Transfer: consensus.Transfer, Coinbase: test.Context.Miner, BlockNumber: uint64(test.Context.Number), Time: uint64(test.Context.Time), @@ -248,7 +249,7 @@ func benchTracer(b *testing.B, tracerName string, test *callTracerTest) { } context := evmtypes.BlockContext{ CanTransfer: core.CanTransfer, - Transfer: core.Transfer, + Transfer: consensus.Transfer, Coinbase: test.Context.Miner, BlockNumber: uint64(test.Context.Number), Time: uint64(test.Context.Time), @@ -308,7 +309,7 @@ func TestZeroValueToNotExitCall(t *testing.T) { } context := evmtypes.BlockContext{ CanTransfer: core.CanTransfer, - Transfer: core.Transfer, + Transfer: consensus.Transfer, Coinbase: libcommon.Address{}, BlockNumber: 8000000, Time: 5, diff --git a/eth/tracers/internal/tracetest/prestate_test.go b/eth/tracers/internal/tracetest/prestate_test.go index c6a3cfcfe06..007fbd17a42 100644 --- a/eth/tracers/internal/tracetest/prestate_test.go +++ b/eth/tracers/internal/tracetest/prestate_test.go @@ -30,6 +30,7 @@ import ( libcommon "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon-lib/common/dir" "github.com/ledgerwatch/erigon/common" + "github.com/ledgerwatch/erigon/consensus" "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/core/vm" @@ -100,7 +101,7 @@ func testPrestateDiffTracer(tracerName string, dirPath string, t *testing.T) { signer := types.MakeSigner(test.Genesis.Config, uint64(test.Context.Number), uint64(test.Context.Time)) context := evmtypes.BlockContext{ CanTransfer: core.CanTransfer, - Transfer: core.Transfer, + Transfer: consensus.Transfer, Coinbase: test.Context.Miner, BlockNumber: uint64(test.Context.Number), Time: uint64(test.Context.Time), diff --git a/eth/tracers/tracers_test.go b/eth/tracers/tracers_test.go index 378f8ff7488..5067a30f97c 100644 --- a/eth/tracers/tracers_test.go +++ b/eth/tracers/tracers_test.go @@ -20,11 +20,14 @@ import ( "crypto/ecdsa" "crypto/rand" "encoding/json" - "github.com/ledgerwatch/erigon-lib/common/hexutil" "math/big" "testing" + "github.com/ledgerwatch/erigon-lib/common/hexutil" + "github.com/stretchr/testify/require" + libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon/consensus" "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/core/vm" @@ -33,7 +36,6 @@ import ( "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/tests" "github.com/ledgerwatch/erigon/turbo/stages/mock" - "github.com/stretchr/testify/require" "github.com/holiman/uint256" @@ -73,7 +75,7 @@ func TestPrestateTracerCreate2(t *testing.T) { excessBlobGas := uint64(50000) context := evmtypes.BlockContext{ CanTransfer: core.CanTransfer, - Transfer: core.Transfer, + Transfer: consensus.Transfer, Coinbase: libcommon.Address{}, BlockNumber: 8000000, Time: 5, diff --git a/polygon/bor/bor.go b/polygon/bor/bor.go index b014ab27750..6235f2ca870 100644 --- a/polygon/bor/bor.go +++ b/polygon/bor/bor.go @@ -17,6 +17,7 @@ import ( "time" lru "github.com/hashicorp/golang-lru/arc/v2" + "github.com/holiman/uint256" "github.com/ledgerwatch/erigon-lib/common/dbg" "github.com/ledgerwatch/log/v3" "github.com/xsleonard/go-merkle" @@ -34,6 +35,7 @@ import ( "github.com/ledgerwatch/erigon/core/state" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/core/types/accounts" + "github.com/ledgerwatch/erigon/core/vm/evmtypes" "github.com/ledgerwatch/erigon/crypto" "github.com/ledgerwatch/erigon/crypto/cryptopool" "github.com/ledgerwatch/erigon/eth/ethconfig/estimate" @@ -1569,6 +1571,52 @@ func isSprintStart(number, sprint uint64) bool { return number%sprint == 0 } +// BorTransfer transfer in Bor +func BorTransfer(db evmtypes.IntraBlockState, sender, recipient libcommon.Address, amount *uint256.Int, bailout bool) { + // get inputs before + input1 := db.GetBalance(sender).Clone() + input2 := db.GetBalance(recipient).Clone() + + if !bailout { + db.SubBalance(sender, amount) + } + db.AddBalance(recipient, amount) + + // get outputs after + output1 := db.GetBalance(sender).Clone() + output2 := db.GetBalance(recipient).Clone() + + // add transfer log into state + addTransferLog(db, transferLogSig, sender, recipient, amount, input1, input2, output1, output2) +} + +func (c *Bor) GetTransferFunc() evmtypes.TransferFunc { + return BorTransfer +} + +// AddFeeTransferLog adds fee transfer log into state +// Deprecating transfer log and will be removed in future fork. PLEASE DO NOT USE this transfer log going forward. Parameters won't get updated as expected going forward with EIP1559 +func AddFeeTransferLog(ibs evmtypes.IntraBlockState, sender libcommon.Address, coinbase libcommon.Address, result *evmtypes.ExecutionResult) { + output1 := result.SenderInitBalance.Clone() + output2 := result.CoinbaseInitBalance.Clone() + addTransferLog( + ibs, + transferFeeLogSig, + sender, + coinbase, + result.FeeTipped, + result.SenderInitBalance, + result.CoinbaseInitBalance, + output1.Sub(output1, result.FeeTipped), + output2.Add(output2, result.FeeTipped), + ) + +} + +func (c *Bor) GetPostApplyMessageFunc() evmtypes.PostApplyMessageFunc { + return AddFeeTransferLog +} + // In bor, RLP encoding of BlockExtraData will be stored in the Extra field in the header type BlockExtraData struct { // Validator bytes of bor diff --git a/core/bor_fee_log.go b/polygon/bor/fee_log.go similarity index 55% rename from core/bor_fee_log.go rename to polygon/bor/fee_log.go index 135ffa64f5c..a3b68c2b532 100644 --- a/core/bor_fee_log.go +++ b/polygon/bor/fee_log.go @@ -1,7 +1,8 @@ -package core +package bor import ( "github.com/holiman/uint256" + libcommon "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon/core/types" @@ -11,64 +12,6 @@ import ( var transferLogSig = libcommon.HexToHash("0xe6497e3ee548a3372136af2fcb0696db31fc6cf20260707645068bd3fe97f3c4") var transferFeeLogSig = libcommon.HexToHash("0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63") var feeAddress = libcommon.HexToAddress("0x0000000000000000000000000000000000001010") -var zero = uint256.NewInt(0) - -// AddTransferLog adds transfer log into state -func AddTransferLog( - state evmtypes.IntraBlockState, - - sender, - recipient libcommon.Address, - - amount, - input1, - input2, - output1, - output2 *uint256.Int, -) { - addTransferLog( - state, - transferLogSig, - - sender, - recipient, - - amount, - input1, - input2, - output1, - output2, - ) -} - -// AddFeeTransferLog adds transfer log into state -// Deprecating transfer log and will be removed in future fork. PLEASE DO NOT USE this transfer log going forward. Parameters won't get updated as expected going forward with EIP1559 -func AddFeeTransferLog( - state evmtypes.IntraBlockState, - - sender, - recipient libcommon.Address, - - amount, - input1, - input2, - output1, - output2 *uint256.Int, -) { - addTransferLog( - state, - transferFeeLogSig, - - sender, - recipient, - - amount, - input1, - input2, - output1, - output2, - ) -} // addTransferLog adds transfer log into state func addTransferLog( @@ -85,7 +28,7 @@ func addTransferLog( output2 *uint256.Int, ) { // ignore if amount is 0 - if amount.Cmp(zero) <= 0 { + if amount.IsZero() { return } diff --git a/polygon/tracer/trace_bor_state_sync_txn.go b/polygon/tracer/trace_bor_state_sync_txn.go index ad08ce6a9f9..265ba7daed6 100644 --- a/polygon/tracer/trace_bor_state_sync_txn.go +++ b/polygon/tracer/trace_bor_state_sync_txn.go @@ -10,6 +10,7 @@ import ( "github.com/ledgerwatch/erigon-lib/chain" libcommon "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon/common/u256" "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/core/state" @@ -56,7 +57,7 @@ func TraceBorStateSyncTxnDebugAPI( tracer = NewBorStateSyncTxnTracer(tracer, len(stateSyncEvents), stateReceiverContract) rules := chainConfig.Rules(blockNum, blockTime) stateWriter := state.NewNoopWriter() - execCb := func(evm *vm.EVM, refunds bool) (*core.ExecutionResult, error) { + execCb := func(evm *vm.EVM, refunds bool) (*evmtypes.ExecutionResult, error) { return traceBorStateSyncTxn(ctx, ibs, stateWriter, stateReceiverContract, stateSyncEvents, evm, rules, txCtx, refunds) } @@ -75,7 +76,7 @@ func TraceBorStateSyncTxnTraceAPI( blockHash libcommon.Hash, blockNum uint64, blockTime uint64, -) (*core.ExecutionResult, error) { +) (*evmtypes.ExecutionResult, error) { stateSyncEvents, err := blockReader.EventsByBlock(ctx, dbTx, blockHash, blockNum) if err != nil { return nil, err @@ -102,7 +103,7 @@ func traceBorStateSyncTxn( rules *chain.Rules, txCtx evmtypes.TxContext, refunds bool, -) (*core.ExecutionResult, error) { +) (*evmtypes.ExecutionResult, error) { for _, eventData := range stateSyncEvents { select { case <-ctx.Done(): @@ -141,7 +142,7 @@ func traceBorStateSyncTxn( evm.Reset(txCtx, ibs) } - return &core.ExecutionResult{}, nil + return &evmtypes.ExecutionResult{}, nil } func initStateSyncTxContext(blockNum uint64, blockHash libcommon.Hash) evmtypes.TxContext { diff --git a/turbo/adapter/ethapi/api.go b/turbo/adapter/ethapi/api.go index e17c7c9d80d..70e31e82d86 100644 --- a/turbo/adapter/ethapi/api.go +++ b/turbo/adapter/ethapi/api.go @@ -21,19 +21,18 @@ import ( "fmt" "math/big" - "github.com/ledgerwatch/erigon-lib/common/hexutil" - "github.com/holiman/uint256" "github.com/ledgerwatch/log/v3" libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutil" "github.com/ledgerwatch/erigon-lib/common/hexutility" types2 "github.com/ledgerwatch/erigon-lib/types" "github.com/ledgerwatch/erigon/accounts/abi" "github.com/ledgerwatch/erigon/common/math" - "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/core/types" + "github.com/ledgerwatch/erigon/core/vm/evmtypes" "github.com/ledgerwatch/erigon/eth/tracers/logger" ) @@ -177,7 +176,7 @@ type Account struct { StateDiff *map[libcommon.Hash]libcommon.Hash `json:"stateDiff"` } -func NewRevertError(result *core.ExecutionResult) *RevertError { +func NewRevertError(result *evmtypes.ExecutionResult) *RevertError { reason, errUnpack := abi.UnpackRevert(result.Revert()) err := errors.New("execution reverted") if errUnpack == nil { diff --git a/turbo/jsonrpc/eth_call.go b/turbo/jsonrpc/eth_call.go index de0566ed6c1..6c0d22a1b2d 100644 --- a/turbo/jsonrpc/eth_call.go +++ b/turbo/jsonrpc/eth_call.go @@ -6,14 +6,13 @@ import ( "fmt" "math/big" - "github.com/ledgerwatch/erigon-lib/common/hexutil" - "github.com/holiman/uint256" "github.com/ledgerwatch/erigon-lib/kv/membatchwithdb" "github.com/ledgerwatch/log/v3" "google.golang.org/grpc" libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutil" "github.com/ledgerwatch/erigon-lib/common/hexutility" "github.com/ledgerwatch/erigon-lib/gointerfaces" txpool_proto "github.com/ledgerwatch/erigon-lib/gointerfaces/txpool" @@ -25,6 +24,7 @@ import ( "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/core/types/accounts" "github.com/ledgerwatch/erigon/core/vm" + "github.com/ledgerwatch/erigon/core/vm/evmtypes" "github.com/ledgerwatch/erigon/crypto" "github.com/ledgerwatch/erigon/eth/stagedsync" "github.com/ledgerwatch/erigon/eth/tracers/logger" @@ -256,7 +256,7 @@ func (api *APIImpl) EstimateGas(ctx context.Context, argsOrNil *ethapi2.CallArgs } // Create a helper to check if a gas allowance results in an executable transaction - executable := func(gas uint64) (bool, *core.ExecutionResult, error) { + executable := func(gas uint64) (bool, *evmtypes.ExecutionResult, error) { result, err := caller.DoCallWithNewGas(ctx, gas) if err != nil { if errors.Is(err, core.ErrIntrinsicGas) { diff --git a/turbo/jsonrpc/eth_receipts.go b/turbo/jsonrpc/eth_receipts.go index 4e89310e8e4..7371a21c6a1 100644 --- a/turbo/jsonrpc/eth_receipts.go +++ b/turbo/jsonrpc/eth_receipts.go @@ -537,7 +537,7 @@ func (e *intraBlockExec) changeBlock(header *types.Header) { e.vmConfig.SkipAnalysis = core.SkipAnalysis(e.chainConfig, e.blockNum) } -func (e *intraBlockExec) execTx(txNum uint64, txIndex int, txn types.Transaction) ([]*types.Log, *core.ExecutionResult, error) { +func (e *intraBlockExec) execTx(txNum uint64, txIndex int, txn types.Transaction) ([]*types.Log, *evmtypes.ExecutionResult, error) { e.stateReader.SetTxNum(txNum) txHash := txn.Hash() e.ibs.Reset() diff --git a/turbo/jsonrpc/otterscan_api.go b/turbo/jsonrpc/otterscan_api.go index 4e0a3940ad9..e2a1c284a51 100644 --- a/turbo/jsonrpc/otterscan_api.go +++ b/turbo/jsonrpc/otterscan_api.go @@ -23,6 +23,7 @@ import ( "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/core/vm" + "github.com/ledgerwatch/erigon/core/vm/evmtypes" "github.com/ledgerwatch/erigon/eth/ethutils" "github.com/ledgerwatch/erigon/rpc" "github.com/ledgerwatch/erigon/turbo/adapter/ethapi" @@ -115,7 +116,7 @@ func (api *OtterscanAPIImpl) getTransactionByHash(ctx context.Context, tx kv.Tx, return txn, block, blockHash, blockNum, txnIndex, nil } -func (api *OtterscanAPIImpl) runTracer(ctx context.Context, tx kv.Tx, hash common.Hash, tracer vm.EVMLogger) (*core.ExecutionResult, error) { +func (api *OtterscanAPIImpl) runTracer(ctx context.Context, tx kv.Tx, hash common.Hash, tracer vm.EVMLogger) (*evmtypes.ExecutionResult, error) { txn, block, _, _, txIndex, err := api.getTransactionByHash(ctx, tx, hash) if err != nil { return nil, err diff --git a/turbo/jsonrpc/overlay_api.go b/turbo/jsonrpc/overlay_api.go index f526755d6cc..6fc3fd3be22 100644 --- a/turbo/jsonrpc/overlay_api.go +++ b/turbo/jsonrpc/overlay_api.go @@ -19,6 +19,7 @@ import ( "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon-lib/kv/bitmapdb" "github.com/ledgerwatch/erigon/common/math" + "github.com/ledgerwatch/erigon/consensus" "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/core/state" "github.com/ledgerwatch/erigon/core/types" @@ -165,7 +166,7 @@ func (api *OverlayAPIImpl) CallConstructor(ctx context.Context, address common.A blockCtx = evmtypes.BlockContext{ CanTransfer: core.CanTransfer, - Transfer: core.Transfer, + Transfer: consensus.Transfer, GetHash: getHash, Coinbase: parent.Coinbase, BlockNumber: parent.Number.Uint64(), @@ -457,7 +458,7 @@ func (api *OverlayAPIImpl) replayBlock(ctx context.Context, blockNum uint64, sta var excessBlobGas uint64 = 0 blockCtx = evmtypes.BlockContext{ CanTransfer: core.CanTransfer, - Transfer: core.Transfer, + Transfer: consensus.Transfer, GetHash: getHash, Coinbase: parent.Coinbase, BlockNumber: parent.Number.Uint64(), diff --git a/turbo/jsonrpc/trace_adhoc.go b/turbo/jsonrpc/trace_adhoc.go index 519437796de..86fc74af6d5 100644 --- a/turbo/jsonrpc/trace_adhoc.go +++ b/turbo/jsonrpc/trace_adhoc.go @@ -16,12 +16,14 @@ import ( "github.com/ledgerwatch/erigon-lib/common/hexutility" "github.com/ledgerwatch/erigon-lib/kv" types2 "github.com/ledgerwatch/erigon-lib/types" + math2 "github.com/ledgerwatch/erigon/common/math" "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/core/state" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/core/types/accounts" "github.com/ledgerwatch/erigon/core/vm" + "github.com/ledgerwatch/erigon/core/vm/evmtypes" "github.com/ledgerwatch/erigon/eth/tracers" "github.com/ledgerwatch/erigon/polygon/tracer" "github.com/ledgerwatch/erigon/rpc" @@ -1015,7 +1017,7 @@ func (api *TraceAPIImpl) Call(ctx context.Context, args TraceCallParam, traceTyp }() gp := new(core.GasPool).AddGas(msg.Gas()).AddBlobGas(msg.BlobGas()) - var execResult *core.ExecutionResult + var execResult *evmtypes.ExecutionResult ibs.SetTxContext(libcommon.Hash{}, libcommon.Hash{}, 0) execResult, err = core.ApplyMessage(evm, msg, gp, true /* refunds */, true /* gasBailout */) if err != nil { @@ -1257,7 +1259,7 @@ func (api *TraceAPIImpl) doCallMany(ctx context.Context, dbtx kv.Tx, msgs []type ibs.Reset() var txFinalized bool - var execResult *core.ExecutionResult + var execResult *evmtypes.ExecutionResult if args.isBorStateSyncTxn { txFinalized = true execResult, err = tracer.TraceBorStateSyncTxnTraceAPI( diff --git a/turbo/jsonrpc/trace_adhoc_test.go b/turbo/jsonrpc/trace_adhoc_test.go index 547fb3dd1a1..e89eb674924 100644 --- a/turbo/jsonrpc/trace_adhoc_test.go +++ b/turbo/jsonrpc/trace_adhoc_test.go @@ -20,6 +20,7 @@ import ( "github.com/ledgerwatch/erigon/cmd/rpcdaemon/rpcdaemontest" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/math" + "github.com/ledgerwatch/erigon/consensus" "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/core/vm" @@ -160,7 +161,7 @@ func TestOeTracer(t *testing.T) { signer := types.MakeSigner(test.Genesis.Config, uint64(test.Context.Number), uint64(test.Context.Time)) context := evmtypes.BlockContext{ CanTransfer: core.CanTransfer, - Transfer: core.Transfer, + Transfer: consensus.Transfer, Coinbase: test.Context.Miner, BlockNumber: uint64(test.Context.Number), Time: uint64(test.Context.Time), diff --git a/turbo/jsonrpc/trace_filtering.go b/turbo/jsonrpc/trace_filtering.go index 29dd9d22852..584bf7f446e 100644 --- a/turbo/jsonrpc/trace_filtering.go +++ b/turbo/jsonrpc/trace_filtering.go @@ -17,6 +17,7 @@ import ( "github.com/ledgerwatch/erigon-lib/kv/iter" "github.com/ledgerwatch/erigon-lib/kv/order" "github.com/ledgerwatch/erigon-lib/kv/rawdbv3" + "github.com/ledgerwatch/erigon/consensus" "github.com/ledgerwatch/erigon/consensus/ethash" "github.com/ledgerwatch/erigon/core" @@ -24,6 +25,7 @@ import ( "github.com/ledgerwatch/erigon/core/state" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/core/vm" + "github.com/ledgerwatch/erigon/core/vm/evmtypes" "github.com/ledgerwatch/erigon/eth/stagedsync" "github.com/ledgerwatch/erigon/eth/tracers" "github.com/ledgerwatch/erigon/ethdb" @@ -792,7 +794,7 @@ func (api *TraceAPIImpl) filterV3(ctx context.Context, dbtx kv.TemporalTx, fromB gp := new(core.GasPool).AddGas(msg.Gas()).AddBlobGas(msg.BlobGas()) ibs.SetTxContext(txHash, lastBlockHash, txIndex) - var execResult *core.ExecutionResult + var execResult *evmtypes.ExecutionResult execResult, err = core.ApplyMessage(evm, msg, gp, true /* refunds */, false /* gasBailout */) if err != nil { if first { diff --git a/turbo/transactions/call.go b/turbo/transactions/call.go index 822f7505e4b..d5687c9a007 100644 --- a/turbo/transactions/call.go +++ b/turbo/transactions/call.go @@ -36,7 +36,7 @@ func DoCall( stateReader state.StateReader, headerReader services.HeaderReader, callTimeout time.Duration, -) (*core.ExecutionResult, error) { +) (*evmtypes.ExecutionResult, error) { // todo: Pending state is only known by the miner /* if blockNrOrHash.BlockNumber != nil && *blockNrOrHash.BlockNumber == rpc.PendingBlockNumber { @@ -137,7 +137,7 @@ type ReusableCaller struct { func (r *ReusableCaller) DoCallWithNewGas( ctx context.Context, newGas uint64, -) (*core.ExecutionResult, error) { +) (*evmtypes.ExecutionResult, error) { var cancel context.CancelFunc if r.callTimeout > 0 { ctx, cancel = context.WithTimeout(ctx, r.callTimeout) diff --git a/turbo/transactions/tracing.go b/turbo/transactions/tracing.go index e8b1fc4c364..1ee638bb558 100644 --- a/turbo/transactions/tracing.go +++ b/turbo/transactions/tracing.go @@ -14,6 +14,7 @@ import ( "github.com/ledgerwatch/erigon-lib/chain" libcommon "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon/consensus" "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/core/state" @@ -156,7 +157,7 @@ func TraceTx( defer cancel() - execCb := func(evm *vm.EVM, refunds bool) (*core.ExecutionResult, error) { + execCb := func(evm *vm.EVM, refunds bool) (*evmtypes.ExecutionResult, error) { gp := new(core.GasPool).AddGas(message.Gas()).AddBlobGas(message.BlobGas()) return core.ApplyMessage(evm, message, gp, refunds, false /* gasBailout */) } @@ -218,7 +219,7 @@ func ExecuteTraceTx( stream *jsoniter.Stream, tracer vm.EVMLogger, streaming bool, - execCb func(evm *vm.EVM, refunds bool) (*core.ExecutionResult, error), + execCb func(evm *vm.EVM, refunds bool) (*evmtypes.ExecutionResult, error), ) error { // Run the transaction with tracing enabled. evm := vm.NewEVM(blockCtx, txCtx, ibs, chainConfig, vm.Config{Debug: true, Tracer: tracer, NoBaseFee: true})