-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
fix: use alloy-trie
for eth_getProof
#7546
Conversation
alloy-trie
for eth_getProof
alloy-trie
for eth_getProof
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.
amazing!
testing these is a bit hard...
I think we should get rid of all the tests/it/proof.rs helper code, and instead perhaps get some test vecs from somewhere else.
ptal @rkrasiuk @DaniPopes
@@ -5440,31 +5456,6 @@ dependencies = [ | |||
"winapi", | |||
] | |||
|
|||
[[package]] | |||
name = "parity-util-mem" |
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 should allow enabling jemalloc for anvil
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.
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.
alloy-trie
for eth_getProof
alloy-trie
for eth_getProof
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.
so much work for one endpoint -.-
last dep nit, lgtm
crates/anvil/tests/it/proof.rs
Outdated
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.
amazing!
Tested on #7039 repro and don't see any differences, TPS is still drops significantly for low number of transactions in block |
Can you share a samply profile if you have it? Anyway can be in a follow up |
looking forward to this fix! |
@DaniPopes yeah, the overhead is definitely coming from state root calculation. It is negligible while the state is small but becomes much higher when it grows. https://share.firefox.dev/3VMJ8QM - this is a profile for a run which mined 1000 blocks with 10 simple CREATE transactions each, thus state at the end of execution contained 10.000 addresses |
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.
sick
You absolute hero. I owe you a beer - or several - @klkvr. |
Motivation
Closes #5004
Closes #5577
Solution
Changes eth_getProof logic to use alloy-trie crate. Changes
MaybeHashDatabase
trait toMaybeFullDatabase
as currently the only scenario in which we can obtain proofs is when using in-memory database and building trie from full state available in it.I've been testing proofs manually and they seem correct, however, the tests for them won't pass because they are still using parity libraries which seem to rely on different encoding making it impossible to decode correct eth_getProof outputs out-of-the box (ref #5004 (comment))
I'll probably change tests to concrete fixtures as it's done in Reth: https://github.com/paradigmxyz/reth/blob/112c8a3f1e1bcab1a1418e6150400012bc195548/crates/trie/src/proof.rs#L165