Skip to content

Commit

Permalink
Add zero check in tx.Sender func (#10737)
Browse files Browse the repository at this point in the history
This is an additional check as #9990 could not be reliably reproduced.
The conjecture is that at some point there is a race condition somewhere
related to either storing snapshot file for an older block or updating
the DB for a more recent block.
Somewhere the code sets sender value directly to zero or overwrites a
pointer, leading to sender address being incorrectly assigned to ZERO.
  • Loading branch information
somnathb1 authored and yperbasis committed Jul 5, 2024
1 parent a77234e commit ba98f73
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 ba98f73

Please sign in to comment.