From c1cfaa19cee8849fdd2f49d2b5de498c60d1d45a Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Tue, 31 Oct 2023 13:50:52 -0700 Subject: [PATCH 1/6] Fix get_map_and_key indexing --- .../src/helpers/rocksdb/internal/nested_map.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/ledger/store/src/helpers/rocksdb/internal/nested_map.rs b/ledger/store/src/helpers/rocksdb/internal/nested_map.rs index 73bf49bee0..84be7c9096 100644 --- a/ledger/store/src/helpers/rocksdb/internal/nested_map.rs +++ b/ledger/store/src/helpers/rocksdb/internal/nested_map.rs @@ -16,7 +16,7 @@ use super::*; use crate::helpers::{NestedMap, NestedMapRead}; -use console::prelude::FromBytes; +use console::prelude::{anyhow, FromBytes}; use core::{fmt, fmt::Debug, hash::Hash, mem}; use std::{borrow::Cow, sync::atomic::Ordering}; @@ -80,10 +80,20 @@ impl Result<(&[u8], &[u8])> { - let map_len = u32::from_bytes_le(&map_key[PREFIX_LEN..][..4])? as usize; - let map = &map_key[PREFIX_LEN + 4..][..map_len]; - let key = &map_key[PREFIX_LEN + 4 + map_len..]; + // Retrieve the map length. + let map_len = u32::from_bytes_le( + map_key.get(PREFIX_LEN..PREFIX_LEN + 4).ok_or_else(|| anyhow!("NestedMap map_len index out of range"))?, + )? as usize; + // Retrieve the map bytes. + let map = map_key + .get(PREFIX_LEN + 4..PREFIX_LEN + 4 + map_len) + .ok_or_else(|| anyhow!("NestedMap map index out of range"))?; + + // Retrieve the key bytes. + let key = map_key.get(PREFIX_LEN + 4 + map_len..).ok_or_else(|| anyhow!("NestedMap key index out of range"))?; + + // Return the map and key bytes. Ok((map, key)) } From d7c4e8121e9295f083db03bebae26b93b9aa062f Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Tue, 31 Oct 2023 21:08:18 -0700 Subject: [PATCH 2/6] Adds in test case --- .circleci/config.yml | 12 +++++++ ledger/src/lib.rs | 18 ++++++++-- ledger/src/tests.rs | 52 ++++++++++++++++++++++++++- ledger/store/src/program/committee.rs | 5 ++- synthesizer/src/vm/mod.rs | 18 +++++++--- 5 files changed, 95 insertions(+), 10 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c78cf5f13b..2402f7faa9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -480,6 +480,16 @@ jobs: workspace_member: ledger cache_key: snarkvm-ledger-cache + ledger-with-rocksdb: + docker: + - image: cimg/rust:1.71.1 + resource_class: 2xlarge + steps: + - run_serial: + flags: --features=rocks + workspace_member: ledger + cache_key: snarkvm-ledger-with-rocksdb-cache + ledger-authority: docker: - image: cimg/rust:1.71.1 @@ -854,6 +864,8 @@ workflows: - curves - fields - ledger +# TODO (howardwu) - Implement `open_testing` on all storage, update to `CurrentConsensusStore::open_testing`, then re-enable. +# - ledger-with-rocksdb - ledger-authority - ledger-block - ledger-coinbase diff --git a/ledger/src/lib.rs b/ledger/src/lib.rs index 568d501ac2..0e5511b798 100644 --- a/ledger/src/lib.rs +++ b/ledger/src/lib.rs @@ -392,11 +392,23 @@ pub(crate) mod test_helpers { prelude::*, }; use ledger_block::Block; - use ledger_store::{helpers::memory::ConsensusMemory, ConsensusStore}; + use ledger_store::ConsensusStore; use synthesizer::vm::VM; pub(crate) type CurrentNetwork = Testnet3; - pub(crate) type CurrentLedger = Ledger>; + + #[cfg(not(feature = "rocks"))] + pub(crate) type CurrentLedger = + Ledger>; + #[cfg(feature = "rocks")] + pub(crate) type CurrentLedger = Ledger>; + + #[cfg(not(feature = "rocks"))] + pub(crate) type CurrentConsensusStore = + ConsensusStore>; + #[cfg(feature = "rocks")] + pub(crate) type CurrentConsensusStore = + ConsensusStore>; #[allow(dead_code)] pub(crate) struct TestEnv { @@ -426,7 +438,7 @@ pub(crate) mod test_helpers { rng: &mut (impl Rng + CryptoRng), ) -> CurrentLedger { // Initialize the store. - let store = ConsensusStore::<_, ConsensusMemory<_>>::open(None).unwrap(); + let store = CurrentConsensusStore::open(None).unwrap(); // Create a genesis block. let genesis = VM::from(store).unwrap().genesis_beacon(&private_key, rng).unwrap(); // Initialize the ledger with the genesis block. diff --git a/ledger/src/tests.rs b/ledger/src/tests.rs index d033edef82..93fd576793 100644 --- a/ledger/src/tests.rs +++ b/ledger/src/tests.rs @@ -81,7 +81,7 @@ fn test_state_path() { } #[test] -fn test_insufficient_fees() { +fn test_insufficient_private_fees() { let rng = &mut TestRng::default(); // Initialize the test environment. @@ -190,6 +190,56 @@ finalize foo: } } +#[test] +fn test_insufficient_public_fees() { + let rng = &mut TestRng::default(); + + // Initialize the test environment. + let crate::test_helpers::TestEnv { ledger, private_key, address, .. } = crate::test_helpers::sample_test_env(rng); + + // Sample recipient. + let recipient_private_key = PrivateKey::new(rng).unwrap(); + let recipient_address = Address::try_from(&recipient_private_key).unwrap(); + + // Fund the recipient with 1 million credits. + { + let inputs = + [Value::from_str(&format!("{recipient_address}")).unwrap(), Value::from_str("1000000000000u64").unwrap()]; + let transaction = ledger + .vm + .execute(&private_key, ("credits.aleo", "transfer_public"), inputs.into_iter(), None, 0, None, rng) + .unwrap(); + + let block = + ledger.prepare_advance_to_next_beacon_block(&private_key, vec![], vec![], vec![transaction], rng).unwrap(); + + // Check that the next block is valid. + ledger.check_next_block(&block).unwrap(); + // Add the deployment block to the ledger. + ledger.advance_to_next_block(&block).unwrap(); + } + + println!("-----------"); + + // Attempt to bond the node with insufficient public fees. + { + let inputs = + [Value::from_str(&format!("{recipient_address}")).unwrap(), Value::from_str("1000000000000u64").unwrap()]; + let transaction = ledger + .vm + .execute(&recipient_private_key, ("credits.aleo", "bond_public"), inputs.into_iter(), None, 0, None, rng) + .unwrap(); + + let block = + ledger.prepare_advance_to_next_beacon_block(&private_key, vec![], vec![], vec![transaction], rng).unwrap(); + + // Check that the next block is valid. + ledger.check_next_block(&block).unwrap(); + // Add the deployment block to the ledger. + ledger.advance_to_next_block(&block).unwrap(); + } +} + #[test] fn test_insufficient_finalize_fees() { let rng = &mut TestRng::default(); diff --git a/ledger/store/src/program/committee.rs b/ledger/store/src/program/committee.rs index 71c764d51a..62cd6e0bbb 100644 --- a/ledger/store/src/program/committee.rs +++ b/ledger/store/src/program/committee.rs @@ -114,7 +114,10 @@ pub trait CommitteeStorage: 'static + Clone + Send + Sync { // If the current round is 0, ensure the next round is 0. Err(..) => ensure!(next_round == 0, "Next round must be block round 0"), // Otherwise, ensure the next round sequentially follows the current round. - Ok(current_round) => ensure!(next_round > current_round, "Next round must be greater than current round"), + Ok(current_round) => ensure!( + next_round > current_round, + "Next round {next_round} must be greater than current round {current_round}" + ), } // Check the next height. diff --git a/synthesizer/src/vm/mod.rs b/synthesizer/src/vm/mod.rs index bfcc0b6d5e..baa491b906 100644 --- a/synthesizer/src/vm/mod.rs +++ b/synthesizer/src/vm/mod.rs @@ -187,18 +187,26 @@ impl> VM { impl> VM { /// Returns a new genesis block for a beacon chain. pub fn genesis_beacon(&self, private_key: &PrivateKey, rng: &mut R) -> Result> { + let private_keys = [*private_key, PrivateKey::new(rng)?, PrivateKey::new(rng)?, PrivateKey::new(rng)?]; + // Construct the committee members. let members = indexmap::indexmap! { - Address::try_from(private_key)? => (ledger_committee::MIN_VALIDATOR_STAKE, true), - Address::try_from(PrivateKey::new(rng)?)? => (ledger_committee::MIN_VALIDATOR_STAKE, true), - Address::try_from(PrivateKey::new(rng)?)? => (ledger_committee::MIN_VALIDATOR_STAKE, true), - Address::try_from(PrivateKey::new(rng)?)? => (ledger_committee::MIN_VALIDATOR_STAKE, true), + Address::try_from(private_keys[0])? => (ledger_committee::MIN_VALIDATOR_STAKE, true), + Address::try_from(private_keys[1])? => (ledger_committee::MIN_VALIDATOR_STAKE, true), + Address::try_from(private_keys[2])? => (ledger_committee::MIN_VALIDATOR_STAKE, true), + Address::try_from(private_keys[3])? => (ledger_committee::MIN_VALIDATOR_STAKE, true), }; // Construct the committee. let committee = Committee::::new_genesis(members)?; + + // Compute the remaining supply. + let remaining_supply = N::STARTING_SUPPLY - (ledger_committee::MIN_VALIDATOR_STAKE * 4); // Construct the public balances. let public_balances = indexmap::indexmap! { - Address::try_from(private_key)? => N::STARTING_SUPPLY - (ledger_committee::MIN_VALIDATOR_STAKE * 4), + Address::try_from(private_keys[0])? => remaining_supply / 4, + Address::try_from(private_keys[1])? => remaining_supply / 4, + Address::try_from(private_keys[2])? => remaining_supply / 4, + Address::try_from(private_keys[3])? => remaining_supply / 4, }; // Return the genesis block. self.genesis_quorum(private_key, committee, public_balances, rng) From 536956862d8091e333f9a1e6bb75d560077c245b Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Tue, 31 Oct 2023 21:17:44 -0700 Subject: [PATCH 3/6] Add breaks in db iterators --- ledger/src/tests.rs | 2 +- .../store/src/helpers/rocksdb/internal/nested_map.rs | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ledger/src/tests.rs b/ledger/src/tests.rs index 93fd576793..af95102191 100644 --- a/ledger/src/tests.rs +++ b/ledger/src/tests.rs @@ -195,7 +195,7 @@ fn test_insufficient_public_fees() { let rng = &mut TestRng::default(); // Initialize the test environment. - let crate::test_helpers::TestEnv { ledger, private_key, address, .. } = crate::test_helpers::sample_test_env(rng); + let crate::test_helpers::TestEnv { ledger, private_key, .. } = crate::test_helpers::sample_test_env(rng); // Sample recipient. let recipient_private_key = PrivateKey::new(rng).unwrap(); diff --git a/ledger/store/src/helpers/rocksdb/internal/nested_map.rs b/ledger/store/src/helpers/rocksdb/internal/nested_map.rs index 84be7c9096..43ddc457e7 100644 --- a/ledger/store/src/helpers/rocksdb/internal/nested_map.rs +++ b/ledger/store/src/helpers/rocksdb/internal/nested_map.rs @@ -150,7 +150,9 @@ impl< let (map_key, _) = entry?; // Extract the bytes belonging to the map and the key. - let (entry_map, _) = get_map_and_key(&map_key)?; + let Ok((entry_map, _)) = get_map_and_key(&map_key) else { + break; + }; // If the 'entry_map' matches 'serialized_map', delete the key. if entry_map == serialized_map { @@ -292,7 +294,9 @@ impl< let (map_key, _) = entry?; // Extract the bytes belonging to the map and the key. - let (entry_map, _) = get_map_and_key(&map_key)?; + let Ok((entry_map, _)) = get_map_and_key(&map_key) else { + break; + }; // If the 'entry_map' matches 'serialized_map', delete the key. if entry_map == serialized_map { @@ -407,7 +411,9 @@ impl< let (map_key, value) = entry?; // Extract the bytes belonging to the map and the key. - let (entry_map, entry_key) = get_map_and_key(&map_key)?; + let Ok((entry_map, entry_key)) = get_map_and_key(&map_key) else { + break; + }; // If the 'entry_map' matches 'serialized_map', deserialize the key and value. if entry_map == serialized_map { From 06e80aa2dddd770fe2e711bb8e80b3e6b793d73e Mon Sep 17 00:00:00 2001 From: ljedrz Date: Tue, 31 Oct 2023 10:47:50 +0100 Subject: [PATCH 4/6] tests: add a case for a mixed map storage Signed-off-by: ljedrz --- .../store/src/helpers/rocksdb/internal/id.rs | 3 + .../helpers/rocksdb/internal/nested_map.rs | 68 +++++++++++++++++-- 2 files changed, 67 insertions(+), 4 deletions(-) diff --git a/ledger/store/src/helpers/rocksdb/internal/id.rs b/ledger/store/src/helpers/rocksdb/internal/id.rs index 3091895661..0d47eecd83 100644 --- a/ledger/store/src/helpers/rocksdb/internal/id.rs +++ b/ledger/store/src/helpers/rocksdb/internal/id.rs @@ -195,6 +195,7 @@ pub enum TestMap { Test2 = DataID::Test2 as u16, Test3 = DataID::Test3 as u16, Test4 = DataID::Test4 as u16, + Test5 = DataID::Test5 as u16, } /// The RocksDB map prefix. @@ -282,4 +283,6 @@ enum DataID { Test3, #[cfg(test)] Test4, + #[cfg(test)] + Test5, } diff --git a/ledger/store/src/helpers/rocksdb/internal/nested_map.rs b/ledger/store/src/helpers/rocksdb/internal/nested_map.rs index 43ddc457e7..ff20f34319 100644 --- a/ledger/store/src/helpers/rocksdb/internal/nested_map.rs +++ b/ledger/store/src/helpers/rocksdb/internal/nested_map.rs @@ -724,7 +724,10 @@ mod tests { use crate::{ atomic_batch_scope, atomic_finalize, - helpers::rocksdb::{internal::tests::temp_dir, MapID, TestMap}, + helpers::{ + rocksdb::{internal::tests::temp_dir, MapID, TestMap}, + traits::Map, + }, FinalizeMode, }; use console::{ @@ -764,6 +767,28 @@ mod tests { } } + fn open_non_nested_map_testing_from_db< + K: Serialize + DeserializeOwned, + V: Serialize + DeserializeOwned, + T: Into, + >( + database: RocksDB, + map_id: T, + ) -> DataMap { + // Combine contexts to create a new scope. + let mut context = database.network_id.to_le_bytes().to_vec(); + context.extend_from_slice(&(map_id.into()).to_le_bytes()); + + // Return the DataMap. + DataMap(Arc::new(InnerDataMap { + database, + context, + atomic_batch: Default::default(), + batch_in_progress: Default::default(), + checkpoints: Default::default(), + })) + } + struct TestStorage { own_map: NestedDataMap, extra_maps: TestStorage2, @@ -872,35 +897,44 @@ mod tests { struct TestStorage3 { own_map: NestedDataMap, + own_non_nested_map: DataMap, } impl TestStorage3 { fn open(database: RocksDB) -> Self { - Self { own_map: open_map_testing_from_db(database, MapID::Test(TestMap::Test4)) } + Self { + own_map: open_map_testing_from_db(database.clone(), MapID::Test(TestMap::Test4)), + own_non_nested_map: open_non_nested_map_testing_from_db(database, MapID::Test(TestMap::Test5)), + } } fn start_atomic(&self) { self.own_map.start_atomic(); + self.own_non_nested_map.start_atomic(); } fn is_atomic_in_progress(&self) -> bool { - self.own_map.is_atomic_in_progress() + self.own_map.is_atomic_in_progress() || self.own_non_nested_map.is_atomic_in_progress() } fn atomic_checkpoint(&self) { self.own_map.atomic_checkpoint(); + self.own_non_nested_map.atomic_checkpoint(); } fn clear_latest_checkpoint(&self) { self.own_map.clear_latest_checkpoint(); + self.own_non_nested_map.clear_latest_checkpoint(); } fn atomic_rewind(&self) { self.own_map.atomic_rewind(); + self.own_non_nested_map.atomic_rewind(); } fn finish_atomic(&self) -> Result<()> { - self.own_map.finish_atomic() + self.own_map.finish_atomic()?; + self.own_non_nested_map.finish_atomic() } } @@ -982,6 +1016,32 @@ mod tests { crate::helpers::test_helpers::nested_map::check_iterators_match(map); } + #[test] + #[serial] + #[traced_test] + fn test_iter_from_nested_to_non_nested() { + // Open a storage with a DataMap right after a NestedDataMap. + let database = RocksDB::open_testing(temp_dir(), None).expect("Failed to open a test database"); + let test_storage = TestStorage3::open(database); + + // Insert 5 (confirmed) records into a nested map 77. + for i in 0..5 { + test_storage.own_map.insert(77, i, i.to_string()).expect("Failed to insert"); + } + + // Insert 5 (confirmed) records into the neighboring data map; the keys are large on purpose. + for i in 0..5 { + test_storage + .own_non_nested_map + .insert(usize::MAX - i, (usize::MAX - i).to_string()) + .expect("Failed to insert"); + } + + // We should be able to collect the 5 records from the nested data map. + let confirmed = test_storage.own_map.get_map_confirmed(&77).unwrap(); + assert_eq!(confirmed.len(), 5); + } + #[test] #[serial] #[traced_test] From de4ae987db12c2f0a1b2affe9ba1cca50ae07337 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Tue, 31 Oct 2023 21:35:41 -0700 Subject: [PATCH 5/6] Rename test variables --- .../helpers/rocksdb/internal/nested_map.rs | 51 +++++++++---------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/ledger/store/src/helpers/rocksdb/internal/nested_map.rs b/ledger/store/src/helpers/rocksdb/internal/nested_map.rs index ff20f34319..b168b3591a 100644 --- a/ledger/store/src/helpers/rocksdb/internal/nested_map.rs +++ b/ledger/store/src/helpers/rocksdb/internal/nested_map.rs @@ -839,7 +839,7 @@ mod tests { self.own_map.is_atomic_in_progress() && self.extra_maps.own_map1.is_atomic_in_progress() && self.extra_maps.own_map1.is_atomic_in_progress() - && self.extra_maps.extra_maps.own_map.is_atomic_in_progress() + && self.extra_maps.extra_maps.own_nested_map.is_atomic_in_progress() } } @@ -896,45 +896,45 @@ mod tests { } struct TestStorage3 { - own_map: NestedDataMap, - own_non_nested_map: DataMap, + own_nested_map: NestedDataMap, + own_map: DataMap, } impl TestStorage3 { fn open(database: RocksDB) -> Self { Self { - own_map: open_map_testing_from_db(database.clone(), MapID::Test(TestMap::Test4)), - own_non_nested_map: open_non_nested_map_testing_from_db(database, MapID::Test(TestMap::Test5)), + own_nested_map: open_map_testing_from_db(database.clone(), MapID::Test(TestMap::Test4)), + own_map: open_non_nested_map_testing_from_db(database, MapID::Test(TestMap::Test5)), } } fn start_atomic(&self) { + self.own_nested_map.start_atomic(); self.own_map.start_atomic(); - self.own_non_nested_map.start_atomic(); } fn is_atomic_in_progress(&self) -> bool { - self.own_map.is_atomic_in_progress() || self.own_non_nested_map.is_atomic_in_progress() + self.own_nested_map.is_atomic_in_progress() || self.own_map.is_atomic_in_progress() } fn atomic_checkpoint(&self) { + self.own_nested_map.atomic_checkpoint(); self.own_map.atomic_checkpoint(); - self.own_non_nested_map.atomic_checkpoint(); } fn clear_latest_checkpoint(&self) { + self.own_nested_map.clear_latest_checkpoint(); self.own_map.clear_latest_checkpoint(); - self.own_non_nested_map.clear_latest_checkpoint(); } fn atomic_rewind(&self) { + self.own_nested_map.atomic_rewind(); self.own_map.atomic_rewind(); - self.own_non_nested_map.atomic_rewind(); } fn finish_atomic(&self) -> Result<()> { - self.own_map.finish_atomic()?; - self.own_non_nested_map.finish_atomic() + self.own_nested_map.finish_atomic()?; + self.own_map.finish_atomic() } } @@ -1026,19 +1026,16 @@ mod tests { // Insert 5 (confirmed) records into a nested map 77. for i in 0..5 { - test_storage.own_map.insert(77, i, i.to_string()).expect("Failed to insert"); + test_storage.own_nested_map.insert(77, i, i.to_string()).expect("Failed to insert"); } // Insert 5 (confirmed) records into the neighboring data map; the keys are large on purpose. for i in 0..5 { - test_storage - .own_non_nested_map - .insert(usize::MAX - i, (usize::MAX - i).to_string()) - .expect("Failed to insert"); + test_storage.own_map.insert(usize::MAX - i, (usize::MAX - i).to_string()).expect("Failed to insert"); } // We should be able to collect the 5 records from the nested data map. - let confirmed = test_storage.own_map.get_map_confirmed(&77).unwrap(); + let confirmed = test_storage.own_nested_map.get_map_confirmed(&77).unwrap(); assert_eq!(confirmed.len(), 5); } @@ -1650,7 +1647,7 @@ mod tests { assert!(test_storage.own_map.iter_confirmed().next().is_none()); assert!(test_storage.extra_maps.own_map1.iter_confirmed().next().is_none()); assert!(test_storage.extra_maps.own_map2.iter_confirmed().next().is_none()); - assert!(test_storage.extra_maps.extra_maps.own_map.iter_confirmed().next().is_none()); + assert!(test_storage.extra_maps.extra_maps.own_nested_map.iter_confirmed().next().is_none()); assert_eq!(test_storage.own_map.checkpoints.lock().last(), None); @@ -1679,11 +1676,11 @@ mod tests { test_storage.extra_maps.own_map2.insert(2, 2, 2.to_string()).unwrap(); // Start another atomic write batch. - atomic_batch_scope!(test_storage.extra_maps.extra_maps.own_map, { - assert!(test_storage.extra_maps.extra_maps.own_map.is_atomic_in_progress()); + atomic_batch_scope!(test_storage.extra_maps.extra_maps.own_nested_map, { + assert!(test_storage.extra_maps.extra_maps.own_nested_map.is_atomic_in_progress()); // Write an item into the fourth map. - test_storage.extra_maps.extra_maps.own_map.insert(3, 3, 3.to_string()).unwrap(); + test_storage.extra_maps.extra_maps.own_nested_map.insert(3, 3, 3.to_string()).unwrap(); Ok(()) })?; @@ -1704,7 +1701,7 @@ mod tests { assert_eq!(test_storage.own_map.iter_confirmed().count(), 1); assert_eq!(test_storage.extra_maps.own_map1.iter_confirmed().count(), 1); assert_eq!(test_storage.extra_maps.own_map2.iter_confirmed().count(), 1); - assert_eq!(test_storage.extra_maps.extra_maps.own_map.iter_confirmed().count(), 1); + assert_eq!(test_storage.extra_maps.extra_maps.own_nested_map.iter_confirmed().count(), 1); // The atomic_write_batch macro uses ?, so the test returns a Result for simplicity. Ok(()) @@ -1735,11 +1732,11 @@ mod tests { test_storage.extra_maps.own_map2.insert(2, 2, 2.to_string()).unwrap(); // Start another atomic write batch. - let result: Result<()> = atomic_batch_scope!(test_storage.extra_maps.extra_maps.own_map, { + let result: Result<()> = atomic_batch_scope!(test_storage.extra_maps.extra_maps.own_nested_map, { assert!(test_storage.is_atomic_in_progress_everywhere()); // Write an item into the fourth map. - test_storage.extra_maps.extra_maps.own_map.insert(3, 3, 3.to_string()).unwrap(); + test_storage.extra_maps.extra_maps.own_nested_map.insert(3, 3, 3.to_string()).unwrap(); // Rewind the atomic batch via a simulated error. bail!("An error that will trigger a single rewind."); @@ -1766,7 +1763,7 @@ mod tests { assert!(test_storage.own_map.iter_confirmed().next().is_none()); assert!(test_storage.extra_maps.own_map1.iter_confirmed().next().is_none()); assert!(test_storage.extra_maps.own_map2.iter_confirmed().next().is_none()); - assert!(test_storage.extra_maps.extra_maps.own_map.iter_confirmed().next().is_none()); + assert!(test_storage.extra_maps.extra_maps.own_nested_map.iter_confirmed().next().is_none()); // Note: all the checks going through .database can be performed on any one // of the objects, as all of them share the same instance of the database. @@ -1782,6 +1779,6 @@ mod tests { assert_eq!(test_storage.own_map.iter_confirmed().count(), 1); assert_eq!(test_storage.extra_maps.own_map1.iter_confirmed().count(), 1); assert_eq!(test_storage.extra_maps.own_map2.iter_confirmed().count(), 1); - assert_eq!(test_storage.extra_maps.extra_maps.own_map.iter_confirmed().count(), 0); + assert_eq!(test_storage.extra_maps.extra_maps.own_nested_map.iter_confirmed().count(), 0); } } From 21325b63f17f3281c5b53f0e2f4b2dce81bfdd6d Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 1 Nov 2023 01:01:22 -0400 Subject: [PATCH 6/6] Regenerate expectations --- .../vm/execute_and_finalize/child_and_parent.out | 4 ++-- .../vm/execute_and_finalize/complex_finalization.out | 8 ++++---- .../expectations/vm/execute_and_finalize/count_usages.out | 8 ++++---- .../vm/execute_and_finalize/program_callable.out | 4 ++-- .../vm/execute_and_finalize/public_wallet.out | 2 +- .../expectations/vm/execute_and_finalize/test_rand.out | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/synthesizer/tests/expectations/vm/execute_and_finalize/child_and_parent.out b/synthesizer/tests/expectations/vm/execute_and_finalize/child_and_parent.out index a33be90307..46e5687c00 100644 --- a/synthesizer/tests/expectations/vm/execute_and_finalize/child_and_parent.out +++ b/synthesizer/tests/expectations/vm/execute_and_finalize/child_and_parent.out @@ -26,8 +26,8 @@ additional: - child_outputs: child.aleo/foo: outputs: - - '{"type":"public","id":"994990058621570799386345097567825463488929977263218477287025824851872546446field","value":"aleo16w8t56s7v6ud7vu33fr388ph0dq0c7yhp597cyjt88rr3nultcyqcyk9yy"}' - - '{"type":"public","id":"2256104170911230762284986427287133867149405204422634231010917189963141359010field","value":"aleo1qr2ha4pfs5l28aze88yn6fhleeythklkczrule2v838uwj65n5gqxt9djx"}' + - '{"type":"public","id":"5247898905227353609778507804894201830213116355942129794185831563892847697904field","value":"aleo16w8t56s7v6ud7vu33fr388ph0dq0c7yhp597cyjt88rr3nultcyqcyk9yy"}' + - '{"type":"public","id":"5696731482704228331490606142901378912648054832970914942122047737341299330880field","value":"aleo1qr2ha4pfs5l28aze88yn6fhleeythklkczrule2v838uwj65n5gqxt9djx"}' credits.aleo/fee_private: outputs: - '{"type":"record","id":"3845927395044855364546905308732895913294823927145229411137666358260055754822field","checksum":"1584433976273241291707799637296934525591046977180320555626848307441674321598field","value":"record1qyqsp3c590shnra6j8rc3ezq5k229gcd8srjpxpf2vn7drkccmrq8tqrqyxx66trwfhkxun9v35hguerqqpqzq9m2h242d3v2sm53yzkqkuu6v2cwaz0jpq7nseh2uxqedph6gz9pmsvcdfnpn0htvu2lvx9cpvs6sssvhj972rpakkdzjmj4n7fhwhs6fjpcap"}' diff --git a/synthesizer/tests/expectations/vm/execute_and_finalize/complex_finalization.out b/synthesizer/tests/expectations/vm/execute_and_finalize/complex_finalization.out index 62b00223bd..efb5cc2e49 100644 --- a/synthesizer/tests/expectations/vm/execute_and_finalize/complex_finalization.out +++ b/synthesizer/tests/expectations/vm/execute_and_finalize/complex_finalization.out @@ -11,16 +11,16 @@ additional: - child_outputs: zero_program.aleo/c: outputs: - - '{"type":"future","id":"6952696836717992189844193836164206763601783392883300349164619423689411832957field","value":"{\n program_id: zero_program.aleo,\n function_name: c,\n arguments: [\n aleo1kw4knandael9qcpxs6g36rr6h7dwvjz6q25ueah6zz9v57zjlvxsx5llq8\n ]\n}"}' + - '{"type":"future","id":"1905462962689695038453701745598203401537060599092388120411862554545031055970field","value":"{\n program_id: zero_program.aleo,\n function_name: c,\n arguments: [\n aleo1kw4knandael9qcpxs6g36rr6h7dwvjz6q25ueah6zz9v57zjlvxsx5llq8\n ]\n}"}' one_program.aleo/d: outputs: - - '{"type":"future","id":"3375358791246667464469024643039205630228640255715459354259647324302115771724field","value":"{\n program_id: one_program.aleo,\n function_name: d,\n arguments: [\n aleo1kw4knandael9qcpxs6g36rr6h7dwvjz6q25ueah6zz9v57zjlvxsx5llq8\n ]\n}"}' + - '{"type":"future","id":"6693143058720846069430783074439454880228662860018405276072484028873963650423field","value":"{\n program_id: one_program.aleo,\n function_name: d,\n arguments: [\n aleo1kw4knandael9qcpxs6g36rr6h7dwvjz6q25ueah6zz9v57zjlvxsx5llq8\n ]\n}"}' two_program.aleo/b: outputs: - - '{"type":"future","id":"364582187421035500339943835636532028870700065252111564274460853535036892560field","value":"{\n program_id: two_program.aleo,\n function_name: b,\n arguments: [\n {\n program_id: zero_program.aleo,\n function_name: c,\n arguments: [\n aleo1kw4knandael9qcpxs6g36rr6h7dwvjz6q25ueah6zz9v57zjlvxsx5llq8\n ]\n },\n {\n program_id: one_program.aleo,\n function_name: d,\n arguments: [\n aleo1kw4knandael9qcpxs6g36rr6h7dwvjz6q25ueah6zz9v57zjlvxsx5llq8\n ]\n },\n aleo1kw4knandael9qcpxs6g36rr6h7dwvjz6q25ueah6zz9v57zjlvxsx5llq8\n ]\n}"}' + - '{"type":"future","id":"491254750407294442708769751402250675930358534067257210689773980657773666656field","value":"{\n program_id: two_program.aleo,\n function_name: b,\n arguments: [\n {\n program_id: zero_program.aleo,\n function_name: c,\n arguments: [\n aleo1kw4knandael9qcpxs6g36rr6h7dwvjz6q25ueah6zz9v57zjlvxsx5llq8\n ]\n },\n {\n program_id: one_program.aleo,\n function_name: d,\n arguments: [\n aleo1kw4knandael9qcpxs6g36rr6h7dwvjz6q25ueah6zz9v57zjlvxsx5llq8\n ]\n },\n aleo1kw4knandael9qcpxs6g36rr6h7dwvjz6q25ueah6zz9v57zjlvxsx5llq8\n ]\n}"}' three_program.aleo/e: outputs: - - '{"type":"future","id":"5353639949292491626228591653810953466693160316414035702266036019526362677427field","value":"{\n program_id: three_program.aleo,\n function_name: e,\n arguments: [\n {\n program_id: two_program.aleo,\n function_name: b,\n arguments: [\n {\n program_id: zero_program.aleo,\n function_name: c,\n arguments: [\n aleo1kw4knandael9qcpxs6g36rr6h7dwvjz6q25ueah6zz9v57zjlvxsx5llq8\n ]\n },\n {\n program_id: one_program.aleo,\n function_name: d,\n arguments: [\n aleo1kw4knandael9qcpxs6g36rr6h7dwvjz6q25ueah6zz9v57zjlvxsx5llq8\n ]\n },\n aleo1kw4knandael9qcpxs6g36rr6h7dwvjz6q25ueah6zz9v57zjlvxsx5llq8\n ]\n },\n {\n program_id: one_program.aleo,\n function_name: d,\n arguments: [\n aleo1kw4knandael9qcpxs6g36rr6h7dwvjz6q25ueah6zz9v57zjlvxsx5llq8\n ]\n },\n {\n program_id: zero_program.aleo,\n function_name: c,\n arguments: [\n aleo1kw4knandael9qcpxs6g36rr6h7dwvjz6q25ueah6zz9v57zjlvxsx5llq8\n ]\n },\n aleo1kw4knandael9qcpxs6g36rr6h7dwvjz6q25ueah6zz9v57zjlvxsx5llq8\n ]\n}"}' + - '{"type":"future","id":"3726717185600495415803494559204677788759912659186157220182093722580745931290field","value":"{\n program_id: three_program.aleo,\n function_name: e,\n arguments: [\n {\n program_id: two_program.aleo,\n function_name: b,\n arguments: [\n {\n program_id: zero_program.aleo,\n function_name: c,\n arguments: [\n aleo1kw4knandael9qcpxs6g36rr6h7dwvjz6q25ueah6zz9v57zjlvxsx5llq8\n ]\n },\n {\n program_id: one_program.aleo,\n function_name: d,\n arguments: [\n aleo1kw4knandael9qcpxs6g36rr6h7dwvjz6q25ueah6zz9v57zjlvxsx5llq8\n ]\n },\n aleo1kw4knandael9qcpxs6g36rr6h7dwvjz6q25ueah6zz9v57zjlvxsx5llq8\n ]\n },\n {\n program_id: one_program.aleo,\n function_name: d,\n arguments: [\n aleo1kw4knandael9qcpxs6g36rr6h7dwvjz6q25ueah6zz9v57zjlvxsx5llq8\n ]\n },\n {\n program_id: zero_program.aleo,\n function_name: c,\n arguments: [\n aleo1kw4knandael9qcpxs6g36rr6h7dwvjz6q25ueah6zz9v57zjlvxsx5llq8\n ]\n },\n aleo1kw4knandael9qcpxs6g36rr6h7dwvjz6q25ueah6zz9v57zjlvxsx5llq8\n ]\n}"}' credits.aleo/fee_private: outputs: - '{"type":"record","id":"5283229445241909733017633528975572727346436141849413233403355092851851760389field","checksum":"799210811176292053431285281723859450131511292642705172333396010564735450437field","value":"record1qyqsqkme4g74y49w7v70p63ywtq5nate5r75dk8m05ss5zmer5zeqrggqyxx66trwfhkxun9v35hguerqqpqzqx2jzxmtf2rksjtwnl4xz5uu33vh0hdl5gys60lw5tdywm6w864qpzvzv6t35yczkzxqpeh7ckc5wtmt5sxynlcz9fy5ellqapnz8squlrzfgw"}' diff --git a/synthesizer/tests/expectations/vm/execute_and_finalize/count_usages.out b/synthesizer/tests/expectations/vm/execute_and_finalize/count_usages.out index 3a80e7786a..ca1856b203 100644 --- a/synthesizer/tests/expectations/vm/execute_and_finalize/count_usages.out +++ b/synthesizer/tests/expectations/vm/execute_and_finalize/count_usages.out @@ -12,12 +12,12 @@ additional: - child_outputs: basic_math.aleo/add_and_count: outputs: - - '{"type":"private","id":"2189963205002380951731804610675645921799015755766185151265166514396381689207field","value":"ciphertext1qyqwpu5p92d4lrcfhthx0emqpj6cldsty3ghv6mhztl69wyk7j42cpqpq2uaz"}' - - '{"type":"future","id":"1762068320811124981245699286589805951610339834807816585249322967070273785765field","value":"{\n program_id: basic_math.aleo,\n function_name: add_and_count,\n arguments: [\n aleo1mrughg5ssadd9fc2uwve7l6u24xn76kyz24zsjtzta03vgkq4vpqggl6fg\n ]\n}"}' + - '{"type":"private","id":"1772315556078612939485167533472365297291684867177607257721621802696977947575field","value":"ciphertext1qyqgcklg8azjw9cvg8ctguretgpwhf6s2wqfy9kcpat8fez58s8zkrsxh67uj"}' + - '{"type":"future","id":"7119746076995582562745785454448389581684828092421379752708247448276937401483field","value":"{\n program_id: basic_math.aleo,\n function_name: add_and_count,\n arguments: [\n aleo1mrughg5ssadd9fc2uwve7l6u24xn76kyz24zsjtzta03vgkq4vpqggl6fg\n ]\n}"}' basic_math.aleo/sub_and_count: outputs: - - '{"type":"private","id":"3237068809383979468892967123729721371250496145349751597456577370896562797315field","value":"ciphertext1qyqrqc0329zggejxfkdju3e5ng8cahudh6gmmwcu9kvhp2x784lrqqgfua69p"}' - - '{"type":"future","id":"4237975671848212071086918441612015189870459327089330453971374309755212325698field","value":"{\n program_id: basic_math.aleo,\n function_name: sub_and_count,\n arguments: [\n aleo1mrughg5ssadd9fc2uwve7l6u24xn76kyz24zsjtzta03vgkq4vpqggl6fg\n ]\n}"}' + - '{"type":"private","id":"4385798570457226847447139993266058099729895220721504161659868031463911613327field","value":"ciphertext1qyqdtuhzwzdqd0ezjqv0qakjqcwjgnve7u2q0mttr9fhmrfk8lppgrgns3l5x"}' + - '{"type":"future","id":"1481600775514027453204849289042631419545525289712332246758716884227294896058field","value":"{\n program_id: basic_math.aleo,\n function_name: sub_and_count,\n arguments: [\n aleo1mrughg5ssadd9fc2uwve7l6u24xn76kyz24zsjtzta03vgkq4vpqggl6fg\n ]\n}"}' credits.aleo/fee_private: outputs: - '{"type":"record","id":"3873686337596264307426391445386469102660995373532676522475799639542084414660field","checksum":"2174613677640073315115047311154070353095418041185484773007639715599946288810field","value":"record1qyqsq758xfnepvvywvf4tjnve5qkfr0hur7gttevq66hpvl97ulxzkgyqyxx66trwfhkxun9v35hguerqqpqzq85ufcypfdv6unklsc9m066e86drkzx32yzj9kwx7enflqv7j6xqz5v6hx0r0qp5r564yuanadwjkhvx4tj3xp407hh058jl7u0v9qq2z6nqqz"}' diff --git a/synthesizer/tests/expectations/vm/execute_and_finalize/program_callable.out b/synthesizer/tests/expectations/vm/execute_and_finalize/program_callable.out index 150420a0fa..aefc6c15e6 100644 --- a/synthesizer/tests/expectations/vm/execute_and_finalize/program_callable.out +++ b/synthesizer/tests/expectations/vm/execute_and_finalize/program_callable.out @@ -16,8 +16,8 @@ additional: - child_outputs: child.aleo/foo: outputs: - - '{"type":"public","id":"5601132905719769837487481041811167147031721408864816226961174115045250639394field","value":"aleo16w8t56s7v6ud7vu33fr388ph0dq0c7yhp597cyjt88rr3nultcyqcyk9yy"}' - - '{"type":"public","id":"4866955403610457225216600968672882719581841491915839063024906456611968828355field","value":"aleo1qr2ha4pfs5l28aze88yn6fhleeythklkczrule2v838uwj65n5gqxt9djx"}' + - '{"type":"public","id":"5334867623218595534708726257738756067611806976563813684130095277315778727015field","value":"aleo16w8t56s7v6ud7vu33fr388ph0dq0c7yhp597cyjt88rr3nultcyqcyk9yy"}' + - '{"type":"public","id":"1727089994158808720293796677503877381843056781736540181516614343299100979544field","value":"aleo1qr2ha4pfs5l28aze88yn6fhleeythklkczrule2v838uwj65n5gqxt9djx"}' credits.aleo/fee_private: outputs: - '{"type":"record","id":"3405674025766329369434309421947987188809020226610822755338621799001328840366field","checksum":"2290293865028149494249499535633241867489656506924610383724277827943521435010field","value":"record1qyqsq8u5n9rn77xzqqemfr60lr5gd0kl3kmcr8y4kvf34rtxkn5jzhsyqyxx66trwfhkxun9v35hguerqqpqzqyhetu9jy8vsyeaqsq5thyrj7nldd626s0fgatwpffv5j3hecq6p7pkx5xqz4xfcrlu8u2tz8hew0wuagx3cc0wgzlq7uhr2lrc35nqy7dgy47"}' diff --git a/synthesizer/tests/expectations/vm/execute_and_finalize/public_wallet.out b/synthesizer/tests/expectations/vm/execute_and_finalize/public_wallet.out index 83bd95ab4c..3ac28d5188 100644 --- a/synthesizer/tests/expectations/vm/execute_and_finalize/public_wallet.out +++ b/synthesizer/tests/expectations/vm/execute_and_finalize/public_wallet.out @@ -11,7 +11,7 @@ additional: - child_outputs: token.aleo/mint_public: outputs: - - '{"type":"future","id":"4537627763763327286502315223758961709385837795977680378235435937164895010454field","value":"{\n program_id: token.aleo,\n function_name: mint_public,\n arguments: [\n aleo1sry3pke49ykrf0aeshf889tr98r4c86p5f4ms766795ssdwfdyqq9jdg0j,\n 10u64\n ]\n}"}' + - '{"type":"future","id":"4427917061221785896976649017270098343030953189539524433709150411558826004395field","value":"{\n program_id: token.aleo,\n function_name: mint_public,\n arguments: [\n aleo1sry3pke49ykrf0aeshf889tr98r4c86p5f4ms766795ssdwfdyqq9jdg0j,\n 10u64\n ]\n}"}' credits.aleo/fee_private: outputs: - '{"type":"record","id":"5907104904483017944370886525724321520913422122645092211228240860024172441663field","checksum":"5028009166132212399635589181092346921835371600420834084268447856042439491field","value":"record1qyqspshxjatwcdkrde0m2rspsm338q8p7s4eru9m8ftjqzf0ttxpkag0qyxx66trwfhkxun9v35hguerqqpqzqqzvfyzxfn5qlq5aewnafp8z576qvqjjx9pup92f6dxywga9qdupchalpjgkqrwva74ssnqjqgewu8xwj285f0c08t6czss5lcftjhqjuazgdk"}' diff --git a/synthesizer/tests/expectations/vm/execute_and_finalize/test_rand.out b/synthesizer/tests/expectations/vm/execute_and_finalize/test_rand.out index f31addd98f..c5c06ec684 100644 --- a/synthesizer/tests/expectations/vm/execute_and_finalize/test_rand.out +++ b/synthesizer/tests/expectations/vm/execute_and_finalize/test_rand.out @@ -19,7 +19,7 @@ outputs: test_rand.aleo/rand_chacha_check: outputs: - '{"type":"future","id":"5111075340000719619409954898038080805237607157543987731445343150082162501419field","value":"{\n program_id: test_rand.aleo,\n function_name: rand_chacha_check,\n arguments: [\n 0field,\n false\n ]\n}"}' - speculate: the execution was rejected + speculate: the execution was accepted add_next_block: succeeded. - verified: true execute: