Skip to content

Commit

Permalink
patches
Browse files Browse the repository at this point in the history
  • Loading branch information
distractedm1nd committed Sep 11, 2024
1 parent f4931f9 commit 300b76d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 22 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

12 changes: 7 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,11 @@ keystore-rs = "0.1.0"
toml = "0.8.14"
dirs = "5.0.1"
anyhow = "1.0.44"
jmt = { path = "../jmt", features = [
"mocks",
] } #{ version = "0.10.0", features = ["mocks"] }
jmt = { version = "0.10.0", features = ["mocks"] }
bellpepper-core = { version = "0.4.0", default-features = false }
bellpepper = "0.4.1"
arecibo = { git = "https://github.com/deltadevsde/arecibo" }
itertools = "0.13.0" # zip_eq
itertools = "0.13.0" # zip_eq
arecibo = "0.2.0"
sha2 = "0.10.8"
auto_impl = "1.2.0"
bincode = "1.3.3"
Expand All @@ -86,6 +84,10 @@ sp1-helper = "1.2.0"

[patch.crates-io]
sha2-v0-10-8 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha2", branch = "patch-sha2-v0.10.8" }
arecibo = { git = "https://github.com/deltadevsde/arecibo" }
jmt = { git = "https://github.com/deltadevsde/jmt", branch = "rehashing-circuit", features = [
"mocks",
] }

# [workspace.dev-dependencies]
# serial_test = "3.1.1"
Expand Down
12 changes: 5 additions & 7 deletions crates/prism/src/node_types/sequencer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ impl Sequencer {
let proof =
tree.update(KeyHash::with::<Hasher>(hashed_id), current_chain.clone())?;
self.db
.update_hashchain(operation, &current_chain)
.set_hashchain(operation, &current_chain)
.context(format!(
"Failed to update hashchain for operation {:?}",
operation
Expand Down Expand Up @@ -408,12 +408,10 @@ impl Sequencer {
let mut chain = Hashchain::new(id.clone());
chain.create_account(value.into(), source.clone())?;

self.db
.update_hashchain(operation, &chain)
.context(format!(
"Failed to create hashchain for operation {:?}",
operation
))?;
self.db.set_hashchain(operation, &chain).context(format!(
"Failed to create hashchain for operation {:?}",
operation
))?;

let mut tree = self.tree.lock().await;
let hashed_id = hash(id.as_bytes());
Expand Down
17 changes: 7 additions & 10 deletions crates/prism/src/storage.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use anyhow::{anyhow, Context, Result};
use anyhow::{anyhow, Result};
use auto_impl::auto_impl;
use jmt::{
storage::{LeafNode, Node, NodeBatch, NodeKey, TreeReader, TreeWriter},
Expand Down Expand Up @@ -32,11 +32,8 @@ pub struct RedisConnection {
#[auto_impl(&, Box, Arc)]
pub trait Database: Send + Sync + TreeReader + TreeWriter {
fn get_hashchain(&self, key: &str) -> Result<Hashchain>;
fn update_hashchain(
&self,
incoming_operation: &Operation,
value: &[HashchainEntry],
) -> Result<()>;
fn set_hashchain(&self, incoming_operation: &Operation, value: &[HashchainEntry])
-> Result<()>;

fn get_commitment(&self, epoch: &u64) -> Result<String>;
fn set_commitment(&self, epoch: &u64, commitment: &Digest) -> Result<()>;
Expand Down Expand Up @@ -220,7 +217,7 @@ impl Database for RedisConnection {
.map_err(|_| anyhow!(DatabaseError::WriteError(format!("epoch: {}", epoch))))
}

fn update_hashchain(
fn set_hashchain(
&self,
incoming_operation: &Operation,
value: &[HashchainEntry],
Expand Down Expand Up @@ -313,7 +310,7 @@ mod tests {
let chain_entry = create_mock_chain_entry();

redis_connections
.update_hashchain(&incoming_operation, &[chain_entry.clone()])
.set_hashchain(&incoming_operation, &[chain_entry.clone()])
.unwrap();

let hashchain = redis_connections
Expand All @@ -338,7 +335,7 @@ mod tests {
let chain_entry = create_mock_chain_entry();

redis_connections
.update_hashchain(&incoming_operation, &[chain_entry.clone()])
.set_hashchain(&incoming_operation, &[chain_entry.clone()])
.unwrap();

let hashchain = redis_connections.get_hashchain("main:missing_test_key");
Expand Down Expand Up @@ -406,7 +403,7 @@ mod tests {

let chain_entries: Vec<HashchainEntry> = vec![create_mock_chain_entry()];

match redis_connections.update_hashchain(&incoming_operation, &chain_entries) {
match redis_connections.set_hashchain(&incoming_operation, &chain_entries) {
Ok(_) => (),
Err(e) => panic!("Failed to update hashchain: {}", e),
}
Expand Down

0 comments on commit 300b76d

Please sign in to comment.