diff --git a/Cargo.lock b/Cargo.lock index 9bca0c7..c3e27f2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1141,6 +1141,12 @@ version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" +[[package]] +name = "crunchy" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" + [[package]] name = "crypto-bigint" version = "0.5.5" @@ -4371,6 +4377,7 @@ dependencies = [ "serde", "serde_json", "storage", + "tiny-keccak", ] [[package]] @@ -4859,6 +4866,15 @@ dependencies = [ "time-core", ] +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + [[package]] name = "tinystr" version = "0.8.1" diff --git a/Cargo.toml b/Cargo.toml index f2bcab8..daaeeaf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,6 +45,7 @@ tempfile = "3.14.0" light-poseidon = "0.3.0" ark-bn254 = "0.5.0" ark-ff = "0.5.0" +tiny-keccak = { version = "2.0.2", features = ["keccak"]} rocksdb = { version = "0.21.0", default-features = false, features = [ "snappy", diff --git a/common/src/transaction.rs b/common/src/transaction.rs index 26dc670..78e1930 100644 --- a/common/src/transaction.rs +++ b/common/src/transaction.rs @@ -235,8 +235,8 @@ pub type SignaturePrivateKey = SigningKey; #[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)] pub struct Transaction { body: TransactionBody, - signature: TransactionSignature, - public_key: VerifyingKey, + pub signature: TransactionSignature, + pub public_key: VerifyingKey, } impl Transaction { diff --git a/sequencer_core/Cargo.toml b/sequencer_core/Cargo.toml index 14c047c..0c676e0 100644 --- a/sequencer_core/Cargo.toml +++ b/sequencer_core/Cargo.toml @@ -13,6 +13,7 @@ serde.workspace = true rand.workspace = true elliptic-curve.workspace = true k256.workspace = true +tiny-keccak.workspace = true [dependencies.storage] path = "../storage" diff --git a/sequencer_core/src/config.rs b/sequencer_core/src/config.rs index d7937d5..aa40351 100644 --- a/sequencer_core/src/config.rs +++ b/sequencer_core/src/config.rs @@ -1,15 +1,8 @@ +use accounts::account_core::AccountForSerialization; use serde::{Deserialize, Serialize}; use std::path::PathBuf; -// - -#[derive(Debug, Serialize, Deserialize, Clone)] -///Helperstruct for account serialization -pub struct AccountInitialData { - pub balance: u64, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Clone, Serialize, Deserialize)] pub struct SequencerConfig { ///Home dir of sequencer storage pub home: PathBuf, @@ -26,5 +19,5 @@ pub struct SequencerConfig { ///Port to listen pub port: u16, ///List of initial accounts data - pub initial_accounts: Vec, + pub initial_accounts: Vec, } diff --git a/sequencer_core/src/lib.rs b/sequencer_core/src/lib.rs index d22841a..d3a108d 100644 --- a/sequencer_core/src/lib.rs +++ b/sequencer_core/src/lib.rs @@ -15,6 +15,7 @@ use mempool::MemPool; use mempool_transaction::MempoolTransaction; use sequencer_store::SequecerChainStore; use serde::{Deserialize, Serialize}; +use tiny_keccak::{Hasher, Keccak}; pub mod config; pub mod mempool_transaction; @@ -38,6 +39,7 @@ pub enum TransactionMalformationErrorKind { ChainStateFurtherThanTransactionState { tx: TreeHashType }, FailedToInsert { tx: TreeHashType, details: String }, InvalidSignature, + IncorrectSender, BalanceMismatch { tx: TreeHashType }, FailedToDecode { tx: TreeHashType }, } @@ -140,6 +142,20 @@ impl SequencerCore { _ => {} }; + //Correct sender check + if let Ok(native_transfer_action) = + serde_json::from_slice::(execution_input) + { + let mut output = [0; 32]; + let mut keccak_hasher = Keccak::v256(); + keccak_hasher.update(&tx.transaction().signature.to_bytes()); + keccak_hasher.finalize(&mut output); + + if native_transfer_action.from != output { + return Err(TransactionMalformationErrorKind::IncorrectSender); + } + } + //Tree checks let tx_tree_check = self.store.pub_tx_store.get_tx(tx_hash).is_some(); let nullifier_tree_check = nullifier_created_hashes.iter().any(|nullifier_hash| { @@ -303,18 +319,17 @@ impl SequencerCore { #[cfg(test)] mod tests { - use crate::config::AccountInitialData; - use super::*; use std::path::PathBuf; + use accounts::account_core::AccountForSerialization; use common::transaction::{SignaturePrivateKey, Transaction, TransactionBody, TxKind}; use mempool_transaction::MempoolTransaction; use rand::Rng; use secp256k1_zkp::Tweak; fn setup_sequencer_config_variable_initial_accounts( - initial_accounts: Vec, + initial_accounts: Vec, ) -> SequencerConfig { let mut rng = rand::thread_rng(); let random_u8: u8 = rng.gen(); @@ -334,10 +349,243 @@ mod tests { } fn setup_sequencer_config() -> SequencerConfig { - let initial_accounts = vec![ - AccountInitialData { balance: 10 }, - AccountInitialData { balance: 100 }, - ]; + let initial_acc1 = serde_json::from_str(r#"{ + "address": [ + 244, + 55, + 238, + 205, + 74, + 115, + 179, + 192, + 65, + 186, + 166, + 169, + 221, + 45, + 6, + 57, + 200, + 65, + 195, + 70, + 118, + 252, + 206, + 100, + 215, + 250, + 72, + 230, + 19, + 71, + 217, + 249 + ], + "balance": 10, + "key_holder": { + "address": [ + 244, + 55, + 238, + 205, + 74, + 115, + 179, + 192, + 65, + 186, + 166, + 169, + 221, + 45, + 6, + 57, + 200, + 65, + 195, + 70, + 118, + 252, + 206, + 100, + 215, + 250, + 72, + 230, + 19, + 71, + 217, + 249 + ], + "nullifer_public_key": "03A340BECA9FAAB444CED0140681D72EA1318B5C611704FEE017DA9836B17DB718", + "pub_account_signing_key": [ + 244, + 88, + 134, + 61, + 35, + 209, + 229, + 101, + 85, + 35, + 140, + 140, + 192, + 226, + 83, + 83, + 190, + 189, + 110, + 8, + 89, + 127, + 147, + 142, + 157, + 204, + 51, + 109, + 189, + 92, + 144, + 68 + ], + "top_secret_key_holder": { + "secret_spending_key": "7BC46784DB1BC67825D8F029436846712BFDF9B5D79EA3AB11D39A52B9B229D4" + }, + "utxo_secret_key_holder": { + "nullifier_secret_key": "BB54A8D3C9C51B82C431082D1845A74677B0EF829A11B517E1D9885DE3139506", + "viewing_secret_key": "AD923E92F6A5683E30140CEAB2702AFB665330C1EE4EFA70FAF29767B6B52BAF" + }, + "viewing_public_key": "0361220C5D277E7A1709340FD31A52600C1432B9C45B9BCF88A43581D58824A8B6" + }, + "utxos": {} + }"#).unwrap(); + + let initial_acc2 = serde_json::from_str(r#"{ + "address": [ + 72, + 169, + 70, + 237, + 1, + 96, + 35, + 157, + 25, + 15, + 83, + 18, + 52, + 206, + 202, + 63, + 48, + 59, + 173, + 76, + 78, + 7, + 254, + 229, + 28, + 45, + 194, + 79, + 6, + 89, + 58, + 85 + ], + "balance": 100, + "key_holder": { + "address": [ + 72, + 169, + 70, + 237, + 1, + 96, + 35, + 157, + 25, + 15, + 83, + 18, + 52, + 206, + 202, + 63, + 48, + 59, + 173, + 76, + 78, + 7, + 254, + 229, + 28, + 45, + 194, + 79, + 6, + 89, + 58, + 85 + ], + "nullifer_public_key": "02172F50274DE67C4087C344F5D58E11DF761D90285B095060E0994FAA6BCDE271", + "pub_account_signing_key": [ + 136, + 105, + 9, + 53, + 180, + 145, + 64, + 5, + 235, + 174, + 62, + 211, + 206, + 116, + 185, + 24, + 214, + 62, + 244, + 64, + 224, + 59, + 120, + 150, + 30, + 249, + 160, + 46, + 189, + 254, + 47, + 244 + ], + "top_secret_key_holder": { + "secret_spending_key": "80A186737C8D38B4288A03F0F589957D9C040D79C19F3E0CC4BA80F8494E5179" + }, + "utxo_secret_key_holder": { + "nullifier_secret_key": "746928E63F0984F6F4818933493CE9C067562D9CB932FDC06D82C86CDF6D7122", + "viewing_secret_key": "89176CF4BC9E673807643FD52110EF99D4894335AFB10D881AC0B5041FE1FCB7" + }, + "viewing_public_key": "026072A8F83FEC3472E30CDD4767683F30B91661D25B1040AD9A5FC2E01D659F99" + }, + "utxos": {} + }"#).unwrap(); + + let initial_accounts = vec![initial_acc1, initial_acc2]; setup_sequencer_config_variable_initial_accounts(initial_accounts) } @@ -389,8 +637,8 @@ mod tests { assert_eq!(sequencer.sequencer_config.max_num_tx_in_block, 10); assert_eq!(sequencer.sequencer_config.port, 8080); - let acc1_addr = sequencer.store.testnet_initial_accounts_full_data[0].address; - let acc2_addr = sequencer.store.testnet_initial_accounts_full_data[1].address; + let acc1_addr = config.initial_accounts[0].address; + let acc2_addr = config.initial_accounts[1].address; assert!(sequencer.store.acc_store.contains_account(&acc1_addr)); assert!(sequencer.store.acc_store.contains_account(&acc2_addr)); @@ -406,19 +654,252 @@ mod tests { } #[test] - fn test_start_different_intial_accounts() { - let initial_accounts = vec![ - AccountInitialData { balance: 1000 }, - AccountInitialData { balance: 1000 }, - ]; + fn test_start_different_intial_accounts_balances() { + let initial_acc1 = serde_json::from_str(r#"{ + "address": [ + 244, + 55, + 238, + 205, + 74, + 115, + 179, + 192, + 65, + 186, + 166, + 169, + 221, + 45, + 6, + 57, + 200, + 65, + 195, + 70, + 118, + 252, + 206, + 100, + 215, + 250, + 72, + 230, + 19, + 71, + 217, + 249 + ], + "balance": 1000, + "key_holder": { + "address": [ + 244, + 55, + 238, + 205, + 74, + 115, + 179, + 192, + 65, + 186, + 166, + 169, + 221, + 45, + 6, + 57, + 200, + 65, + 195, + 70, + 118, + 252, + 206, + 100, + 215, + 250, + 72, + 230, + 19, + 71, + 217, + 249 + ], + "nullifer_public_key": "03A340BECA9FAAB444CED0140681D72EA1318B5C611704FEE017DA9836B17DB718", + "pub_account_signing_key": [ + 244, + 88, + 134, + 61, + 35, + 209, + 229, + 101, + 85, + 35, + 140, + 140, + 192, + 226, + 83, + 83, + 190, + 189, + 110, + 8, + 89, + 127, + 147, + 142, + 157, + 204, + 51, + 109, + 189, + 92, + 144, + 68 + ], + "top_secret_key_holder": { + "secret_spending_key": "7BC46784DB1BC67825D8F029436846712BFDF9B5D79EA3AB11D39A52B9B229D4" + }, + "utxo_secret_key_holder": { + "nullifier_secret_key": "BB54A8D3C9C51B82C431082D1845A74677B0EF829A11B517E1D9885DE3139506", + "viewing_secret_key": "AD923E92F6A5683E30140CEAB2702AFB665330C1EE4EFA70FAF29767B6B52BAF" + }, + "viewing_public_key": "0361220C5D277E7A1709340FD31A52600C1432B9C45B9BCF88A43581D58824A8B6" + }, + "utxos": {} + }"#).unwrap(); + + let initial_acc2 = serde_json::from_str(r#"{ + "address": [ + 72, + 169, + 70, + 237, + 1, + 96, + 35, + 157, + 25, + 15, + 83, + 18, + 52, + 206, + 202, + 63, + 48, + 59, + 173, + 76, + 78, + 7, + 254, + 229, + 28, + 45, + 194, + 79, + 6, + 89, + 58, + 85 + ], + "balance": 1000, + "key_holder": { + "address": [ + 72, + 169, + 70, + 237, + 1, + 96, + 35, + 157, + 25, + 15, + 83, + 18, + 52, + 206, + 202, + 63, + 48, + 59, + 173, + 76, + 78, + 7, + 254, + 229, + 28, + 45, + 194, + 79, + 6, + 89, + 58, + 85 + ], + "nullifer_public_key": "02172F50274DE67C4087C344F5D58E11DF761D90285B095060E0994FAA6BCDE271", + "pub_account_signing_key": [ + 136, + 105, + 9, + 53, + 180, + 145, + 64, + 5, + 235, + 174, + 62, + 211, + 206, + 116, + 185, + 24, + 214, + 62, + 244, + 64, + 224, + 59, + 120, + 150, + 30, + 249, + 160, + 46, + 189, + 254, + 47, + 244 + ], + "top_secret_key_holder": { + "secret_spending_key": "80A186737C8D38B4288A03F0F589957D9C040D79C19F3E0CC4BA80F8494E5179" + }, + "utxo_secret_key_holder": { + "nullifier_secret_key": "746928E63F0984F6F4818933493CE9C067562D9CB932FDC06D82C86CDF6D7122", + "viewing_secret_key": "89176CF4BC9E673807643FD52110EF99D4894335AFB10D881AC0B5041FE1FCB7" + }, + "viewing_public_key": "026072A8F83FEC3472E30CDD4767683F30B91661D25B1040AD9A5FC2E01D659F99" + }, + "utxos": {} + }"#).unwrap(); + + let initial_accounts = vec![initial_acc1, initial_acc2]; 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()); - let acc1_addr = sequencer.store.testnet_initial_accounts_full_data[0].address; - let acc2_addr = sequencer.store.testnet_initial_accounts_full_data[1].address; + let acc1_addr = config.initial_accounts[0].address; + let acc2_addr = config.initial_accounts[1].address; assert!(sequencer.store.acc_store.contains_account(&acc1_addr)); assert!(sequencer.store.acc_store.contains_account(&acc2_addr)); diff --git a/sequencer_core/src/sequencer_store/accounts_store.rs b/sequencer_core/src/sequencer_store/accounts_store.rs index ae27302..3944d03 100644 --- a/sequencer_core/src/sequencer_store/accounts_store.rs +++ b/sequencer_core/src/sequencer_store/accounts_store.rs @@ -1,4 +1,4 @@ -use accounts::account_core::{Account, AccountAddress}; +use accounts::account_core::AccountAddress; use anyhow::Result; use serde::{Deserialize, Serialize}; use std::collections::HashMap; @@ -28,13 +28,13 @@ pub struct SequencerAccountsStore { } impl SequencerAccountsStore { - pub fn new(initial_accounts: &[Account]) -> Self { + pub fn new(initial_accounts: &[(AccountAddress, u64)]) -> Self { let mut accounts = HashMap::new(); - for account in initial_accounts { + for (account_addr, balance) in initial_accounts { accounts.insert( - account.address, - AccountPublicData::new_with_balance(account.address, account.balance), + *account_addr, + AccountPublicData::new_with_balance(*account_addr, *balance), ); } @@ -167,14 +167,9 @@ mod tests { #[test] fn account_sequencer_store_unregister_acc_not_zero_balance() { - let acc1 = Account::new_with_balance(12); - let acc2 = Account::new_with_balance(100); + let mut seq_acc_store = SequencerAccountsStore::new(&[([1; 32], 12), ([2; 32], 100)]); - let acc1_addr = acc1.address; - - let mut seq_acc_store = SequencerAccountsStore::new(&[acc1, acc2]); - - let rem_res = seq_acc_store.unregister_account(acc1_addr); + let rem_res = seq_acc_store.unregister_account([1; 32]); assert!(rem_res.is_err()); } @@ -194,62 +189,46 @@ mod tests { #[test] fn account_sequencer_store_with_preset_accounts_1() { - let acc1 = Account::new_with_balance(12); - let acc2 = Account::new_with_balance(100); + let seq_acc_store = SequencerAccountsStore::new(&[([1; 32], 12), ([2; 32], 100)]); - let acc1_addr = acc1.address; - let acc2_addr = acc2.address; + assert!(seq_acc_store.contains_account(&[1; 32])); + assert!(seq_acc_store.contains_account(&[2; 32])); - let seq_acc_store = SequencerAccountsStore::new(&[acc1, acc2]); - - assert!(seq_acc_store.contains_account(&acc1_addr)); - assert!(seq_acc_store.contains_account(&acc2_addr)); - - let acc_balance = seq_acc_store.get_account_balance(&acc1_addr); + let acc_balance = seq_acc_store.get_account_balance(&[1; 32]); assert_eq!(acc_balance, 12); - let acc_balance = seq_acc_store.get_account_balance(&acc2_addr); + let acc_balance = seq_acc_store.get_account_balance(&[2; 32]); assert_eq!(acc_balance, 100); } #[test] fn account_sequencer_store_with_preset_accounts_2() { - let acc1 = Account::new_with_balance(120); - let acc2 = Account::new_with_balance(15); - let acc3 = Account::new_with_balance(10); + let seq_acc_store = + SequencerAccountsStore::new(&[([6; 32], 120), ([7; 32], 15), ([8; 32], 10)]); - let acc1_addr = acc1.address; - let acc2_addr = acc2.address; - let acc3_addr = acc3.address; + 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 seq_acc_store = SequencerAccountsStore::new(&[acc1, acc2, acc3]); - - assert!(seq_acc_store.contains_account(&acc1_addr)); - assert!(seq_acc_store.contains_account(&acc2_addr)); - assert!(seq_acc_store.contains_account(&acc3_addr)); - - let acc_balance = seq_acc_store.get_account_balance(&acc1_addr); + let acc_balance = seq_acc_store.get_account_balance(&[6; 32]); assert_eq!(acc_balance, 120); - let acc_balance = seq_acc_store.get_account_balance(&acc2_addr); + let acc_balance = seq_acc_store.get_account_balance(&[7; 32]); assert_eq!(acc_balance, 15); - let acc_balance = seq_acc_store.get_account_balance(&acc3_addr); + let acc_balance = seq_acc_store.get_account_balance(&[8; 32]); assert_eq!(acc_balance, 10); } #[test] fn account_sequencer_store_fetch_unknown_account() { - let acc1 = Account::new_with_balance(120); - let acc2 = Account::new_with_balance(15); - let acc3 = Account::new_with_balance(10); - - let seq_acc_store = SequencerAccountsStore::new(&[acc1, acc2, acc3]); + 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]); diff --git a/sequencer_core/src/sequencer_store/mod.rs b/sequencer_core/src/sequencer_store/mod.rs index 7748475..3a74fb3 100644 --- a/sequencer_core/src/sequencer_store/mod.rs +++ b/sequencer_core/src/sequencer_store/mod.rs @@ -1,6 +1,6 @@ use std::{collections::HashSet, path::Path}; -use accounts::account_core::Account; +use accounts::account_core::AccountForSerialization; use accounts_store::SequencerAccountsStore; use block_store::SequecerBlockStore; use common::{ @@ -10,8 +10,6 @@ use common::{ }; use rand::{rngs::OsRng, RngCore}; -use crate::config::AccountInitialData; - pub mod accounts_store; pub mod block_store; @@ -21,8 +19,6 @@ pub struct SequecerChainStore { pub nullifier_store: HashSet, pub utxo_commitments_store: UTXOCommitmentsMerkleTree, pub pub_tx_store: PublicTransactionMerkleTree, - //ToDo: For testing purposes, remove after testnet - pub testnet_initial_accounts_full_data: Vec, } impl SequecerChainStore { @@ -30,11 +26,11 @@ impl SequecerChainStore { home_dir: &Path, genesis_id: u64, is_genesis_random: bool, - initial_accounts: &[AccountInitialData], + initial_accounts: &[AccountForSerialization], ) -> Self { - let accs_pregenerated: Vec = initial_accounts + let accs_pregenerated: Vec<_> = initial_accounts .iter() - .map(|acc_data| Account::new_with_balance(acc_data.balance)) + .map(|acc| (acc.address, acc.balance)) .collect(); let acc_store = SequencerAccountsStore::new(&accs_pregenerated); @@ -74,7 +70,6 @@ impl SequecerChainStore { nullifier_store, utxo_commitments_store, pub_tx_store, - testnet_initial_accounts_full_data: accs_pregenerated, } } } diff --git a/sequencer_rpc/src/process.rs b/sequencer_rpc/src/process.rs index 4375f9c..b1237ad 100644 --- a/sequencer_rpc/src/process.rs +++ b/sequencer_rpc/src/process.rs @@ -146,12 +146,7 @@ impl JsonHandler { let accounts_for_serialization: Vec = { let state = self.sequencer_state.lock().await; - state - .store - .testnet_initial_accounts_full_data - .iter() - .map(|acc| acc.clone().into()) - .collect() + state.sequencer_config.initial_accounts.clone() }; respond(accounts_for_serialization) @@ -198,10 +193,7 @@ mod tests { use crate::{rpc_handler, JsonHandler}; use accounts::account_core::Account; use common::rpc_primitives::RpcPollingConfig; - use sequencer_core::{ - config::{AccountInitialData, SequencerConfig}, - SequencerCore, - }; + use sequencer_core::{config::SequencerConfig, SequencerCore}; use serde_json::Value; use tempfile::tempdir; use tokio::sync::Mutex; @@ -209,10 +201,243 @@ mod tests { fn sequencer_config_for_tests() -> SequencerConfig { let tempdir = tempdir().unwrap(); let home = tempdir.path().to_path_buf(); - let initial_accounts = vec![ - AccountInitialData { balance: 100 }, - AccountInitialData { balance: 200 }, - ]; + let initial_acc1 = serde_json::from_str(r#"{ + "address": [ + 244, + 55, + 238, + 205, + 74, + 115, + 179, + 192, + 65, + 186, + 166, + 169, + 221, + 45, + 6, + 57, + 200, + 65, + 195, + 70, + 118, + 252, + 206, + 100, + 215, + 250, + 72, + 230, + 19, + 71, + 217, + 249 + ], + "balance": 100, + "key_holder": { + "address": [ + 244, + 55, + 238, + 205, + 74, + 115, + 179, + 192, + 65, + 186, + 166, + 169, + 221, + 45, + 6, + 57, + 200, + 65, + 195, + 70, + 118, + 252, + 206, + 100, + 215, + 250, + 72, + 230, + 19, + 71, + 217, + 249 + ], + "nullifer_public_key": "03A340BECA9FAAB444CED0140681D72EA1318B5C611704FEE017DA9836B17DB718", + "pub_account_signing_key": [ + 244, + 88, + 134, + 61, + 35, + 209, + 229, + 101, + 85, + 35, + 140, + 140, + 192, + 226, + 83, + 83, + 190, + 189, + 110, + 8, + 89, + 127, + 147, + 142, + 157, + 204, + 51, + 109, + 189, + 92, + 144, + 68 + ], + "top_secret_key_holder": { + "secret_spending_key": "7BC46784DB1BC67825D8F029436846712BFDF9B5D79EA3AB11D39A52B9B229D4" + }, + "utxo_secret_key_holder": { + "nullifier_secret_key": "BB54A8D3C9C51B82C431082D1845A74677B0EF829A11B517E1D9885DE3139506", + "viewing_secret_key": "AD923E92F6A5683E30140CEAB2702AFB665330C1EE4EFA70FAF29767B6B52BAF" + }, + "viewing_public_key": "0361220C5D277E7A1709340FD31A52600C1432B9C45B9BCF88A43581D58824A8B6" + }, + "utxos": {} + }"#).unwrap(); + + let initial_acc2 = serde_json::from_str(r#"{ + "address": [ + 72, + 169, + 70, + 237, + 1, + 96, + 35, + 157, + 25, + 15, + 83, + 18, + 52, + 206, + 202, + 63, + 48, + 59, + 173, + 76, + 78, + 7, + 254, + 229, + 28, + 45, + 194, + 79, + 6, + 89, + 58, + 85 + ], + "balance": 200, + "key_holder": { + "address": [ + 72, + 169, + 70, + 237, + 1, + 96, + 35, + 157, + 25, + 15, + 83, + 18, + 52, + 206, + 202, + 63, + 48, + 59, + 173, + 76, + 78, + 7, + 254, + 229, + 28, + 45, + 194, + 79, + 6, + 89, + 58, + 85 + ], + "nullifer_public_key": "02172F50274DE67C4087C344F5D58E11DF761D90285B095060E0994FAA6BCDE271", + "pub_account_signing_key": [ + 136, + 105, + 9, + 53, + 180, + 145, + 64, + 5, + 235, + 174, + 62, + 211, + 206, + 116, + 185, + 24, + 214, + 62, + 244, + 64, + 224, + 59, + 120, + 150, + 30, + 249, + 160, + 46, + 189, + 254, + 47, + 244 + ], + "top_secret_key_holder": { + "secret_spending_key": "80A186737C8D38B4288A03F0F589957D9C040D79C19F3E0CC4BA80F8494E5179" + }, + "utxo_secret_key_holder": { + "nullifier_secret_key": "746928E63F0984F6F4818933493CE9C067562D9CB932FDC06D82C86CDF6D7122", + "viewing_secret_key": "89176CF4BC9E673807643FD52110EF99D4894335AFB10D881AC0B5041FE1FCB7" + }, + "viewing_public_key": "026072A8F83FEC3472E30CDD4767683F30B91661D25B1040AD9A5FC2E01D659F99" + }, + "utxos": {} + }"#).unwrap(); + + let initial_accounts = vec![initial_acc1, initial_acc2]; SequencerConfig { home, @@ -231,9 +456,11 @@ mod tests { let sequencer_core = SequencerCore::start_from_config(config); let initial_accounts = sequencer_core - .store - .testnet_initial_accounts_full_data - .clone(); + .sequencer_config + .initial_accounts + .iter() + .map(|acc_ser| acc_ser.clone().into()) + .collect(); let sequencer_core = Arc::new(Mutex::new(sequencer_core)); diff --git a/sequencer_runner/configs/debug/sequencer_config.json b/sequencer_runner/configs/debug/sequencer_config.json index 1f121ef..b707b85 100644 --- a/sequencer_runner/configs/debug/sequencer_config.json +++ b/sequencer_runner/configs/debug/sequencer_config.json @@ -8,10 +8,238 @@ "port": 3040, "initial_accounts": [ { - "balance": 10 + "address": [ + 244, + 55, + 238, + 205, + 74, + 115, + 179, + 192, + 65, + 186, + 166, + 169, + 221, + 45, + 6, + 57, + 200, + 65, + 195, + 70, + 118, + 252, + 206, + 100, + 215, + 250, + 72, + 230, + 19, + 71, + 217, + 249 + ], + "balance": 100, + "key_holder": { + "address": [ + 244, + 55, + 238, + 205, + 74, + 115, + 179, + 192, + 65, + 186, + 166, + 169, + 221, + 45, + 6, + 57, + 200, + 65, + 195, + 70, + 118, + 252, + 206, + 100, + 215, + 250, + 72, + 230, + 19, + 71, + 217, + 249 + ], + "nullifer_public_key": "03A340BECA9FAAB444CED0140681D72EA1318B5C611704FEE017DA9836B17DB718", + "pub_account_signing_key": [ + 244, + 88, + 134, + 61, + 35, + 209, + 229, + 101, + 85, + 35, + 140, + 140, + 192, + 226, + 83, + 83, + 190, + 189, + 110, + 8, + 89, + 127, + 147, + 142, + 157, + 204, + 51, + 109, + 189, + 92, + 144, + 68 + ], + "top_secret_key_holder": { + "secret_spending_key": "7BC46784DB1BC67825D8F029436846712BFDF9B5D79EA3AB11D39A52B9B229D4" + }, + "utxo_secret_key_holder": { + "nullifier_secret_key": "BB54A8D3C9C51B82C431082D1845A74677B0EF829A11B517E1D9885DE3139506", + "viewing_secret_key": "AD923E92F6A5683E30140CEAB2702AFB665330C1EE4EFA70FAF29767B6B52BAF" + }, + "viewing_public_key": "0361220C5D277E7A1709340FD31A52600C1432B9C45B9BCF88A43581D58824A8B6" + }, + "utxos": {} }, { - "balance": 100 + "address": [ + 72, + 169, + 70, + 237, + 1, + 96, + 35, + 157, + 25, + 15, + 83, + 18, + 52, + 206, + 202, + 63, + 48, + 59, + 173, + 76, + 78, + 7, + 254, + 229, + 28, + 45, + 194, + 79, + 6, + 89, + 58, + 85 + ], + "balance": 1000, + "key_holder": { + "address": [ + 72, + 169, + 70, + 237, + 1, + 96, + 35, + 157, + 25, + 15, + 83, + 18, + 52, + 206, + 202, + 63, + 48, + 59, + 173, + 76, + 78, + 7, + 254, + 229, + 28, + 45, + 194, + 79, + 6, + 89, + 58, + 85 + ], + "nullifer_public_key": "02172F50274DE67C4087C344F5D58E11DF761D90285B095060E0994FAA6BCDE271", + "pub_account_signing_key": [ + 136, + 105, + 9, + 53, + 180, + 145, + 64, + 5, + 235, + 174, + 62, + 211, + 206, + 116, + 185, + 24, + 214, + 62, + 244, + 64, + 224, + 59, + 120, + 150, + 30, + 249, + 160, + 46, + 189, + 254, + 47, + 244 + ], + "top_secret_key_holder": { + "secret_spending_key": "80A186737C8D38B4288A03F0F589957D9C040D79C19F3E0CC4BA80F8494E5179" + }, + "utxo_secret_key_holder": { + "nullifier_secret_key": "746928E63F0984F6F4818933493CE9C067562D9CB932FDC06D82C86CDF6D7122", + "viewing_secret_key": "89176CF4BC9E673807643FD52110EF99D4894335AFB10D881AC0B5041FE1FCB7" + }, + "viewing_public_key": "026072A8F83FEC3472E30CDD4767683F30B91661D25B1040AD9A5FC2E01D659F99" + }, + "utxos": {} } ] } \ No newline at end of file