Skip to content

Commit

Permalink
Add zero check in tx.Sender func (#11049)
Browse files Browse the repository at this point in the history
Copy PR #10737 into `main`

Co-authored-by: Somnath <snb895@outlook.com>
  • Loading branch information
yperbasis and somnathb1 authored Jul 5, 2024
1 parent 9251600 commit 1eb5d3d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
5 changes: 4 additions & 1 deletion core/types/access_list_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,10 @@ func (tx *AccessListTx) cashedSender() (sender libcommon.Address, ok bool) {
}
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 {
Expand Down
5 changes: 4 additions & 1 deletion core/types/blob_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ func (stx *BlobTx) cashedSender() (sender libcommon.Address, ok bool) {

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 {
Expand Down
5 changes: 4 additions & 1 deletion core/types/dynamic_fee_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,10 @@ func (tx *DynamicFeeTransaction) cashedSender() (sender libcommon.Address, ok bo
}
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 {
Expand Down
5 changes: 4 additions & 1 deletion core/types/legacy_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,10 @@ func (tx *LegacyTx) cashedSender() (sender libcommon.Address, ok bool) {
}
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 {
Expand Down

0 comments on commit 1eb5d3d

Please sign in to comment.