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

Feature/public and private states shared cache #1353

Conversation

nicolae-leonte-go
Copy link
Contributor

This change allows the private state (or states in case of MPS) to behave similarly to the public state when it comes to what is written to the disk and how often.
Before this PR the private state is being flushed to the disk for each block (even though the corresponding public state is not - depending on the --gcmode parameter value).
The behaviour is enabled by passing a command line parameter: --privatetriecache.enable

When enabled, the public and the private state(s) share the same state.Database instance. The single cache management (previously applying only to the public state) now also applies to the private state(s). The TrieDB.Reference mechanism is used to link the various tries with each-other so that when a TrieDB.Commit on the public state root is issued it cascades to all other referenced tries (including the private states).

When disabled (the parameter is missing from the command line) the private state(s) is still committed for each block with ONE NOTABLE DIFFERENCE: the order of commits is reversed - public state is committed first followed by the private state(s). The reason for the reversal is that when we commit the private state the public state root is already in the cache (which then allows us to add the reference from the private state root to the public state root).

@CLAassistant
Copy link

CLAassistant commented Mar 7, 2022

CLA assistant check
All committers have signed the CLA.

Krish1979
Krish1979 previously approved these changes Mar 8, 2022
antonydenyer
antonydenyer previously approved these changes Mar 8, 2022
Copy link
Contributor

@antonydenyer antonydenyer left a comment

Choose a reason for hiding this comment

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

An elegant solution that will mean we can benefit more easily from upstream changes. 🙏

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.

6 participants