-
Notifications
You must be signed in to change notification settings - Fork 687
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: record nodes for writes in memtrie (#10841)
Fixes #10769. ## UPD: New motivation While all said below is true, the main motivation is to account for nodes impacted at `squash_nodes` which can be touched without much pain only at `Trie::update`. ## Old motivation The root cause of errors "node not found" on reads from recorded storage is that nodes touched only at `Trie::update` - KV updates in the end of chunk applictaion - were never recorded on memtrie. It happens automatically on disk tries. For memtries we retroactively account for trie node accesses, but this wasn't done in similar way for memtrie updates. While infrastructure indeed needs to be improved so these issues won't surprise us anymore, the easiest way is to account for all accesses in the same way as `move_node_to_mutable` does - on memtrie paths like `ensure_updated` which move node out of storage to memory, which means that node has to be recorded, so trie can be validated. Unfortunately refcount changes are not enough to cover this, so I record trie accesses separately. Also, memtrie doesn't have access to values, so I have to retrieve values and record them in the `Trie::update`. ### Testing * New logic is covered by trie_recording tests. I also discovered an issue there - `destructively_delete_in_memory_state_from_disk` was removing all keys because key decoding was incorrect. Now these tests fully cover trie access scenario: first we have get&get_ref accesses, and in the very end we have update call for some KV pairs. I confirmed that for incorrect impl some tests fail because of the same "node not found" error, and also that new sanity check on `Trie::update` works. * test_memtrie_discrepancy is renamed and works now --------- Co-authored-by: Longarithm <the.aleksandr.logunov@gmail.com>
- Loading branch information
1 parent
254698a
commit 73b8827
Showing
5 changed files
with
152 additions
and
45 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
Oops, something went wrong.