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

Unclear unwrap inside core execution logic #1769

Closed
SuperFluffy opened this issue Oct 30, 2024 · 3 comments · Fixed by #1772
Closed

Unclear unwrap inside core execution logic #1769

SuperFluffy opened this issue Oct 30, 2024 · 3 comments · Fixed by #1772
Assignees
Labels
ignore-stale Override for issues or PRs which should not be removed if stale. stale

Comments

@SuperFluffy
Copy link
Member

SuperFluffy commented Oct 30, 2024

astria_sequencer::App::execute_transaction_prepare_proposal [1] unwraps a Result. The expect message it provides does not give any indication why unwrapping at that point is acceptable. Tracing it through the stack the error that is being bubbled up comes from a call deep inside astria_sequencer::Mempool::builder_queue [2] and [3].

It is not clear why this expect here is acceptable or why it is an invariant of the system that the return value of of the method call is always Ok.

1:

.expect("failed to fetch pending transactions");

2:
self.pending.read().await.builder_queue(state).await

3:
pub(super) async fn builder_queue<S: accounts::StateReadExt>(

The code that introduced this was #1323.

┆Issue Number: ENG-960

@joroshiba
Copy link
Member

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

@joroshiba
Copy link
Member

This issue was closed because it was stale

@joroshiba joroshiba closed this as not planned Won't fix, can't repro, duplicate, stale Dec 23, 2024
@SuperFluffy SuperFluffy added the ignore-stale Override for issues or PRs which should not be removed if stale. label Jan 6, 2025
@SuperFluffy
Copy link
Member Author

Reopening because it's actively tracked by PR #1772

@SuperFluffy SuperFluffy reopened this Jan 6, 2025
github-merge-queue bot pushed a commit that referenced this issue Jan 18, 2025
## Summary
This PR changes the mempool's `builder_queue()` to be infallible. The
code previously would return an error if the nonce fetch from the
database failed. Now it handles the error case by using the pending's
lowest nonce for the account as an educated guess of what nonce to use
for transaction priority construction. This is okay since
`prepare_proposal()`'s logic will just reject invalid nonces if the
mempool's state is out of date due to a bug.

## Background
We shouldn't have non-existential issues in the mempool cause failures
in the sequencer.

## Changes
- Changed mempool `builder_queue()` to be infallible with reasonable
fallbacks.

## Testing
Manually changed the code path to only use the new logic and watched all
tests pass except for those explicitly testing the jitter between the
mempool and database (which shouldn't happen if the rest of the code
works). The tests in those scenarios only fail due to unmet assertions
and not because of panics.

## Changelogs
No updates required.


## Related Issues
closes #1769

---------

Co-authored-by: Fraser Hutchison <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ignore-stale Override for issues or PRs which should not be removed if stale. stale
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants