-
Notifications
You must be signed in to change notification settings - Fork 38
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: SMT support in trace_decoder
ignores storage
#693
Conversation
b9f107c
to
f27bbdf
Compare
trace_decoder
ignores storage
@@ -377,31 +465,30 @@ impl From<StateMpt> for HashedPartialTrie { | |||
} | |||
} | |||
|
|||
// TODO(0xaatif): https://github.com/0xPolygonZero/zk_evm/issues/706 |
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.
One or two sentences about what is StateSmt
struct and why are we using it would be nice.
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 like to defer this to #722
@@ -411,7 +498,101 @@ impl StateTrie for StateSmt { | |||
.map(|(addr, acct)| (keccak_hash::keccak(addr), *acct)) | |||
} | |||
fn root(&self) -> H256 { | |||
todo!() | |||
conv_hash::smt2eth(self.as_smt().root) |
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.
Non blocking: This seems like a quite expensive operation just to get the root of the trie (which may be called often in the code handling the state tries). Maybe we should internally cache smt
?
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 we're going to go the caching route then I'd vote leaving it for now and opening an issue for it.
fn visit( | ||
hashes: &mut BTreeMap<SmtKey, H256>, | ||
leaves: &mut BTreeMap<Address, CollatedLeaf>, | ||
path: Stack<bool>, |
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.
Any compelling reason why common Vec
could not be used as a stack, but external stackstack
dependency is needed?
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.
It removes a footgun, and limits misuse:
fn visit(path: &mut Vec<bool>) {
path.push(true);
visit(path);
path.pop(); // often forgotten
}
It also happens to have no heap usage in this case too
c111680
to
adeaa4e
Compare
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 should open an issue for the caching improvement Marko mentioned but I'm good with this.
You can now give
trace_decoder
an encoded SMT, and have it do... something.Changes
trait StateTrie { type Key }
, and a newSmtKey
.TrieKey
toMptKey
.WireDisposition
for deciding which way to parse encoded tries.cargo doc --document-private-items
#718)Note this code is incorrect given #707, and we're probably doing the hash conversions wrong, but it does finalize the external API, and is a meaningful feature increment over the previous code.
fyi @hratoanina iteration of
trait StateTrie