Skip to content
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

Remove unused StateDB::update_db method #1074

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 full-node/db/sov-db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ pub mod ledger_db;
pub mod rocks_db_config;
/// Defines the tables used by the Sovereign SDK.
pub mod schema;
/// Implements a wrapper around RocksDB meant for storing rollup state. This is primarily used
/// as the backing store for the JMT.
/// Implements a wrapper around [RocksDB](https://rocksdb.org/) meant for storing rollup state.
/// This is primarily used as the backing store for the [JMT(JellyfishMerkleTree)](https://docs.rs/jmt/latest/jmt/).
pub mod state_db;

/// Implements a wrapper around RocksDB meant for storing state only accessible
Expand Down
21 changes: 4 additions & 17 deletions full-node/db/sov-db/src/state_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,6 @@ impl StateDB {
}
}

/// Store an item in the database, given a key, a key hash, a version, and a value
pub fn update_db(
&self,
key: StateKey,
key_hash: KeyHash,
value: Option<Vec<u8>>,
next_version: Version,
) -> anyhow::Result<()> {
self.put_preimage(key_hash, &key)?;
self.db.put::<JmtValues>(&(key, next_version), &value)?;
Ok(())
}

/// Increment the `next_version` counter by 1.
pub fn inc_next_version(&self) {
let mut version = self.next_version.lock().unwrap();
Expand Down Expand Up @@ -134,7 +121,7 @@ impl TreeReader for StateDB {
fn get_rightmost_leaf(
&self,
) -> anyhow::Result<Option<(jmt::storage::NodeKey, jmt::storage::LeafNode)>> {
todo!()
todo!("StateDB does not support [`TreeReader::get_rightmost_leaf`] yet")
}
}

Expand All @@ -149,7 +136,7 @@ impl TreeWriter for StateDB {
self.db
.get::<KeyHashToKey>(&key_hash.0)?
.ok_or(anyhow::format_err!(
"Could not find preimage for key hash {key_hash:?}"
"Could not find preimage for key hash {key_hash:?}. Has `StateDB::put_preimage` been called for this key?"
))?;
self.db.put::<JmtValues>(&(key_preimage, *version), value)?;
}
Expand Down Expand Up @@ -214,8 +201,6 @@ pub mod arbitrary {

impl proptest::arbitrary::Arbitrary for FallibleArbitraryStateDB {
type Parameters = ();
type Strategy = LazyJust<Self, fn() -> FallibleArbitraryStateDB>;

fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy {
fn gen() -> FallibleArbitraryStateDB {
FallibleArbitraryStateDB {
Expand All @@ -231,6 +216,8 @@ pub mod arbitrary {
}
LazyJust::new(gen)
}

type Strategy = LazyJust<Self, fn() -> FallibleArbitraryStateDB>;
}
}

Expand Down