-
Notifications
You must be signed in to change notification settings - Fork 31
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: fallback preimage recovery w/o debug_dbGet #30
feat: fallback preimage recovery w/o debug_dbGet #30
Conversation
crates/primitives/src/storage.rs
Outdated
|
||
/// Custom database access methods implemented by RSP storage backends. | ||
pub trait ExtDatabaseRef { | ||
/// The database error type. | ||
type Error; | ||
|
||
/// Gets the preimage of a trie node given its Keccak hash. | ||
fn trie_node_ref(&self, hash: B256) -> Result<Bytes, Self::Error>; | ||
fn trie_node_ref(&self, hash: B256, context: PreimageContext) -> Result<Bytes, Self::Error>; |
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.
Does passing this around affect the number of cycles in the client program? I feel like since client program cycles are super critical, we should make sure it doesn't
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 was thinking about the same thing but thought it shouldn't matter since it's just passing 2 references. But I can do a quick benchmark on a before/after for this. Will update here. Do note that since the code is not yet deterministic it might not be 100% accurate.
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.
Hmmm to my surprise the cycle count change turns out to be not really negligible. I was expected it to be buried in the noise of the non-determinism. Turns out for the block tested 20600000
(avg out of 10 runs each):
- Before:
762,727,324
cycles - After:
765,003,639
cycles
We got some 0.5% increase from this. This is quite surprising as this is really just passing 2 references, and I was half expecting the compiler to optimize it away since it's unused.
0.5% isn't huge but for something that can be avoided altogether it's not ideal. Will do a bit refactor here to add a feature that makes this host-only. Was hoping that it would be negligible so we don't have to over-engineer it.
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.
@puma314 Just pushed a new commit that uses Rust feature to make sure none of the changes affect client other than adding a unit type parameter (which I'm kina sure gets optimized away since it's zero-sized).
Ran the test against the same block and I'm now getting 762,685,729
which is actually even lower than before this change, though I'm pretty sure this comes from the noise of non-determinism.
In any case, we're now no longer sacrificing client efficiency for this feature.
Enables running RSP against a node that does not serve
debug_dbGet
. Changes README to not require but only recommend ageth
node runningstate.scheme=hash
.