-
Notifications
You must be signed in to change notification settings - Fork 0
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: implement MPT part of generic extraction (Part 1) #385
base: main
Are you sure you want to change the base?
Conversation
feat: allow for either aggregation-only or tabular-only queries
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.
Quite good for me, just a few simple changes left and should be good to go ;) Thanks for all the efforts
mp2-common/src/storage_key.rs
Outdated
// Unwrap safe because input always fixed 32 bytes. | ||
&InputData::Assigned(&Vector::from_vec(&inputs).unwrap()), | ||
); | ||
let location_bytes = inputs |
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.
Up to here most of the code looks like the same as assign_single
. Isn't is possible to refactor it in a common method to avoid code duplication?
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 refactor this code in commit aea77c6.
mp2-common/src/storage_key.rs
Outdated
@@ -515,7 +619,7 @@ impl MappingSlot { | |||
let inputs = mapping_key.into_iter().chain(padded_slot).collect_vec(); | |||
// Then compute the expected resulting hash for MPT key derivation. | |||
let base = keccak256(&inputs).try_into().unwrap(); | |||
KeccakMPT::assign(pw, &wires.keccak_mpt, inputs, base, offset); | |||
KeccakStructMPT::assign(pw, &wires.keccak_mpt, inputs, base, offset); |
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.
Same as above: most of the code between assign_simple
and assign_struct
looks the same, wouldn't it be worthy to refactor the methods to avoid code duplication?
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 refactor this code in commit aea77c6.
mp2-common/src/storage_key.rs
Outdated
) -> KeccakMPTWires { | ||
// location = keccak(inputs) + offset | ||
let keccak_base = KeccakCircuit::<{ INPUT_PADDED_LEN }>::hash_to_bytes(b, &inputs); | ||
let base = keccak_base.output.arr.pack(b, Endianness::Big); |
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 really depends how EVM is interpreting the output of Keccak as a U256 to add offset. I think your current way of initializing the UInt256Target
makes sense, but maybe a range-check on each byte of the hash_to_bytes
output is needed, as hash_to_bytes
should be safe to use without range-checking the output bytes only if those bytes are then fed as input to another Keccak, which is not the case here. Wdyt?
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 a circuit to expose the results of simple `SELECT` queries without aggregation functions, avoiding the need to build a results tree.
…ic-mpt-extraction
…ic-mpt-extraction
Related issue https://github.com/Lagrange-Labs/zkmr-tracking/issues/265
Design document MPT Extraction
Summary
ColumnGadget
andMetadataGadget
.