-
Notifications
You must be signed in to change notification settings - Fork 133
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
Merkle list and token account update iterator #1398
Conversation
… but not yet the new implementation
@@ -31,6 +30,7 @@ export { | |||
provable, | |||
provablePure, | |||
Struct, | |||
Unconstrained, |
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 a fixup - Unconstrained
was announced in a previous release but not exported
@@ -66,6 +66,17 @@ const Poseidon = { | |||
return MlFieldArray.from(newState) as [Field, Field, Field]; | |||
}, | |||
|
|||
hashWithPrefix(prefix: string, input: Field[]) { |
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'm exporting this since I wanted to use this in dogfooding already as well
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.
lgtm
This PR introduces several provable types to represent dynamic-sized data structures (on which we perform a fixed number of operations)
MerkleList<T>
represents a list which supportspush()
andpop()
(if you pop an empty list, it returns a dummy)MerkleListIterator<T>
exposes the functionality of popping through the elements of a Merkle list, but without removing them from the list. Main method:next()
, which returns a dummy if we're past the end of the listAccountUpdateForest
is built up from Merkle lists recursively to represent a forest of account updates -- i.e., the children of another account updateAccountUpdateForest
, we will be given nodes (account updates) along with their child account updates, which are a Merkle list themselvesTokenAccountUpdateIterator
pulls it all together: It iterates deeply through anAccountUpdateForest
, stepping down in the tree after every new account update with children is encountered, and stepping up once a layer is done. Since this will be used by token contracts, it supports skipping "inaccessible subtrees", i.e. it skips the children of an update that already doesn't inherit token permissions itself. Assuming that no subtree is skipped, the iteration will return every update in the tree exactly once, in depth-first order. After the full tree has been processed, it returns dummies.TokenAccountUpdateIterator
. It also tests flat iteration through a Merkle list