From 3516e37cd7f8d53b41154a5859e4d01579e3b772 Mon Sep 17 00:00:00 2001 From: Somnath Banerjee Date: Thu, 13 Jun 2024 17:12:28 +0400 Subject: [PATCH 1/3] Add zero check in tx.Sender func --- core/types/blob_tx.go | 5 ++++- core/types/dynamic_fee_tx.go | 5 ++++- core/types/legacy_tx.go | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/core/types/blob_tx.go b/core/types/blob_tx.go index d9f0eb0ec6c..cdda3ea7ef3 100644 --- a/core/types/blob_tx.go +++ b/core/types/blob_tx.go @@ -82,7 +82,10 @@ func (stx *BlobTx) AsMessage(s Signer, baseFee *big.Int, rules *chain.Rules) (Me func (stx *BlobTx) Sender(signer Signer) (libcommon.Address, error) { if sc := stx.from.Load(); sc != nil { - return sc.(libcommon.Address), nil + zeroAddr := libcommon.Address{} + if sc.(libcommon.Address) != zeroAddr { // Sender address can never be zero in a transaction with a valid signer + return sc.(libcommon.Address), nil + } } addr, err := signer.Sender(stx) if err != nil { diff --git a/core/types/dynamic_fee_tx.go b/core/types/dynamic_fee_tx.go index 11e4ec8b45b..834b33fd8cd 100644 --- a/core/types/dynamic_fee_tx.go +++ b/core/types/dynamic_fee_tx.go @@ -428,7 +428,10 @@ func (tx *DynamicFeeTransaction) GetChainID() *uint256.Int { func (tx *DynamicFeeTransaction) Sender(signer Signer) (libcommon.Address, error) { if sc := tx.from.Load(); sc != nil { - return sc.(libcommon.Address), nil + zeroAddr := libcommon.Address{} + if sc.(libcommon.Address) != zeroAddr{ // Sender address can never be zero in a transaction with a valid signer + return sc.(libcommon.Address), nil + } } addr, err := signer.Sender(tx) if err != nil { diff --git a/core/types/legacy_tx.go b/core/types/legacy_tx.go index 21139d9aa22..4bf4c3d5f4e 100644 --- a/core/types/legacy_tx.go +++ b/core/types/legacy_tx.go @@ -432,7 +432,10 @@ func (tx *LegacyTx) GetChainID() *uint256.Int { func (tx *LegacyTx) Sender(signer Signer) (libcommon.Address, error) { if sc := tx.from.Load(); sc != nil { - return sc.(libcommon.Address), nil + zeroAddr := libcommon.Address{} + if sc.(libcommon.Address) != zeroAddr { // Sender address can never be zero in a transaction with a valid signer + return sc.(libcommon.Address), nil + } } addr, err := signer.Sender(tx) if err != nil { From ccfc06fc592e072cd944e7240cb1d9e8d00e2c98 Mon Sep 17 00:00:00 2001 From: Somnath Banerjee Date: Thu, 13 Jun 2024 18:07:10 +0400 Subject: [PATCH 2/3] fmt --- core/types/dynamic_fee_tx.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/types/dynamic_fee_tx.go b/core/types/dynamic_fee_tx.go index 834b33fd8cd..96c30846b63 100644 --- a/core/types/dynamic_fee_tx.go +++ b/core/types/dynamic_fee_tx.go @@ -429,7 +429,7 @@ func (tx *DynamicFeeTransaction) GetChainID() *uint256.Int { func (tx *DynamicFeeTransaction) Sender(signer Signer) (libcommon.Address, error) { if sc := tx.from.Load(); sc != nil { zeroAddr := libcommon.Address{} - if sc.(libcommon.Address) != zeroAddr{ // Sender address can never be zero in a transaction with a valid signer + if sc.(libcommon.Address) != zeroAddr { // Sender address can never be zero in a transaction with a valid signer return sc.(libcommon.Address), nil } } From 008b8e62ebd35b1fc49c8b4353e28e476d0b3611 Mon Sep 17 00:00:00 2001 From: Somnath Banerjee Date: Fri, 28 Jun 2024 15:34:00 +0400 Subject: [PATCH 3/3] Add check to access list tx --- core/types/access_list_tx.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/types/access_list_tx.go b/core/types/access_list_tx.go index c0b659fec12..8e418e7b907 100644 --- a/core/types/access_list_tx.go +++ b/core/types/access_list_tx.go @@ -506,7 +506,10 @@ func (tx *AccessListTx) GetChainID() *uint256.Int { func (tx *AccessListTx) Sender(signer Signer) (libcommon.Address, error) { if sc := tx.from.Load(); sc != nil { - return sc.(libcommon.Address), nil + zeroAddr := libcommon.Address{} + if sc.(libcommon.Address) != zeroAddr { // Sender address can never be zero in a transaction with a valid signer + return sc.(libcommon.Address), nil + } } addr, err := signer.Sender(tx) if err != nil {