Skip to content

Commit

Permalink
Addres feedback; clippy; fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
d0cd committed Feb 22, 2024
1 parent 7be7995 commit 1c9e77a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 16 deletions.
14 changes: 6 additions & 8 deletions ledger/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ use indexmap::IndexMap;
use ledger_block::{ConfirmedTransaction, Rejected, Transaction};
use ledger_committee::{Committee, MIN_VALIDATOR_STAKE};
use ledger_store::{helpers::memory::ConsensusMemory, ConsensusStore};
use synthesizer::{program::Program, Stack, vm::VM};
use synthesizer::prelude::cost_in_microcredits;
use synthesizer::{prelude::cost_in_microcredits, program::Program, vm::VM, Stack};

#[test]
fn test_load() {
Expand Down Expand Up @@ -1422,7 +1421,7 @@ fn test_max_committee_limit_with_bonds() {
Value::<CurrentNetwork>::from_str(&first_address.to_string()).unwrap(),
Value::<CurrentNetwork>::from_str(&format!("{MIN_VALIDATOR_STAKE}u64")).unwrap(),
]
.iter(),
.iter(),
None,
0,
None,
Expand Down Expand Up @@ -1465,7 +1464,7 @@ fn test_max_committee_limit_with_bonds() {
Value::<CurrentNetwork>::from_str(&second_address.to_string()).unwrap(),
Value::<CurrentNetwork>::from_str(&format!("{MIN_VALIDATOR_STAKE}u64")).unwrap(),
]
.iter(),
.iter(),
None,
0,
None,
Expand Down Expand Up @@ -1524,7 +1523,7 @@ fn test_deployment_exceeding_max_transaction_spend() {
finalize foo:{finalize_body}",
))
.unwrap();
.unwrap();

// Initialize a stack for the program.
let stack = Stack::<CurrentNetwork>::new(&ledger.vm().process().read(), &program).unwrap();
Expand Down Expand Up @@ -1556,9 +1555,8 @@ fn test_deployment_exceeding_max_transaction_spend() {
assert!(ledger.vm().check_transaction(&deployment, None, rng).is_ok());

// Construct the next block.
let block = ledger
.prepare_advance_to_next_beacon_block(&private_key, vec![], vec![], vec![deployment], rng)
.unwrap();
let block =
ledger.prepare_advance_to_next_beacon_block(&private_key, vec![], vec![], vec![deployment], rng).unwrap();

// Check that the next block is valid.
ledger.check_next_block(&block, rng).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion synthesizer/src/vm/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl<N: Network, C: ConsensusStorage<N>> VM<N, C> {
let owner = ProgramOwner::new(private_key, deployment_id, rng)?;

// Compute the minimum deployment cost.
let (minimum_deployment_cost, _) = process::deployment_cost(&deployment)?;
let (minimum_deployment_cost, _) = deployment_cost(&deployment)?;
// Authorize the fee.
let fee_authorization = match fee_record {
Some(record) => self.authorize_fee_private(
Expand Down
2 changes: 1 addition & 1 deletion synthesizer/src/vm/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl<N: Network, C: ConsensusStorage<N>> VM<N, C> {
let fee = match is_fee_required || is_priority_fee_declared {
true => {
// Compute the minimum execution cost.
let (minimum_execution_cost, (_, _)) = process::execution_cost(&self.process().read(), &execution)?;
let (minimum_execution_cost, (_, _)) = execution_cost(&self.process().read(), &execution)?;
// Compute the execution ID.
let execution_id = execution.to_execution_id()?;
// Authorize the fee.
Expand Down
5 changes: 1 addition & 4 deletions synthesizer/src/vm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ use ledger_store::{
TransactionStore,
TransitionStore,
};
use synthesizer_process::{Authorization, Process, Trace};
use synthesizer_process::{deployment_cost, execution_cost, Authorization, Process, Trace};
use synthesizer_program::{FinalizeGlobalState, FinalizeOperation, FinalizeStoreTrait, Program};

use aleo_std::prelude::{finish, lap, timer};
Expand Down Expand Up @@ -397,7 +397,6 @@ pub(crate) mod test_helpers {
use indexmap::IndexMap;
use once_cell::sync::OnceCell;
use std::borrow::Borrow;
use synthesizer_process::{cost_in_microcredits, Stack};
use synthesizer_snark::VerifyingKey;

pub(crate) type CurrentNetwork = MainnetV0;
Expand Down Expand Up @@ -1396,6 +1395,4 @@ finalize do:
// Verify.
vm.check_transaction(&transaction, None, rng).unwrap();
}


}
4 changes: 2 additions & 2 deletions synthesizer/src/vm/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ impl<N: Network, C: ConsensusStorage<N>> VM<N, C> {
bail!("Failed to compute the Merkle root for deployment transaction '{id}'")
};
// Compute the minimum deployment cost.
let (cost, _) = process::deployment_cost(deployment)?;
let (cost, _) = deployment_cost(deployment)?;
// Ensure the fee is sufficient to cover the cost.
if *fee.base_amount()? < cost {
bail!("Transaction '{id}' has an insufficient base fee (deployment) - requires {cost} microcredits")
Expand All @@ -183,7 +183,7 @@ impl<N: Network, C: ConsensusStorage<N>> VM<N, C> {
// If the fee is required, then check that the base fee amount is satisfied.
if is_fee_required {
// Compute the execution cost.
let (cost, _) = process::execution_cost(&self.process().read(), execution)?;
let (cost, _) = execution_cost(&self.process().read(), execution)?;
// Ensure the fee is sufficient to cover the cost.
if *fee.base_amount()? < cost {
bail!(
Expand Down

0 comments on commit 1c9e77a

Please sign in to comment.