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

Bonsai TrieLogFactory serializer/deserializer #5372

Merged
merged 11 commits into from
Apr 21, 2023

Conversation

garyschulte
Copy link
Contributor

PR description

This PR introduces a TrieLogFactory interface and default implementation that will allow for a pluggable implementation of bonsai trie log serialization and deserialization.

This pr also introduces a StorageSlotKey record type that enables accumulators and serializers to utilize slotKeys and/or slotKeyHashes when writing trieLogs.

Fixed Issue(s)

related to protocol-misc # 755

@github-actions
Copy link

  • I thought about documentation and added the doc-change-required label to this PR if updates are required.
  • I have considered running ./gradlew acceptanceTestNonMainnet locally if my PR affects non-mainnet modules.
  • I thought about the changelog and included a changelog update if required.
  • If my PR includes database changes (e.g. KeyValueSegmentIdentifier) I have thought about compatibility and performed forwards and backwards compatibility tests

…ge as cleared

Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
…e rather than slotHash

Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
…es equivalence check

Signed-off-by: garyschulte <garyschulte@gmail.com>
…in TrieLogLayer.addCodeChange rather than Bytes.EMPTY

Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
Copy link
Contributor

@macfarla macfarla left a comment

Choose a reason for hiding this comment

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

LGTM

address,
new BonsaiValue<>(
oldValue == null ? Bytes.EMPTY : oldValue, newValue == null ? Bytes.EMPTY : newValue));
code.put(address, new BonsaiValue<>(oldValue, newValue, newValue == null));
Copy link
Contributor Author

@garyschulte garyschulte Apr 20, 2023

Choose a reason for hiding this comment

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

@matkt I believe we were previously returning Bytes.EMPTY here because the old BonsaiLayeredWorldState implementation would serve state directly from TrieLogs.

Since the 5123 bonsai refactor, we should be able to treat this consistently as null. Otherwise a constructed trielog != that same trielog serialized and then deserialized. It was the difference between code == null vs code == 0x.

@ahamlat
Copy link
Contributor

ahamlat commented Apr 21, 2023

Based on my observations, I haven't noticed any decrease in performance. The time it takes to process blocks is very similar, and after analyzing the CPU profiling, I haven't identified any additional strain.

Screenshot 2023-04-21 at 09 39 27

@garyschulte garyschulte enabled auto-merge (squash) April 21, 2023 16:42
@garyschulte garyschulte merged commit 6367f98 into hyperledger:main Apr 21, 2023
@garyschulte garyschulte deleted the zkbesu-755/trielogfactory branch April 21, 2023 17:20
elenduuche pushed a commit to elenduuche/besu that referenced this pull request Aug 16, 2023
* add account zero reads, mark self-destructed accounts, code and storage as cleared
* refactor BonsaiWorldView and TrieLog to use StorageSlotKey record type rather than slotHash
* add isCleared to read/write of BonsaiValues
* for consistency between serialize and deserialize, use null directly in TrieLogLayer.addCodeChange rather than Bytes.EMPTY

Signed-off-by: garyschulte <garyschulte@gmail.com>
eum602 pushed a commit to lacchain/besu that referenced this pull request Nov 3, 2023
* add account zero reads, mark self-destructed accounts, code and storage as cleared
* refactor BonsaiWorldView and TrieLog to use StorageSlotKey record type rather than slotHash
* add isCleared to read/write of BonsaiValues
* for consistency between serialize and deserialize, use null directly in TrieLogLayer.addCodeChange rather than Bytes.EMPTY

Signed-off-by: garyschulte <garyschulte@gmail.com>
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