From 8e987847eeffe99326292e9d3ccde4c17d96c074 Mon Sep 17 00:00:00 2001 From: Oleksandr Pravdyvyi Date: Wed, 9 Jul 2025 08:16:12 +0300 Subject: [PATCH 01/15] feat: AccountPublicData struct changed --- .../src/sequencer_store/accounts_store.rs | 24 ++++--------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/sequencer_core/src/sequencer_store/accounts_store.rs b/sequencer_core/src/sequencer_store/accounts_store.rs index fe1286f4..3e43e67e 100644 --- a/sequencer_core/src/sequencer_store/accounts_store.rs +++ b/sequencer_core/src/sequencer_store/accounts_store.rs @@ -1,29 +1,13 @@ -use accounts::account_core::{AccountAddress, PublicKey}; -use k256::AffinePoint; +use accounts::account_core::AccountAddress; +use serde::{Deserialize, Serialize}; use std::collections::HashMap; -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize)] pub struct AccountPublicData { - pub nullifier_public_key: PublicKey, - pub viewing_public_key: PublicKey, + pub balance: u64, pub address: AccountAddress, } -impl AccountPublicData { - pub fn from_raw( - address: AccountAddress, - nullifier_public_key: Vec, - viewing_public_key: Vec, - ) -> Self { - Self { - nullifier_public_key: serde_json::from_slice::(&nullifier_public_key) - .unwrap(), - viewing_public_key: serde_json::from_slice::(&viewing_public_key).unwrap(), - address, - } - } -} - #[derive(Debug, Clone)] pub struct SequencerAccountsStore { pub accounts: HashMap, From 54284be74b88673a03c629b4be99c4df1dc435b1 Mon Sep 17 00:00:00 2001 From: Oleksandr Pravdyvyi Date: Wed, 9 Jul 2025 16:03:30 +0300 Subject: [PATCH 02/15] fix: account data public only for sequencer --- common/src/rpc_primitives/requests.rs | 2 -- node_core/src/sequencer_client/mod.rs | 3 --- sequencer_core/src/lib.rs | 16 ++++++++-------- .../src/sequencer_store/accounts_store.rs | 17 +++++++++++++---- sequencer_rpc/src/process.rs | 7 +------ 5 files changed, 22 insertions(+), 23 deletions(-) diff --git a/common/src/rpc_primitives/requests.rs b/common/src/rpc_primitives/requests.rs index 6cad01d5..395badf2 100644 --- a/common/src/rpc_primitives/requests.rs +++ b/common/src/rpc_primitives/requests.rs @@ -13,8 +13,6 @@ pub struct HelloRequest {} #[derive(Serialize, Deserialize, Debug)] pub struct RegisterAccountRequest { - pub nullifier_public_key: Vec, - pub viewing_public_key: Vec, pub address: [u8; 32], } diff --git a/node_core/src/sequencer_client/mod.rs b/node_core/src/sequencer_client/mod.rs index 7accd5ff..c3483957 100644 --- a/node_core/src/sequencer_client/mod.rs +++ b/node_core/src/sequencer_client/mod.rs @@ -7,7 +7,6 @@ use common::rpc_primitives::requests::{ use common::transaction::Transaction; use common::{SequencerClientError, SequencerRpcError}; use json::{SendTxRequest, SendTxResponse, SequencerRpcRequest, SequencerRpcResponse}; -use k256::elliptic_curve::group::GroupEncoding; use reqwest::Client; use serde_json::Value; @@ -94,8 +93,6 @@ impl SequencerClient { account: &Account, ) -> Result { let acc_req = RegisterAccountRequest { - nullifier_public_key: account.key_holder.nullifer_public_key.to_bytes().to_vec(), - viewing_public_key: account.key_holder.viewing_public_key.to_bytes().to_vec(), address: account.address, }; diff --git a/sequencer_core/src/lib.rs b/sequencer_core/src/lib.rs index 7a083f10..1ed603be 100644 --- a/sequencer_core/src/lib.rs +++ b/sequencer_core/src/lib.rs @@ -1,5 +1,6 @@ use std::fmt::Display; +use accounts::account_core::AccountAddress; use anyhow::Result; use common::{ block::{Block, HashableBlockData}, @@ -10,7 +11,7 @@ use common::{ }; use config::SequencerConfig; use mempool::MemPool; -use sequencer_store::{accounts_store::AccountPublicData, SequecerChainStore}; +use sequencer_store::SequecerChainStore; use serde::{Deserialize, Serialize}; use transaction_mempool::TransactionMempool; @@ -209,11 +210,8 @@ impl SequencerCore { Ok(()) } - pub fn register_account(&mut self, acc_data: AccountPublicData) { - self.store - .acc_store - .accounts - .insert(acc_data.address, acc_data); + pub fn register_account(&mut self, account_addr: AccountAddress) { + self.store.acc_store.register_account(account_addr); } ///Produces new block from transactions in mempool @@ -306,12 +304,14 @@ mod tests { } } - fn common_setup(mut sequencer: &mut SequencerCore) { + fn common_setup(sequencer: &mut SequencerCore) { let tx = create_dummy_transaction([12; 32], vec![[9; 32]], vec![[7; 32]], vec![[8; 32]]); let tx_mempool = TransactionMempool { tx }; sequencer.mempool.push_item(tx_mempool); - sequencer.produce_new_block_with_mempool_transactions(); + sequencer + .produce_new_block_with_mempool_transactions() + .unwrap(); } #[test] diff --git a/sequencer_core/src/sequencer_store/accounts_store.rs b/sequencer_core/src/sequencer_store/accounts_store.rs index 3e43e67e..8f3eef0b 100644 --- a/sequencer_core/src/sequencer_store/accounts_store.rs +++ b/sequencer_core/src/sequencer_store/accounts_store.rs @@ -3,14 +3,23 @@ use serde::{Deserialize, Serialize}; use std::collections::HashMap; #[derive(Debug, Clone, Serialize, Deserialize)] -pub struct AccountPublicData { +pub(crate) struct AccountPublicData { pub balance: u64, pub address: AccountAddress, } +impl AccountPublicData { + pub fn new(address: AccountAddress) -> Self { + Self { + balance: 0, + address, + } + } +} + #[derive(Debug, Clone)] pub struct SequencerAccountsStore { - pub accounts: HashMap, + accounts: HashMap, } impl SequencerAccountsStore { @@ -20,9 +29,9 @@ impl SequencerAccountsStore { } } - pub fn register_account(&mut self, account_pub_data: AccountPublicData) { + pub fn register_account(&mut self, account_addr: AccountAddress) { self.accounts - .insert(account_pub_data.address, account_pub_data); + .insert(account_addr, AccountPublicData::new(account_addr)); } pub fn unregister_account(&mut self, account_addr: AccountAddress) { diff --git a/sequencer_rpc/src/process.rs b/sequencer_rpc/src/process.rs index 5bac835e..cab07bf0 100644 --- a/sequencer_rpc/src/process.rs +++ b/sequencer_rpc/src/process.rs @@ -1,5 +1,4 @@ use actix_web::Error as HttpError; -use sequencer_core::sequencer_store::accounts_store::AccountPublicData; use serde_json::Value; use common::rpc_primitives::{ @@ -61,11 +60,7 @@ impl JsonHandler { { let mut acc_store = self.sequencer_state.lock().await; - acc_store.register_account(AccountPublicData::from_raw( - acc_req.address, - acc_req.nullifier_public_key, - acc_req.viewing_public_key, - )); + acc_store.register_account(acc_req.address); } let helperstruct = RegisterAccountResponse { From 1d4548fb3b412471d7b72f4a8c6d4c56554d6cdb Mon Sep 17 00:00:00 2001 From: Sergio Chouhy Date: Thu, 10 Jul 2025 14:15:07 -0300 Subject: [PATCH 03/15] bump risc0 version to 2.2 --- Cargo.lock | 60 ++++++++++++++++++------------------ 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, 35 insertions(+), 35 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1cbacc52..0200d46a 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.1#f34d6913945ab9f214219f3cbee1703f63936cc4" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.2#eff3c74bf9992401c2c68bea95eb6c93b27999ec" dependencies = [ "duplicate", "maybe-async", @@ -3715,8 +3715,8 @@ checksum = "3df6368f71f205ff9c33c076d170dd56ebf68e8161c733c0caa07a7a5509ed53" [[package]] name = "risc0-binfmt" -version = "2.0.1" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" +version = "2.0.2" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.2#eff3c74bf9992401c2c68bea95eb6c93b27999ec" dependencies = [ "anyhow", "borsh", @@ -3733,8 +3733,8 @@ dependencies = [ [[package]] name = "risc0-build" -version = "2.1.2" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" +version = "2.2.0" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.2#eff3c74bf9992401c2c68bea95eb6c93b27999ec" 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.1#f34d6913945ab9f214219f3cbee1703f63936cc4" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.2#eff3c74bf9992401c2c68bea95eb6c93b27999ec" dependencies = [ "cc", "directories", @@ -3770,8 +3770,8 @@ dependencies = [ [[package]] name = "risc0-circuit-keccak" -version = "2.0.2" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" +version = "3.0.0" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.2#eff3c74bf9992401c2c68bea95eb6c93b27999ec" dependencies = [ "anyhow", "bytemuck", @@ -3791,8 +3791,8 @@ dependencies = [ [[package]] name = "risc0-circuit-keccak-sys" -version = "2.0.0" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" +version = "3.0.0" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.2#eff3c74bf9992401c2c68bea95eb6c93b27999ec" dependencies = [ "cc", "cust", @@ -3806,8 +3806,8 @@ dependencies = [ [[package]] name = "risc0-circuit-recursion" -version = "2.0.2" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" +version = "3.0.0" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.2#eff3c74bf9992401c2c68bea95eb6c93b27999ec" dependencies = [ "anyhow", "bytemuck", @@ -3831,8 +3831,8 @@ dependencies = [ [[package]] name = "risc0-circuit-recursion-sys" -version = "2.0.0" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" +version = "3.0.0" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.2#eff3c74bf9992401c2c68bea95eb6c93b27999ec" dependencies = [ "glob", "risc0-build-kernel", @@ -3843,8 +3843,8 @@ dependencies = [ [[package]] name = "risc0-circuit-rv32im" -version = "2.0.4" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" +version = "3.0.0" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.2#eff3c74bf9992401c2c68bea95eb6c93b27999ec" dependencies = [ "anyhow", "auto_ops", @@ -3874,8 +3874,8 @@ dependencies = [ [[package]] name = "risc0-circuit-rv32im-sys" -version = "2.0.2" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" +version = "3.0.0" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.2#eff3c74bf9992401c2c68bea95eb6c93b27999ec" 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.1#f34d6913945ab9f214219f3cbee1703f63936cc4" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.2#eff3c74bf9992401c2c68bea95eb6c93b27999ec" dependencies = [ "bytemuck", "bytemuck_derive", @@ -3901,8 +3901,8 @@ dependencies = [ [[package]] name = "risc0-groth16" -version = "2.0.1" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" +version = "2.0.2" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.2#eff3c74bf9992401c2c68bea95eb6c93b27999ec" 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.1#f34d6913945ab9f214219f3cbee1703f63936cc4" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.2#eff3c74bf9992401c2c68bea95eb6c93b27999ec" 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.1#f34d6913945ab9f214219f3cbee1703f63936cc4" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.2#eff3c74bf9992401c2c68bea95eb6c93b27999ec" dependencies = [ "include_bytes_aligned", "no_std_strings", @@ -3945,8 +3945,8 @@ dependencies = [ [[package]] name = "risc0-zkp" -version = "2.0.1" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" +version = "2.0.2" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.2#eff3c74bf9992401c2c68bea95eb6c93b27999ec" dependencies = [ "anyhow", "blake2", @@ -3976,8 +3976,8 @@ dependencies = [ [[package]] name = "risc0-zkvm" -version = "2.1.0" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" +version = "2.2.0" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.2#eff3c74bf9992401c2c68bea95eb6c93b27999ec" dependencies = [ "addr2line 0.22.0", "anyhow", @@ -4022,8 +4022,8 @@ dependencies = [ [[package]] name = "risc0-zkvm-platform" -version = "2.0.2" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" +version = "2.0.3" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.2#eff3c74bf9992401c2c68bea95eb6c93b27999ec" 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.1#f34d6913945ab9f214219f3cbee1703f63936cc4" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.2#eff3c74bf9992401c2c68bea95eb6c93b27999ec" dependencies = [ "semver", "serde", diff --git a/common/Cargo.toml b/common/Cargo.toml index 2b51d666..b1988ad6 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.1" } +risc0-zkvm = { git = "https://github.com/risc0/risc0.git", branch = "release-2.2" } rs_merkle.workspace = true sha2.workspace = true diff --git a/node_core/Cargo.toml b/node_core/Cargo.toml index 109a96a0..c85e0e0c 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.1" } +risc0-zkvm = { git = "https://github.com/risc0/risc0.git", branch = "release-2.2" } hex.workspace = true actix-rt.workspace = true diff --git a/sc_core/Cargo.toml b/sc_core/Cargo.toml index ea580d67..3d6a2135 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.1" } +risc0-zkvm = { git = "https://github.com/risc0/risc0.git", branch = "release-2.2" } [dependencies.accounts] path = "../accounts" diff --git a/zkvm/Cargo.toml b/zkvm/Cargo.toml index 1a64da4d..a0701cb7 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.1" } +risc0-zkvm = { git = "https://github.com/risc0/risc0.git", branch = "release-2.2" } test-methods = { path = "test_methods" } [dependencies.accounts] diff --git a/zkvm/test_methods/Cargo.toml b/zkvm/test_methods/Cargo.toml index 70584d6a..eb771c52 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.1" } +risc0-build = { git = "https://github.com/risc0/risc0.git", branch = "release-2.2" } [package.metadata.risc0] methods = ["guest"] From 5e9c6a0677c4dc73b0148d7dbad915378b202170 Mon Sep 17 00:00:00 2001 From: Oleksandr Pravdyvyi Date: Fri, 11 Jul 2025 10:34:13 +0300 Subject: [PATCH 04/15] feat: preset accounts in sequencer account store --- .../src/sequencer_store/accounts_store.rs | 119 +++++++++++++++++- 1 file changed, 115 insertions(+), 4 deletions(-) diff --git a/sequencer_core/src/sequencer_store/accounts_store.rs b/sequencer_core/src/sequencer_store/accounts_store.rs index 8f3eef0b..bc65565a 100644 --- a/sequencer_core/src/sequencer_store/accounts_store.rs +++ b/sequencer_core/src/sequencer_store/accounts_store.rs @@ -15,6 +15,10 @@ impl AccountPublicData { address, } } + + pub fn new_with_balance(address: AccountAddress, balance: u64) -> Self { + Self { balance, address } + } } #[derive(Debug, Clone)] @@ -23,10 +27,17 @@ pub struct SequencerAccountsStore { } impl SequencerAccountsStore { - pub fn new() -> Self { - Self { - accounts: HashMap::new(), + pub fn new(initial_accounts: &[(AccountAddress, u64)]) -> Self { + let mut accounts = HashMap::new(); + + for (account_addr, balance) in initial_accounts { + accounts.insert( + *account_addr, + AccountPublicData::new_with_balance(*account_addr, *balance), + ); } + + Self { accounts } } pub fn register_account(&mut self, account_addr: AccountAddress) { @@ -34,6 +45,14 @@ impl SequencerAccountsStore { .insert(account_addr, AccountPublicData::new(account_addr)); } + pub fn contains_account(&self, account_addr: &AccountAddress) -> bool { + self.accounts.contains_key(account_addr) + } + + pub fn get_account_balance(&self, account_addr: &AccountAddress) -> Option { + self.accounts.get(account_addr).map(|acc| acc.balance) + } + pub fn unregister_account(&mut self, account_addr: AccountAddress) { self.accounts.remove(&account_addr); } @@ -41,6 +60,98 @@ impl SequencerAccountsStore { impl Default for SequencerAccountsStore { fn default() -> Self { - Self::new() + Self::new(&[]) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_zero_balance_account_data_creation() { + let new_acc = AccountPublicData::new([1; 32]); + + assert_eq!(new_acc.balance, 0); + assert_eq!(new_acc.address, [1; 32]); + } + + #[test] + fn test_non_zero_balance_account_data_creation() { + let new_acc = AccountPublicData::new_with_balance([1; 32], 10); + + assert_eq!(new_acc.balance, 10); + assert_eq!(new_acc.address, [1; 32]); + } + + #[test] + fn default_account_sequencer_store() { + let seq_acc_store = SequencerAccountsStore::default(); + + assert!(seq_acc_store.accounts.is_empty()); + } + + #[test] + fn account_sequencer_store_register_acc() { + let mut seq_acc_store = SequencerAccountsStore::default(); + + seq_acc_store.register_account([1; 32]); + + assert!(seq_acc_store.contains_account(&[1; 32])); + + let acc_balance = seq_acc_store.get_account_balance(&[1; 32]).unwrap(); + + assert_eq!(acc_balance, 0); + } + + #[test] + fn account_sequencer_store_unregister_acc() { + let mut seq_acc_store = SequencerAccountsStore::default(); + + seq_acc_store.register_account([1; 32]); + + assert!(seq_acc_store.contains_account(&[1; 32])); + + seq_acc_store.unregister_account([1; 32]); + + assert!(!seq_acc_store.contains_account(&[1; 32])); + } + + #[test] + fn account_sequencer_store_with_preset_accounts_1() { + let seq_acc_store = SequencerAccountsStore::new(&[([1; 32], 12), ([2; 32], 100)]); + + assert!(seq_acc_store.contains_account(&[1; 32])); + assert!(seq_acc_store.contains_account(&[2; 32])); + + let acc_balance = seq_acc_store.get_account_balance(&[1; 32]).unwrap(); + + assert_eq!(acc_balance, 12); + + let acc_balance = seq_acc_store.get_account_balance(&[2; 32]).unwrap(); + + assert_eq!(acc_balance, 100); + } + + #[test] + fn account_sequencer_store_with_preset_accounts_2() { + let seq_acc_store = + SequencerAccountsStore::new(&[([6; 32], 120), ([7; 32], 15), ([8; 32], 10)]); + + assert!(seq_acc_store.contains_account(&[6; 32])); + assert!(seq_acc_store.contains_account(&[7; 32])); + assert!(seq_acc_store.contains_account(&[8; 32])); + + let acc_balance = seq_acc_store.get_account_balance(&[6; 32]).unwrap(); + + assert_eq!(acc_balance, 120); + + let acc_balance = seq_acc_store.get_account_balance(&[7; 32]).unwrap(); + + assert_eq!(acc_balance, 15); + + let acc_balance = seq_acc_store.get_account_balance(&[8; 32]).unwrap(); + + assert_eq!(acc_balance, 10); } } From a43a32fc551221f06a6ac281e67f24c3841aad16 Mon Sep 17 00:00:00 2001 From: Oleksandr Pravdyvyi Date: Mon, 14 Jul 2025 10:43:35 +0300 Subject: [PATCH 05/15] feat: initial accounts configuration --- Cargo.lock | 1 + sequencer_core/Cargo.toml | 1 + sequencer_core/src/config.rs | 10 +++- sequencer_core/src/lib.rs | 48 +++++++++++++++++++ sequencer_core/src/sequencer_store/mod.rs | 26 +++++++++- .../configs/debug/sequencer_config.json | 12 ++++- 6 files changed, 94 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0200d46a..8c4a3960 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4336,6 +4336,7 @@ dependencies = [ "common", "elliptic-curve", "env_logger", + "hex", "k256", "log", "mempool", diff --git a/sequencer_core/Cargo.toml b/sequencer_core/Cargo.toml index 06df7c53..14c047c5 100644 --- a/sequencer_core/Cargo.toml +++ b/sequencer_core/Cargo.toml @@ -4,6 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] +hex.workspace = true anyhow.workspace = true serde_json.workspace = true env_logger.workspace = true diff --git a/sequencer_core/src/config.rs b/sequencer_core/src/config.rs index 53b18a99..707b8b9b 100644 --- a/sequencer_core/src/config.rs +++ b/sequencer_core/src/config.rs @@ -1,6 +1,12 @@ +use serde::{Deserialize, Serialize}; use std::path::PathBuf; -use serde::{Deserialize, Serialize}; +#[derive(Debug, Serialize, Deserialize, Clone)] +pub struct AccountInitialData { + ///Hex encoded AccountAddress + pub addr: String, + pub balance: u64, +} #[derive(Debug, Clone, Serialize, Deserialize)] pub struct SequencerConfig { @@ -18,4 +24,6 @@ pub struct SequencerConfig { pub block_create_timeout_millis: u64, ///Port to listen pub port: u16, + ///List of pairs (account_address, initial_balance) + pub initial_accounts: Vec, } diff --git a/sequencer_core/src/lib.rs b/sequencer_core/src/lib.rs index 1ed603be..2ebff42b 100644 --- a/sequencer_core/src/lib.rs +++ b/sequencer_core/src/lib.rs @@ -53,6 +53,7 @@ impl SequencerCore { &config.home, config.genesis_id, config.is_genesis_random, + &config.initial_accounts, ), mempool: MemPool::::default(), chain_height: config.genesis_id, @@ -252,6 +253,8 @@ impl SequencerCore { #[cfg(test)] mod tests { + use crate::config::AccountInitialData; + use super::*; use std::path::PathBuf; @@ -274,6 +277,18 @@ mod tests { max_num_tx_in_block: 10, block_create_timeout_millis: 1000, port: 8080, + initial_accounts: vec![ + AccountInitialData { + addr: "bfd91e6703273a115ad7f099ef32f621243be69369d00ddef5d3a25117d09a8c" + .to_string(), + balance: 10, + }, + AccountInitialData { + addr: "20573479053979b98d2ad09ef31a0750f22c77709bed51c4e64946bd1e376f31" + .to_string(), + balance: 100, + }, + ], } } @@ -322,6 +337,39 @@ mod tests { assert_eq!(sequencer.chain_height, config.genesis_id); assert_eq!(sequencer.sequencer_config.max_num_tx_in_block, 10); assert_eq!(sequencer.sequencer_config.port, 8080); + + let acc1_addr: [u8; 32] = hex::decode( + "bfd91e6703273a115ad7f099ef32f621243be69369d00ddef5d3a25117d09a8c".to_string(), + ) + .unwrap() + .try_into() + .unwrap(); + let acc2_addr: [u8; 32] = hex::decode( + "20573479053979b98d2ad09ef31a0750f22c77709bed51c4e64946bd1e376f31".to_string(), + ) + .unwrap() + .try_into() + .unwrap(); + + assert!(sequencer.store.acc_store.contains_account(&acc1_addr)); + assert!(sequencer.store.acc_store.contains_account(&acc2_addr)); + + assert_eq!( + 10, + sequencer + .store + .acc_store + .get_account_balance(&acc1_addr) + .unwrap() + ); + assert_eq!( + 100, + sequencer + .store + .acc_store + .get_account_balance(&acc2_addr) + .unwrap() + ); } #[test] diff --git a/sequencer_core/src/sequencer_store/mod.rs b/sequencer_core/src/sequencer_store/mod.rs index 322c99d7..daffc917 100644 --- a/sequencer_core/src/sequencer_store/mod.rs +++ b/sequencer_core/src/sequencer_store/mod.rs @@ -9,6 +9,8 @@ use common::{ }; use rand::{rngs::OsRng, RngCore}; +use crate::config::AccountInitialData; + pub mod accounts_store; pub mod block_store; @@ -21,8 +23,28 @@ pub struct SequecerChainStore { } impl SequecerChainStore { - pub fn new_with_genesis(home_dir: &Path, genesis_id: u64, is_genesis_random: bool) -> Self { - let acc_store = SequencerAccountsStore::default(); + pub fn new_with_genesis( + home_dir: &Path, + genesis_id: u64, + is_genesis_random: bool, + initial_accounts: &[AccountInitialData], + ) -> Self { + let acc_data_decoded: Vec<([u8; 32], u64)> = initial_accounts + .iter() + .map(|acc_data| { + ( + //ToDo: Handle this error for direct error message + //Failure to produce account address is critical, so error handling is needed only for clarity + hex::decode(acc_data.addr.clone()) + .unwrap() + .try_into() + .unwrap(), + acc_data.balance, + ) + }) + .collect(); + + let acc_store = SequencerAccountsStore::new(&acc_data_decoded); let nullifier_store = HashSet::new(); let utxo_commitments_store = UTXOCommitmentsMerkleTree::new(vec![]); let pub_tx_store = PublicTransactionMerkleTree::new(vec![]); diff --git a/sequencer_runner/configs/debug/sequencer_config.json b/sequencer_runner/configs/debug/sequencer_config.json index 5eccadd4..18d1b72c 100644 --- a/sequencer_runner/configs/debug/sequencer_config.json +++ b/sequencer_runner/configs/debug/sequencer_config.json @@ -5,5 +5,15 @@ "is_genesis_random": true, "max_num_tx_in_block": 20, "block_create_timeout_millis": 10000, - "port": 3040 + "port": 3040, + "initial_accounts": [ + { + "addr": "bfd91e6703273a115ad7f099ef32f621243be69369d00ddef5d3a25117d09a8c", + "balance": 10 + }, + { + "addr": "20573479053979b98d2ad09ef31a0750f22c77709bed51c4e64946bd1e376f31", + "balance": 100 + } + ] } \ No newline at end of file From 5f4d6c0f8d05b34f97a37e59fe7e5f250866a169 Mon Sep 17 00:00:00 2001 From: Oleksandr Pravdyvyi Date: Mon, 14 Jul 2025 13:17:46 +0300 Subject: [PATCH 06/15] fix: additional test with other accounts --- sequencer_core/src/lib.rs | 72 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/sequencer_core/src/lib.rs b/sequencer_core/src/lib.rs index 2ebff42b..308b2f63 100644 --- a/sequencer_core/src/lib.rs +++ b/sequencer_core/src/lib.rs @@ -292,6 +292,26 @@ mod tests { } } + fn setup_sequencer_config_variable_initial_accounts( + initial_accounts: Vec, + ) -> SequencerConfig { + let mut rng = rand::thread_rng(); + let random_u8: u8 = rng.gen(); + + let path_str = format!("/tmp/sequencer_{:?}", random_u8); + + SequencerConfig { + home: PathBuf::from(path_str), + override_rust_log: Some("info".to_string()), + genesis_id: 1, + is_genesis_random: false, + max_num_tx_in_block: 10, + block_create_timeout_millis: 1000, + port: 8080, + initial_accounts, + } + } + fn create_dummy_transaction( hash: TreeHashType, nullifier_created_hashes: Vec<[u8; 32]>, @@ -372,6 +392,58 @@ mod tests { ); } + #[test] + fn test_start_different_intial_accounts() { + let initial_accounts = vec![ + AccountInitialData { + addr: "bfd91e6703273a115ad7f099ef32f621243be69369d00ddef5d3a25117ffffff" + .to_string(), + balance: 1000, + }, + AccountInitialData { + addr: "bfd91e6703273a115ad7f099ef32f621243be69369d00ddef5d3a25117ffffff" + .to_string(), + balance: 1000, + }, + ]; + + let config = setup_sequencer_config_variable_initial_accounts(initial_accounts); + let sequencer = SequencerCore::start_from_config(config.clone()); + + let acc1_addr: [u8; 32] = hex::decode( + "bfd91e6703273a115ad7f099ef32f621243be69369d00ddef5d3a25117ffffff".to_string(), + ) + .unwrap() + .try_into() + .unwrap(); + let acc2_addr: [u8; 32] = hex::decode( + "bfd91e6703273a115ad7f099ef32f621243be69369d00ddef5d3a25117ffffff".to_string(), + ) + .unwrap() + .try_into() + .unwrap(); + + assert!(sequencer.store.acc_store.contains_account(&acc1_addr)); + assert!(sequencer.store.acc_store.contains_account(&acc2_addr)); + + assert_eq!( + 1000, + sequencer + .store + .acc_store + .get_account_balance(&acc1_addr) + .unwrap() + ); + assert_eq!( + 1000, + sequencer + .store + .acc_store + .get_account_balance(&acc2_addr) + .unwrap() + ); + } + #[test] fn test_get_tree_roots() { let config = setup_sequencer_config(); From a24a40f4bc597bdb161c8e69575d92513c3220bb Mon Sep 17 00:00:00 2001 From: Oleksandr Pravdyvyi Date: Mon, 14 Jul 2025 13:25:40 +0300 Subject: [PATCH 07/15] fix: docs added --- sequencer_core/src/config.rs | 3 ++- sequencer_core/src/sequencer_store/accounts_store.rs | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/sequencer_core/src/config.rs b/sequencer_core/src/config.rs index 707b8b9b..374a9406 100644 --- a/sequencer_core/src/config.rs +++ b/sequencer_core/src/config.rs @@ -2,8 +2,9 @@ use serde::{Deserialize, Serialize}; use std::path::PathBuf; #[derive(Debug, Serialize, Deserialize, Clone)] +///Helperstruct for account serialization pub struct AccountInitialData { - ///Hex encoded AccountAddress + ///Hex encoded `AccountAddress` pub addr: String, pub balance: u64, } diff --git a/sequencer_core/src/sequencer_store/accounts_store.rs b/sequencer_core/src/sequencer_store/accounts_store.rs index bc65565a..49df8ea8 100644 --- a/sequencer_core/src/sequencer_store/accounts_store.rs +++ b/sequencer_core/src/sequencer_store/accounts_store.rs @@ -40,19 +40,27 @@ impl SequencerAccountsStore { Self { accounts } } + ///Register new account in accounts store + /// + ///Starts with zero public balance pub fn register_account(&mut self, account_addr: AccountAddress) { self.accounts .insert(account_addr, AccountPublicData::new(account_addr)); } + ///Check, if `account_addr` present in account store pub fn contains_account(&self, account_addr: &AccountAddress) -> bool { self.accounts.contains_key(account_addr) } + ///Check `account_addr` balance, + /// + ///returns `None`, if account address not found pub fn get_account_balance(&self, account_addr: &AccountAddress) -> Option { self.accounts.get(account_addr).map(|acc| acc.balance) } + ///Remove account from storage pub fn unregister_account(&mut self, account_addr: AccountAddress) { self.accounts.remove(&account_addr); } From 00532b564b23afd4d1134025fece8cbf6bcb0f0e Mon Sep 17 00:00:00 2001 From: Oleksandr Pravdyvyi Date: Thu, 17 Jul 2025 08:09:27 +0300 Subject: [PATCH 08/15] fix: comments fix 1 --- sequencer_core/src/lib.rs | 54 ++++++++----------- .../src/sequencer_store/accounts_store.rs | 17 +++++- 2 files changed, 39 insertions(+), 32 deletions(-) diff --git a/sequencer_core/src/lib.rs b/sequencer_core/src/lib.rs index 308b2f63..5ec58ca0 100644 --- a/sequencer_core/src/lib.rs +++ b/sequencer_core/src/lib.rs @@ -263,35 +263,6 @@ mod tests { use secp256k1_zkp::Tweak; use transaction_mempool::TransactionMempool; - fn setup_sequencer_config() -> SequencerConfig { - let mut rng = rand::thread_rng(); - let random_u8: u8 = rng.gen(); - - let path_str = format!("/tmp/sequencer_{:?}", random_u8); - - SequencerConfig { - home: PathBuf::from(path_str), - override_rust_log: Some("info".to_string()), - genesis_id: 1, - is_genesis_random: false, - max_num_tx_in_block: 10, - block_create_timeout_millis: 1000, - port: 8080, - initial_accounts: vec![ - AccountInitialData { - addr: "bfd91e6703273a115ad7f099ef32f621243be69369d00ddef5d3a25117d09a8c" - .to_string(), - balance: 10, - }, - AccountInitialData { - addr: "20573479053979b98d2ad09ef31a0750f22c77709bed51c4e64946bd1e376f31" - .to_string(), - balance: 100, - }, - ], - } - } - fn setup_sequencer_config_variable_initial_accounts( initial_accounts: Vec, ) -> SequencerConfig { @@ -312,6 +283,23 @@ mod tests { } } + fn setup_sequencer_config() -> SequencerConfig { + let initial_accounts = vec![ + AccountInitialData { + addr: "bfd91e6703273a115ad7f099ef32f621243be69369d00ddef5d3a25117d09a8c" + .to_string(), + balance: 10, + }, + AccountInitialData { + addr: "20573479053979b98d2ad09ef31a0750f22c77709bed51c4e64946bd1e376f31" + .to_string(), + balance: 100, + }, + ]; + + setup_sequencer_config_variable_initial_accounts(initial_accounts) + } + fn create_dummy_transaction( hash: TreeHashType, nullifier_created_hashes: Vec<[u8; 32]>, @@ -401,12 +389,14 @@ mod tests { balance: 1000, }, AccountInitialData { - addr: "bfd91e6703273a115ad7f099ef32f621243be69369d00ddef5d3a25117ffffff" + addr: "20573479053979b98d2ad09ef31a0750f22c77709bed51c4e64946bd1effffff" .to_string(), balance: 1000, }, ]; + let intial_accounts_len = initial_accounts.len(); + let config = setup_sequencer_config_variable_initial_accounts(initial_accounts); let sequencer = SequencerCore::start_from_config(config.clone()); @@ -417,7 +407,7 @@ mod tests { .try_into() .unwrap(); let acc2_addr: [u8; 32] = hex::decode( - "bfd91e6703273a115ad7f099ef32f621243be69369d00ddef5d3a25117ffffff".to_string(), + "20573479053979b98d2ad09ef31a0750f22c77709bed51c4e64946bd1effffff".to_string(), ) .unwrap() .try_into() @@ -426,6 +416,8 @@ mod tests { assert!(sequencer.store.acc_store.contains_account(&acc1_addr)); assert!(sequencer.store.acc_store.contains_account(&acc2_addr)); + assert_eq!(sequencer.store.acc_store.len(), intial_accounts_len); + assert_eq!( 1000, sequencer diff --git a/sequencer_core/src/sequencer_store/accounts_store.rs b/sequencer_core/src/sequencer_store/accounts_store.rs index 49df8ea8..2f493197 100644 --- a/sequencer_core/src/sequencer_store/accounts_store.rs +++ b/sequencer_core/src/sequencer_store/accounts_store.rs @@ -16,7 +16,7 @@ impl AccountPublicData { } } - pub fn new_with_balance(address: AccountAddress, balance: u64) -> Self { + fn new_with_balance(address: AccountAddress, balance: u64) -> Self { Self { balance, address } } } @@ -64,6 +64,11 @@ impl SequencerAccountsStore { pub fn unregister_account(&mut self, account_addr: AccountAddress) { self.accounts.remove(&account_addr); } + + ///Number of accounts present in store + pub fn len(&self) -> usize { + self.accounts.len() + } } impl Default for SequencerAccountsStore { @@ -162,4 +167,14 @@ mod tests { assert_eq!(acc_balance, 10); } + + #[test] + fn account_sequencer_store_fetch_unknown_account() { + let seq_acc_store = + SequencerAccountsStore::new(&[([6; 32], 120), ([7; 32], 15), ([8; 32], 10)]); + + let acc_balance = seq_acc_store.get_account_balance(&[9; 32]); + + assert!(acc_balance.is_none()); + } } From 8b6769d7e8739459672f29795f0bf2079204ac37 Mon Sep 17 00:00:00 2001 From: Oleksandr Pravdyvyi Date: Thu, 17 Jul 2025 08:22:04 +0300 Subject: [PATCH 09/15] fix: comments fix 2 --- .../src/sequencer_store/accounts_store.rs | 42 +++++++++++++++++-- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/sequencer_core/src/sequencer_store/accounts_store.rs b/sequencer_core/src/sequencer_store/accounts_store.rs index 2f493197..853247fd 100644 --- a/sequencer_core/src/sequencer_store/accounts_store.rs +++ b/sequencer_core/src/sequencer_store/accounts_store.rs @@ -1,4 +1,5 @@ use accounts::account_core::AccountAddress; +use anyhow::Result; use serde::{Deserialize, Serialize}; use std::collections::HashMap; @@ -61,8 +62,23 @@ impl SequencerAccountsStore { } ///Remove account from storage - pub fn unregister_account(&mut self, account_addr: AccountAddress) { - self.accounts.remove(&account_addr); + /// + /// Fails, if `balance` is != 0 + /// + /// Returns `Option` which is `None` if `account_addr` vere not present in store + pub fn unregister_account( + &mut self, + account_addr: AccountAddress, + ) -> Result> { + if let Some(account_balance) = self.get_account_balance(&account_addr) { + if account_balance == 0 { + Ok(self.accounts.remove(&account_addr).map(|data| data.address)) + } else { + anyhow::bail!("Chain consistency violation: It is forbidden to remove account with nonzero balance"); + } + } else { + Ok(None) + } } ///Number of accounts present in store @@ -117,6 +133,26 @@ mod tests { assert_eq!(acc_balance, 0); } + #[test] + fn account_sequencer_store_unregister_acc_not_present() { + let mut seq_acc_store = SequencerAccountsStore::default(); + + seq_acc_store.register_account([1; 32]); + + let rem_res = seq_acc_store.unregister_account([2; 32]).unwrap(); + + assert!(rem_res.is_none()); + } + + #[test] + fn account_sequencer_store_unregister_acc_not_zero_balance() { + let mut seq_acc_store = SequencerAccountsStore::new(&[([1; 32], 12), ([2; 32], 100)]); + + let rem_res = seq_acc_store.unregister_account([1; 32]); + + assert!(rem_res.is_err()); + } + #[test] fn account_sequencer_store_unregister_acc() { let mut seq_acc_store = SequencerAccountsStore::default(); @@ -125,7 +161,7 @@ mod tests { assert!(seq_acc_store.contains_account(&[1; 32])); - seq_acc_store.unregister_account([1; 32]); + seq_acc_store.unregister_account([1; 32]).unwrap().unwrap(); assert!(!seq_acc_store.contains_account(&[1; 32])); } From 0211ff78e1c222761e50417592706810544d2f42 Mon Sep 17 00:00:00 2001 From: Pravdyvy <46261001+Pravdyvy@users.noreply.github.com> Date: Thu, 17 Jul 2025 08:56:11 +0300 Subject: [PATCH 10/15] Update Cargo.toml --- common/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/Cargo.toml b/common/Cargo.toml index b1988ad6..bc929e37 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.2" } +risc0-zkvm = { git = "https://github.com/risc0/risc0.git", branch = "release-2.3" } rs_merkle.workspace = true sha2.workspace = true From 14da838637893da77900845e8cbea46466da5536 Mon Sep 17 00:00:00 2001 From: Pravdyvy <46261001+Pravdyvy@users.noreply.github.com> Date: Thu, 17 Jul 2025 09:01:26 +0300 Subject: [PATCH 11/15] Update Cargo.toml --- node_core/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node_core/Cargo.toml b/node_core/Cargo.toml index c85e0e0c..969e4ec5 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.2" } +risc0-zkvm = { git = "https://github.com/risc0/risc0.git", branch = "release-2.3" } hex.workspace = true actix-rt.workspace = true From d1a7b03b554bcd0c45798397dced46b298351a61 Mon Sep 17 00:00:00 2001 From: Pravdyvy <46261001+Pravdyvy@users.noreply.github.com> Date: Thu, 17 Jul 2025 09:02:27 +0300 Subject: [PATCH 12/15] Update Cargo.toml --- sc_core/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sc_core/Cargo.toml b/sc_core/Cargo.toml index 3d6a2135..bc6bade3 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.2" } +risc0-zkvm = { git = "https://github.com/risc0/risc0.git", branch = "release-2.3" } [dependencies.accounts] path = "../accounts" From 085d7b4c95b093160c51df15b057625f8a96fb74 Mon Sep 17 00:00:00 2001 From: Pravdyvy <46261001+Pravdyvy@users.noreply.github.com> Date: Thu, 17 Jul 2025 09:04:00 +0300 Subject: [PATCH 13/15] Update Cargo.toml --- zkvm/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zkvm/Cargo.toml b/zkvm/Cargo.toml index a0701cb7..d87d1428 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.2" } +risc0-zkvm = { git = "https://github.com/risc0/risc0.git", branch = "release-2.3" } test-methods = { path = "test_methods" } [dependencies.accounts] From 9954f8e0da8afe412ea33576e98ae44b752dff3b Mon Sep 17 00:00:00 2001 From: Pravdyvy <46261001+Pravdyvy@users.noreply.github.com> Date: Thu, 17 Jul 2025 09:04:24 +0300 Subject: [PATCH 14/15] Update Cargo.toml --- zkvm/test_methods/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zkvm/test_methods/Cargo.toml b/zkvm/test_methods/Cargo.toml index eb771c52..48f27b8c 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.2" } +risc0-build = { git = "https://github.com/risc0/risc0.git", branch = "release-2.3" } [package.metadata.risc0] methods = ["guest"] From de8462803d99739ff678e8436350d2df06342d5f Mon Sep 17 00:00:00 2001 From: Oleksandr Pravdyvyi Date: Thu, 17 Jul 2025 11:51:46 +0300 Subject: [PATCH 15/15] fix: api rate limit refetch --- Cargo.lock | 40 ++++++++++++++++++------------------ sequencer_core/src/config.rs | 2 ++ 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8c4a3960..10ab1e97 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.2#eff3c74bf9992401c2c68bea95eb6c93b27999ec" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.3#c6297fc2075cb66aadb733ee677223b5a7f8c85a" dependencies = [ "duplicate", "maybe-async", @@ -3716,7 +3716,7 @@ checksum = "3df6368f71f205ff9c33c076d170dd56ebf68e8161c733c0caa07a7a5509ed53" [[package]] name = "risc0-binfmt" version = "2.0.2" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.2#eff3c74bf9992401c2c68bea95eb6c93b27999ec" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.3#c6297fc2075cb66aadb733ee677223b5a7f8c85a" dependencies = [ "anyhow", "borsh", @@ -3733,8 +3733,8 @@ dependencies = [ [[package]] name = "risc0-build" -version = "2.2.0" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.2#eff3c74bf9992401c2c68bea95eb6c93b27999ec" +version = "2.3.0" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.3#c6297fc2075cb66aadb733ee677223b5a7f8c85a" 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.2#eff3c74bf9992401c2c68bea95eb6c93b27999ec" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.3#c6297fc2075cb66aadb733ee677223b5a7f8c85a" dependencies = [ "cc", "directories", @@ -3771,7 +3771,7 @@ dependencies = [ [[package]] name = "risc0-circuit-keccak" version = "3.0.0" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.2#eff3c74bf9992401c2c68bea95eb6c93b27999ec" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.3#c6297fc2075cb66aadb733ee677223b5a7f8c85a" dependencies = [ "anyhow", "bytemuck", @@ -3792,7 +3792,7 @@ dependencies = [ [[package]] name = "risc0-circuit-keccak-sys" version = "3.0.0" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.2#eff3c74bf9992401c2c68bea95eb6c93b27999ec" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.3#c6297fc2075cb66aadb733ee677223b5a7f8c85a" dependencies = [ "cc", "cust", @@ -3807,7 +3807,7 @@ dependencies = [ [[package]] name = "risc0-circuit-recursion" version = "3.0.0" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.2#eff3c74bf9992401c2c68bea95eb6c93b27999ec" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.3#c6297fc2075cb66aadb733ee677223b5a7f8c85a" dependencies = [ "anyhow", "bytemuck", @@ -3832,7 +3832,7 @@ dependencies = [ [[package]] name = "risc0-circuit-recursion-sys" version = "3.0.0" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.2#eff3c74bf9992401c2c68bea95eb6c93b27999ec" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.3#c6297fc2075cb66aadb733ee677223b5a7f8c85a" dependencies = [ "glob", "risc0-build-kernel", @@ -3844,7 +3844,7 @@ dependencies = [ [[package]] name = "risc0-circuit-rv32im" version = "3.0.0" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.2#eff3c74bf9992401c2c68bea95eb6c93b27999ec" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.3#c6297fc2075cb66aadb733ee677223b5a7f8c85a" dependencies = [ "anyhow", "auto_ops", @@ -3875,7 +3875,7 @@ dependencies = [ [[package]] name = "risc0-circuit-rv32im-sys" version = "3.0.0" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.2#eff3c74bf9992401c2c68bea95eb6c93b27999ec" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.3#c6297fc2075cb66aadb733ee677223b5a7f8c85a" 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.2#eff3c74bf9992401c2c68bea95eb6c93b27999ec" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.3#c6297fc2075cb66aadb733ee677223b5a7f8c85a" dependencies = [ "bytemuck", "bytemuck_derive", @@ -3902,7 +3902,7 @@ dependencies = [ [[package]] name = "risc0-groth16" version = "2.0.2" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.2#eff3c74bf9992401c2c68bea95eb6c93b27999ec" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.3#c6297fc2075cb66aadb733ee677223b5a7f8c85a" 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.2#eff3c74bf9992401c2c68bea95eb6c93b27999ec" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.3#c6297fc2075cb66aadb733ee677223b5a7f8c85a" 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.2#eff3c74bf9992401c2c68bea95eb6c93b27999ec" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.3#c6297fc2075cb66aadb733ee677223b5a7f8c85a" dependencies = [ "include_bytes_aligned", "no_std_strings", @@ -3946,7 +3946,7 @@ dependencies = [ [[package]] name = "risc0-zkp" version = "2.0.2" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.2#eff3c74bf9992401c2c68bea95eb6c93b27999ec" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.3#c6297fc2075cb66aadb733ee677223b5a7f8c85a" dependencies = [ "anyhow", "blake2", @@ -3976,8 +3976,8 @@ dependencies = [ [[package]] name = "risc0-zkvm" -version = "2.2.0" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.2#eff3c74bf9992401c2c68bea95eb6c93b27999ec" +version = "2.3.0" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.3#c6297fc2075cb66aadb733ee677223b5a7f8c85a" dependencies = [ "addr2line 0.22.0", "anyhow", @@ -4023,7 +4023,7 @@ dependencies = [ [[package]] name = "risc0-zkvm-platform" version = "2.0.3" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.2#eff3c74bf9992401c2c68bea95eb6c93b27999ec" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.3#c6297fc2075cb66aadb733ee677223b5a7f8c85a" 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.2#eff3c74bf9992401c2c68bea95eb6c93b27999ec" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.3#c6297fc2075cb66aadb733ee677223b5a7f8c85a" dependencies = [ "semver", "serde", diff --git a/sequencer_core/src/config.rs b/sequencer_core/src/config.rs index 374a9406..95ed7bca 100644 --- a/sequencer_core/src/config.rs +++ b/sequencer_core/src/config.rs @@ -1,6 +1,8 @@ use serde::{Deserialize, Serialize}; use std::path::PathBuf; +// + #[derive(Debug, Serialize, Deserialize, Clone)] ///Helperstruct for account serialization pub struct AccountInitialData {