diff --git a/Cargo.lock b/Cargo.lock index f6f2569f..cad9f516 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2834,7 +2834,7 @@ dependencies = [ [[package]] name = "kairos-trie" version = "0.1.0" -source = "git+https://github.com/cspr-rad/kairos-trie#d1aa8f6f2c3012ab416631ccf852df1a58a6bf4e" +source = "git+https://github.com/cspr-rad/kairos-trie#e649cb702d12f4711714fc37d44a2186b20007f0" dependencies = [ "bumpalo", "digest 0.10.7", diff --git a/kairos-contracts/Cargo.lock b/kairos-contracts/Cargo.lock index 68f99807..f9f2ab65 100644 --- a/kairos-contracts/Cargo.lock +++ b/kairos-contracts/Cargo.lock @@ -785,7 +785,7 @@ dependencies = [ [[package]] name = "kairos-trie" version = "0.1.0" -source = "git+https://github.com/cspr-rad/kairos-trie#d1aa8f6f2c3012ab416631ccf852df1a58a6bf4e" +source = "git+https://github.com/cspr-rad/kairos-trie#e649cb702d12f4711714fc37d44a2186b20007f0" dependencies = [ "bumpalo", "digest 0.10.7", diff --git a/kairos-prover/Cargo.lock b/kairos-prover/Cargo.lock index e9b32908..41403c28 100644 --- a/kairos-prover/Cargo.lock +++ b/kairos-prover/Cargo.lock @@ -1829,7 +1829,7 @@ dependencies = [ [[package]] name = "kairos-trie" version = "0.1.0" -source = "git+https://github.com/cspr-rad/kairos-trie#d1aa8f6f2c3012ab416631ccf852df1a58a6bf4e" +source = "git+https://github.com/cspr-rad/kairos-trie#e649cb702d12f4711714fc37d44a2186b20007f0" dependencies = [ "bumpalo", "digest 0.10.7", @@ -2486,7 +2486,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" dependencies = [ "anyhow", - "itertools 0.12.1", + "itertools 0.10.5", "proc-macro2", "quote", "syn 2.0.72", diff --git a/kairos-prover/kairos-circuit-logic/src/account_trie.rs b/kairos-prover/kairos-circuit-logic/src/account_trie.rs index 4b3e99f3..683898e8 100644 --- a/kairos-prover/kairos-circuit-logic/src/account_trie.rs +++ b/kairos-prover/kairos-circuit-logic/src/account_trie.rs @@ -5,28 +5,28 @@ use sha2::{digest::FixedOutputReset, Digest, Sha256}; use crate::transactions::{KairosTransaction, L1Deposit, PublicKey, Signed, Transfer, Withdraw}; use kairos_trie::{ stored::{ - merkle::{Snapshot, SnapshotBuilder}, + merkle::{Snapshot, SnapshotBuilder, VerifiedSnapshot}, DatabaseGet, Store, }, KeyHash, NodeHash, PortableHash, PortableUpdate, TrieRoot, }; /// The state of the batch transaction against the trie. -pub struct AccountTrie> { +pub struct AccountTrie> { pub txn: AccountTrieTxn, } -pub type AccountTrieTxn = kairos_trie::Transaction; +pub type AccountTrieTxn = kairos_trie::Transaction; /// TODO panic on error should be behind a feature flag type TxnErr = String; -impl<'s> TryFrom<&'s Snapshot> for AccountTrie<&'s Snapshot> { - type Error = TxnErr; - - fn try_from(snapshot: &'s Snapshot) -> Result { - Ok(Self { - txn: kairos_trie::Transaction::from_snapshot(snapshot)?, - }) +impl + AsRef>> From> + for AccountTrie> +{ + fn from(snapshot: VerifiedSnapshot) -> Self { + Self { + txn: kairos_trie::Transaction::from_verified_snapshot(snapshot), + } } } @@ -41,14 +41,6 @@ impl> TryFrom> } } -impl<'s> AccountTrie<&'s Snapshot> { - pub fn new_try_from_snapshot(snapshot: &'s Snapshot) -> Result { - Ok(Self { - txn: kairos_trie::Transaction::from_snapshot(snapshot)?, - }) - } -} - impl> AccountTrie> { pub fn new_try_from_db(db: Db, root_hash: TrieRoot) -> Self { Self { @@ -59,7 +51,7 @@ impl> AccountTrie> AccountTrie { +impl> AccountTrie { #[allow(clippy::type_complexity)] pub fn apply_batch( &mut self, diff --git a/kairos-prover/kairos-circuit-logic/src/lib.rs b/kairos-prover/kairos-circuit-logic/src/lib.rs index a431ba01..905892f8 100644 --- a/kairos-prover/kairos-circuit-logic/src/lib.rs +++ b/kairos-prover/kairos-circuit-logic/src/lib.rs @@ -59,8 +59,9 @@ impl ProofInputs { let hasher = &mut DigestHasher::::default(); - let mut trie = AccountTrie::new_try_from_snapshot(&trie_snapshot)?; - let pre_batch_trie_root = trie.txn.calc_root_hash(hasher)?.into(); + let verified_snapshot = trie_snapshot.verify(hasher)?; + let pre_batch_trie_root = verified_snapshot.trie_root_hash().into(); + let mut trie = AccountTrie::from(verified_snapshot); let (deposits, withdrawals) = trie.apply_batch( // TODO Replace with Box<[T]>: IntoIterator once Rust 2024 is stable diff --git a/kairos-prover/kairos-verifier-risc0-lib/src/lib.rs b/kairos-prover/kairos-verifier-risc0-lib/src/lib.rs index e533825c..6dfae169 100644 --- a/kairos-prover/kairos-verifier-risc0-lib/src/lib.rs +++ b/kairos-prover/kairos-verifier-risc0-lib/src/lib.rs @@ -1,12 +1,13 @@ #![no_std] +#[allow(clippy::too_long_first_doc_paragraph)] /// The risc0 image_id of the batch update circuit program. /// To update this you must rebuild the circuit with `cargo risczero build`, which will use docker /// to reproducibly build the circuit. /// Then you must copy the output ELF to `kairos-prover/methods/prove_batch_bin` /// and run `cargo build` which will output the new hash. pub const BATCH_CIRCUIT_PROGRAM_HASH: [u32; 8] = [ - 2249819926, 1807275128, 879420467, 753150136, 3885109892, 1252737579, 1362575552, 43533945, + 162636669, 3420136214, 482235019, 1624934074, 1024623463, 972941903, 3671681564, 1824242109, ]; #[cfg(feature = "verifier")] diff --git a/kairos-prover/methods/prove-batch/Cargo.lock b/kairos-prover/methods/prove-batch/Cargo.lock index bcaa330f..30b523b4 100644 --- a/kairos-prover/methods/prove-batch/Cargo.lock +++ b/kairos-prover/methods/prove-batch/Cargo.lock @@ -458,7 +458,7 @@ dependencies = [ [[package]] name = "kairos-trie" version = "0.1.0" -source = "git+https://github.com/cspr-rad/kairos-trie#d1aa8f6f2c3012ab416631ccf852df1a58a6bf4e" +source = "git+https://github.com/cspr-rad/kairos-trie#e649cb702d12f4711714fc37d44a2186b20007f0" dependencies = [ "bumpalo", "digest", diff --git a/kairos-prover/methods/prove_batch_bin b/kairos-prover/methods/prove_batch_bin index cdf66965..e9a03165 100755 Binary files a/kairos-prover/methods/prove_batch_bin and b/kairos-prover/methods/prove_batch_bin differ