Skip to content

eth: add tx to locals only if it has a chance of acceptance #31618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 17, 2025

Conversation

rjl493456442
Copy link
Member

@rjl493456442 rjl493456442 commented Apr 12, 2025

This pull request improves error handling for local transaction submissions.

Specifically, if a transaction fails with a temporary error but might be accepted later,
the error will not be returned to the user; instead, the transaction will be tracked locally
for resubmission.

However, if the transaction fails with a permanent error (e.g., invalid transaction or
insufficient balance), the error will be propagated to the user.

These errors returned in the legacyPool are regarded as temporary failure:

  • ErrOutOfOrderTxFromDelegated
  • txpool.ErrInflightTxLimitReached
  • ErrAuthorityReserved
  • txpool.ErrUnderpriced
  • ErrTxPoolOverflow
  • ErrFutureReplacePending

Notably, InsufficientBalance is also treated as a permanent error, as it’s highly unlikely
that users will transfer funds into the sender account after submitting the transaction.
Otherwise, users may be confused—seeing their transaction submitted but unaware
that the sender lacks sufficient funds—and continue waiting for it to be included.

@rjl493456442 rjl493456442 added this to the 1.15.9 milestone Apr 14, 2025
@fjl
Copy link
Contributor

fjl commented Apr 17, 2025

I don't like how the wrapping is implemented. It's way too complicated with the extra type. We can just add a function that checks if the error is temporary:

func IsTemporaryReject(error) bool

and then use this function in the RPC handler. The problem is just where this function should live. We can't have it in package txpool because of import cycle. So we'd need a subpackage of txpool to contain this.

I guess it could be in package txpool/locals.

// reason to reject a transaction from being included in the txpool. The result
// may change if the txpool's state changes later.
func IsTemporaryReject(err error) bool {
return legacypool.IsTemporaryReject(err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's kind of OK like this, but also still feels like too much indirection. We can just put the switch here.

@lightclient
Copy link
Member

@rjl493456442 I pushed a change to move the switch solely into locals, feel free to revert and do something different if you had another idea. I think this addresses Felix's concern about the indirection. Could have also removed it from locals and kept only in legacypool? I don't have a strong opinion between the two.

@fjl fjl changed the title core/txpool: annotate tx error if it might be accepted later internal/ethapi: add tx to locals only if it has a chance of acceptance Apr 17, 2025
@fjl
Copy link
Contributor

fjl commented Apr 17, 2025

I wanted to have this in package locals because the concept of temporary reject only matters in order to decide if something should be tracked in locals.

@fjl fjl changed the title internal/ethapi: add tx to locals only if it has a chance of acceptance eth: add tx to locals only if it has a chance of acceptance Apr 17, 2025
@fjl fjl merged commit 9089f94 into ethereum:master Apr 17, 2025
4 checks passed
sivaratrisrinivas pushed a commit to sivaratrisrinivas/go-ethereum that referenced this pull request Apr 21, 2025
…#31618)

This pull request improves error handling for local transaction submissions.

Specifically, if a transaction fails with a temporary error but might be
accepted later, the error will not be returned to the user; instead, the
transaction will be tracked locally for resubmission. 

However, if the transaction fails with a permanent error (e.g., invalid
transaction or insufficient balance), the error will be propagated to the user.

These errors returned in the legacyPool are regarded as temporary failure:

- `ErrOutOfOrderTxFromDelegated`
- `txpool.ErrInflightTxLimitReached`
- `ErrAuthorityReserved`
- `txpool.ErrUnderpriced`
- `ErrTxPoolOverflow`
- `ErrFutureReplacePending`

Notably, InsufficientBalance is also treated as a permanent error, as
it’s highly unlikely that users will transfer funds into the sender account
after submitting the transaction. Otherwise, users may be confused—seeing
their transaction submitted but unaware that the sender lacks sufficient funds—and
continue waiting for it to be included.

---------

Co-authored-by: lightclient <[email protected]>
0g-wh pushed a commit to 0glabs/0g-geth that referenced this pull request Apr 22, 2025
…#31618)

This pull request improves error handling for local transaction submissions.

Specifically, if a transaction fails with a temporary error but might be
accepted later, the error will not be returned to the user; instead, the
transaction will be tracked locally for resubmission. 

However, if the transaction fails with a permanent error (e.g., invalid
transaction or insufficient balance), the error will be propagated to the user.

These errors returned in the legacyPool are regarded as temporary failure:

- `ErrOutOfOrderTxFromDelegated`
- `txpool.ErrInflightTxLimitReached`
- `ErrAuthorityReserved`
- `txpool.ErrUnderpriced`
- `ErrTxPoolOverflow`
- `ErrFutureReplacePending`

Notably, InsufficientBalance is also treated as a permanent error, as
it’s highly unlikely that users will transfer funds into the sender account
after submitting the transaction. Otherwise, users may be confused—seeing
their transaction submitted but unaware that the sender lacks sufficient funds—and
continue waiting for it to be included.

---------

Co-authored-by: lightclient <[email protected]>
@will-yjn
Copy link

From my understanding, after the v1.15.9, only successful txs will return txhash. Permanently failed txs will return error. And only temporarily failed txs will be tracked locally for resubmission. Am I correct?

@rjl493456442
Copy link
Member Author

rjl493456442 commented Apr 22, 2025

From my understanding, after the v1.15.9, only successful txs will return txhash. Permanently failed txs will return error. And only temporarily failed txs will be tracked locally for resubmission. Am I correct?

If the transaction is failed with permanent error, this error will be bubbled up to users;
otherwise, the transaction hash is returned, regardless of it's accepted successfully,
or fails with the temporary error and waits for resubmission.

0g-wh pushed a commit to 0g-wh/0g-geth that referenced this pull request May 8, 2025
…#31618)

This pull request improves error handling for local transaction submissions.

Specifically, if a transaction fails with a temporary error but might be
accepted later, the error will not be returned to the user; instead, the
transaction will be tracked locally for resubmission. 

However, if the transaction fails with a permanent error (e.g., invalid
transaction or insufficient balance), the error will be propagated to the user.

These errors returned in the legacyPool are regarded as temporary failure:

- `ErrOutOfOrderTxFromDelegated`
- `txpool.ErrInflightTxLimitReached`
- `ErrAuthorityReserved`
- `txpool.ErrUnderpriced`
- `ErrTxPoolOverflow`
- `ErrFutureReplacePending`

Notably, InsufficientBalance is also treated as a permanent error, as
it’s highly unlikely that users will transfer funds into the sender account
after submitting the transaction. Otherwise, users may be confused—seeing
their transaction submitted but unaware that the sender lacks sufficient funds—and
continue waiting for it to be included.

---------

Co-authored-by: lightclient <[email protected]>
Rampex1 pushed a commit to streamingfast/go-ethereum that referenced this pull request May 15, 2025
…#31618)

This pull request improves error handling for local transaction submissions.

Specifically, if a transaction fails with a temporary error but might be
accepted later, the error will not be returned to the user; instead, the
transaction will be tracked locally for resubmission. 

However, if the transaction fails with a permanent error (e.g., invalid
transaction or insufficient balance), the error will be propagated to the user.

These errors returned in the legacyPool are regarded as temporary failure:

- `ErrOutOfOrderTxFromDelegated`
- `txpool.ErrInflightTxLimitReached`
- `ErrAuthorityReserved`
- `txpool.ErrUnderpriced`
- `ErrTxPoolOverflow`
- `ErrFutureReplacePending`

Notably, InsufficientBalance is also treated as a permanent error, as
it’s highly unlikely that users will transfer funds into the sender account
after submitting the transaction. Otherwise, users may be confused—seeing
their transaction submitted but unaware that the sender lacks sufficient funds—and
continue waiting for it to be included.

---------

Co-authored-by: lightclient <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants