-
Notifications
You must be signed in to change notification settings - Fork 664
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Memtrie] (5/5) Integrate memtries into the protocol. (#10087)
This is a large PR, but it does a few independent things - these independent things could in theory be split, but their tests are somewhat interdependent so splitting is tricky. * Incorporates MemTries into Trie, so that lookups, writes, and recording are done via memtries if it is available. This logic is done by adding a `lookup_from_memory` function, which is invoked by `get_optimized_ref` as a first choice. * The testing of this logic is in `trie_recording.rs`; previously this test performs T (access via on-disk trie), F (access via flat storage), RT (access via recorded state proof, with trie-like gas accounting), and RF (access via recorded state proof, with flat storage-like gas accounting), and asserts that T = RT, and F = RF. Now, we additionally perform in-memory versions of these setups (use M for that), thereby asserting that T = MT = RT, and F = MF = RF. * Memtrie updates are produced via `Trie::update`, which uses the memtrie to produce the update if available. * Incorporates a map<shard uid, MemTries> into ShardTries, so that a collection of memtries can be maintained. * Memtrie updates are applied via `WrappedTrieChanges::apply_memtrie_changes`; the block height is additionally included into `WrappedTrieChanges` to facilitate memtrie GC. * Initial loading is done by calling runtime's load_mem_tries_on_startup. It is called from the chain after ensuring that flat storage is available (which is critical when populating genesis for the first time). * Three configuration parameters are added to configure the memtrie loading behavior. These configs should immediately be usable. * GC is called from the chain at the same time as when flat storage GC happens. * An integration test has been added in `integration-tests/.../in_memory_tries.rs`, which brings up two nodes with different memtrie loading configs and asserts that under a workload of various cross-shard transactions the two nodes remain consistent, even with frequent forks. It also tests both the initial loading behavior as well as behavior after restarts, and also sanity checks GC logic.
- Loading branch information
1 parent
ca852b7
commit eb82408
Showing
19 changed files
with
1,070 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.