From 1cd4c565633d63853de819f6219d5f9e590076a1 Mon Sep 17 00:00:00 2001 From: Sun Hyuk Ahn Date: Fri, 31 Jan 2025 06:24:19 +0900 Subject: [PATCH] core: explicit eoa skip check --- core/types/eth_transaction.go | 15 ++++++----- core/types/transaction.go | 49 +++++++++++++++++++---------------- rpc/harmony/types.go | 2 +- 3 files changed, 35 insertions(+), 31 deletions(-) diff --git a/core/types/eth_transaction.go b/core/types/eth_transaction.go index ee8757cae7..ac3e0ff8a5 100644 --- a/core/types/eth_transaction.go +++ b/core/types/eth_transaction.go @@ -358,13 +358,14 @@ func (tx *EthTransaction) IsEthCompatible() bool { // XXX Rename message to something less arbitrary? func (tx *EthTransaction) AsMessage(s Signer) (Message, error) { msg := Message{ - nonce: tx.data.AccountNonce, - gasLimit: tx.data.GasLimit, - gasPrice: new(big.Int).Set(tx.data.Price), - to: tx.data.Recipient, - value: tx.data.Amount, - data: tx.data.Payload, - skipNonceChecks: false, + nonce: tx.data.AccountNonce, + gasLimit: tx.data.GasLimit, + gasPrice: new(big.Int).Set(tx.data.Price), + to: tx.data.Recipient, + value: tx.data.Amount, + data: tx.data.Payload, + skipNonceChecks: false, + skipFromEOACheck: false, } var err error diff --git a/core/types/transaction.go b/core/types/transaction.go index 1e3f55cbba..a98b999026 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -470,13 +470,14 @@ func (tx *Transaction) ConvertToEth() *EthTransaction { // XXX Rename message to something less arbitrary? func (tx *Transaction) AsMessage(s Signer) (Message, error) { msg := Message{ - nonce: tx.data.AccountNonce, - gasLimit: tx.data.GasLimit, - gasPrice: new(big.Int).Set(tx.data.Price), - to: tx.data.Recipient, - value: tx.data.Amount, - data: tx.data.Payload, - skipNonceChecks: false, + nonce: tx.data.AccountNonce, + gasLimit: tx.data.GasLimit, + gasPrice: new(big.Int).Set(tx.data.Price), + to: tx.data.Recipient, + value: tx.data.Amount, + data: tx.data.Payload, + skipNonceChecks: false, + skipFromEOACheck: false, } var err error @@ -700,16 +701,17 @@ type Message struct { } // NewMessage returns new message. -func NewMessage(from common.Address, to *common.Address, nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, skipNonceChecks bool) Message { +func NewMessage(from common.Address, to *common.Address, nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, skipNonceChecks, skipFromEOACheck bool) Message { return Message{ - from: from, - to: to, - nonce: nonce, - value: amount, - gasLimit: gasLimit, - gasPrice: gasPrice, - data: data, - skipNonceChecks: skipNonceChecks, + from: from, + to: to, + nonce: nonce, + value: amount, + gasLimit: gasLimit, + gasPrice: gasPrice, + data: data, + skipNonceChecks: skipNonceChecks, + skipFromEOACheck: skipFromEOACheck, } } @@ -717,13 +719,14 @@ func NewMessage(from common.Address, to *common.Address, nonce uint64, amount *b // always need checkNonce func NewStakingMessage(from common.Address, nonce uint64, gasLimit uint64, gasPrice *big.Int, data []byte, blockNum *big.Int) Message { return Message{ - from: from, - nonce: nonce, - gasLimit: gasLimit, - gasPrice: new(big.Int).Set(gasPrice), - data: data, - skipNonceChecks: false, - blockNum: blockNum, + from: from, + nonce: nonce, + gasLimit: gasLimit, + gasPrice: new(big.Int).Set(gasPrice), + data: data, + blockNum: blockNum, + skipNonceChecks: false, + skipFromEOACheck: false, } } diff --git a/rpc/harmony/types.go b/rpc/harmony/types.go index 479763ccee..64609f98d6 100644 --- a/rpc/harmony/types.go +++ b/rpc/harmony/types.go @@ -72,7 +72,7 @@ func (args *CallArgs) ToMessage(globalGasCap *big.Int) types.Message { data = []byte(*args.Data) } - msg := types.NewMessage(addr, args.To, 0, value, gas, gasPrice, data, true) + msg := types.NewMessage(addr, args.To, 0, value, gas, gasPrice, data, true, true) return msg }