Skip to content

Commit

Permalink
feat: enable trie cache
Browse files Browse the repository at this point in the history
  • Loading branch information
forcodedancing committed Oct 11, 2024
1 parent 9a1ca46 commit a094c68
Show file tree
Hide file tree
Showing 9 changed files with 895 additions and 11 deletions.
15 changes: 15 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 9 additions & 8 deletions crates/engine/tree/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ reth-tasks.workspace = true
reth-node-types.workspace = true
reth-trie.workspace = true
reth-trie-parallel.workspace = true
reth-trie-db.workspace = true

# common
futures.workspace = true
Expand Down Expand Up @@ -79,14 +80,14 @@ rand.workspace = true

[features]
test-utils = [
"reth-db/test-utils",
"reth-chain-state/test-utils",
"reth-network-p2p/test-utils",
"reth-prune-types",
"reth-stages/test-utils",
"reth-static-file",
"reth-tracing",
"reth-chainspec"
"reth-db/test-utils",
"reth-chain-state/test-utils",
"reth-network-p2p/test-utils",
"reth-prune-types",
"reth-stages/test-utils",
"reth-static-file",
"reth-tracing",
"reth-chainspec"
]

bsc = []
8 changes: 8 additions & 0 deletions crates/engine/tree/src/persistence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use reth_provider::{
};
use reth_prune::{PrunerError, PrunerOutput, PrunerWithFactory};
use reth_stages_api::{MetricEvent, MetricEventsSender};
use reth_trie_db;
use std::{
sync::mpsc::{Receiver, SendError, Sender},
time::Instant,
Expand Down Expand Up @@ -126,6 +127,13 @@ impl<N: ProviderNodeTypes> PersistenceService<N> {
.map(|block| BlockNumHash { hash: block.block().hash(), number: block.block().number });

if last_block_hash_num.is_some() {
for block in &blocks {
debug!("Start to write block {} to cache", block.block.header.number);
let trie_updates = block.trie_updates();
reth_trie_db::cache::write_trie_updates(&trie_updates);
debug!("Finish to write block {} to cache", block.block.header.number);
}

let provider_rw = self.provider.provider_rw()?;
let static_file_provider = self.provider.static_file_provider();

Expand Down
3 changes: 3 additions & 0 deletions crates/trie/db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ triehash = { version = "0.8", optional = true }
# `serde` feature
serde = { workspace = true, optional = true }

lazy_static = "1.5.0"
quick_cache = "0.6.9"

[dev-dependencies]
# reth
reth-chainspec.workspace = true
Expand Down
Loading

0 comments on commit a094c68

Please sign in to comment.