-
Notifications
You must be signed in to change notification settings - Fork 61
fix: correctly track reverted hashes #498
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,34 @@ | ||
| mod builder; | ||
| mod delegate; | ||
|
|
||
| use alloy_primitives::TxHash; | ||
| pub use builder::FlashpoolBuilder; | ||
|
|
||
| use moka::sync::Cache; | ||
| use reth_transaction_pool::TransactionPool; | ||
|
|
||
| use crate::tx::FBPooledTransaction; | ||
|
|
||
| #[derive(Debug, Clone)] | ||
| pub struct Flashpool<P: TransactionPool<Transaction = FBPooledTransaction>> { | ||
| inner: P, | ||
|
|
||
| /// Cache to store reverted tx hashes | ||
| reverted_cache: Option<Cache<TxHash, ()>>, | ||
| } | ||
|
|
||
| /// Custom extensions on the pool where it doesn't make sense to intercept an | ||
| /// existing pool method. | ||
| pub trait FlashpoolExt { | ||
| /// Checks if a transaction is reverted by checking if the given transaction | ||
| /// hash is present in the reverted cache. | ||
| fn is_tx_reverted(&self, hash: TxHash) -> bool; | ||
| } | ||
|
|
||
| impl<P: TransactionPool<Transaction = FBPooledTransaction>> FlashpoolExt for Flashpool<P> { | ||
| fn is_tx_reverted(&self, hash: TxHash) -> bool { | ||
| self.reverted_cache | ||
| .as_ref() | ||
| .is_some_and(|cache| cache.get(&hash).is_some()) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need a reverted cache? is it for easier test assertions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no this is a core feature for revert protection functionality. it's so senders can track if their txs have been evicted from the pool because they were reverted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't expose rpc methods for transaction receipts though? rollup-boost only forwards bundles and raw transactions
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if its for debug purposes, the cache size should be configurable - right now the bundle request rate is 300 req/s for reverted transactions on mainnet when the cache max_capacity is only 100
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this pr is meant to just fix the bug, not add features. i think the cache capacity should be configured in terms of storage size (like configured to a max of 4mb).
and i thought the plan was to expose the rpc for receipts at some point
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no plans for receipts rpc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is what i'm referring to #188