Skip to content
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

feat(sequencer)!: make parked mempool nonces replaceable #1763

Closed
wants to merge 11 commits into from

Conversation

Lilyjjo
Copy link
Contributor

@Lilyjjo Lilyjjo commented Oct 29, 2024

Summary

This PR enables nonce replacement for all transactions inside of the mempool's parked queue.

It was discovered while writing this PR that nonce replacement for the bottom nonce in parked was already enabled if the new nonce was able to enter the pending queue, when this happened the replaced nonce was being cleared out during the mempool's maintenance loop. This PR enables all of parked to have nonce replacement as well as adds the new notion of 'removed due to nonce replacement' to the information propagated up to cometBFT.

Background

People have started to use the internal rust CLI and have had trouble with transactions getting stuck inside of the mempool's parked queue due to incorrect parameters. This PR enables nonce replacement of parked transactions for a better UX. This feature should be disabled if people start trying to spam the mempool with it.

Changes

  • Enabled nonce replacement in the mempool's parked queue.
  • Removes replaced nonces from the appside and cometBFT mempool.

Testing

Ran locally and wrote unit tests.

Breaking Changes

Added new ABCI error code NONCE_REPLACEMENT. This is to signal through cometBFT when a transaction has been removed from the mempool due to being replaced.

Metrics

Added counter MEMPOOL_NONCE_REPLACEMENT to track how many times users have used nonce replacement.

Changelogs

Changelogs updated.

@github-actions github-actions bot added the sequencer pertaining to the astria-sequencer crate label Oct 29, 2024
@Lilyjjo Lilyjjo changed the title feat(sequencer): make parked mempool nonces replaceable feat(sequencer)!: make parked mempool nonces replaceable Oct 29, 2024
@Lilyjjo Lilyjjo marked this pull request as ready for review October 30, 2024 02:23
@Lilyjjo Lilyjjo requested a review from a team as a code owner October 30, 2024 02:23
@@ -64,6 +65,9 @@ impl AbciErrorCode {
"the account has reached the maximum number of parked transactions".into()
}
Self::PARKED_FULL => "the mempool is out of space for more parked transactions".into(),
Self::NONCE_REPLACEMENT => {
"the transaction was replaced by a different transaction with the same nonce".into()
Copy link
Member

@SuperFluffy SuperFluffy Oct 31, 2024

Choose a reason for hiding this comment

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

What will the flow look like to actually see this abci error code?

If I understand the follow correctly:

  1. transaction is stuck in mempool
  2. new transaction is submitted to the mempool, replacing the old one
  3. check-tx for the new transaction should return a success code (that is abci code 0).

But NONCE_REPLACEMENT is an error code for the transaction that got replaced if I understand correctly. What would I need to do to observe this error code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The next task I have is for general transaction observability (#1773), we don't currently have the infra to communicate it now to the users but we should

Copy link
Member

@SuperFluffy SuperFluffy Oct 31, 2024

Choose a reason for hiding this comment

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

I don't think one this is strictly related to the other. The AbciErrorCodes are intended to be returned in response to abci requests and put into the code field of the various responses (in this case CheckTx).

All the ABCI error codes can be observed right now (even if clunky). I don't understand when/how this new code would be observed.

@@ -434,7 +447,7 @@ pub(super) trait TransactionsForAccount: Default {
ttx: TimemarkedTransaction,
current_account_nonce: u32,
current_account_balances: &HashMap<IbcPrefixed, u128>,
) -> Result<(), InsertionError> {
) -> Result<Option<[u8; 32]>, InsertionError> {
Copy link
Member

Choose a reason for hiding this comment

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

This has a bad code smell. The behavior of the trait method can no longer be understood from by just looking at the signature, but I also need to understand the implementation of nonce_replacement_enabled to understand its behavior.

Now that the behavior of the two queues is so fundamentally different, they should be represented by two different types.

@SuperFluffy
Copy link
Member

For new ABCI error codes we should be able to observe the error from the outside. We should add a smoke test that performs the nonce replacement and observes the abci code.

@joroshiba
Copy link
Member

This PR is stale because it has been open 45 days with no activity. Remove stale label or this PR will be
closed in 7 days.

@joroshiba
Copy link
Member

This PR was closed because it has been stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-stale sequencer pertaining to the astria-sequencer crate stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants