From 4dde0418387466535a834c55b1501c0aec358ee0 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 8 Mar 2024 16:39:14 -0800 Subject: [PATCH 01/13] Update minimum validator and delegator stake --- ledger/committee/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ledger/committee/src/lib.rs b/ledger/committee/src/lib.rs index 75b4a988a8..eb70bba201 100644 --- a/ledger/committee/src/lib.rs +++ b/ledger/committee/src/lib.rs @@ -34,9 +34,9 @@ use ledger_narwhal_batch_header::BatchHeader; use std::collections::HashSet; /// The minimum amount of stake required for a validator to bond. -pub const MIN_VALIDATOR_STAKE: u64 = 1_000_000_000_000u64; // microcredits +pub const MIN_VALIDATOR_STAKE: u64 = 10_000_000_000_000u64; // microcredits /// The minimum amount of stake required for a delegator to bond. -pub const MIN_DELEGATOR_STAKE: u64 = 10_000_000u64; // microcredits +pub const MIN_DELEGATOR_STAKE: u64 = 10_000_000_000u64; // microcredits /// The maximum number of delegators. pub const MAX_DELEGATORS: u32 = 100_000u32; From 051c703d272492c5529095408a440c96cb0193a2 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 8 Mar 2024 16:41:59 -0800 Subject: [PATCH 02/13] Update MAX_CERTIFICATES to 10 --- ledger/narwhal/batch-header/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ledger/narwhal/batch-header/src/lib.rs b/ledger/narwhal/batch-header/src/lib.rs index ce79fc6c6a..5c82b1f243 100644 --- a/ledger/narwhal/batch-header/src/lib.rs +++ b/ledger/narwhal/batch-header/src/lib.rs @@ -52,7 +52,7 @@ pub struct BatchHeader { impl BatchHeader { /// The maximum number of certificates in a batch. - pub const MAX_CERTIFICATES: u16 = 200; + pub const MAX_CERTIFICATES: u16 = 10; /// The maximum number of rounds to store before garbage collecting. pub const MAX_GC_ROUNDS: usize = 100; /// The maximum number of transmissions in a batch. From 9b039961ffff10edbd32b1a31c32dffb318c1028 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 8 Mar 2024 16:50:38 -0800 Subject: [PATCH 03/13] Update tests --- ledger/committee/src/lib.rs | 4 ++-- ledger/committee/src/prop_tests.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ledger/committee/src/lib.rs b/ledger/committee/src/lib.rs index eb70bba201..81b67461bd 100644 --- a/ledger/committee/src/lib.rs +++ b/ledger/committee/src/lib.rs @@ -408,7 +408,7 @@ mod tests { // Set the number of rounds. const NUM_ROUNDS: u64 = 256 * 2_000; // Sample the number of members. - let num_members = rng.gen_range(3..50); + let num_members = rng.gen_range(3..=10); // Sample a committee. let committee = crate::test_helpers::sample_committee_custom(num_members, rng); // Check the leader distribution. @@ -420,7 +420,7 @@ mod tests { // Initialize the RNG. let rng = &mut TestRng::default(); // Sample a committee. - let committee = crate::test_helpers::sample_committee_custom(200, rng); + let committee = crate::test_helpers::sample_committee_custom(10, rng); // Start a timer. let timer = std::time::Instant::now(); diff --git a/ledger/committee/src/prop_tests.rs b/ledger/committee/src/prop_tests.rs index 992be5e216..ebdbdbc06a 100644 --- a/ledger/committee/src/prop_tests.rs +++ b/ledger/committee/src/prop_tests.rs @@ -193,7 +193,7 @@ fn committee_members(input: CommitteeContext) { fn invalid_stakes(#[strategy(too_low_stake_committee())] committee: Result>) { assert!(committee.is_err()); if let Err(err) = committee { - assert_eq!(err.to_string().as_str(), "All members must have at least 1000000000000 microcredits in stake"); + assert_eq!(err.to_string().as_str(), "All members must have at least 10000000000000 microcredits in stake"); } } From 698a26480fd021adfe384c76a9eadf25f0596090 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 8 Mar 2024 17:14:58 -0800 Subject: [PATCH 04/13] Add a testing value for MAX_CERTIFICATES --- ledger/committee/src/lib.rs | 5 +++-- ledger/narwhal/batch-header/src/lib.rs | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ledger/committee/src/lib.rs b/ledger/committee/src/lib.rs index 81b67461bd..43ad8d1511 100644 --- a/ledger/committee/src/lib.rs +++ b/ledger/committee/src/lib.rs @@ -408,7 +408,7 @@ mod tests { // Set the number of rounds. const NUM_ROUNDS: u64 = 256 * 2_000; // Sample the number of members. - let num_members = rng.gen_range(3..=10); + let num_members = rng.gen_range(3..=Committee::::MAX_COMMITTEE_SIZE); // Sample a committee. let committee = crate::test_helpers::sample_committee_custom(num_members, rng); // Check the leader distribution. @@ -420,7 +420,8 @@ mod tests { // Initialize the RNG. let rng = &mut TestRng::default(); // Sample a committee. - let committee = crate::test_helpers::sample_committee_custom(10, rng); + let committee = + crate::test_helpers::sample_committee_custom(Committee::::MAX_COMMITTEE_SIZE, rng); // Start a timer. let timer = std::time::Instant::now(); diff --git a/ledger/narwhal/batch-header/src/lib.rs b/ledger/narwhal/batch-header/src/lib.rs index 5c82b1f243..63e195c980 100644 --- a/ledger/narwhal/batch-header/src/lib.rs +++ b/ledger/narwhal/batch-header/src/lib.rs @@ -52,7 +52,12 @@ pub struct BatchHeader { impl BatchHeader { /// The maximum number of certificates in a batch. + #[cfg(not(any(test, feature = "test")))] pub const MAX_CERTIFICATES: u16 = 10; + /// The maximum number of certificates in a batch. + /// This is set to a deliberately high value (200) for testing purposes only. + #[cfg(any(test, feature = "test"))] + pub const MAX_CERTIFICATES: u16 = 200; /// The maximum number of rounds to store before garbage collecting. pub const MAX_GC_ROUNDS: usize = 100; /// The maximum number of transmissions in a batch. From a638a40652e11500791ce196b8256faf9152300f Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 8 Mar 2024 17:20:16 -0800 Subject: [PATCH 05/13] Update credits.aleo with the minimum stake amounts --- .../program/src/resources/credits.aleo | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/synthesizer/program/src/resources/credits.aleo b/synthesizer/program/src/resources/credits.aleo index 980f9208ca..e38dc3fe92 100644 --- a/synthesizer/program/src/resources/credits.aleo +++ b/synthesizer/program/src/resources/credits.aleo @@ -180,9 +180,9 @@ finalize bond_public: // Increment the microcredits in the bond state. add r9.microcredits r2 into r14; - // Determine if the amount is at least one million credits. - gte r14 1_000_000_000_000u64 into r15; - // Enforce the amount is at least one million credits. + // Determine if the amount is at least 10 million credits. + gte r14 10_000_000_000_000u64 into r15; + // Enforce the amount is at least 10 million credits. assert.eq r15 true; // Construct the updated bond state. @@ -260,9 +260,9 @@ finalize bond_public: // Increment the microcredits in the bond state. add r28.microcredits r2 into r29; - // Determine if the amount is at least 10 credits. - gte r29 10_000_000u64 into r30; - // Enforce the amount is at least 10 credits. + // Determine if the amount is at least 10 thousand credits. + gte r29 10_000_000_000u64 into r30; + // Enforce the amount is at least 10 thousand credits. assert.eq r30 true; // Construct the updated bond state. @@ -345,12 +345,12 @@ finalize unbond_public: // Decrement the microcredits in the bond state. sub r8.microcredits r1 into r9; - // Determine if the remaining bond is at least one million credits. - gte r9 1_000_000_000_000u64 into r10; + // Determine if the remaining bond is at least 10 million credits. + gte r9 10_000_000_000_000u64 into r10; - // If the remaining balance is at least 1 million credits, jump to the `decrement_validator` logic. + // If the remaining balance is at least 10 million credits, jump to the `decrement_validator` logic. branch.eq r10 true to decrement_validator; - // If the remaining balance is less than 1 million credits, jump to the `remove_validator` logic. + // If the remaining balance is less than 10 million credits, jump to the `remove_validator` logic. branch.eq r10 false to remove_validator; /*** Decrement Validator ***/ @@ -433,12 +433,12 @@ finalize unbond_public: // Decrement the microcredits in the bond state. sub r19.microcredits r1 into r20; - // Determine if the remaining bond is at least 10 credits. - gte r20 10_000_000u64 into r21; + // Determine if the remaining bond is at least 10 thousand credits. + gte r20 10_000_000_000u64 into r21; - // If the remaining balance is at least 10 credits, jump to the `decrement_delegator` logic. + // If the remaining balance is at least 10 thousand credits, jump to the `decrement_delegator` logic. branch.eq r21 true to decrement_delegator; - // If the remaining balance is less than 10 credits, jump to the `remove_delegator` logic. + // If the remaining balance is less than 10 thousand credits, jump to the `remove_delegator` logic. branch.eq r21 false to remove_delegator; /*** Decrement Delegator ***/ From 7cd6557e4ca22bf60e9886add587beb6c4d9b43d Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 8 Mar 2024 17:32:24 -0800 Subject: [PATCH 06/13] Update credits.aleo with maximum committee size --- synthesizer/program/src/resources/credits.aleo | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/synthesizer/program/src/resources/credits.aleo b/synthesizer/program/src/resources/credits.aleo index e38dc3fe92..d629eba8bb 100644 --- a/synthesizer/program/src/resources/credits.aleo +++ b/synthesizer/program/src/resources/credits.aleo @@ -146,9 +146,9 @@ finalize bond_public: get.or_use metadata[aleo1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq3ljyzc] 0u32 into r5; // Increment the committee size by one. add r5 1u32 into r6; - // Determine if the committee size is less than or equal to 200. - lte r6 200u32 into r7; - // Enforce that the committee size is less than or equal to 200. + // Determine if the committee size is less than or equal to 10. + lte r6 10u32 into r7; + // Enforce that the committee size is less than or equal to 10. assert.eq r7 true; // Set the new committee size. set r6 into metadata[aleo1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq3ljyzc]; From 30b78b1840ac351ce415ab018d176b4c69a16f37 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 8 Mar 2024 18:16:22 -0800 Subject: [PATCH 07/13] Update staker initialization in tests --- ledger/narwhal/batch-header/src/lib.rs | 4 ++-- ledger/src/tests.rs | 6 +++--- synthesizer/process/src/tests/test_credits.rs | 18 +++++++++--------- synthesizer/src/vm/helpers/committee.rs | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/ledger/narwhal/batch-header/src/lib.rs b/ledger/narwhal/batch-header/src/lib.rs index 63e195c980..a8647da004 100644 --- a/ledger/narwhal/batch-header/src/lib.rs +++ b/ledger/narwhal/batch-header/src/lib.rs @@ -55,9 +55,9 @@ impl BatchHeader { #[cfg(not(any(test, feature = "test")))] pub const MAX_CERTIFICATES: u16 = 10; /// The maximum number of certificates in a batch. - /// This is set to a deliberately high value (200) for testing purposes only. + /// This is set to a deliberately high value (100) for testing purposes only. #[cfg(any(test, feature = "test"))] - pub const MAX_CERTIFICATES: u16 = 200; + pub const MAX_CERTIFICATES: u16 = 100; /// The maximum number of rounds to store before garbage collecting. pub const MAX_GC_ROUNDS: usize = 100; /// The maximum number of transmissions in a batch. diff --git a/ledger/src/tests.rs b/ledger/src/tests.rs index 3ede876f82..a44b5e5308 100644 --- a/ledger/src/tests.rs +++ b/ledger/src/tests.rs @@ -499,7 +499,7 @@ fn test_bond_and_unbond_validator() { // Fund the new committee member. let inputs = [ Value::from_str(&format!("{new_member_address}")).unwrap(), - Value::from_str("10000000000000u64").unwrap(), // 10 million credits. + Value::from_str("20000000000000u64").unwrap(), // 20 million credits. ]; let transfer_transaction = ledger .vm @@ -518,7 +518,7 @@ fn test_bond_and_unbond_validator() { ledger.advance_to_next_block(&transfer_block).unwrap(); // Construct the bond public - let bond_amount = 1000000000000u64; // 1 million credits. + let bond_amount = MIN_VALIDATOR_STAKE; let inputs = [ Value::from_str(&format!("{new_member_address}")).unwrap(), Value::from_str(&format!("{bond_amount}u64")).unwrap(), @@ -565,7 +565,7 @@ fn test_bond_and_unbond_validator() { assert_eq!(num_validators, committee.num_members()); // Construct the bond public - let unbond_amount = committee.get_stake(new_member_address); // 1 million credits. + let unbond_amount = committee.get_stake(new_member_address); let inputs = [Value::from_str(&format!("{unbond_amount}u64")).unwrap()]; let unbond_public_transaction = ledger .vm diff --git a/synthesizer/process/src/tests/test_credits.rs b/synthesizer/process/src/tests/test_credits.rs index 201a9a7313..07afa92690 100644 --- a/synthesizer/process/src/tests/test_credits.rs +++ b/synthesizer/process/src/tests/test_credits.rs @@ -216,7 +216,7 @@ fn initialize_stakers>( // Initialize a new account. let private_key = PrivateKey::::new(rng)?; let address = Address::try_from(&private_key)?; - let balance = 10_000_000_000_000u64; + let balance = 100_000_000_000_000u64; // Add the balance directly to the finalize store. let key = Plaintext::from(Literal::Address(address)); @@ -497,7 +497,7 @@ fn test_bond_validator_multiple_bonds() { /* First Bond */ // Perform the first bond. - let amount = 1_000_000_000_000u64; + let amount = MIN_VALIDATOR_STAKE; assert!(amount < public_balance); bond_public(&process, &store, validator_private_key, validator_address, amount, rng).unwrap(); @@ -513,7 +513,7 @@ fn test_bond_validator_multiple_bonds() { /* Second Bond */ // Perform the second bond. - let amount = 1_000_000_000_000u64; + let amount = MIN_VALIDATOR_STAKE; assert!(amount < public_balance_1); bond_public(&process, &store, validator_private_key, validator_address, amount, rng).unwrap(); @@ -1314,7 +1314,7 @@ fn test_unbond_delegator_as_validator() { /* Ensure unbonding a delegator as an open validator fails. */ // Bond the validators. - let validator_amount = 1_000_000_000_000u64; + let validator_amount = MIN_VALIDATOR_STAKE; bond_public(&process, &finalize_store, &validator_private_key_1, &validator_address_1, validator_amount, rng) .unwrap(); bond_public(&process, &finalize_store, &validator_private_key_2, &validator_address_2, validator_amount, rng) @@ -1369,7 +1369,7 @@ fn test_claim_unbond() { let public_balance = account_balance(&finalize_store, validator_address).unwrap(); // Perform the bond. - let validator_amount = 1_000_000_000_000u64; + let validator_amount = MIN_VALIDATOR_STAKE; bond_public(&process, &finalize_store, validator_private_key, validator_address, validator_amount, rng).unwrap(); /* Ensure claiming an unbond fails when no unbond_state exists. */ @@ -1406,7 +1406,7 @@ fn test_set_validator_state() { /* Ensure calling `set_validator_state` succeeds. */ // Perform the bond. - let amount = 1_000_000_000_000u64; + let amount = MIN_VALIDATOR_STAKE; bond_public(&process, &finalize_store, validator_private_key, validator_address, amount, rng).unwrap(); // Check that the validator state is correct. @@ -1462,21 +1462,21 @@ fn test_bonding_to_closed_fails() { /* Ensure bonding to a closed validator fails. */ // Perform the bond. - let amount = 1_000_000_000_000u64; + let amount = MIN_VALIDATOR_STAKE; bond_public(&process, &finalize_store, validator_private_key, validator_address, amount, rng).unwrap(); // Set the validator `is_open` state to `false`. set_validator_state(&process, &finalize_store, validator_private_key, false, rng).unwrap(); // Ensure that the validator can't bond additional stake. - let validator_amount = 1_000_000_000_000u64; + let validator_amount = MIN_VALIDATOR_STAKE; assert!( bond_public(&process, &finalize_store, validator_private_key, validator_address, validator_amount, rng) .is_err() ); // Ensure that delegators can't bond to the validator. - let delegator_amount = 1_000_000u64; + let delegator_amount = MIN_DELEGATOR_STAKE; assert!( bond_public(&process, &finalize_store, delegator_private_key, validator_address, delegator_amount, rng) .is_err() diff --git a/synthesizer/src/vm/helpers/committee.rs b/synthesizer/src/vm/helpers/committee.rs index d44c4eafd1..fef83ff5f4 100644 --- a/synthesizer/src/vm/helpers/committee.rs +++ b/synthesizer/src/vm/helpers/committee.rs @@ -233,7 +233,7 @@ pub fn to_next_commitee_map_and_bonded_map( pub(crate) mod test_helpers { use super::*; use crate::vm::TestRng; - use ledger_committee::MIN_VALIDATOR_STAKE; + use ledger_committee::{MIN_DELEGATOR_STAKE, MIN_VALIDATOR_STAKE}; use rand::{CryptoRng, Rng}; @@ -249,7 +249,7 @@ pub(crate) mod test_helpers { // Keep a tally of the remaining microcredits. let remaining_microcredits = microcredits.saturating_sub(MIN_VALIDATOR_STAKE); // Set the staker amount to 10 credit. - let staker_amount = 10_000_000; + let staker_amount = MIN_DELEGATOR_STAKE; // Determine the number of iterations. let num_iterations = (remaining_microcredits / staker_amount).saturating_sub(1); From 70bf41b504a793f344fef9bd8ae7a650626a24c0 Mon Sep 17 00:00:00 2001 From: Niklas Date: Mon, 11 Mar 2024 19:24:50 +0100 Subject: [PATCH 08/13] tests: fix consensus constants compilation --- Cargo.lock | 1 + ledger/narwhal/batch-header/src/lib.rs | 4 ++-- synthesizer/Cargo.toml | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f91e9879a7..6516eb89e2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3369,6 +3369,7 @@ dependencies = [ "snarkvm-console", "snarkvm-ledger-block", "snarkvm-ledger-committee", + "snarkvm-ledger-narwhal-batch-header", "snarkvm-ledger-query", "snarkvm-ledger-store", "snarkvm-ledger-test-helpers", diff --git a/ledger/narwhal/batch-header/src/lib.rs b/ledger/narwhal/batch-header/src/lib.rs index a8647da004..c1ff8f0760 100644 --- a/ledger/narwhal/batch-header/src/lib.rs +++ b/ledger/narwhal/batch-header/src/lib.rs @@ -52,11 +52,11 @@ pub struct BatchHeader { impl BatchHeader { /// The maximum number of certificates in a batch. - #[cfg(not(any(test, feature = "test")))] + #[cfg(not(any(test, feature = "test-helpers")))] pub const MAX_CERTIFICATES: u16 = 10; /// The maximum number of certificates in a batch. /// This is set to a deliberately high value (100) for testing purposes only. - #[cfg(any(test, feature = "test"))] + #[cfg(any(test, feature = "test-helpers"))] pub const MAX_CERTIFICATES: u16 = 100; /// The maximum number of rounds to store before garbage collecting. pub const MAX_GC_ROUNDS: usize = 100; diff --git a/synthesizer/Cargo.toml b/synthesizer/Cargo.toml index 5d12a29164..5645e3f8c0 100644 --- a/synthesizer/Cargo.toml +++ b/synthesizer/Cargo.toml @@ -161,6 +161,11 @@ package = "snarkvm-ledger-committee" path = "../ledger/committee" features = [ "test-helpers" ] +[dev-dependencies.ledger-narwhal-batch-header] +package = "snarkvm-ledger-narwhal-batch-header" +path = "../ledger/narwhal/batch-header" +features = [ "test-helpers" ] + [dev-dependencies.ledger-test-helpers] package = "snarkvm-ledger-test-helpers" path = "../ledger/test-helpers" From 4f86652eaf1c3ada663ff6aeac02b6af31487dfc Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 11 Mar 2024 14:41:51 -0700 Subject: [PATCH 09/13] Fix tests --- synthesizer/src/vm/finalize.rs | 8 +++++--- synthesizer/src/vm/mod.rs | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/synthesizer/src/vm/finalize.rs b/synthesizer/src/vm/finalize.rs index cd353ac1de..bbc209d3f5 100644 --- a/synthesizer/src/vm/finalize.rs +++ b/synthesizer/src/vm/finalize.rs @@ -1933,8 +1933,9 @@ finalize compute: assert!(result.is_err()); // Reset the validators. + // Note: We use a smaller committee size to ensure that there is enough supply to allocate to the validators and genesis block transactions. let validators = - sample_validators::(Committee::::MAX_COMMITTEE_SIZE as usize, rng); + sample_validators::(Committee::::MAX_COMMITTEE_SIZE as usize / 4, rng); // Construct the committee. // Track the allocated amount. @@ -1976,8 +1977,9 @@ finalize compute: VM::from(ConsensusStore::>::open(None).unwrap()).unwrap(); // Construct the validators. + // Note: We use a smaller committee size to ensure that there is enough supply to allocate to the validators and genesis block transactions. let validators = - sample_validators::(Committee::::MAX_COMMITTEE_SIZE as usize, rng); + sample_validators::(Committee::::MAX_COMMITTEE_SIZE as usize / 4, rng); // Construct the delegators, greater than the maximum delegator size. let delegators = (0..MAX_DELEGATORS + 1) @@ -2136,7 +2138,7 @@ finalize compute: // Note that the first validator is used to execute additional transactions in `VM::genesis_quorum`. // Therefore, the balance of the first validator will be different from the expected balance. if entry.0 == Plaintext::from_str(&first_validator.to_string()).unwrap() { - assert_eq!(entry.1, Value::from_str("294999983894244u64").unwrap()); + assert_eq!(entry.1, Value::from_str("249983999894244u64").unwrap()); } else { assert!(expected_account.contains(entry)); } diff --git a/synthesizer/src/vm/mod.rs b/synthesizer/src/vm/mod.rs index 795499689b..1fde10dfc8 100644 --- a/synthesizer/src/vm/mod.rs +++ b/synthesizer/src/vm/mod.rs @@ -997,7 +997,7 @@ function a: // Note: `deployment_transaction_ids` is sorted lexicographically by transaction ID, so the order may change if we update internal methods. assert_eq!( deployment_transaction_ids, - vec![deployment_1.id(), deployment_2.id(), deployment_3.id(), deployment_4.id()], + vec![deployment_4.id(), deployment_1.id(), deployment_2.id(), deployment_3.id()], "Update me if serialization has changed" ); } From 2ed43cc862abfd6590ff6e6e84e4d7040f60a16a Mon Sep 17 00:00:00 2001 From: Raymond Chu <14917648+raychu86@users.noreply.github.com> Date: Fri, 15 Mar 2024 13:29:19 -0700 Subject: [PATCH 10/13] Update synthesizer/src/vm/helpers/committee.rs Co-authored-by: d0cd <23022326+d0cd@users.noreply.github.com> Signed-off-by: Raymond Chu <14917648+raychu86@users.noreply.github.com> --- synthesizer/src/vm/helpers/committee.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synthesizer/src/vm/helpers/committee.rs b/synthesizer/src/vm/helpers/committee.rs index fef83ff5f4..5f9adefddf 100644 --- a/synthesizer/src/vm/helpers/committee.rs +++ b/synthesizer/src/vm/helpers/committee.rs @@ -248,7 +248,7 @@ pub(crate) mod test_helpers { .flat_map(|(validator, (microcredits, _))| { // Keep a tally of the remaining microcredits. let remaining_microcredits = microcredits.saturating_sub(MIN_VALIDATOR_STAKE); - // Set the staker amount to 10 credit. + // Set the staker amount to `MIN_DELEGATOR_STAKE` microcredits. let staker_amount = MIN_DELEGATOR_STAKE; // Determine the number of iterations. let num_iterations = (remaining_microcredits / staker_amount).saturating_sub(1); From 90a97c1fdb38a918505e8993fd6e9f27be8693f2 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 15 Mar 2024 13:45:07 -0700 Subject: [PATCH 11/13] Fix test --- synthesizer/src/vm/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synthesizer/src/vm/mod.rs b/synthesizer/src/vm/mod.rs index 1630c7737b..78e86a1ea9 100644 --- a/synthesizer/src/vm/mod.rs +++ b/synthesizer/src/vm/mod.rs @@ -998,7 +998,7 @@ function a: // Note: `deployment_transaction_ids` is sorted lexicographically by transaction ID, so the order may change if we update internal methods. assert_eq!( deployment_transaction_ids, - vec![deployment_4.id(), deployment_1.id(), deployment_2.id(), deployment_3.id()], + vec![deployment_3.id(), deployment_4.id(), deployment_1.id(), deployment_2.id()], "Update me if serialization has changed" ); } From 05db4c17351ab9a6fc817ade9e8d7a63eedd018f Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 15 Mar 2024 14:01:09 -0700 Subject: [PATCH 12/13] Rewrite expectations --- .../tests/expectations/vm/execute_and_finalize/test_rand.out | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 0af538e48d..51fb5b5e60 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":"3094014759641313043901697261267946468626327163450942596641947962222295207390field","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: From 06a9d63148dc6e0f27cb746a1c507b2e16109619 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 15 Mar 2024 15:51:17 -0700 Subject: [PATCH 13/13] Rewrite expectations --- .../tests/expectations/vm/execute_and_finalize/test_rand.out | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 51fb5b5e60..0af538e48d 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":"3094014759641313043901697261267946468626327163450942596641947962222295207390field","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 accepted + speculate: the execution was rejected add_next_block: succeeded. - verified: true execute: