Skip to content
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

Remove copy on write for mpt_insert and mpt_delete #1190

Merged
merged 2 commits into from
Aug 19, 2023

Conversation

LindaGuiga
Copy link
Contributor

This PR deals with removing the copy-on-write logic in MPT insertion and deletion, as mentioned in this PR.

When testing on test_simple_transfer, we observe a reduction of the number of rows in a couple of STARKs, from

TraceCheckpoint { arithmetic_len: 10288, cpu_len: 77254, keccak_len: 463, keccak_sponge_len: 26, logic_len: 3347, memory_len: 467164 }
in main, to:

TraceCheckpoint { arithmetic_len: 10288, cpu_len: 77108, keccak_len: 453, keccak_sponge_len: 26, logic_len: 3297, memory_len: 465103 }
with this optimization.

Most of the time, when there was a change of node type, I left a new node creation as I feared using the same node pointer would lead to overwritten data while updating the node. (It was generally easier to do in MPT deletion cases though).

@wborgeaud Please let me know if I forgot cases, or if there's anything I can improve/need to change!

Copy link
Contributor

@wborgeaud wborgeaud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks!

Comment on lines 36 to 37
%stack (first_nibble, node_payload_ptr, retdest) -> (node_payload_ptr, retdest)
PUSH 1 SWAP1 SUB
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Either

%stack (first_nibble, node_payload_ptr, retdest) -> (node_payload_ptr, 1, retdest)
SUB

or

%stack (first_nibble, node_payload_ptr, retdest) -> (node_payload_ptr, retdest)
%sub_const(1) // or %decrement

would be a tad cleaner imo.

@Nashtare Nashtare merged commit f6f9fa3 into 0xPolygonZero:main Aug 19, 2023
2 checks passed
@Nashtare Nashtare deleted the mpt-remove-cow branch September 8, 2023 20:43
@wborgeaud wborgeaud mentioned this pull request Nov 27, 2023
wborgeaud added a commit that referenced this pull request Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants