-
Notifications
You must be signed in to change notification settings - Fork 28
Feat/revert protection status endpoint #76
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
Conversation
crates/op-rbuilder/src/main.rs
Outdated
let da_config = builder_config.da_config.clone(); | ||
let rollup_args = builder_args.rollup_args; | ||
let op_node = OpNode::new(rollup_args.clone()); | ||
let reverted_cache = create_shared_cache(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.
I am open minded to do this in a different way. I have another PR to modify the transaction pool monitor so I think this could get cleaner once that lands and there is a concrete TxPoolMonitor structure.
pub type SharedLruCache<K, V> = Arc<Mutex<LruCache<K, V>>>; | ||
|
||
pub fn create_shared_cache<K, V>(capacity: usize) -> SharedLruCache<K, V> | ||
where | ||
K: std::hash::Hash + Eq, | ||
{ | ||
let cache = LruCache::new(NonZeroUsize::new(capacity).unwrap()); | ||
Arc::new(Mutex::new(cache)) | ||
} |
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.
I'd suggest using Moka instead of this because if we use Arc-Mutex we will be only serving one RPC call at a time and won't have scalable/concurrent RPC API.
Some(receipt) => Ok(Some(receipt)), | ||
None => { | ||
// Try to find the transaction in the reverted cache | ||
let reverted_cache = self.reverted_cache.lock().unwrap(); |
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.
I think ideally we want to use some kind of lock that would prioritize writers
also with sync mutex you could rect the runtime
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.
DashSet
is also a descent option.
|
||
if let Some(revert_protection) = self.with_revert_protection { | ||
if revert_protection { | ||
println!("revert_protection is enabled"); |
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.
debug
π Summary
Closes #46
π‘ Motivation and Context
β I have completed the following steps:
make lint
make test