0xPolygonZero / plonky2

Apache License 2.0
777 stars 289 forks source link

Implement MPT preinitialization #1406

Closed LindaGuiga closed 11 months ago

LindaGuiga commented 11 months ago

This PR preinitializes the TrieData segment with the initial tries. The tries are still checked by asserting the equality of hashes, but we also need to constrain the length of the segment. This is done by computing the expected length in mpt_hash and asserting its equality with the GlobalMetadata value.

For add11_yml, it removes 474 CPU cycles and 9057 memory rows. The gains would be much higher for bigger initial tries.

Please let me know what you think!

LindaGuiga commented 11 months ago

Looks good to me! Can you just explain why we need to constrain the trie data length and root pointers?

I can remove the length and pointers for the extra_block_data and replace that with a memory store in the Kernel, if that' s what you mean? (I still need to have a memory read since GlobalMetadata cannot yet be preinitialized given the constraints).

sonarcloud[bot] commented 11 months ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information