Skip to content

Commit

Permalink
core: explicit eoa skip check
Browse files Browse the repository at this point in the history
  • Loading branch information
Sun Hyuk Ahn committed Jan 30, 2025
1 parent 46780e2 commit 1cd4c56
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 31 deletions.
15 changes: 8 additions & 7 deletions core/types/eth_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
49 changes: 26 additions & 23 deletions core/types/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -700,30 +701,32 @@ 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,
}
}

// NewStakingMessage returns new message of staking type
// 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,
}
}

Expand Down
2 changes: 1 addition & 1 deletion rpc/harmony/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 1cd4c56

Please sign in to comment.