Skip to content

Commit

Permalink
Fix compilation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
raychu86 committed May 31, 2023
1 parent 86203c1 commit dd7a212
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 69 deletions.
4 changes: 2 additions & 2 deletions cli/src/commands/developer/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use super::{CurrentNetwork, Developer};

use snarkvm::{
prelude::{ConsensusStore, Plaintext, PrivateKey, ProgramID, Query, Record, Transaction, VM},
prelude::{ConsensusStore, Plaintext, PrivateKey, ProgramID, Query, Record, VM},
synthesizer::store::helpers::memory::ConsensusMemory,
};

Expand Down Expand Up @@ -83,7 +83,7 @@ impl Deploy {
let fee = (Record::<CurrentNetwork, Plaintext<CurrentNetwork>>::from_str(&self.record)?, self.fee);

// Create a new transaction.
Transaction::deploy(&vm, &private_key, &program, fee, Some(query), rng)?
vm.deploy(&private_key, &program, fee, Some(query), rng)?
};
println!("✅ Created deployment transaction for '{}'", self.program_id.to_string().bold());

Expand Down
26 changes: 3 additions & 23 deletions cli/src/commands/developer/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,7 @@
use super::{CurrentNetwork, Developer, Program};

use snarkvm::{
prelude::{
ConsensusStore,
Identifier,
Locator,
Plaintext,
PrivateKey,
ProgramID,
Query,
Record,
Transaction,
Value,
VM,
},
prelude::{ConsensusStore, Identifier, Locator, Plaintext, PrivateKey, ProgramID, Query, Record, Value, VM},
synthesizer::store::helpers::memory::ConsensusMemory,
};

Expand Down Expand Up @@ -99,7 +87,7 @@ impl Execute {
// Add the program deployment to the VM.
let credits = ProgramID::<CurrentNetwork>::try_from("credits.aleo")?;
if program.id() != &credits {
let deployment = vm.deploy(&program, rng)?;
let deployment = vm.deploy_raw(&program, rng)?;
vm.process().write().load_deployment(&deployment)?;
}

Expand All @@ -119,15 +107,7 @@ impl Execute {
};

// Create a new transaction.
Transaction::execute(
&vm,
&private_key,
(self.program_id, self.function),
self.inputs.iter(),
fee,
Some(query),
rng,
)?
vm.execute(&private_key, (self.program_id, self.function), self.inputs.iter(), fee, Some(query), rng)?
};
let locator = Locator::<CurrentNetwork>::from_str(&format!("{}/{}", self.program_id, self.function))?;
println!("✅ Created execution transaction for '{}'", locator.to_string().bold());
Expand Down
12 changes: 2 additions & 10 deletions cli/src/commands/developer/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use super::{CurrentNetwork, Developer};

use snarkvm::{
prelude::{Address, ConsensusStore, Locator, Plaintext, PrivateKey, Query, Record, Transaction, Value, VM},
prelude::{Address, ConsensusStore, Locator, Plaintext, PrivateKey, Query, Record, Value, VM},
synthesizer::store::helpers::memory::ConsensusMemory,
};

Expand Down Expand Up @@ -90,15 +90,7 @@ impl Transfer {
];

// Create a new transaction.
Transaction::execute(
&vm,
&private_key,
("credits.aleo", "transfer"),
inputs.iter(),
Some(fee),
Some(query),
rng,
)?
vm.execute(&private_key, ("credits.aleo", "transfer"), inputs.iter(), Some(fee), Some(query), rng)?
};
let locator = Locator::<CurrentNetwork>::from_str("credits.aleo/transfer")?;
format!("✅ Created transfer of {} microcredits to {}...\n", &self.amount, self.recipient);
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl Start {
// Initialize a new VM.
let vm = VM::from(ConsensusStore::<N, ConsensusMemory<N>>::open(None)?)?;
// Initialize the genesis block.
let genesis = Block::genesis(&vm, &beacon_private_key, &mut rng)?;
let genesis = vm.genesis(&beacon_private_key, &mut rng)?;

// A helper method to set the account private key in the node type.
let sample_account = |node: &mut Option<String>, is_beacon: bool| -> Result<()> {
Expand Down
43 changes: 13 additions & 30 deletions node/consensus/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@ use snarkvm::{
program::{Entry, Identifier, Literal, Plaintext, Value},
},
prelude::{Ledger, RecordsFilter, TestRng},
synthesizer::{
block::{Block, Transaction},
program::Program,
store::ConsensusStore,
vm::VM,
},
synthesizer::{block::Transaction, program::Program, store::ConsensusStore, vm::VM},
};

use tracing_test::traced_test;
Expand Down Expand Up @@ -71,7 +66,7 @@ pub(crate) mod test_helpers {
// Initialize a new caller.
let caller_private_key = PrivateKey::<CurrentNetwork>::new(rng).unwrap();
// Return the block.
Block::genesis(&vm, &caller_private_key, rng).unwrap()
vm.genesis(&caller_private_key, rng).unwrap()
})
.clone()
}
Expand All @@ -86,7 +81,7 @@ pub(crate) mod test_helpers {
// Initialize the VM.
let vm = crate::tests::test_helpers::sample_vm();
// Return the block.
Block::genesis(&vm, &private_key, rng).unwrap()
vm.genesis(&private_key, rng).unwrap()
})
.clone()
}
Expand Down Expand Up @@ -173,15 +168,8 @@ function compute:
let additional_fee = (credits, 6466000);

// Deploy.
let transaction = Transaction::deploy(
consensus.ledger.vm(),
&caller_private_key,
&program,
additional_fee,
None,
rng,
)
.unwrap();
let transaction =
consensus.ledger.vm().deploy(&caller_private_key, &program, additional_fee, None, rng).unwrap();
// Verify.
assert!(consensus.ledger.vm().verify_transaction(&transaction));
// Return the transaction.
Expand Down Expand Up @@ -235,10 +223,10 @@ function compute:
assert_eq!(authorization.len(), 1);

// Execute the fee.
let fee = Transaction::execute_fee(vm, &caller_private_key, record, 3000, None, rng).unwrap();
let (_, fee, _) = vm.execute_fee_raw(&caller_private_key, record, 3000, None, rng).unwrap();

// Execute.
let transaction = Transaction::execute_authorization(vm, authorization, Some(fee), None, rng).unwrap();
let transaction = vm.execute_authorization(authorization, Some(fee), None, rng).unwrap();
// Verify.
assert!(vm.verify_transaction(&transaction));
// Return the transaction.
Expand All @@ -262,7 +250,7 @@ fn test_validators() {
let vm = crate::tests::test_helpers::sample_vm();

// Create a genesis block.
let genesis = Block::genesis(&vm, &private_key, rng).unwrap();
let genesis = vm.genesis(&private_key, rng).unwrap();

// Initialize the validators.
let validators: IndexMap<Address<_>, ()> = [(address, ())].into_iter().collect();
Expand Down Expand Up @@ -389,16 +377,11 @@ fn test_ledger_execute_many() {
};
let inputs = [Value::Record(record.clone()), Value::from_str(&format!("{}u64", **amount / 2)).unwrap()];
// Create a new transaction.
let transaction = Transaction::execute(
consensus.ledger.vm(),
&private_key,
("credits.aleo", "split"),
inputs.iter(),
None,
None,
rng,
)
.unwrap();
let transaction = consensus
.ledger
.vm()
.execute(&private_key, ("credits.aleo", "split"), inputs.iter(), None, None, rng)
.unwrap();
// Add the transaction to the memory pool.
consensus.add_unconfirmed_transaction(transaction).unwrap();
}
Expand Down
5 changes: 2 additions & 3 deletions node/src/beacon/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,7 @@ impl<N: Network, C: ConsensusStorage<N>> Beacon<N, C> {
let inputs = vec![Value::from_str(&format!("{to}"))?, Value::from_str(&format!("{amount}u64"))?];

// Create a new transaction.
let transaction = Transaction::execute(
beacon.ledger.vm(),
let transaction = beacon.ledger.vm().execute(
beacon.account.private_key(),
("credits.aleo", "mint"),
inputs.iter(),
Expand Down Expand Up @@ -471,7 +470,7 @@ mod tests {
// Initialize a new VM.
let vm = VM::from(ConsensusStore::<CurrentNetwork, ConsensusMemory<CurrentNetwork>>::open(None)?)?;
// Initialize the genesis block.
let genesis = Block::genesis(&vm, beacon_account.private_key(), &mut rng)?;
let genesis = vm.genesis(beacon_account.private_key(), &mut rng)?;

println!("Initializing beacon node...");

Expand Down

0 comments on commit dd7a212

Please sign in to comment.