-
Notifications
You must be signed in to change notification settings - Fork 132
feat(l1): implement flatkeyvalue (snapshots) #4884
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
Conversation
This reverts commit 175de2d.
Benchmark for f8a1effClick to view benchmark
|
Benchmark for 7462ef0Click to view benchmark
|
Benchmark for cc00a65Click to view benchmark
|
Benchmark for 483cbafClick to view benchmark
|
Benchmark for fe41120Click to view benchmark
|
Oppen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few minor comments. I'll make an issue with them. Otherwise it should be good to go.
| if path.len() == 32 { | ||
| self.pending_removal.insert(Nibbles::from_bytes(path)); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not true for all tries (receipts, transactions and withdrawals use their index encoded as RLP as key), but also at this level Trie is just key-value. This should be unconditional.
| pub fn get(&self, pathrlp: &PathRLP) -> Result<Option<ValueRLP>, TrieError> { | ||
| let path = Nibbles::from_bytes(pathrlp); | ||
|
|
||
| if pathrlp.len() == 32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, we shouldn't have to check length here.
| pub const CF_FLATKEYVALUE: &str = "flatkeyvalue"; | ||
|
|
||
| pub const CF_MISC_VALUES: &str = "misc_values"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for pub.
| }; | ||
| let account_state = AccountState::decode(&node.value)?; | ||
| let account_hash = H256::from_slice(&path.to_bytes()); | ||
| batch.put_cf(&cf_misc, "last_written", path.as_ref()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may save some memory and some overhead by miving the last_written updates to inside the if ctr > 10_000 cases.
| let ret = db | ||
| .write(batch) | ||
| .map_err(|e| StoreError::Custom(format!("RocksDB batch write error: {}", e))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing comment explaining we need to unconditionally run the lines below, and that they are order sensitive.
| if let Node::Leaf(leaf) = node.as_ref() { | ||
| acc.push((path.concat(&leaf.partial), leaf.value.clone())); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have a comment here.
Benchmark for e84c87aClick to view benchmark
|
Benchmark for a155d2eClick to view benchmark
|
Benchmark for 9731dacClick to view benchmark
|
Motivation
We want to have a way to query values directly without going through the trie (several reads).
To do this, we have a flattened key=>value mapping, which we call FlatKeyValue. This is sometimes known as "snapshots".
Description
A process is launched to generate this mapping in the background. We ensure
apply_updatesand this process don't conflict, and that block execution can only make use of the calculated snapshots.Closes #1997, closes #2409, closes #2410