Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
e4e1dbf
wip: hack on substore support
hdevalence Oct 2, 2023
910de61
storage: `pub(crate)` *store
Oct 4, 2023
addc8ea
storage: create `multistore::Multistore`
Oct 4, 2023
8e252a4
storage(substore): make substore prefix public
Oct 4, 2023
fdb0e48
storage(snapshot): dispatch reads to substores in `get_raw`
Oct 4, 2023
f92b965
storage: basic commit strategy TODO
Oct 4, 2023
fac3c0a
storage(substore): return an iterator over the config
Oct 4, 2023
126fb2f
storage(lib): `fmt`
Oct 4, 2023
ecae9ad
storage: explicit initialization via `Storage::init`
Oct 4, 2023
8a891a4
storage: equip `Snapshot` with a multistore
Oct 4, 2023
7b76e5e
storage(substore): add note about `rocksdb::OptimisticTransactionDB`
Oct 4, 2023
df12cc1
storage: turn the transparent store into a substore
Oct 4, 2023
a1d8cf6
storage(snapshot): route reads to `SubstoreSnapshot`
Oct 4, 2023
59305f1
storage(snapshot): default to global store for tests
Oct 4, 2023
4df1cfe
storage(snapshot): consolidate `Snapshot` api
Oct 4, 2023
2018711
storage(snapshot): implement substore dispatch for prefix queries
Oct 4, 2023
7ca77a0
storage(snapshot): implement dispatch for `StateRead`
Oct 4, 2023
612cb1b
storage(snapshot): implement dispatch for range queries
Oct 4, 2023
7682f99
storage: simplify multistore api
Oct 5, 2023
8ec0f69
penumbra(storage): root store has an empty prefix
Oct 25, 2023
0f1f206
storage(substore): move all tree accesses to `SubstoreSnapshot`
Oct 25, 2023
be4cedb
penumbra(storage): update the hardcoded cf handles (tmp)
Oct 25, 2023
8f6e460
penumbra(storage): subsume db handles into `SubstoreSnapshot`
Oct 25, 2023
664ff0a
penumbra(storage): use `cf_*` naming
Oct 25, 2023
6f4c43e
penumbra(storage): better error message in cf getters
Oct 25, 2023
50c4f4a
storage(substore): add `SubstoreSnapshot::root_hash`
Oct 27, 2023
1c13cd4
storage(substore): add `SubstoreSnapshot::get_with_proof`
Oct 27, 2023
04e0c87
storage(snapshot): forward proof calls to substore impl
Oct 27, 2023
4aaf990
storage(snapshot): fetch substore root hashes in a blocking task
Oct 27, 2023
5cd77f1
storage(snapshot): ics23 double proof scaffolding
Oct 27, 2023
a581b32
storage(snapshot): empty prefix in tmp spec
Oct 27, 2023
6de066c
storage: implement `commit_inner_substore`
Oct 31, 2023
e95879c
storage: shard unwritten change caches by substore
Oct 31, 2023
971e36e
storage(substore): add derives to `SubstoreConfig`
Oct 31, 2023
f44bc8d
penumbra(storage): stub commit method and rename main store
Oct 31, 2023
cbb5dba
penumbra(storage): remove tree reader impl on `Snapshot`
Oct 31, 2023
f61443d
penumbra(storage): remove stub proof gen code
Oct 31, 2023
bfdae82
penumbra(storage): implement `SubstoreStorage`
Oct 31, 2023
a4177b7
penumbra(storage): persist view in `SubstoreStorage::commit`
Oct 31, 2023
f1ecb32
penumbra(storage): clean-up of TODO comments
Oct 31, 2023
627dc9d
penumbra(storage): move prefix sharding on `Cache`
Nov 1, 2023
018d784
penumbra(storage): remove ad-hoc `get_rightmost_leaf` method
Nov 1, 2023
b02ebe3
penumbra(storage): move `VersionedKeyhash` to `store` crate
Nov 1, 2023
f2c19a1
penumbra(storage): add note on `jh_dispatcher`
Nov 1, 2023
bc24f55
penumbra(storage): implement a first version of `multistore::VersionC…
Nov 1, 2023
ee12022
penumbra(storage): add an iterator of `MultistoreConfig`
Nov 1, 2023
1d68b1d
penumbra(storage): use `new_substore_version`
Nov 2, 2023
3d44607
penumbra(storage): default on empty cache during commit
erwanor Nov 2, 2023
a505b18
penumbra(storage): initialize main store version
erwanor Nov 2, 2023
e5ef734
penumbra(storage): cleanup commit logic
Nov 3, 2023
f685a16
storage: default on an empty changeset in `commit`
Nov 3, 2023
6d37cd0
chore: run `fmt`
Nov 3, 2023
de93498
storage: reorganize multistore crate
Nov 3, 2023
bbfa06b
storage: route empty prefixed keys to main store (wip)
Nov 6, 2023
c64eab4
storage(tests): add integration test for substore R/Ws
Nov 6, 2023
c5b1ec6
storage(snapshot): clean-up `StateRead` impl
Nov 6, 2023
d41aea2
storage: store substore root at prefix key
Nov 6, 2023
6e44c7f
storage: fix and test prefix queries on substore
Nov 6, 2023
6814aa8
storage: fix and test `StateRead::prefix_keys`
Nov 6, 2023
e8e1c4f
storage: remove routing facade on `MultistoreCache`
Nov 6, 2023
3954a4b
storage(multistore): prefix matching methods for range queries
Nov 7, 2023
e9726da
storage(tests): add stub test for range queries over NV-storage
Nov 7, 2023
9ec6eec
storage(snapshot): use `match_prefix_*` in range/prefix queries
Nov 7, 2023
0e6e924
storage(tests): test prefix queries over NV-storage
Nov 7, 2023
c51ea6a
storage: `WriteBatch` scaffold for `SubstoreStorage`
Nov 7, 2023
a498e85
storage(substore): make writes to rocksdb atomic
Nov 8, 2023
44cddd0
storage(substore): fix formatting
Nov 8, 2023
c7651d4
storage(substore): update multistore cache once commit succeeds
Nov 8, 2023
baf7af7
storage: clean-up
Nov 8, 2023
0fc2a57
storage(snapshot): only return a root hash if the substore exists
Nov 9, 2023
9acbe5f
storage(snapshot): better debug logging
Nov 9, 2023
e3d2cd3
storage(snapshot): better expect message
Nov 9, 2023
3e658c5
storage: add comments, remove obsolete TODOs
Nov 10, 2023
88d9de7
storage: read prefix list from config cf
Nov 13, 2023
914f441
storage: rename init/load
Nov 13, 2023
cd6e9d8
storage: use `expect` for db write
Nov 13, 2023
f29077d
storage: improve comments
Nov 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/bin/pd/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ async fn main() -> anyhow::Result<()> {
let mut rocks_path = home.clone();
rocks_path.push("rocksdb");

let storage = Storage::load(rocks_path)
let storage = Storage::init(rocks_path)
.await
.context("Unable to initialize RocksDB storage")?;

Expand Down Expand Up @@ -654,7 +654,7 @@ async fn main() -> anyhow::Result<()> {

tracing::info!("pruning JMT tree");
export_path.push("rocksdb");
let export = Storage::load(export_path).await?;
let export = Storage::init(export_path).await?;
let _ = StateDelta::new(export.latest_snapshot());
// TODO:
// - add utilities in `penumbra_storage` to prune a tree
Expand Down
8 changes: 4 additions & 4 deletions crates/bin/pd/src/mempool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use crate::{metrics, App};
pub struct Mempool {
queue: mpsc::Receiver<Message<Request, Response, tower::BoxError>>,
app: App,
snapshot_rx: watch::Receiver<Snapshot>,
rx_snapshot: watch::Receiver<Snapshot>,
}

impl Mempool {
Expand All @@ -41,7 +41,7 @@ impl Mempool {
Ok(Self {
queue,
app,
snapshot_rx,
rx_snapshot: snapshot_rx,
})
}

Expand Down Expand Up @@ -95,9 +95,9 @@ impl Mempool {
biased;
// Check whether the height has changed, which requires us to throw away our
// ephemeral mempool state, and create a new one based on the new state.
change = self.snapshot_rx.changed() => {
change = self.rx_snapshot.changed() => {
if let Ok(()) = change {
let snapshot = self.snapshot_rx.borrow().clone();
let snapshot = self.rx_snapshot.borrow().clone();
tracing::debug!(height = ?snapshot.version(), "resetting ephemeral mempool state");
self.app = App::new(snapshot).await?;
} else {
Expand Down
2 changes: 1 addition & 1 deletion crates/bin/pd/src/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub async fn migrate(path_to_export: PathBuf, upgrade: Upgrade) -> anyhow::Resul
Upgrade::Testnet60 => {
let mut db_path = path_to_export.clone();
db_path.push("rocksdb");
let storage = Storage::load(db_path).await?;
let storage = Storage::init(db_path).await?;
let export_state = storage.latest_snapshot();
let root_hash = export_state.root_hash().await.expect("can get root hash");
let app_hash_pre_migration: AppHash = root_hash.into();
Expand Down
2 changes: 1 addition & 1 deletion crates/narsil/narsil/src/bin/narsild.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ async fn main() -> anyhow::Result<()> {
let mut rocks_path = home.clone();
rocks_path.push("rocksdb");

let storage = Storage::load(rocks_path)
let storage = Storage::init(rocks_path)
.await
.context("Unable to initialize RocksDB storage")?;

Expand Down
8 changes: 4 additions & 4 deletions crates/narsil/narsil/src/ledger/mempool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use crate::{ledger::app::App, metrics};
pub struct Mempool {
queue: mpsc::Receiver<Message<Request, Response, tower::BoxError>>,
app: App,
snapshot_rx: watch::Receiver<Snapshot>,
rx_snapshot: watch::Receiver<Snapshot>,
}

impl Mempool {
Expand All @@ -41,7 +41,7 @@ impl Mempool {
Self {
queue,
app,
snapshot_rx,
rx_snapshot: snapshot_rx,
}
}

Expand Down Expand Up @@ -95,9 +95,9 @@ impl Mempool {
biased;
// Check whether the height has changed, which requires us to throw away our
// ephemeral mempool state, and create a new one based on the new state.
change = self.snapshot_rx.changed() => {
change = self.rx_snapshot.changed() => {
if let Ok(()) = change {
let snapshot = self.snapshot_rx.borrow().clone();
let snapshot = self.rx_snapshot.borrow().clone();
tracing::debug!(height = ?snapshot.version(), "resetting ephemeral mempool state");
self.app = App::new(snapshot);
} else {
Expand Down
35 changes: 33 additions & 2 deletions crates/storage/src/cache.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
use std::{any::Any, collections::BTreeMap};
use std::{any::Any, collections::BTreeMap, sync::Arc};

use tendermint::abci;

use crate::StateWrite;
use crate::{
store::{multistore::MultistoreConfig, substore::SubstoreConfig},
StateWrite,
};

/// A cache of changes to the state of the blockchain.
///
Expand Down Expand Up @@ -72,4 +75,32 @@ impl Cache {
pub fn take_events(&mut self) -> Vec<abci::Event> {
std::mem::take(&mut self.events)
}

/// Consumes a `Cache` and returns a map of `SubstoreConfig` to `Cache` that
/// corresponds to changes belonging to each substore. The keys in each `Cache`
/// are truncated to remove the substore prefix.
pub fn shard_by_prefix(
self,
prefixes: &MultistoreConfig,
) -> BTreeMap<Arc<SubstoreConfig>, Self> {
let mut changes_by_substore = BTreeMap::new();
for (key, some_value) in self.unwritten_changes.into_iter() {
let (truncated_key, substore_config) = prefixes.route_key_str(&key);
changes_by_substore
.entry(substore_config)
.or_insert_with(Cache::default)
.unwritten_changes
.insert(truncated_key.to_string(), some_value);
}

for (key, some_value) in self.nonverifiable_changes {
let (truncated_key, substore_config) = prefixes.route_key_bytes(&key);
changes_by_substore
.entry(substore_config)
.or_insert_with(Cache::default)
.nonverifiable_changes
.insert(truncated_key.to_vec(), some_value);
}
changes_by_substore
}
}
1 change: 1 addition & 0 deletions crates/storage/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ mod read;
mod snapshot;
mod snapshot_cache;
mod storage;
mod store;
#[cfg(test)]
mod tests;
mod utils;
Expand Down
Loading