Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions execution/types/access_list_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
}

Expand Down
38 changes: 26 additions & 12 deletions execution/types/blob_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
}

Expand Down
32 changes: 22 additions & 10 deletions execution/types/dynamic_fee_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
}

Expand Down
30 changes: 22 additions & 8 deletions execution/types/legacy_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
35 changes: 24 additions & 11 deletions execution/types/set_code_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
}

Expand Down
Loading