diff --git a/execution/types/access_list_tx.go b/execution/types/access_list_tx.go index b8f6a3feb49..cf6bab66da2 100644 --- a/execution/types/access_list_tx.go +++ b/execution/types/access_list_tx.go @@ -462,18 +462,29 @@ func (tx *AccessListTx) Hash() common.Hash { return hash } +type accessListTxSigHash struct { + ChainID *big.Int + Nonce uint64 + GasPrice *uint256.Int + Gas uint64 + To *common.Address `rlp:"nil"` + Value *uint256.Int + Data []byte + AccessList AccessList +} + func (tx *AccessListTx) SigningHash(chainID *big.Int) common.Hash { return prefixedRlpHash( AccessListTxType, - []any{ - chainID, - tx.Nonce, - tx.GasPrice, - tx.GasLimit, - tx.To, - tx.Value, - tx.Data, - tx.AccessList, + &accessListTxSigHash{ + ChainID: chainID, + Nonce: tx.Nonce, + GasPrice: tx.GasPrice, + Gas: tx.GasLimit, + To: tx.To, + Value: tx.Value, + Data: tx.Data, + AccessList: tx.AccessList, }) } diff --git a/execution/types/blob_tx.go b/execution/types/blob_tx.go index be2be5fde76..8a6df3fc889 100644 --- a/execution/types/blob_tx.go +++ b/execution/types/blob_tx.go @@ -135,21 +135,35 @@ func (stx *BlobTx) Hash() common.Hash { return hash } +type blobTxSigHash struct { + ChainID *big.Int + Nonce uint64 + GasTipCap *uint256.Int + GasFeeCap *uint256.Int + Gas uint64 + To *common.Address + Value *uint256.Int + Data []byte + AccessList AccessList + BlobFeeCap *uint256.Int + BlobHashes []common.Hash +} + func (stx *BlobTx) SigningHash(chainID *big.Int) common.Hash { return prefixedRlpHash( BlobTxType, - []any{ - chainID, - stx.Nonce, - stx.TipCap, - stx.FeeCap, - stx.GasLimit, - stx.To, - stx.Value, - stx.Data, - stx.AccessList, - stx.MaxFeePerBlobGas, - stx.BlobVersionedHashes, + &blobTxSigHash{ + ChainID: chainID, + Nonce: stx.Nonce, + GasTipCap: stx.TipCap, + GasFeeCap: stx.FeeCap, + Gas: stx.GasLimit, + To: stx.To, + Value: stx.Value, + Data: stx.Data, + AccessList: stx.AccessList, + BlobFeeCap: stx.MaxFeePerBlobGas, + BlobHashes: stx.BlobVersionedHashes, }) } diff --git a/execution/types/dynamic_fee_tx.go b/execution/types/dynamic_fee_tx.go index c81a9115d96..f284b3ab47c 100644 --- a/execution/types/dynamic_fee_tx.go +++ b/execution/types/dynamic_fee_tx.go @@ -379,19 +379,31 @@ func (tx *DynamicFeeTransaction) Hash() common.Hash { return hash } +type dynamicFeeTxSigHash struct { + ChainID *big.Int + Nonce uint64 + GasTipCap *uint256.Int + GasFeeCap *uint256.Int + Gas uint64 + To *common.Address `rlp:"nil"` + Value *uint256.Int + Data []byte + AccessList AccessList +} + func (tx *DynamicFeeTransaction) SigningHash(chainID *big.Int) common.Hash { return prefixedRlpHash( DynamicFeeTxType, - []any{ - chainID, - tx.Nonce, - tx.TipCap, - tx.FeeCap, - tx.GasLimit, - tx.To, - tx.Value, - tx.Data, - tx.AccessList, + &dynamicFeeTxSigHash{ + ChainID: chainID, + Nonce: tx.Nonce, + GasTipCap: tx.TipCap, + GasFeeCap: tx.FeeCap, + Gas: tx.GasLimit, + To: tx.To, + Value: tx.Value, + Data: tx.Data, + AccessList: tx.AccessList, }) } diff --git a/execution/types/legacy_tx.go b/execution/types/legacy_tx.go index 86da1a8931b..fb210b51af3 100644 --- a/execution/types/legacy_tx.go +++ b/execution/types/legacy_tx.go @@ -384,16 +384,30 @@ func (tx *LegacyTx) Hash() common.Hash { return hash } +type legacyTxSigHash struct { + Nonce uint64 + GasPrice *uint256.Int + Gas uint64 + To *common.Address `rlp:"nil"` + Value *uint256.Int + Data []byte + ChainID *big.Int + V uint + R uint +} + func (tx *LegacyTx) SigningHash(chainID *big.Int) common.Hash { if chainID != nil && chainID.Sign() != 0 { - return rlpHash([]any{ - tx.Nonce, - tx.GasPrice, - tx.GasLimit, - tx.To, - tx.Value, - tx.Data, - chainID, uint(0), uint(0), + return rlpHash(&legacyTxSigHash{ + Nonce: tx.Nonce, + GasPrice: tx.GasPrice, + Gas: tx.GasLimit, + To: tx.To, + Value: tx.Value, + Data: tx.Data, + ChainID: chainID, + V: uint(0), + R: uint(0), }) } return rlpHash([]any{ diff --git a/execution/types/set_code_tx.go b/execution/types/set_code_tx.go index 8e8c2e69d09..0e165711077 100644 --- a/execution/types/set_code_tx.go +++ b/execution/types/set_code_tx.go @@ -196,20 +196,33 @@ func (tx *SetCodeTransaction) Hash() common.Hash { return hash } +type setCodeTxSigHash struct { + ChainID *big.Int + Nonce uint64 + GasTipCap *uint256.Int + GasFeeCap *uint256.Int + Gas uint64 + To *common.Address + Value *uint256.Int + Data []byte + AccessList AccessList + AuthList []Authorization +} + func (tx *SetCodeTransaction) SigningHash(chainID *big.Int) common.Hash { return prefixedRlpHash( SetCodeTxType, - []any{ - chainID, - tx.Nonce, - tx.TipCap, - tx.FeeCap, - tx.GasLimit, - tx.To, - tx.Value, - tx.Data, - tx.AccessList, - tx.Authorizations, + &setCodeTxSigHash{ + ChainID: chainID, + Nonce: tx.Nonce, + GasTipCap: tx.TipCap, + GasFeeCap: tx.FeeCap, + Gas: tx.GasLimit, + To: tx.To, + Value: tx.Value, + Data: tx.Data, + AccessList: tx.AccessList, + AuthList: tx.Authorizations, }) }