From 66def746e6cb4f2bf5fee29e2be1b7cc5fd0bbf6 Mon Sep 17 00:00:00 2001 From: Oleksandr Pravdyvyi Date: Thu, 29 May 2025 12:00:50 +0300 Subject: [PATCH 01/29] feat: periodic snapshooting --- accounts/src/account_core/mod.rs | 1 + accounts/src/key_management/mod.rs | 3 +- accounts/src/key_management/secret_holders.rs | 5 +- node_core/src/chain_storage/block_store.rs | 30 ++++++++++ node_core/src/chain_storage/mod.rs | 60 ++++++++++++++++++- node_core/src/config.rs | 2 + node_core/src/lib.rs | 4 +- node_runner/configs/debug/node_config.json | 3 +- 8 files changed, 99 insertions(+), 9 deletions(-) diff --git a/accounts/src/account_core/mod.rs b/accounts/src/account_core/mod.rs index 32c5359..c990407 100644 --- a/accounts/src/account_core/mod.rs +++ b/accounts/src/account_core/mod.rs @@ -16,6 +16,7 @@ use crate::key_management::{ pub type PublicKey = AffinePoint; pub type AccountAddress = TreeHashType; +#[derive(Debug, Serialize)] pub struct Account { pub key_holder: AddressKeyHolder, pub address: AccountAddress, diff --git a/accounts/src/key_management/mod.rs b/accounts/src/key_management/mod.rs index 474bd99..0f7a7a0 100644 --- a/accounts/src/key_management/mod.rs +++ b/accounts/src/key_management/mod.rs @@ -6,6 +6,7 @@ use ephemeral_key_holder::EphemeralKeyHolder; use k256::AffinePoint; use log::info; use secret_holders::{SeedHolder, TopSecretKeyHolder, UTXOSecretKeyHolder}; +use serde::Serialize; use crate::account_core::PublicKey; @@ -13,7 +14,7 @@ pub mod constants_types; pub mod ephemeral_key_holder; pub mod secret_holders; -#[derive(Clone)] +#[derive(Debug, Serialize, Clone)] ///Entrypoint to key management pub struct AddressKeyHolder { //Will be useful in future diff --git a/accounts/src/key_management/secret_holders.rs b/accounts/src/key_management/secret_holders.rs index 399ef44..eee512e 100644 --- a/accounts/src/key_management/secret_holders.rs +++ b/accounts/src/key_management/secret_holders.rs @@ -2,6 +2,7 @@ use common::merkle_tree_public::TreeHashType; use elliptic_curve::PrimeField; use k256::{AffinePoint, FieldBytes, Scalar}; use rand::{rngs::OsRng, RngCore}; +use serde::Serialize; use sha2::{digest::FixedOutput, Digest}; use super::constants_types::{NULLIFIER_SECRET_CONST, VIEWING_SECRET_CONST}; @@ -13,13 +14,13 @@ pub struct SeedHolder { seed: Scalar, } -#[derive(Debug, Clone)] +#[derive(Debug, Serialize, Clone)] ///Secret spending key holder. Produces `UTXOSecretKeyHolder` objects. pub struct TopSecretKeyHolder { pub secret_spending_key: Scalar, } -#[derive(Debug, Clone)] +#[derive(Debug, Serialize, Clone)] ///Nullifier secret key and viewing secret key holder. Produces public keys. Can produce address. Can produce shared secret for recepient. pub struct UTXOSecretKeyHolder { pub nullifier_secret_key: Scalar, diff --git a/node_core/src/chain_storage/block_store.rs b/node_core/src/chain_storage/block_store.rs index 2956381..38c185e 100644 --- a/node_core/src/chain_storage/block_store.rs +++ b/node_core/src/chain_storage/block_store.rs @@ -2,6 +2,7 @@ use std::path::Path; use anyhow::{anyhow, Result}; use common::block::Block; +use log::warn; use storage::sc_db_utils::{DataBlob, DataBlobChangeVariant}; use storage::RocksDBIO; @@ -56,6 +57,35 @@ impl NodeBlockStore { pub fn get_sc_sc_state(&self, sc_addr: &str) -> Result> { Ok(self.dbio.get_sc_sc_state(sc_addr)?) } + + pub fn put_snapshot_at_block_id( + &self, + id: u64, + accounts_ser: Vec, + comm_ser: Vec, + txs_ser: Vec, + nullifiers_ser: Vec, + ) -> Result<()> { + self.dbio + .put_snapshot_block_id_db(id) + .inspect_err(|err| warn!("Failed to store snapshot block id with error {err:#?}"))?; + self.dbio + .put_snapshot_account_db(accounts_ser) + .inspect_err(|err| warn!("Failed to store snapshot accounts with error {err:#?}"))?; + self.dbio + .put_snapshot_commitement_db(comm_ser) + .inspect_err(|err| warn!("Failed to store snapshot commitments with error {err:#?}"))?; + self.dbio + .put_snapshot_transaction_db(txs_ser) + .inspect_err(|err| { + warn!("Failed to store snapshot transactions with error {err:#?}") + })?; + self.dbio + .put_snapshot_account_db(nullifiers_ser) + .inspect_err(|err| warn!("Failed to store snapshot nullifiers with error {err:#?}"))?; + + Ok(()) + } } #[cfg(test)] diff --git a/node_core/src/chain_storage/mod.rs b/node_core/src/chain_storage/mod.rs index 26bb809..f166a10 100644 --- a/node_core/src/chain_storage/mod.rs +++ b/node_core/src/chain_storage/mod.rs @@ -13,10 +13,11 @@ use common::{ utxo_commitment::UTXOCommitment, }; use k256::AffinePoint; +use log::{info, warn}; use public_context::PublicSCContext; use utxo::utxo_core::UTXO; -use crate::ActionData; +use crate::{config::NodeConfig, ActionData}; pub mod accounts_store; pub mod block_store; @@ -28,10 +29,11 @@ pub struct NodeChainStore { pub nullifier_store: HashSet, pub utxo_commitments_store: UTXOCommitmentsMerkleTree, pub pub_tx_store: PublicTransactionMerkleTree, + pub node_config: NodeConfig, } impl NodeChainStore { - pub fn new_with_genesis(home_dir: &Path, genesis_block: Block) -> Self { + pub fn new_with_genesis(config: NodeConfig, genesis_block: Block) -> Self { let acc_map = HashMap::new(); let nullifier_store = HashSet::new(); let utxo_commitments_store = UTXOCommitmentsMerkleTree::new(vec![]); @@ -40,7 +42,7 @@ impl NodeChainStore { //Sequencer should panic if unable to open db, //as fixing this issue may require actions non-native to program scope let block_store = - NodeBlockStore::open_db_with_genesis(&home_dir.join("rocksdb"), Some(genesis_block)) + NodeBlockStore::open_db_with_genesis(&config.home.join("rocksdb"), Some(genesis_block)) .unwrap(); Self { @@ -49,10 +51,13 @@ impl NodeChainStore { nullifier_store, utxo_commitments_store, pub_tx_store, + node_config: config, } } pub fn dissect_insert_block(&mut self, block: Block) -> Result<()> { + let block_id = block.block_id; + for tx in &block.transactions { if !tx.execution_input.is_empty() { let public_action = serde_json::from_slice::(&tx.execution_input); @@ -136,6 +141,55 @@ impl NodeChainStore { self.block_store.put_block_at_id(block)?; + //Snapshot + if block_id % self.node_config.shapshot_frequency_in_blocks == 0 { + //Serializing all important data structures + + //If we fail snapshot, it is not the reason to stop running + //Logging on warn level in this cases + + let accounts_ser = serde_json::to_vec(&self.acc_map).inspect_err(|err| { + warn!("Failed to serialize accounts data {err:#?}"); + }); + + let comm_tree_serialized = serde_json::to_vec(&self.utxo_commitments_store) + .inspect_err(|err| { + warn!("Failed to serialize commitments {err:#?}"); + }); + + let tx_tree_serialized = serde_json::to_vec(&self.pub_tx_store).inspect_err(|err| { + warn!("Failed to serialize transactions {err:#?}"); + }); + + let nullifiers_serialized = + serde_json::to_vec(&self.nullifier_store).inspect_err(|err| { + warn!("Failed to serialize nullifiers {err:#?}"); + }); + + match ( + accounts_ser, + comm_tree_serialized, + tx_tree_serialized, + nullifiers_serialized, + ) { + (Ok(accounts_ser), Ok(comm_ser), Ok(txs_ser), Ok(nullifiers_ser)) => { + let snapshot_trace = self.block_store.put_snapshot_at_block_id( + block_id, + accounts_ser, + comm_ser, + txs_ser, + nullifiers_ser, + ); + + info!( + "Snapshot executed at {:?} with results {snapshot_trace:#?}", + block_id + ); + } + _ => warn!("Failed to serialize node data for snapshot"), + } + } + Ok(()) } diff --git a/node_core/src/config.rs b/node_core/src/config.rs index d92e358..935a803 100644 --- a/node_core/src/config.rs +++ b/node_core/src/config.rs @@ -49,4 +49,6 @@ pub struct NodeConfig { pub port: u16, ///Gas config pub gas_config: GasConfig, + ///Frequency of snapshots + pub shapshot_frequency_in_blocks: u64, } diff --git a/node_core/src/lib.rs b/node_core/src/lib.rs index ca412c4..147e69e 100644 --- a/node_core/src/lib.rs +++ b/node_core/src/lib.rs @@ -94,11 +94,11 @@ impl NodeCore { let client = Arc::new(SequencerClient::new(config.clone())?); let genesis_id = client.get_genesis_id().await?; - info!("Gesesis id is {genesis_id:?}"); + info!("Genesis id is {genesis_id:?}"); let genesis_block = client.get_block(genesis_id.genesis_id).await?.block; - let mut storage = NodeChainStore::new_with_genesis(&config.home, genesis_block); + let mut storage = NodeChainStore::new_with_genesis(config.clone(), genesis_block); pre_start::setup_empty_sc_states(&storage).await?; diff --git a/node_runner/configs/debug/node_config.json b/node_runner/configs/debug/node_config.json index f8c064e..c948b82 100644 --- a/node_runner/configs/debug/node_config.json +++ b/node_runner/configs/debug/node_config.json @@ -12,5 +12,6 @@ "gas_cost_deploy": 1000, "gas_limit_deploy": 30000000, "gas_limit_runtime": 30000000 - } + }, + "shapshot_frequency_in_blocks": 10 } \ No newline at end of file From 9d3bda9bce5bb03f502a9a7b46d7145aab7d31b1 Mon Sep 17 00:00:00 2001 From: Oleksandr Pravdyvyi Date: Fri, 30 May 2025 08:50:35 +0300 Subject: [PATCH 02/29] fix: fmt --- node_core/src/chain_storage/block_store.rs | 13 ++-- node_core/src/chain_storage/mod.rs | 71 +++++++++------------- 2 files changed, 37 insertions(+), 47 deletions(-) diff --git a/node_core/src/chain_storage/block_store.rs b/node_core/src/chain_storage/block_store.rs index 38c185e..553594e 100644 --- a/node_core/src/chain_storage/block_store.rs +++ b/node_core/src/chain_storage/block_store.rs @@ -2,7 +2,7 @@ use std::path::Path; use anyhow::{anyhow, Result}; use common::block::Block; -use log::warn; +use log::{error, warn}; use storage::sc_db_utils::{DataBlob, DataBlobChangeVariant}; use storage::RocksDBIO; @@ -66,23 +66,24 @@ impl NodeBlockStore { txs_ser: Vec, nullifiers_ser: Vec, ) -> Result<()> { + //Error notification for writing into DB error self.dbio .put_snapshot_block_id_db(id) - .inspect_err(|err| warn!("Failed to store snapshot block id with error {err:#?}"))?; + .inspect_err(|err| error!("Failed to store snapshot block id with error {err:#?}"))?; self.dbio .put_snapshot_account_db(accounts_ser) - .inspect_err(|err| warn!("Failed to store snapshot accounts with error {err:#?}"))?; + .inspect_err(|err| error!("Failed to store snapshot accounts with error {err:#?}"))?; self.dbio .put_snapshot_commitement_db(comm_ser) - .inspect_err(|err| warn!("Failed to store snapshot commitments with error {err:#?}"))?; + .inspect_err(|err| error!("Failed to store snapshot commitments with error {err:#?}"))?; self.dbio .put_snapshot_transaction_db(txs_ser) .inspect_err(|err| { - warn!("Failed to store snapshot transactions with error {err:#?}") + error!("Failed to store snapshot transactions with error {err:#?}") })?; self.dbio .put_snapshot_account_db(nullifiers_ser) - .inspect_err(|err| warn!("Failed to store snapshot nullifiers with error {err:#?}"))?; + .inspect_err(|err| error!("Failed to store snapshot nullifiers with error {err:#?}"))?; Ok(()) } diff --git a/node_core/src/chain_storage/mod.rs b/node_core/src/chain_storage/mod.rs index f166a10..1fbe284 100644 --- a/node_core/src/chain_storage/mod.rs +++ b/node_core/src/chain_storage/mod.rs @@ -1,7 +1,4 @@ -use std::{ - collections::{BTreeMap, HashMap, HashSet}, - path::Path, -}; +use std::collections::{BTreeMap, HashMap, HashSet}; use accounts::account_core::{Account, AccountAddress}; use anyhow::Result; @@ -145,48 +142,40 @@ impl NodeChainStore { if block_id % self.node_config.shapshot_frequency_in_blocks == 0 { //Serializing all important data structures - //If we fail snapshot, it is not the reason to stop running + //If we fail serialization, it is not the reason to stop running //Logging on warn level in this cases - let accounts_ser = serde_json::to_vec(&self.acc_map).inspect_err(|err| { + if let Ok(accounts_ser) = serde_json::to_vec(&self.acc_map).inspect_err(|err| { warn!("Failed to serialize accounts data {err:#?}"); - }); + }) { + if let Ok(comm_ser) = + serde_json::to_vec(&self.utxo_commitments_store).inspect_err(|err| { + warn!("Failed to serialize commitments {err:#?}"); + }) + { + if let Ok(txs_ser) = serde_json::to_vec(&self.pub_tx_store).inspect_err(|err| { + warn!("Failed to serialize transactions {err:#?}"); + }) { + if let Ok(nullifiers_ser) = serde_json::to_vec(&self.nullifier_store) + .inspect_err(|err| { + warn!("Failed to serialize nullifiers {err:#?}"); + }) + { + let snapshot_trace = self.block_store.put_snapshot_at_block_id( + block_id, + accounts_ser, + comm_ser, + txs_ser, + nullifiers_ser, + ); - let comm_tree_serialized = serde_json::to_vec(&self.utxo_commitments_store) - .inspect_err(|err| { - warn!("Failed to serialize commitments {err:#?}"); - }); - - let tx_tree_serialized = serde_json::to_vec(&self.pub_tx_store).inspect_err(|err| { - warn!("Failed to serialize transactions {err:#?}"); - }); - - let nullifiers_serialized = - serde_json::to_vec(&self.nullifier_store).inspect_err(|err| { - warn!("Failed to serialize nullifiers {err:#?}"); - }); - - match ( - accounts_ser, - comm_tree_serialized, - tx_tree_serialized, - nullifiers_serialized, - ) { - (Ok(accounts_ser), Ok(comm_ser), Ok(txs_ser), Ok(nullifiers_ser)) => { - let snapshot_trace = self.block_store.put_snapshot_at_block_id( - block_id, - accounts_ser, - comm_ser, - txs_ser, - nullifiers_ser, - ); - - info!( - "Snapshot executed at {:?} with results {snapshot_trace:#?}", - block_id - ); + info!( + "Snapshot executed at {:?} with results {snapshot_trace:#?}", + block_id + ); + } + } } - _ => warn!("Failed to serialize node data for snapshot"), } } From 894ba1934548c6463912bae44b86d52e66f41397 Mon Sep 17 00:00:00 2001 From: Oleksandr Pravdyvyi Date: Fri, 30 May 2025 09:06:39 +0300 Subject: [PATCH 03/29] fix: fmt --- node_core/src/chain_storage/block_store.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/node_core/src/chain_storage/block_store.rs b/node_core/src/chain_storage/block_store.rs index 553594e..208a7b3 100644 --- a/node_core/src/chain_storage/block_store.rs +++ b/node_core/src/chain_storage/block_store.rs @@ -75,7 +75,9 @@ impl NodeBlockStore { .inspect_err(|err| error!("Failed to store snapshot accounts with error {err:#?}"))?; self.dbio .put_snapshot_commitement_db(comm_ser) - .inspect_err(|err| error!("Failed to store snapshot commitments with error {err:#?}"))?; + .inspect_err(|err| { + error!("Failed to store snapshot commitments with error {err:#?}") + })?; self.dbio .put_snapshot_transaction_db(txs_ser) .inspect_err(|err| { From 7e47ecd91e682821f9ed81cef801de71ad1201dd Mon Sep 17 00:00:00 2001 From: Oleksandr Pravdyvyi Date: Fri, 30 May 2025 09:29:56 +0300 Subject: [PATCH 04/29] fix: warn fix --- node_core/src/chain_storage/block_store.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node_core/src/chain_storage/block_store.rs b/node_core/src/chain_storage/block_store.rs index 208a7b3..a14ec19 100644 --- a/node_core/src/chain_storage/block_store.rs +++ b/node_core/src/chain_storage/block_store.rs @@ -2,7 +2,7 @@ use std::path::Path; use anyhow::{anyhow, Result}; use common::block::Block; -use log::{error, warn}; +use log::error; use storage::sc_db_utils::{DataBlob, DataBlobChangeVariant}; use storage::RocksDBIO; From 5df8763166fb230effcaaff25445d127e7823cc8 Mon Sep 17 00:00:00 2001 From: Oleksandr Pravdyvyi Date: Fri, 30 May 2025 14:08:06 +0300 Subject: [PATCH 05/29] fix: suggestion added 1 --- node_core/src/chain_storage/block_store.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node_core/src/chain_storage/block_store.rs b/node_core/src/chain_storage/block_store.rs index a14ec19..0f9d17c 100644 --- a/node_core/src/chain_storage/block_store.rs +++ b/node_core/src/chain_storage/block_store.rs @@ -84,7 +84,7 @@ impl NodeBlockStore { error!("Failed to store snapshot transactions with error {err:#?}") })?; self.dbio - .put_snapshot_account_db(nullifiers_ser) + .put_snapshot_nullifier_db(nullifiers_ser) .inspect_err(|err| error!("Failed to store snapshot nullifiers with error {err:#?}"))?; Ok(()) From 8cbb8089fbb8882690446d942f3a86c5fd5ed6b3 Mon Sep 17 00:00:00 2001 From: Oleksandr Pravdyvyi Date: Fri, 30 May 2025 19:26:59 +0300 Subject: [PATCH 06/29] fix: suggestion added 2 --- node_core/src/chain_storage/block_store.rs | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/node_core/src/chain_storage/block_store.rs b/node_core/src/chain_storage/block_store.rs index 0f9d17c..2da64ee 100644 --- a/node_core/src/chain_storage/block_store.rs +++ b/node_core/src/chain_storage/block_store.rs @@ -192,4 +192,41 @@ mod tests { let result = node_store.get_block_at_id(42); assert!(result.is_err()); } + + #[test] + fn test_put_snapshot_at_block_id() { + let temp_dir = tempdir().unwrap(); + let path = temp_dir.path(); + + let genesis_block = create_genesis_block(); + let node_store = NodeBlockStore::open_db_with_genesis(path, Some(genesis_block)).unwrap(); + + let id = 3; + let accounts_ser = vec![1, 2, 3, 4]; + let comm_ser = vec![5, 6, 7, 8]; + let txs_ser = vec![9, 10, 11, 12]; + let nullifiers_ser = vec![13, 14, 15, 16]; + + node_store + .put_snapshot_at_block_id( + id, + accounts_ser.clone(), + comm_ser.clone(), + txs_ser.clone(), + nullifiers_ser.clone(), + ) + .unwrap(); + + assert_eq!(node_store.dbio.get_snapshot_block_id().unwrap(), id); + assert_eq!( + node_store.dbio.get_snapshot_account().unwrap(), + accounts_ser + ); + assert_eq!(node_store.dbio.get_snapshot_commitment().unwrap(), comm_ser); + assert_eq!(node_store.dbio.get_snapshot_transaction().unwrap(), txs_ser); + assert_eq!( + node_store.dbio.get_snapshot_nullifier().unwrap(), + nullifiers_ser + ); + } } From 5e9499873d620b810274353f9f8f57656632f760 Mon Sep 17 00:00:00 2001 From: Rostyslav Tyshko Date: Fri, 30 May 2025 15:20:14 -0400 Subject: [PATCH 07/29] serialize/deserialize `Account` --- accounts/src/account_core/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/accounts/src/account_core/mod.rs b/accounts/src/account_core/mod.rs index 32c5359..0caca15 100644 --- a/accounts/src/account_core/mod.rs +++ b/accounts/src/account_core/mod.rs @@ -4,7 +4,7 @@ use anyhow::Result; use common::{merkle_tree_public::TreeHashType, transaction::Tag}; use k256::AffinePoint; use log::info; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use utxo::utxo_core::{UTXOPayload, UTXO}; use crate::key_management::{ @@ -16,6 +16,7 @@ use crate::key_management::{ pub type PublicKey = AffinePoint; pub type AccountAddress = TreeHashType; +#[derive(Serialize, Deserialize, Clone)] pub struct Account { pub key_holder: AddressKeyHolder, pub address: AccountAddress, From fe79365c63772e944dd3f813242b9f2af3fe5c00 Mon Sep 17 00:00:00 2001 From: Rostyslav Tyshko Date: Fri, 30 May 2025 15:20:29 -0400 Subject: [PATCH 08/29] serialize/deserialize `AddressKeyHolder` --- accounts/src/key_management/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/accounts/src/key_management/mod.rs b/accounts/src/key_management/mod.rs index 474bd99..69b8ce0 100644 --- a/accounts/src/key_management/mod.rs +++ b/accounts/src/key_management/mod.rs @@ -6,6 +6,7 @@ use ephemeral_key_holder::EphemeralKeyHolder; use k256::AffinePoint; use log::info; use secret_holders::{SeedHolder, TopSecretKeyHolder, UTXOSecretKeyHolder}; +use serde::{Deserialize, Serialize}; use crate::account_core::PublicKey; @@ -13,7 +14,7 @@ pub mod constants_types; pub mod ephemeral_key_holder; pub mod secret_holders; -#[derive(Clone)] +#[derive(Serialize, Deserialize, Clone)] ///Entrypoint to key management pub struct AddressKeyHolder { //Will be useful in future From 13d8c72a82d09770c6aca2635275010e1b143812 Mon Sep 17 00:00:00 2001 From: Rostyslav Tyshko Date: Fri, 30 May 2025 15:20:52 -0400 Subject: [PATCH 09/29] serialize/deserialize `TopSecretKeyHolder` and `UTXOSecretKeyHolder` --- accounts/src/key_management/secret_holders.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/accounts/src/key_management/secret_holders.rs b/accounts/src/key_management/secret_holders.rs index 399ef44..45fd792 100644 --- a/accounts/src/key_management/secret_holders.rs +++ b/accounts/src/key_management/secret_holders.rs @@ -2,6 +2,7 @@ use common::merkle_tree_public::TreeHashType; use elliptic_curve::PrimeField; use k256::{AffinePoint, FieldBytes, Scalar}; use rand::{rngs::OsRng, RngCore}; +use serde::{Deserialize, Serialize}; use sha2::{digest::FixedOutput, Digest}; use super::constants_types::{NULLIFIER_SECRET_CONST, VIEWING_SECRET_CONST}; @@ -13,13 +14,13 @@ pub struct SeedHolder { seed: Scalar, } -#[derive(Debug, Clone)] +#[derive(Serialize, Deserialize, Debug, Clone)] ///Secret spending key holder. Produces `UTXOSecretKeyHolder` objects. pub struct TopSecretKeyHolder { pub secret_spending_key: Scalar, } -#[derive(Debug, Clone)] +#[derive(Serialize, Deserialize, Debug, Clone)] ///Nullifier secret key and viewing secret key holder. Produces public keys. Can produce address. Can produce shared secret for recepient. pub struct UTXOSecretKeyHolder { pub nullifier_secret_key: Scalar, From 88da732d5c0b54c192426d1c9140b4524b48412d Mon Sep 17 00:00:00 2001 From: Rostyslav Tyshko Date: Fri, 30 May 2025 15:22:15 -0400 Subject: [PATCH 10/29] clear out situation when one tries to start a DB without a block --- storage/src/lib.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/storage/src/lib.rs b/storage/src/lib.rs index e7f7f44..3157bc0 100644 --- a/storage/src/lib.rs +++ b/storage/src/lib.rs @@ -103,9 +103,8 @@ impl RocksDBIO { Ok(dbio) } else { - warn!("Starting db in unset mode, will have to set starting block manually"); - - Ok(dbio) + // Here we are trying to start a DB without a block, one should not do it. + unreachable!() } } From 87e63636867e2982476d15209f239943ea8f3abe Mon Sep 17 00:00:00 2001 From: Rostyslav Tyshko Date: Fri, 30 May 2025 15:23:09 -0400 Subject: [PATCH 11/29] addblock id getter, deserialization of account and commintmant from snapshot --- node_core/src/chain_storage/block_store.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/node_core/src/chain_storage/block_store.rs b/node_core/src/chain_storage/block_store.rs index 2956381..d0356e3 100644 --- a/node_core/src/chain_storage/block_store.rs +++ b/node_core/src/chain_storage/block_store.rs @@ -56,6 +56,20 @@ impl NodeBlockStore { pub fn get_sc_sc_state(&self, sc_addr: &str) -> Result> { Ok(self.dbio.get_sc_sc_state(sc_addr)?) } + + pub fn get_snapshot_block_id(&self) -> Result { + Ok(self.dbio.get_snapshot_block_id()?) + } + + pub fn get_snapshot_account(&self) -> Result> { + Ok(serde_json::from_slice(&self.dbio.get_snapshot_account()?)?) + } + + pub fn get_snapshot_commitment(&self) -> Result> { + Ok(serde_json::from_slice(&self.dbio.get_snapshot_commitment()?)?) + } + + } #[cfg(test)] From 9b8ddb05806a71046670ba73558f44e91be8de88 Mon Sep 17 00:00:00 2001 From: Rostyslav Tyshko Date: Fri, 30 May 2025 15:23:41 -0400 Subject: [PATCH 12/29] add deserialization of nullifier and transaction from snapshot --- node_core/src/chain_storage/block_store.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/node_core/src/chain_storage/block_store.rs b/node_core/src/chain_storage/block_store.rs index d0356e3..f8cb46a 100644 --- a/node_core/src/chain_storage/block_store.rs +++ b/node_core/src/chain_storage/block_store.rs @@ -70,6 +70,9 @@ impl NodeBlockStore { } + pub fn get_snapshot_transaction(&self) -> Result> { + Ok(serde_json::from_slice(&self.dbio.get_snapshot_transaction()?)?) + } } #[cfg(test)] From a9f8dff7e9c55033b993b4bb585b34de6b9a0470 Mon Sep 17 00:00:00 2001 From: Rostyslav Tyshko Date: Fri, 30 May 2025 15:23:55 -0400 Subject: [PATCH 13/29] same --- node_core/src/chain_storage/block_store.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/node_core/src/chain_storage/block_store.rs b/node_core/src/chain_storage/block_store.rs index f8cb46a..d5b0df8 100644 --- a/node_core/src/chain_storage/block_store.rs +++ b/node_core/src/chain_storage/block_store.rs @@ -69,6 +69,9 @@ impl NodeBlockStore { Ok(serde_json::from_slice(&self.dbio.get_snapshot_commitment()?)?) } + pub fn get_snapshot_nullifier(&self) -> Result> { + Ok(serde_json::from_slice(&self.dbio.get_snapshot_nullifier()?)?) + } pub fn get_snapshot_transaction(&self) -> Result> { Ok(serde_json::from_slice(&self.dbio.get_snapshot_transaction()?)?) From 6a351419d67157e4e85ce0a393c4664740d7c552 Mon Sep 17 00:00:00 2001 From: Rostyslav Tyshko Date: Fri, 30 May 2025 15:24:06 -0400 Subject: [PATCH 14/29] imports --- node_core/src/chain_storage/block_store.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/node_core/src/chain_storage/block_store.rs b/node_core/src/chain_storage/block_store.rs index d5b0df8..d666f2d 100644 --- a/node_core/src/chain_storage/block_store.rs +++ b/node_core/src/chain_storage/block_store.rs @@ -1,7 +1,13 @@ +use std::collections::{HashMap, HashSet}; use std::path::Path; +use accounts::account_core::Account; use anyhow::{anyhow, Result}; use common::block::Block; +use common::merkle_tree_public::merkle_tree::HashStorageMerkleTree; +use common::nullifier::UTXONullifier; +use common::transaction::Transaction; +use common::utxo_commitment::UTXOCommitment; use storage::sc_db_utils::{DataBlob, DataBlobChangeVariant}; use storage::RocksDBIO; From 96095955256f2af6586ef93102579b8c9a772375 Mon Sep 17 00:00:00 2001 From: Rostyslav Tyshko Date: Fri, 30 May 2025 15:24:40 -0400 Subject: [PATCH 15/29] fix `NodeChainStore`'s new fn according to snapshoting logic --- node_core/src/chain_storage/mod.rs | 31 ++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/node_core/src/chain_storage/mod.rs b/node_core/src/chain_storage/mod.rs index 26bb809..8868c21 100644 --- a/node_core/src/chain_storage/mod.rs +++ b/node_core/src/chain_storage/mod.rs @@ -7,13 +7,11 @@ use accounts::account_core::{Account, AccountAddress}; use anyhow::Result; use block_store::NodeBlockStore; use common::{ - block::Block, - merkle_tree_public::merkle_tree::{PublicTransactionMerkleTree, UTXOCommitmentsMerkleTree}, - nullifier::UTXONullifier, - utxo_commitment::UTXOCommitment, + block::Block, commitment, merkle_tree_public::merkle_tree::{PublicTransactionMerkleTree, UTXOCommitmentsMerkleTree}, nullifier::{self, UTXONullifier}, utxo_commitment::UTXOCommitment }; -use k256::AffinePoint; +use k256::{pkcs8::der::asn1::Null, AffinePoint}; use public_context::PublicSCContext; +use sc_core::transaction_payloads_tools; use utxo::utxo_core::UTXO; use crate::ActionData; @@ -31,11 +29,12 @@ pub struct NodeChainStore { } impl NodeChainStore { - pub fn new_with_genesis(home_dir: &Path, genesis_block: Block) -> Self { - let acc_map = HashMap::new(); - let nullifier_store = HashSet::new(); - let utxo_commitments_store = UTXOCommitmentsMerkleTree::new(vec![]); - let pub_tx_store = PublicTransactionMerkleTree::new(vec![]); + pub fn new(home_dir: &Path, genesis_block: Block) -> Result<(Self, u64)> { + let mut acc_map = HashMap::new(); + let mut nullifier_store = HashSet::new(); + let mut utxo_commitments_store = UTXOCommitmentsMerkleTree::new(vec![]); + let mut pub_tx_store = PublicTransactionMerkleTree::new(vec![]); + let mut block_id = genesis_block.block_id; //Sequencer should panic if unable to open db, //as fixing this issue may require actions non-native to program scope @@ -43,13 +42,21 @@ impl NodeChainStore { NodeBlockStore::open_db_with_genesis(&home_dir.join("rocksdb"), Some(genesis_block)) .unwrap(); - Self { + if let Ok(temp_block_id) = block_store.get_snapshot_block_id() { + utxo_commitments_store = block_store.get_snapshot_commitment()?; + nullifier_store = block_store.get_snapshot_nullifier()?; + acc_map = block_store.get_snapshot_account()?; + pub_tx_store = block_store.get_snapshot_transaction()?; + block_id = temp_block_id; + } + + Ok((Self { acc_map, block_store, nullifier_store, utxo_commitments_store, pub_tx_store, - } + }, block_id)) } pub fn dissect_insert_block(&mut self, block: Block) -> Result<()> { From 9cd81c62eba0ac738857eb3db819e4859b6ba429 Mon Sep 17 00:00:00 2001 From: Rostyslav Tyshko Date: Fri, 30 May 2025 15:25:02 -0400 Subject: [PATCH 16/29] fix start_from_config_update_chain fn --- node_core/src/lib.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/node_core/src/lib.rs b/node_core/src/lib.rs index ca412c4..c143f59 100644 --- a/node_core/src/lib.rs +++ b/node_core/src/lib.rs @@ -98,12 +98,10 @@ impl NodeCore { let genesis_block = client.get_block(genesis_id.genesis_id).await?.block; - let mut storage = NodeChainStore::new_with_genesis(&config.home, genesis_block); + let (mut storage, mut chain_height) = NodeChainStore::new(&config.home, genesis_block)?; pre_start::setup_empty_sc_states(&storage).await?; - let mut chain_height = genesis_id.genesis_id; - //Chain update loop loop { let next_block = chain_height + 1; From 0c9bbb5dded54527f3e43d4c057c0370f7c91c7b Mon Sep 17 00:00:00 2001 From: Rostyslav Tyshko Date: Fri, 30 May 2025 15:25:21 -0400 Subject: [PATCH 17/29] fmt --- node_core/src/chain_storage/block_store.rs | 12 ++++++++--- node_core/src/chain_storage/mod.rs | 23 ++++++++++++++-------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/node_core/src/chain_storage/block_store.rs b/node_core/src/chain_storage/block_store.rs index d666f2d..5b47612 100644 --- a/node_core/src/chain_storage/block_store.rs +++ b/node_core/src/chain_storage/block_store.rs @@ -72,15 +72,21 @@ impl NodeBlockStore { } pub fn get_snapshot_commitment(&self) -> Result> { - Ok(serde_json::from_slice(&self.dbio.get_snapshot_commitment()?)?) + Ok(serde_json::from_slice( + &self.dbio.get_snapshot_commitment()?, + )?) } pub fn get_snapshot_nullifier(&self) -> Result> { - Ok(serde_json::from_slice(&self.dbio.get_snapshot_nullifier()?)?) + Ok(serde_json::from_slice( + &self.dbio.get_snapshot_nullifier()?, + )?) } pub fn get_snapshot_transaction(&self) -> Result> { - Ok(serde_json::from_slice(&self.dbio.get_snapshot_transaction()?)?) + Ok(serde_json::from_slice( + &self.dbio.get_snapshot_transaction()?, + )?) } } diff --git a/node_core/src/chain_storage/mod.rs b/node_core/src/chain_storage/mod.rs index 8868c21..1cf25d6 100644 --- a/node_core/src/chain_storage/mod.rs +++ b/node_core/src/chain_storage/mod.rs @@ -7,7 +7,11 @@ use accounts::account_core::{Account, AccountAddress}; use anyhow::Result; use block_store::NodeBlockStore; use common::{ - block::Block, commitment, merkle_tree_public::merkle_tree::{PublicTransactionMerkleTree, UTXOCommitmentsMerkleTree}, nullifier::{self, UTXONullifier}, utxo_commitment::UTXOCommitment + block::Block, + commitment, + merkle_tree_public::merkle_tree::{PublicTransactionMerkleTree, UTXOCommitmentsMerkleTree}, + nullifier::{self, UTXONullifier}, + utxo_commitment::UTXOCommitment, }; use k256::{pkcs8::der::asn1::Null, AffinePoint}; use public_context::PublicSCContext; @@ -50,13 +54,16 @@ impl NodeChainStore { block_id = temp_block_id; } - Ok((Self { - acc_map, - block_store, - nullifier_store, - utxo_commitments_store, - pub_tx_store, - }, block_id)) + Ok(( + Self { + acc_map, + block_store, + nullifier_store, + utxo_commitments_store, + pub_tx_store, + }, + block_id, + )) } pub fn dissect_insert_block(&mut self, block: Block) -> Result<()> { From baf43f97802f4bf79123ef2f30a0b682b97f4a6a Mon Sep 17 00:00:00 2001 From: Rostyslav Tyshko Date: Fri, 30 May 2025 15:38:48 -0400 Subject: [PATCH 18/29] fix build CI --- accounts/src/account_core/mod.rs | 2 +- node_core/src/chain_storage/mod.rs | 6 ++---- storage/src/lib.rs | 1 - 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/accounts/src/account_core/mod.rs b/accounts/src/account_core/mod.rs index a698ecf..1adcecc 100644 --- a/accounts/src/account_core/mod.rs +++ b/accounts/src/account_core/mod.rs @@ -5,7 +5,7 @@ use common::{merkle_tree_public::TreeHashType, transaction::Tag}; use k256::AffinePoint; use log::info; use serde::{Deserialize, Serialize}; -use utxo::utxo_core::{UTXOPayload, UTXO}; +use utxo::utxo_core::UTXO; use crate::key_management::{ constants_types::{CipherText, Nonce}, diff --git a/node_core/src/chain_storage/mod.rs b/node_core/src/chain_storage/mod.rs index 1cf25d6..9ca6cfd 100644 --- a/node_core/src/chain_storage/mod.rs +++ b/node_core/src/chain_storage/mod.rs @@ -8,14 +8,12 @@ use anyhow::Result; use block_store::NodeBlockStore; use common::{ block::Block, - commitment, merkle_tree_public::merkle_tree::{PublicTransactionMerkleTree, UTXOCommitmentsMerkleTree}, - nullifier::{self, UTXONullifier}, + nullifier::UTXONullifier, utxo_commitment::UTXOCommitment, }; -use k256::{pkcs8::der::asn1::Null, AffinePoint}; +use k256::AffinePoint; use public_context::PublicSCContext; -use sc_core::transaction_payloads_tools; use utxo::utxo_core::UTXO; use crate::ActionData; diff --git a/storage/src/lib.rs b/storage/src/lib.rs index 3157bc0..424acd5 100644 --- a/storage/src/lib.rs +++ b/storage/src/lib.rs @@ -2,7 +2,6 @@ use std::{path::Path, sync::Arc}; use common::block::Block; use error::DbError; -use log::warn; use rocksdb::{ BoundColumnFamily, ColumnFamilyDescriptor, DBWithThreadMode, MultiThreaded, Options, }; From b57d6f5d21231a9c42df4f5126a525db0dfc08ae Mon Sep 17 00:00:00 2001 From: Rostyslav Tyshko Date: Fri, 30 May 2025 15:58:57 -0400 Subject: [PATCH 19/29] rm test for useless case --- node_core/src/chain_storage/block_store.rs | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/node_core/src/chain_storage/block_store.rs b/node_core/src/chain_storage/block_store.rs index 5b47612..649b13f 100644 --- a/node_core/src/chain_storage/block_store.rs +++ b/node_core/src/chain_storage/block_store.rs @@ -180,15 +180,4 @@ mod tests { assert_eq!(retrieved_block.block_id, block.block_id); assert_eq!(retrieved_block.hash, block.hash); } - - #[test] - fn test_get_block_not_found() { - let temp_dir = tempdir().unwrap(); - let path = temp_dir.path(); - - let node_store = NodeBlockStore::open_db_with_genesis(path, None).unwrap(); - - let result = node_store.get_block_at_id(42); - assert!(result.is_err()); - } } From 79d8bfb864840ebd338429629ed6d31dcc1547de Mon Sep 17 00:00:00 2001 From: Rostyslav Tyshko Date: Fri, 30 May 2025 16:19:40 -0400 Subject: [PATCH 20/29] fix test_open_db_restart --- node_core/src/chain_storage/block_store.rs | 24 ++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/node_core/src/chain_storage/block_store.rs b/node_core/src/chain_storage/block_store.rs index 649b13f..56b3ef0 100644 --- a/node_core/src/chain_storage/block_store.rs +++ b/node_core/src/chain_storage/block_store.rs @@ -27,9 +27,9 @@ impl NodeBlockStore { } ///Reopening existing database - pub fn open_db_restart(location: &Path) -> Result { + pub fn open_db_restart(location: &Path, genesis_block: Block) -> Result { NodeBlockStore::db_destroy(location)?; - NodeBlockStore::open_db_with_genesis(location, None) + NodeBlockStore::open_db_with_genesis(location, Some(genesis_block)) } ///Reloading existing database @@ -139,13 +139,25 @@ mod tests { let path = temp_dir.path(); let genesis_block = create_genesis_block(); - let _ = NodeBlockStore::open_db_with_genesis(path, Some(genesis_block)).unwrap(); + { + let node_store_old = NodeBlockStore::open_db_with_genesis(path, Some(genesis_block.clone())).unwrap(); + + let block = create_sample_block(1, 0); + node_store_old.put_block_at_id(block.clone()).unwrap(); + } + + // Check that the first block is still in the old database + { + let node_store_old = NodeBlockStore::open_db_reload(path).unwrap(); + let result = node_store_old.get_block_at_id(1); + assert!(result.is_ok()); + } // Restart the database - let node_store = NodeBlockStore::open_db_restart(path).unwrap(); + let node_store = NodeBlockStore::open_db_restart(path, genesis_block).unwrap(); - // The block should no longer be available since no genesis block is set on restart - let result = node_store.get_block_at_id(0); + // The block should no longer be available since no first block is set on restart + let result = node_store.get_block_at_id(1); assert!(result.is_err()); } From d755a529efc5a2c10b31e9f2067ceee3e6e3787b Mon Sep 17 00:00:00 2001 From: Rostyslav Tyshko Date: Fri, 30 May 2025 16:19:54 -0400 Subject: [PATCH 21/29] fmt --- node_core/src/chain_storage/block_store.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/node_core/src/chain_storage/block_store.rs b/node_core/src/chain_storage/block_store.rs index 56b3ef0..e05aab3 100644 --- a/node_core/src/chain_storage/block_store.rs +++ b/node_core/src/chain_storage/block_store.rs @@ -140,7 +140,8 @@ mod tests { let genesis_block = create_genesis_block(); { - let node_store_old = NodeBlockStore::open_db_with_genesis(path, Some(genesis_block.clone())).unwrap(); + let node_store_old = + NodeBlockStore::open_db_with_genesis(path, Some(genesis_block.clone())).unwrap(); let block = create_sample_block(1, 0); node_store_old.put_block_at_id(block.clone()).unwrap(); From 720263ae2d3324597ebbaa4073d82ac4f3736b07 Mon Sep 17 00:00:00 2001 From: Rostyslav Tyshko Date: Tue, 10 Jun 2025 01:39:11 -0400 Subject: [PATCH 22/29] fix after merge --- node_core/src/chain_storage/block_store.rs | 2 ++ node_core/src/chain_storage/mod.rs | 3 ++- node_core/src/lib.rs | 2 +- storage/src/lib.rs | 8 ++++---- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/node_core/src/chain_storage/block_store.rs b/node_core/src/chain_storage/block_store.rs index c48ed06..7084fa8 100644 --- a/node_core/src/chain_storage/block_store.rs +++ b/node_core/src/chain_storage/block_store.rs @@ -88,6 +88,8 @@ impl NodeBlockStore { Ok(serde_json::from_slice( &self.dbio.get_snapshot_transaction()?, )?) + } + pub fn put_snapshot_at_block_id( &self, id: u64, diff --git a/node_core/src/chain_storage/mod.rs b/node_core/src/chain_storage/mod.rs index f28a2ae..1f5c07d 100644 --- a/node_core/src/chain_storage/mod.rs +++ b/node_core/src/chain_storage/mod.rs @@ -30,7 +30,7 @@ pub struct NodeChainStore { } impl NodeChainStore { - pub fn new(home_dir: &Path, genesis_block: Block) -> Result<(Self, u64)> { + pub fn new(config: NodeConfig, genesis_block: Block) -> Result<(Self, u64)> { let mut acc_map = HashMap::new(); let mut nullifier_store = HashSet::new(); let mut utxo_commitments_store = UTXOCommitmentsMerkleTree::new(vec![]); @@ -58,6 +58,7 @@ impl NodeChainStore { nullifier_store, utxo_commitments_store, pub_tx_store, + node_config: config, }, block_id, )) diff --git a/node_core/src/lib.rs b/node_core/src/lib.rs index 3708b82..49f1285 100644 --- a/node_core/src/lib.rs +++ b/node_core/src/lib.rs @@ -98,7 +98,7 @@ impl NodeCore { let genesis_block = client.get_block(genesis_id.genesis_id).await?.block; - let (mut storage, mut chain_height) = NodeChainStore::new(&config.home, genesis_block)?; + let (mut storage, mut chain_height) = NodeChainStore::new(config.clone(), genesis_block)?; pre_start::setup_empty_sc_states(&storage).await?; diff --git a/storage/src/lib.rs b/storage/src/lib.rs index 424acd5..7616842 100644 --- a/storage/src/lib.rs +++ b/storage/src/lib.rs @@ -122,19 +122,19 @@ impl RocksDBIO { .map_err(|rerr| DbError::rocksdb_cast_message(rerr, None)) } - pub fn meta_column(&self) -> Arc { + pub fn meta_column(&self) -> Arc> { self.db.cf_handle(CF_META_NAME).unwrap() } - pub fn block_column(&self) -> Arc { + pub fn block_column(&self) -> Arc> { self.db.cf_handle(CF_BLOCK_NAME).unwrap() } - pub fn sc_column(&self) -> Arc { + pub fn sc_column(&self) -> Arc> { self.db.cf_handle(CF_SC_NAME).unwrap() } - pub fn snapshot_column(&self) -> Arc { + pub fn snapshot_column(&self) -> Arc> { self.db.cf_handle(CF_SNAPSHOT_NAME).unwrap() } From 222b0136bfc58d321bdc8f276d2c8da416dc0c42 Mon Sep 17 00:00:00 2001 From: Rostyslav Tyshko Date: Wed, 11 Jun 2025 01:20:46 -0400 Subject: [PATCH 23/29] `AccountForSerialization` struct for Account serialization --- accounts/src/account_core/mod.rs | 60 +++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/accounts/src/account_core/mod.rs b/accounts/src/account_core/mod.rs index 1adcecc..192c158 100644 --- a/accounts/src/account_core/mod.rs +++ b/accounts/src/account_core/mod.rs @@ -16,7 +16,7 @@ use crate::key_management::{ pub type PublicKey = AffinePoint; pub type AccountAddress = TreeHashType; -#[derive(Serialize, Deserialize, Clone)] +#[derive(Clone)] pub struct Account { pub key_holder: AddressKeyHolder, pub address: AccountAddress, @@ -24,6 +24,64 @@ pub struct Account { pub utxos: HashMap, } +#[derive(Serialize, Deserialize, Clone)] +pub struct AccountForSerialization { + pub key_holder: AddressKeyHolder, + pub address: AccountAddress, + pub balance: u64, + pub utxos: HashMap, +} + +impl From for AccountForSerialization { + fn from(value: Account) -> Self { + AccountForSerialization { + key_holder: value.key_holder, + address: value.address, + balance: value.balance, + utxos: value + .utxos + .into_iter() + .map(|(key, val)| (hex::encode(key), val)) + .collect(), + } + } +} + +impl From for Account { + fn from(value: AccountForSerialization) -> Self { + Account { + key_holder: value.key_holder, + address: value.address, + balance: value.balance, + utxos: value + .utxos + .into_iter() + .map(|(key, val)| (hex::decode(key).unwrap().try_into().unwrap(), val)) + .collect(), + } + } +} + +impl Serialize for Account { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let account_for_serialization: AccountForSerialization = From::from(self.clone()); + account_for_serialization.serialize(serializer) + } +} + +impl<'de> Deserialize<'de> for Account { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + let account_for_serialization = ::deserialize(deserializer)?; + Ok(account_for_serialization.into()) + } +} + ///A strucure, which represents all the visible(public) information /// /// known to each node about account `address` From 62f06582ef803b8c1d4bae20de3e094a6b9afeae Mon Sep 17 00:00:00 2001 From: Rostyslav Tyshko Date: Wed, 11 Jun 2025 01:22:48 -0400 Subject: [PATCH 24/29] `AccMap` struct for `HashMap<[u8;32], Account>,` serialization --- node_core/src/chain_storage/block_store.rs | 5 +- node_core/src/chain_storage/mod.rs | 64 +++++++++++++++++++++- 2 files changed, 66 insertions(+), 3 deletions(-) diff --git a/node_core/src/chain_storage/block_store.rs b/node_core/src/chain_storage/block_store.rs index 7084fa8..f55eeaa 100644 --- a/node_core/src/chain_storage/block_store.rs +++ b/node_core/src/chain_storage/block_store.rs @@ -12,6 +12,8 @@ use log::error; use storage::sc_db_utils::{DataBlob, DataBlobChangeVariant}; use storage::RocksDBIO; +use crate::chain_storage::AccMap; + pub struct NodeBlockStore { dbio: RocksDBIO, } @@ -69,7 +71,8 @@ impl NodeBlockStore { } pub fn get_snapshot_account(&self) -> Result> { - Ok(serde_json::from_slice(&self.dbio.get_snapshot_account()?)?) + let temp: AccMap = serde_json::from_slice(&self.dbio.get_snapshot_account()?)?; + Ok(temp.into()) } pub fn get_snapshot_commitment(&self) -> Result> { diff --git a/node_core/src/chain_storage/mod.rs b/node_core/src/chain_storage/mod.rs index 1f5c07d..04ad7d1 100644 --- a/node_core/src/chain_storage/mod.rs +++ b/node_core/src/chain_storage/mod.rs @@ -12,6 +12,7 @@ use common::{ use k256::AffinePoint; use log::{info, warn}; use public_context::PublicSCContext; +use serde::{Deserialize, Serialize}; use utxo::utxo_core::UTXO; use crate::{config::NodeConfig, ActionData}; @@ -20,6 +21,32 @@ pub mod accounts_store; pub mod block_store; pub mod public_context; +#[derive(Deserialize, Serialize)] +pub struct AccMap { + pub acc_map: HashMap, +} + +impl From> for AccMap { + fn from(value: HashMap<[u8; 32], Account>) -> Self { + AccMap { + acc_map: value + .into_iter() + .map(|(key, val)| (hex::encode(key), val)) + .collect(), + } + } +} + +impl From for HashMap<[u8; 32], Account> { + fn from(value: AccMap) -> Self { + value + .acc_map + .into_iter() + .map(|(key, val)| (hex::decode(key).unwrap().try_into().unwrap(), val)) + .collect() + } +} + pub struct NodeChainStore { pub acc_map: HashMap, pub block_store: NodeBlockStore, @@ -51,6 +78,38 @@ impl NodeChainStore { block_id = temp_block_id; } + Ok(( + Self { + acc_map: From::from(acc_map), + block_store, + nullifier_store, + utxo_commitments_store, + pub_tx_store, + node_config: config, + }, + block_id, + )) + } + + pub fn new_after_restart(config: NodeConfig, genesis_block: Block) -> Result<(Self, u64)> { + let mut acc_map = HashMap::new(); + let mut nullifier_store = HashSet::new(); + let mut utxo_commitments_store = UTXOCommitmentsMerkleTree::new(vec![]); + let mut pub_tx_store = PublicTransactionMerkleTree::new(vec![]); + let mut block_id = genesis_block.block_id; + + //Sequencer should panic if unable to open db, + //as fixing this issue may require actions non-native to program scope + let block_store = NodeBlockStore::open_db_reload(&config.home.join("rocksdb")).unwrap(); + + if let Ok(temp_block_id) = block_store.get_snapshot_block_id() { + utxo_commitments_store = block_store.get_snapshot_commitment()?; + nullifier_store = block_store.get_snapshot_nullifier()?; + acc_map = block_store.get_snapshot_account()?; + pub_tx_store = block_store.get_snapshot_transaction()?; + block_id = temp_block_id; + } + Ok(( Self { acc_map, @@ -125,7 +184,7 @@ impl NodeChainStore { let nonce = accounts::key_management::constants_types::Nonce::clone_from_slice(slice); for (acc_id, acc) in self.acc_map.iter_mut() { - if acc_id[0] == tag { + if hex::decode(acc_id).unwrap()[0] == tag { let decoded_data_curr_acc = acc.decrypt_data( ephemeral_public_key_sender, ciphertext.clone(), @@ -156,8 +215,9 @@ impl NodeChainStore { //If we fail serialization, it is not the reason to stop running //Logging on warn level in this cases + let acc_map: AccMap = self.acc_map.clone().into(); - if let Ok(accounts_ser) = serde_json::to_vec(&self.acc_map).inspect_err(|err| { + if let Ok(accounts_ser) = serde_json::to_vec(&acc_map).inspect_err(|err| { warn!("Failed to serialize accounts data {err:#?}"); }) { if let Ok(comm_ser) = From b62821cb7468a763b393b56279f0a18aab023fdc Mon Sep 17 00:00:00 2001 From: Rostyslav Tyshko Date: Wed, 11 Jun 2025 01:23:12 -0400 Subject: [PATCH 25/29] add test_new_initializes_correctly --- node_core/src/chain_storage/mod.rs | 113 +++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) diff --git a/node_core/src/chain_storage/mod.rs b/node_core/src/chain_storage/mod.rs index 04ad7d1..880f445 100644 --- a/node_core/src/chain_storage/mod.rs +++ b/node_core/src/chain_storage/mod.rs @@ -270,3 +270,116 @@ impl NodeChainStore { } } } + +#[cfg(test)] +mod tests { + use std::path::PathBuf; + use crate::config::GasConfig; + use super::*; + use common::merkle_tree_public::TreeHashType; + use secp256k1_zkp::Tweak; + use tempfile::tempdir; + use accounts::account_core::Account; + use common::block::{Block, Data}; + use common::transaction::{Transaction, TxKind}; + + fn create_genesis_block() -> Block { + Block { + block_id: 0, + prev_block_id: 0, + prev_block_hash: [0; 32], + hash: [1; 32], + transactions: vec![], + data: Data::default(), + } + } + + fn create_dummy_transaction( + hash: TreeHashType, + // execution_input: Vec, + nullifier_created_hashes: Vec<[u8; 32]>, + utxo_commitments_spent_hashes: Vec<[u8; 32]>, + utxo_commitments_created_hashes: Vec<[u8; 32]>, + ) -> Transaction { + let mut rng = rand::thread_rng(); + + Transaction { + hash, + tx_kind: TxKind::Private, + execution_input: vec![], + execution_output: vec![], + utxo_commitments_spent_hashes, + utxo_commitments_created_hashes, + nullifier_created_hashes, + execution_proof_private: "dummy_proof".to_string(), + encoded_data: vec![], + ephemeral_pub_key: vec![10, 11, 12], + commitment: vec![], + tweak: Tweak::new(&mut rng), + secret_r: [0; 32], + sc_addr: "sc_addr".to_string(), + state_changes: (serde_json::Value::Null, 0), + } + } + + fn create_sample_block(block_id: u64, prev_block_id: u64) -> Block { + Block { + block_id: block_id, + prev_block_id: prev_block_id, + prev_block_hash: [0; 32], + hash: [1; 32], + transactions: vec![], + data: Data::default(), + } + } + + fn create_sample_node_config(home: PathBuf) -> NodeConfig { + NodeConfig { + home, + override_rust_log: None, + sequencer_addr: "http://127.0.0.1".to_string(), + seq_poll_timeout_secs: 1, + port: 8000, + gas_config: create_sample_gas_config(), + shapshot_frequency_in_blocks: 1, + } + } + + fn create_sample_gas_config() -> GasConfig { + GasConfig { + gas_fee_per_byte_deploy: 0, + gas_fee_per_input_buffer_runtime: 0, + gas_fee_per_byte_runtime: 0, + gas_cost_runtime: 0, + gas_cost_deploy: 0, + gas_limit_deploy: 0, + gas_limit_runtime: 0, + } + } + + fn generate_dummy_utxo(address: TreeHashType, amount: u128) -> UTXO { + UTXO::new(address, vec![], amount, false) + } + + #[test] + fn test_new_initializes_correctly() { + let temp_dir = tempdir().unwrap(); + let path = temp_dir.path(); + + let config = create_sample_node_config(path.to_path_buf()); + + let genesis_block = create_genesis_block(); + + let (store, block_id) = NodeChainStore::new(config.clone(), genesis_block.clone()).unwrap(); + + assert_eq!(block_id, 0); + assert!(store.acc_map.is_empty()); + assert!(store.nullifier_store.is_empty()); + assert_eq!( + store.utxo_commitments_store.get_root().unwrap_or([0; 32]), + [0; 32] + ); + } + + +} From a65dcd518d696051ff9c4c1a3f0415995ba4656f Mon Sep 17 00:00:00 2001 From: Rostyslav Tyshko Date: Wed, 11 Jun 2025 01:23:28 -0400 Subject: [PATCH 26/29] add test_new_recovers_from_snapshot --- node_core/src/chain_storage/mod.rs | 57 ++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/node_core/src/chain_storage/mod.rs b/node_core/src/chain_storage/mod.rs index 880f445..4766be8 100644 --- a/node_core/src/chain_storage/mod.rs +++ b/node_core/src/chain_storage/mod.rs @@ -381,5 +381,62 @@ mod tests { ); } + #[test] + fn test_new_recovers_from_snapshot() { + let temp_dir = tempdir().unwrap(); + let path = temp_dir.path().to_path_buf(); + let config = create_sample_node_config(path); + + let nullifier_secret_const = + "261d61d294ac4bdc24f91b6f490efa263757a4a95f65871cd4f16b2ea23c3b5d"; + std::env::set_var("NULLIFIER_SECRET_CONST", nullifier_secret_const); + + let viewing_secret_const = + "6117af750b30d7a296672ec3b3b25d3489beca3cfe5770fa39f275cec395d5ce"; + std::env::set_var("VIEWING_SECRET_CONST", viewing_secret_const); + + let genesis_block = create_genesis_block(); + + // Initialize once to create DB and store fake snapshot + { + let (mut store, _) = + NodeChainStore::new(config.clone(), genesis_block.clone()).unwrap(); + + // Insert state + let mut account = Account::new(); + account + .add_new_utxo_outputs(vec![generate_dummy_utxo(account.address, 100)]) + .unwrap(); + store.acc_map.insert(account.address, account); + store.nullifier_store.insert(UTXONullifier { + utxo_hash: [2u8; 32], + }); + store + .utxo_commitments_store + .add_tx_multiple(vec![UTXOCommitment { hash: [3u8; 32] }]); + store.pub_tx_store.add_tx(create_dummy_transaction( + [12; 32], + vec![[9; 32]], + vec![[7; 32]], + vec![[8; 32]], + )); + + // Put block snapshot to trigger snapshot recovery on next load + let dummy_block = create_sample_block(1, 0); + + store.dissect_insert_block(dummy_block).unwrap(); + } + + // Now reload and verify snapshot is used + let (recovered_store, block_id) = + NodeChainStore::new_after_restart(config.clone(), genesis_block).unwrap(); + + assert_eq!(block_id, 1); + assert_eq!(recovered_store.acc_map.len(), 1); + assert_eq!( + recovered_store.utxo_commitments_store.get_root().is_some(), + true + ); + } } From 31722b2f72074477d1735e2b52b60378c58f3101 Mon Sep 17 00:00:00 2001 From: Rostyslav Tyshko Date: Wed, 11 Jun 2025 01:25:47 -0400 Subject: [PATCH 27/29] fmt --- node_core/src/chain_storage/mod.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/node_core/src/chain_storage/mod.rs b/node_core/src/chain_storage/mod.rs index 4766be8..f6b1343 100644 --- a/node_core/src/chain_storage/mod.rs +++ b/node_core/src/chain_storage/mod.rs @@ -273,15 +273,15 @@ impl NodeChainStore { #[cfg(test)] mod tests { - use std::path::PathBuf; - use crate::config::GasConfig; use super::*; - use common::merkle_tree_public::TreeHashType; - use secp256k1_zkp::Tweak; - use tempfile::tempdir; + use crate::config::GasConfig; use accounts::account_core::Account; use common::block::{Block, Data}; + use common::merkle_tree_public::TreeHashType; use common::transaction::{Transaction, TxKind}; + use secp256k1_zkp::Tweak; + use std::path::PathBuf; + use tempfile::tempdir; fn create_genesis_block() -> Block { Block { From adb802f28e02e728a860555af7d159af58d6ce74 Mon Sep 17 00:00:00 2001 From: Rostyslav Tyshko Date: Wed, 11 Jun 2025 01:46:35 -0400 Subject: [PATCH 28/29] redundunt --- node_core/src/chain_storage/block_store.rs | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/node_core/src/chain_storage/block_store.rs b/node_core/src/chain_storage/block_store.rs index f55eeaa..677f426 100644 --- a/node_core/src/chain_storage/block_store.rs +++ b/node_core/src/chain_storage/block_store.rs @@ -230,17 +230,6 @@ mod tests { assert_eq!(retrieved_block.hash, block.hash); } - #[test] - fn test_get_block_not_found() { - let temp_dir = tempdir().unwrap(); - let path = temp_dir.path(); - - let node_store = NodeBlockStore::open_db_with_genesis(path, None).unwrap(); - - let result = node_store.get_block_at_id(42); - assert!(result.is_err()); - } - #[test] fn test_put_snapshot_at_block_id() { let temp_dir = tempdir().unwrap(); From 5e3fd4bbf8780659d0fb254e538c76b8ea162412 Mon Sep 17 00:00:00 2001 From: Rostyslav Tyshko Date: Wed, 11 Jun 2025 02:08:36 -0400 Subject: [PATCH 29/29] update risc0 version --- Cargo.lock | 48 ++++++++++++++++++------------------ common/Cargo.toml | 2 +- node_core/Cargo.toml | 2 +- sc_core/Cargo.toml | 2 +- zkvm/Cargo.toml | 2 +- zkvm/test_methods/Cargo.toml | 2 +- 6 files changed, 29 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2c2323d..1cbacc5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -767,7 +767,7 @@ dependencies = [ [[package]] name = "bonsai-sdk" version = "1.4.0" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.0#c0db0713671c8ec467b3efc26b22a0b0591897ff" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" dependencies = [ "duplicate", "maybe-async", @@ -3716,7 +3716,7 @@ checksum = "3df6368f71f205ff9c33c076d170dd56ebf68e8161c733c0caa07a7a5509ed53" [[package]] name = "risc0-binfmt" version = "2.0.1" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.0#c0db0713671c8ec467b3efc26b22a0b0591897ff" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" dependencies = [ "anyhow", "borsh", @@ -3733,8 +3733,8 @@ dependencies = [ [[package]] name = "risc0-build" -version = "2.1.1" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.0#c0db0713671c8ec467b3efc26b22a0b0591897ff" +version = "2.1.2" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" dependencies = [ "anyhow", "cargo_metadata", @@ -3757,7 +3757,7 @@ dependencies = [ [[package]] name = "risc0-build-kernel" version = "2.0.0" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.0#c0db0713671c8ec467b3efc26b22a0b0591897ff" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" dependencies = [ "cc", "directories", @@ -3770,8 +3770,8 @@ dependencies = [ [[package]] name = "risc0-circuit-keccak" -version = "2.0.1" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.0#c0db0713671c8ec467b3efc26b22a0b0591897ff" +version = "2.0.2" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" dependencies = [ "anyhow", "bytemuck", @@ -3792,7 +3792,7 @@ dependencies = [ [[package]] name = "risc0-circuit-keccak-sys" version = "2.0.0" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.0#c0db0713671c8ec467b3efc26b22a0b0591897ff" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" dependencies = [ "cc", "cust", @@ -3806,8 +3806,8 @@ dependencies = [ [[package]] name = "risc0-circuit-recursion" -version = "2.0.1" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.0#c0db0713671c8ec467b3efc26b22a0b0591897ff" +version = "2.0.2" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" dependencies = [ "anyhow", "bytemuck", @@ -3832,7 +3832,7 @@ dependencies = [ [[package]] name = "risc0-circuit-recursion-sys" version = "2.0.0" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.0#c0db0713671c8ec467b3efc26b22a0b0591897ff" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" dependencies = [ "glob", "risc0-build-kernel", @@ -3843,8 +3843,8 @@ dependencies = [ [[package]] name = "risc0-circuit-rv32im" -version = "2.0.3" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.0#c0db0713671c8ec467b3efc26b22a0b0591897ff" +version = "2.0.4" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" dependencies = [ "anyhow", "auto_ops", @@ -3874,8 +3874,8 @@ dependencies = [ [[package]] name = "risc0-circuit-rv32im-sys" -version = "2.0.1" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.0#c0db0713671c8ec467b3efc26b22a0b0591897ff" +version = "2.0.2" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" dependencies = [ "cc", "cust", @@ -3890,7 +3890,7 @@ dependencies = [ [[package]] name = "risc0-core" version = "2.0.0" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.0#c0db0713671c8ec467b3efc26b22a0b0591897ff" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" dependencies = [ "bytemuck", "bytemuck_derive", @@ -3902,7 +3902,7 @@ dependencies = [ [[package]] name = "risc0-groth16" version = "2.0.1" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.0#c0db0713671c8ec467b3efc26b22a0b0591897ff" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" dependencies = [ "anyhow", "ark-bn254", @@ -3926,7 +3926,7 @@ dependencies = [ [[package]] name = "risc0-sys" version = "1.4.0" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.0#c0db0713671c8ec467b3efc26b22a0b0591897ff" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" dependencies = [ "anyhow", "cust", @@ -3937,7 +3937,7 @@ dependencies = [ [[package]] name = "risc0-zkos-v1compat" version = "2.0.1" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.0#c0db0713671c8ec467b3efc26b22a0b0591897ff" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" dependencies = [ "include_bytes_aligned", "no_std_strings", @@ -3946,7 +3946,7 @@ dependencies = [ [[package]] name = "risc0-zkp" version = "2.0.1" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.0#c0db0713671c8ec467b3efc26b22a0b0591897ff" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" dependencies = [ "anyhow", "blake2", @@ -3976,8 +3976,8 @@ dependencies = [ [[package]] name = "risc0-zkvm" -version = "2.0.2" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.0#c0db0713671c8ec467b3efc26b22a0b0591897ff" +version = "2.1.0" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" dependencies = [ "addr2line 0.22.0", "anyhow", @@ -4023,7 +4023,7 @@ dependencies = [ [[package]] name = "risc0-zkvm-platform" version = "2.0.2" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.0#c0db0713671c8ec467b3efc26b22a0b0591897ff" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" dependencies = [ "bytemuck", "cfg-if", @@ -4185,7 +4185,7 @@ checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "rzup" version = "0.4.1" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.0#c0db0713671c8ec467b3efc26b22a0b0591897ff" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" dependencies = [ "semver", "serde", diff --git a/common/Cargo.toml b/common/Cargo.toml index b692f5f..2b51d66 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -9,7 +9,7 @@ thiserror.workspace = true serde_json.workspace = true serde.workspace = true reqwest.workspace = true -risc0-zkvm = { git = "https://github.com/risc0/risc0.git", branch = "release-2.0" } +risc0-zkvm = { git = "https://github.com/risc0/risc0.git", branch = "release-2.1" } rs_merkle.workspace = true sha2.workspace = true diff --git a/node_core/Cargo.toml b/node_core/Cargo.toml index 18120b2..109a96a 100644 --- a/node_core/Cargo.toml +++ b/node_core/Cargo.toml @@ -18,7 +18,7 @@ reqwest.workspace = true thiserror.workspace = true tokio.workspace = true tempfile.workspace = true -risc0-zkvm = { git = "https://github.com/risc0/risc0.git", branch = "release-2.0" } +risc0-zkvm = { git = "https://github.com/risc0/risc0.git", branch = "release-2.1" } hex.workspace = true actix-rt.workspace = true diff --git a/sc_core/Cargo.toml b/sc_core/Cargo.toml index e93c955..ea580d6 100644 --- a/sc_core/Cargo.toml +++ b/sc_core/Cargo.toml @@ -19,7 +19,7 @@ light-poseidon.workspace = true ark-bn254.workspace = true ark-ff.workspace = true -risc0-zkvm = { git = "https://github.com/risc0/risc0.git", branch = "release-2.0" } +risc0-zkvm = { git = "https://github.com/risc0/risc0.git", branch = "release-2.1" } [dependencies.accounts] path = "../accounts" diff --git a/zkvm/Cargo.toml b/zkvm/Cargo.toml index 7de7002..1a64da4 100644 --- a/zkvm/Cargo.toml +++ b/zkvm/Cargo.toml @@ -12,7 +12,7 @@ serde.workspace = true thiserror.workspace = true rand.workspace = true -risc0-zkvm = { git = "https://github.com/risc0/risc0.git", branch = "release-2.0" } +risc0-zkvm = { git = "https://github.com/risc0/risc0.git", branch = "release-2.1" } test-methods = { path = "test_methods" } [dependencies.accounts] diff --git a/zkvm/test_methods/Cargo.toml b/zkvm/test_methods/Cargo.toml index 35dc8bd..70584d6 100644 --- a/zkvm/test_methods/Cargo.toml +++ b/zkvm/test_methods/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [build-dependencies] -risc0-build = { git = "https://github.com/risc0/risc0.git", branch = "release-2.0" } +risc0-build = { git = "https://github.com/risc0/risc0.git", branch = "release-2.1" } [package.metadata.risc0] methods = ["guest"]