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

Mpt fixes #1014

Merged
merged 5 commits into from
Jun 4, 2020
Merged

Mpt fixes #1014

merged 5 commits into from
Jun 4, 2020

Conversation

roman-khimov
Copy link
Member

Some fixes and optimizations.

It should always be invalidated if something changes in the `next` (below the
extension node).
Converting to MPT value serializes the StorageItem, so it makes no sense doing
it again.
This was differing from C# notion of PrevHash. It's not a previous root, but
rather a hash of the previous serialized MPTRoot structure (that is to be
signed by CNs).
Items were serialized several times if there were several successful
transactions in a block, prevent that by using State field as a bitfield (as
it almost was intended to) and adding one more bit. It also eliminates useless
duplicate MPT traversions.

Confirmed to not break storage changes up to 3.3M on testnet.
We need to compact our in-memory MPT from time to time, otherwise it quickly
fills up all available memory. This raises two obvious quesions --- when to do
that and to what level do that.

As for 'when', I think it's quite easy to use our regular persistence interval
as an anchor (and it also frees up some memory), but we can't do that in the
persistence routine itself because of synchronization issues (adding some
synchronization primitives would add some cost that I'd also like to avoid),
so do it indirectly by comparing persisted and current height in `storeBlock`.

Choosing proper level is another problem, but if we're to roughly estimate one
full branch node to use 1K of memory (usually it's way less than that) then we
can easily store 1K of these nodes and that gives us a depth of 10 for our
trie.
@roman-khimov roman-khimov added this to the v0.75.1-neox1 milestone Jun 4, 2020
@roman-khimov roman-khimov requested a review from fyrchik June 4, 2020 14:36
@roman-khimov roman-khimov merged commit 0b87a68 into neox-2.x Jun 4, 2020
@roman-khimov roman-khimov deleted the mpt-fixes branch June 4, 2020 16:04
@roman-khimov roman-khimov modified the milestones: v0.75.1-neox1, v0.76.0 Jun 22, 2020
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.

None yet

2 participants