diff --git a/rusk/src/lib/error.rs b/rusk/src/lib/error.rs index c38c4fcdf..4da2903a6 100644 --- a/rusk/src/lib/error.rs +++ b/rusk/src/lib/error.rs @@ -11,7 +11,7 @@ use dusk_core::{ signatures::bls::PublicKey as BlsPublicKey, transfer::phoenix::CoreError, BlsScalar, Error as ExecErr, }; -use dusk_vm::PiecrustError; +use dusk_vm::Error as VMError; #[derive(Debug)] pub enum Error { @@ -44,7 +44,7 @@ pub enum Error { /// Originating from Phoenix. Phoenix(CoreError), /// Piecrust VM internal Errors - Vm(PiecrustError), + Vm(VMError), /// IO Errors Io(io::Error), /// Failed to produce proper state @@ -70,8 +70,8 @@ impl From> for Error { } } -impl From for Error { - fn from(err: PiecrustError) -> Self { +impl From for Error { + fn from(err: VMError) -> Self { Error::Vm(err) } } diff --git a/rusk/src/lib/node/rusk.rs b/rusk/src/lib/node/rusk.rs index 7b82e854a..6f521eb4d 100644 --- a/rusk/src/lib/node/rusk.rs +++ b/rusk/src/lib/node/rusk.rs @@ -27,7 +27,7 @@ use dusk_core::transfer::{ TRANSFER_CONTRACT, }; use dusk_core::{BlsScalar, Dusk}; -use dusk_vm::{CallReceipt, PiecrustError, Session}; +use dusk_vm::{new_session, CallReceipt, Error as VMError, Session, VM}; use node::vm::bytecode_charge; use node_data::events::contract::{ContractEvent, ContractTxEvent}; use node_data::ledger::{Hash, Slash, SpentTransaction, Transaction}; @@ -85,7 +85,7 @@ impl Rusk { let mut base_commit = [0u8; 32]; base_commit.copy_from_slice(&base_commit_bytes); - let vm = Arc::new(dusk_vm::new_vm(dir)?); + let vm = Arc::new(VM::new(dir)?); let tip = Arc::new(RwLock::new(RuskTip { current: base_commit, @@ -219,9 +219,7 @@ impl Rusk { err, }); } - Err(PiecrustError::Panic(val)) - if val == PANIC_NONCE_NOT_READY => - { + Err(VMError::Panic(val)) if val == PANIC_NONCE_NOT_READY => { // If the transaction panic due to a not yet valid nonce, // we should not discard the transactions since it can be // included in future. @@ -537,12 +535,8 @@ impl Rusk { tip.current }); - let session = dusk_vm::new_session( - &self.vm, - commit, - self.chain_id, - block_height, - )?; + let session = + new_session(&self.vm, commit, self.chain_id, block_height)?; Ok(session) } @@ -769,7 +763,7 @@ fn execute( gas_per_deploy_byte: u64, min_deploy_points: u64, min_deployment_gas_price: u64, -) -> Result, ContractError>>, PiecrustError> { +) -> Result, ContractError>>, VMError> { // Transaction will be discarded if it is a deployment transaction // with gas limit smaller than deploy charge. if let Some(deploy) = tx.deploy() { @@ -779,14 +773,10 @@ fn execute( min_deploy_points, ); if tx.gas_price() < min_deployment_gas_price { - return Err(PiecrustError::Panic( - "gas price too low to deploy".into(), - )); + return Err(VMError::Panic("gas price too low to deploy".into())); } if tx.gas_limit() < deploy_charge { - return Err(PiecrustError::Panic( - "not enough gas to deploy".into(), - )); + return Err(VMError::Panic("not enough gas to deploy".into())); } } diff --git a/rusk/src/lib/verifier.rs b/rusk/src/lib/verifier.rs index 65cce3ec9..112d7cfce 100644 --- a/rusk/src/lib/verifier.rs +++ b/rusk/src/lib/verifier.rs @@ -13,6 +13,7 @@ use dusk_core::transfer::{ moonlight::Transaction as MoonlightTransaction, phoenix::Transaction as PhoenixTransaction, }; +use dusk_vm::host_queries; use rusk_profile::Circuit as CircuitProfile; use std::sync::LazyLock; @@ -48,7 +49,7 @@ pub fn verify_proof(tx: &PhoenixTransaction) -> Result { // Maybe we want to handle internal serialization error too, // currently they map to `false`. - Ok(dusk_vm::verify_plonk( + Ok(host_queries::verify_plonk( vd.to_vec(), tx.proof().to_vec(), tx.public_inputs(), @@ -57,7 +58,7 @@ pub fn verify_proof(tx: &PhoenixTransaction) -> Result { /// Verifies the signature of the incoming transaction. pub fn verify_signature(tx: &MoonlightTransaction) -> Result { - Ok(dusk_vm::verify_bls( + Ok(host_queries::verify_bls( tx.signature_message(), *tx.sender(), *tx.signature(), diff --git a/rusk/tests/services/contract_deployment.rs b/rusk/tests/services/contract_deployment.rs index 7d906435b..83c0fdd09 100644 --- a/rusk/tests/services/contract_deployment.rs +++ b/rusk/tests/services/contract_deployment.rs @@ -12,7 +12,7 @@ use dusk_core::abi::ContractId; use dusk_core::transfer::data::{ ContractBytecode, ContractDeploy, TransactionData, }; -use dusk_vm::{ContractData, PiecrustError}; +use dusk_vm::{new_session, ContractData, Error as VMError, VM}; use rand::prelude::*; use rand::rngs::StdRng; use rusk::gen_id::gen_contract_id; @@ -230,9 +230,9 @@ impl Fixture { pub fn assert_bob_contract_is_not_deployed(&self) { let commit = self.rusk.state_root(); - let vm = dusk_vm::new_vm(self.path.as_path()) - .expect("VM creation should succeed"); - let mut session = dusk_vm::new_session(&vm, commit, CHAIN_ID, 0) + let vm = + VM::new(self.path.as_path()).expect("VM creation should succeed"); + let mut session = new_session(&vm, commit, CHAIN_ID, 0) .expect("Session creation should succeed"); let result = session.call::<_, u64>( self.contract_id, @@ -241,16 +241,16 @@ impl Fixture { u64::MAX, ); match result.err() { - Some(PiecrustError::ContractDoesNotExist(_)) => (), + Some(VMError::ContractDoesNotExist(_)) => (), _ => assert!(false), } } pub fn assert_bob_contract_is_deployed(&self) { let commit = self.rusk.state_root(); - let vm = dusk_vm::new_vm(self.path.as_path()) - .expect("VM creation should succeed"); - let mut session = dusk_vm::new_session(&vm, commit, CHAIN_ID, 0) + let vm = + VM::new(self.path.as_path()).expect("VM creation should succeed"); + let mut session = new_session(&vm, commit, CHAIN_ID, 0) .expect("Session creation should succeed"); let result = session.call::<_, u64>( self.contract_id, diff --git a/rusk/tests/services/owner_calls.rs b/rusk/tests/services/owner_calls.rs index d22e65585..451614150 100644 --- a/rusk/tests/services/owner_calls.rs +++ b/rusk/tests/services/owner_calls.rs @@ -19,7 +19,7 @@ use dusk_core::signatures::bls::{ PublicKey as BlsPublicKey, SecretKey as BlsSecretKey, Signature as BlsSignature, }; -use dusk_vm::{CallReceipt, ContractData, Session}; +use dusk_vm::{new_session, CallReceipt, ContractData, Session, VM}; use rusk::gen_id::gen_contract_id; use rusk::{Error, Result, Rusk}; use rusk_recovery_tools::state; @@ -144,9 +144,9 @@ impl Fixture { pub fn assert_bob_contract_is_deployed(&self) { const BOB_ECHO_VALUE: u64 = 775; let commit = self.rusk.state_root(); - let vm = dusk_vm::new_vm(self.path.as_path()) - .expect("VM creation should succeed"); - let mut session = dusk_vm::new_session(&vm, commit, CHAIN_ID, 0) + let vm = + VM::new(self.path.as_path()).expect("VM creation should succeed"); + let mut session = new_session(&vm, commit, CHAIN_ID, 0) .expect("Session creation should succeed"); let result = session.call::<_, u64>( self.contract_id, @@ -168,10 +168,10 @@ impl Fixture { pub fn set_session(&mut self) { let commit = self.rusk.state_root(); - let vm = dusk_vm::new_vm(self.path.as_path()) - .expect("VM creation should succeed"); + let vm = + VM::new(self.path.as_path()).expect("VM creation should succeed"); self.session = Some( - dusk_vm::new_session(&vm, commit, CHAIN_ID, 0) + new_session(&vm, commit, CHAIN_ID, 0) .expect("Session creation should succeed"), ); } diff --git a/rusk/tests/services/transfer.rs b/rusk/tests/services/transfer.rs index b3bb262d7..c618119e9 100644 --- a/rusk/tests/services/transfer.rs +++ b/rusk/tests/services/transfer.rs @@ -78,7 +78,7 @@ fn wallet_transfer( info!("Tx: {}", hex::encode(tx.to_var_bytes())); let tx_hash_input_bytes = tx.to_hash_input_bytes(); - let tx_id = dusk_vm::hash(tx_hash_input_bytes); + let tx_id = dusk_vm::host_queries::hash(tx_hash_input_bytes); info!("Tx ID: {}", hex::encode(tx_id.to_bytes())); let txs: Vec = generator_procedure(