Skip to content

Commit

Permalink
rusk: Move new_session and new_genesis_session under VM
Browse files Browse the repository at this point in the history
  • Loading branch information
moCello committed Dec 22, 2024
1 parent 4a57371 commit 9b98d54
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
9 changes: 3 additions & 6 deletions rusk/src/lib/node/rusk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ use dusk_core::transfer::{
moonlight::AccountData, PANIC_NONCE_NOT_READY, TRANSFER_CONTRACT,
};
use dusk_core::{BlsScalar, Dusk};
use dusk_vm::{
execute, new_session, CallReceipt, Error as VMError, Session, VM,
};
use dusk_vm::{execute, CallReceipt, Error as VMError, Session, VM};
use node::DUSK_CONSENSUS_KEY;
use node_data::events::contract::{ContractEvent, ContractTxEvent};
use node_data::ledger::{Hash, Slash, SpentTransaction, Transaction};
Expand Down Expand Up @@ -528,8 +526,7 @@ impl Rusk {
tip.current
});

let session =
new_session(&self.vm, commit, self.chain_id, block_height)?;
let session = self.vm.session(commit, self.chain_id, block_height)?;

Ok(session)
}
Expand All @@ -548,7 +545,7 @@ impl Rusk {
for d in to_merge {
if d == base {
// Don't finalize the new tip, otherwise it will not be
// aceessible anymore
// accessible anymore
continue;
};
self.vm.finalize_commit(d)?;
Expand Down
6 changes: 3 additions & 3 deletions rusk/tests/rusk-state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ where

rusk.with_tip(|mut tip, vm| {
let current_commit = tip.current;
let mut session =
dusk_vm::new_session(vm, current_commit, CHAIN_ID, BLOCK_HEIGHT)
.expect("current commit should exist");
let mut session = vm
.session(current_commit, CHAIN_ID, BLOCK_HEIGHT)
.expect("current commit should exist");

session
.call::<_, Note>(
Expand Down
8 changes: 5 additions & 3 deletions rusk/tests/services/contract_deployment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use dusk_core::abi::{gen_contract_id, ContractId};
use dusk_core::transfer::data::{
ContractBytecode, ContractDeploy, TransactionData,
};
use dusk_vm::{new_session, ContractData, Error as VMError, VM};
use dusk_vm::{ContractData, Error as VMError, VM};
use rand::prelude::*;
use rand::rngs::StdRng;
use rusk::{Result, Rusk};
Expand Down Expand Up @@ -231,7 +231,8 @@ impl Fixture {
let commit = self.rusk.state_root();
let vm =
VM::new(self.path.as_path()).expect("VM creation should succeed");
let mut session = new_session(&vm, commit, CHAIN_ID, 0)
let mut session = vm
.session(commit, CHAIN_ID, 0)
.expect("Session creation should succeed");
let result = session.call::<_, u64>(
self.contract_id,
Expand All @@ -249,7 +250,8 @@ impl Fixture {
let commit = self.rusk.state_root();
let vm =
VM::new(self.path.as_path()).expect("VM creation should succeed");
let mut session = new_session(&vm, commit, CHAIN_ID, 0)
let mut session = vm
.session(commit, CHAIN_ID, 0)
.expect("Session creation should succeed");
let result = session.call::<_, u64>(
self.contract_id,
Expand Down
7 changes: 4 additions & 3 deletions rusk/tests/services/owner_calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use dusk_core::signatures::bls::{
PublicKey as BlsPublicKey, SecretKey as BlsSecretKey,
Signature as BlsSignature,
};
use dusk_vm::{new_session, CallReceipt, ContractData, Session, VM};
use dusk_vm::{CallReceipt, ContractData, Session, VM};
use rusk::{Error, Result, Rusk};
use rusk_recovery_tools::state;
use tempfile::tempdir;
Expand Down Expand Up @@ -145,7 +145,8 @@ impl Fixture {
let commit = self.rusk.state_root();
let vm =
VM::new(self.path.as_path()).expect("VM creation should succeed");
let mut session = new_session(&vm, commit, CHAIN_ID, 0)
let mut session = vm
.session(commit, CHAIN_ID, 0)
.expect("Session creation should succeed");
let result = session.call::<_, u64>(
self.contract_id,
Expand All @@ -170,7 +171,7 @@ impl Fixture {
let vm =
VM::new(self.path.as_path()).expect("VM creation should succeed");
self.session = Some(
new_session(&vm, commit, CHAIN_ID, 0)
vm.session(commit, CHAIN_ID, 0)
.expect("Session creation should succeed"),
);
}
Expand Down

0 comments on commit 9b98d54

Please sign in to comment.