From 33400fb1529cfade2f9fe774fb5851bea9100984 Mon Sep 17 00:00:00 2001 From: Sina Mahmoodi Date: Fri, 16 Aug 2024 09:23:53 +0200 Subject: [PATCH] review comments, pt. 1 --- core/state_processor.go | 2 +- core/state_transition.go | 9 +++++---- core/vm/contracts.go | 3 ++- internal/ethapi/transaction_args.go | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/core/state_processor.go b/core/state_processor.go index cc5d459252..75573d7e6d 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -135,7 +135,7 @@ func ApplyTransactionWithEVM(msg *Message, config *params.ChainConfig, gp *GasPo } *usedGas += result.UsedGas - return MakeReceipt(evm, result, statedb, blockNumber, blockHash, tx, *usedGas, root), err + return MakeReceipt(evm, result, statedb, blockNumber, blockHash, tx, *usedGas, root), nil } // MakeReceipt generates the receipt object for a transaction given its execution result. diff --git a/core/state_transition.go b/core/state_transition.go index 2f42890cb4..823967b220 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -146,8 +146,9 @@ type Message struct { // account nonce in state. // This field will be set to true for operations like RPC eth_call. SkipNonceChecks bool - // When SkipFromEoACheck is true, the message sender is not checked to be an EOA. - SkipFromEoACheck bool + + // When SkipFromEOACheck is true, the message sender is not checked to be an EOA. + SkipFromEOACheck bool } // TransactionToMessage converts a transaction into a Message. @@ -163,7 +164,7 @@ func TransactionToMessage(tx *types.Transaction, s types.Signer, baseFee *big.In Data: tx.Data(), AccessList: tx.AccessList(), SkipNonceChecks: false, - SkipFromEoACheck: false, + SkipFromEOACheck: false, BlobHashes: tx.BlobHashes(), BlobGasFeeCap: tx.BlobGasFeeCap(), } @@ -297,7 +298,7 @@ func (st *StateTransition) preCheck() error { msg.From.Hex(), stNonce) } } - if !msg.SkipFromEoACheck { + if !msg.SkipFromEOACheck { // Make sure the sender is an EOA codeHash := st.state.GetCodeHash(msg.From) if codeHash != (common.Hash{}) && codeHash != types.EmptyCodeHash { diff --git a/core/vm/contracts.go b/core/vm/contracts.go index 74347b8fdb..a0c3cee70a 100644 --- a/core/vm/contracts.go +++ b/core/vm/contracts.go @@ -172,7 +172,8 @@ func init() { } } -// Copy returns a copy of the precompiled contracts. +// Copy returns a copy of the precompiled contracts. The precompiled +// contracts are shallow-copied. It should be safe as they are stateless/immutable. func (p PrecompiledContracts) Copy() PrecompiledContracts { c := make(PrecompiledContracts) for k, v := range p { diff --git a/internal/ethapi/transaction_args.go b/internal/ethapi/transaction_args.go index 37d8b1a058..92cb9c5327 100644 --- a/internal/ethapi/transaction_args.go +++ b/internal/ethapi/transaction_args.go @@ -465,7 +465,7 @@ func (args *TransactionArgs) ToMessage(baseFee *big.Int, skipNonceCheck, skipEoA BlobGasFeeCap: (*big.Int)(args.BlobFeeCap), BlobHashes: args.BlobHashes, SkipNonceChecks: skipNonceCheck, - SkipFromEoACheck: skipEoACheck, + SkipFromEOACheck: skipEoACheck, } }