diff --git a/rusk/src/lib/node/vm/config.rs b/rusk/src/lib/node/vm/config.rs index 6c8d1378f..4ed6bc581 100644 --- a/rusk/src/lib/node/vm/config.rs +++ b/rusk/src/lib/node/vm/config.rs @@ -39,7 +39,7 @@ impl Default for Config { } impl Config { - pub const fn new() -> Self { + pub fn new() -> Self { Self { gas_per_deploy_byte: DEFAULT_GAS_PER_DEPLOY_BYTE, min_deploy_gas_price: DEFAULT_MIN_DEPLOYMENT_GAS_PRICE, diff --git a/rusk/tests/common/state.rs b/rusk/tests/common/state.rs index aaab1526a..de4a75357 100644 --- a/rusk/tests/common/state.rs +++ b/rusk/tests/common/state.rs @@ -31,7 +31,6 @@ use tokio::sync::broadcast; use tracing::info; const CHAIN_ID: u8 = 0xFA; -pub const DEFAULT_VM_CONFIG: RuskVmConfig = RuskVmConfig::new(); pub const DEFAULT_MIN_GAS_LIMIT: u64 = 75000; // Creates a Rusk initial state in the given directory diff --git a/rusk/tests/services/contract_deployment.rs b/rusk/tests/services/contract_deployment.rs index 7f2d76ecb..916f2357d 100644 --- a/rusk/tests/services/contract_deployment.rs +++ b/rusk/tests/services/contract_deployment.rs @@ -25,7 +25,6 @@ use tracing::info; use crate::common::logger; use crate::common::state::{ generator_procedure, ExecuteResult, DEFAULT_MIN_GAS_LIMIT, - DEFAULT_VM_CONFIG, }; use crate::common::wallet::{ test_wallet as wallet, TestStateClient, TestStore, Wallet, @@ -105,7 +104,7 @@ fn initial_state>(dir: P, deploy_bob: bool) -> Result { let rusk = Rusk::new( dir, CHAIN_ID, - DEFAULT_VM_CONFIG, + RuskVmConfig::new(), DEFAULT_MIN_GAS_LIMIT, u64::MAX, sender, diff --git a/rusk/tests/services/contract_stake.rs b/rusk/tests/services/contract_stake.rs index f5bde8123..9f7778898 100644 --- a/rusk/tests/services/contract_stake.rs +++ b/rusk/tests/services/contract_stake.rs @@ -31,8 +31,6 @@ use crate::common::*; const BLOCK_HEIGHT: u64 = 1; const BLOCK_GAS_LIMIT: u64 = 100_000_000_000; -const VM_CONFIG: RuskVmConfig = - RuskVmConfig::new().with_block_gas_limit(BLOCK_GAS_LIMIT); const GAS_LIMIT: u64 = 10_000_000_000; const GAS_PRICE: u64 = 1; @@ -42,8 +40,9 @@ fn stake_state>(dir: P) -> Result { let snapshot = toml::from_str(include_str!("../config/stake_from_contract.toml")) .expect("Cannot deserialize config"); + let vm_config = RuskVmConfig::new().with_block_gas_limit(BLOCK_GAS_LIMIT); - new_state(dir, &snapshot, VM_CONFIG) + new_state(dir, &snapshot, vm_config) } #[tokio::test(flavor = "multi_thread")] diff --git a/rusk/tests/services/conversion.rs b/rusk/tests/services/conversion.rs index 28c6783ed..96399c8a8 100644 --- a/rusk/tests/services/conversion.rs +++ b/rusk/tests/services/conversion.rs @@ -22,8 +22,6 @@ use crate::common::wallet::{ }; const BLOCK_GAS_LIMIT: u64 = 100_000_000_000; -const VM_CONFIG: RuskVmConfig = - RuskVmConfig::new().with_block_gas_limit(BLOCK_GAS_LIMIT); const INITIAL_PHOENIX_BALANCE: u64 = 10_000_000_000; const INITIAL_MOONLIGHT_BALANCE: u64 = 10_000_000_000; @@ -32,8 +30,9 @@ const INITIAL_MOONLIGHT_BALANCE: u64 = 10_000_000_000; fn initial_state>(dir: P) -> Result { let snapshot = toml::from_str(include_str!("../config/convert.toml")) .expect("Cannot deserialize config"); + let vm_config = RuskVmConfig::new().with_block_gas_limit(BLOCK_GAS_LIMIT); - new_state(dir, &snapshot, VM_CONFIG) + new_state(dir, &snapshot, vm_config) } /// Makes a transaction that converts Dusk from Phoenix to Moonlight, and diff --git a/rusk/tests/services/finalization.rs b/rusk/tests/services/finalization.rs index c83a6fc44..fdccf37df 100644 --- a/rusk/tests/services/finalization.rs +++ b/rusk/tests/services/finalization.rs @@ -12,8 +12,6 @@ use tempfile::tempdir; use crate::common::state::{generator_procedure2, new_state}; const BLOCK_GAS_LIMIT: u64 = 24_000_000; -const VM_CONFIG: RuskVmConfig = - RuskVmConfig::new().with_block_gas_limit(BLOCK_GAS_LIMIT); const BLOCKS_NUM: u64 = 10; // Creates the Rusk initial state for the tests below @@ -21,8 +19,9 @@ fn initial_state>(dir: P) -> Result { let snapshot = toml::from_str(include_str!("../config/multi_transfer.toml")) .expect("Cannot deserialize config"); + let vm_config = RuskVmConfig::new().with_block_gas_limit(BLOCK_GAS_LIMIT); - new_state(dir, &snapshot, VM_CONFIG) + new_state(dir, &snapshot, vm_config) } #[tokio::test(flavor = "multi_thread")] diff --git a/rusk/tests/services/gas_behavior.rs b/rusk/tests/services/gas_behavior.rs index 5596bcc0b..cc3ba2f88 100644 --- a/rusk/tests/services/gas_behavior.rs +++ b/rusk/tests/services/gas_behavior.rs @@ -27,8 +27,6 @@ use crate::common::wallet::{ const BLOCK_HEIGHT: u64 = 1; const BLOCK_GAS_LIMIT: u64 = 1_000_000_000_000; -const VM_CONFIG: RuskVmConfig = - RuskVmConfig::new().with_block_gas_limit(BLOCK_GAS_LIMIT); const INITIAL_BALANCE: u64 = 10_000_000_000; @@ -41,8 +39,9 @@ const DEPOSIT: u64 = 0; fn initial_state>(dir: P) -> Result { let snapshot = toml::from_str(include_str!("../config/gas-behavior.toml")) .expect("Cannot deserialize config"); + let vm_config = RuskVmConfig::new().with_block_gas_limit(BLOCK_GAS_LIMIT); - new_state(dir, &snapshot, VM_CONFIG) + new_state(dir, &snapshot, vm_config) } const SENDER_INDEX_0: u8 = 0; diff --git a/rusk/tests/services/moonlight_stake.rs b/rusk/tests/services/moonlight_stake.rs index e48a04a75..057eac977 100644 --- a/rusk/tests/services/moonlight_stake.rs +++ b/rusk/tests/services/moonlight_stake.rs @@ -25,8 +25,6 @@ use crate::common::*; const BLOCK_HEIGHT: u64 = 1; const BLOCK_GAS_LIMIT: u64 = 100_000_000_000; -const VM_CONFIG: RuskVmConfig = - RuskVmConfig::new().with_block_gas_limit(BLOCK_GAS_LIMIT); const GAS_LIMIT: u64 = 10_000_000_000; const GAS_PRICE: u64 = 1; @@ -34,8 +32,9 @@ const GAS_PRICE: u64 = 1; fn stake_state>(dir: P) -> Result { let snapshot = toml::from_str(include_str!("../config/stake.toml")) .expect("Cannot deserialize config"); + let vm_config = RuskVmConfig::new().with_block_gas_limit(BLOCK_GAS_LIMIT); - new_state(dir, &snapshot, VM_CONFIG) + new_state(dir, &snapshot, vm_config) } /// Stakes an amount Dusk and produces a block with this single transaction, diff --git a/rusk/tests/services/multi_transfer.rs b/rusk/tests/services/multi_transfer.rs index 2532738d7..c80970499 100644 --- a/rusk/tests/services/multi_transfer.rs +++ b/rusk/tests/services/multi_transfer.rs @@ -25,8 +25,6 @@ const BLOCK_HEIGHT: u64 = 1; // This is purposefully chosen to be low to trigger the discarding of a // perfectly good transaction. const BLOCK_GAS_LIMIT: u64 = 24_000_000; -const VM_CONFIG: RuskVmConfig = - RuskVmConfig::new().with_block_gas_limit(BLOCK_GAS_LIMIT); const GAS_LIMIT: u64 = 12_000_000; // Lowest value for a transfer const INITIAL_BALANCE: u64 = 10_000_000_000; @@ -41,8 +39,9 @@ fn initial_state>(dir: P) -> Result { let snapshot = toml::from_str(include_str!("../config/multi_transfer.toml")) .expect("Cannot deserialize config"); + let vm_config = RuskVmConfig::new().with_block_gas_limit(BLOCK_GAS_LIMIT); - new_state(dir, &snapshot, VM_CONFIG) + new_state(dir, &snapshot, vm_config) } // Creates the Rusk initial state for the tests below @@ -50,8 +49,9 @@ fn initial_state_deploy>(dir: P) -> Result { let snapshot = toml::from_str(include_str!("../config/multi_transfer_deploy.toml")) .expect("Cannot deserialize config"); + let vm_config = RuskVmConfig::new().with_block_gas_limit(BLOCK_GAS_LIMIT); - new_state(dir, &snapshot, VM_CONFIG) + new_state(dir, &snapshot, vm_config) } /// Executes three different transactions in the same block, expecting only two diff --git a/rusk/tests/services/owner_calls.rs b/rusk/tests/services/owner_calls.rs index 44e7e91f1..941561601 100644 --- a/rusk/tests/services/owner_calls.rs +++ b/rusk/tests/services/owner_calls.rs @@ -10,6 +10,7 @@ use rand::rngs::StdRng; use rand::SeedableRng; use rkyv::validation::validators::DefaultValidator; use rkyv::{Archive, Deserialize, Infallible, Serialize}; +use rusk::node::RuskVmConfig; use std::collections::HashMap; use std::path::{Path, PathBuf}; use std::sync::{Arc, RwLock}; @@ -27,7 +28,7 @@ use tokio::sync::broadcast; use tracing::info; use crate::common::logger; -use crate::common::state::{DEFAULT_MIN_GAS_LIMIT, DEFAULT_VM_CONFIG}; +use crate::common::state::DEFAULT_MIN_GAS_LIMIT; use crate::common::wallet::{ test_wallet as wallet, test_wallet::Wallet, TestStateClient, TestStore, }; @@ -79,7 +80,7 @@ fn initial_state>( let rusk = Rusk::new( dir, CHAIN_ID, - DEFAULT_VM_CONFIG, + RuskVmConfig::new(), DEFAULT_MIN_GAS_LIMIT, u64::MAX, sender, diff --git a/rusk/tests/services/phoenix_stake.rs b/rusk/tests/services/phoenix_stake.rs index c3c539691..d8b73c282 100644 --- a/rusk/tests/services/phoenix_stake.rs +++ b/rusk/tests/services/phoenix_stake.rs @@ -31,8 +31,6 @@ use crate::common::*; const BLOCK_HEIGHT: u64 = 1; const BLOCK_GAS_LIMIT: u64 = 100_000_000_000; -const VM_CONFIG: RuskVmConfig = - RuskVmConfig::new().with_block_gas_limit(BLOCK_GAS_LIMIT); const GAS_LIMIT: u64 = 10_000_000_000; const GAS_PRICE: u64 = 1; const DEPOSIT: u64 = 0; @@ -41,16 +39,18 @@ const DEPOSIT: u64 = 0; fn stake_state>(dir: P) -> Result { let snapshot = toml::from_str(include_str!("../config/stake.toml")) .expect("Cannot deserialize config"); + let vm_config = RuskVmConfig::new().with_block_gas_limit(BLOCK_GAS_LIMIT); - new_state(dir, &snapshot, VM_CONFIG) + new_state(dir, &snapshot, vm_config) } // Creates the Rusk initial state for the tests below fn slash_state>(dir: P) -> Result { let snapshot = toml::from_str(include_str!("../config/slash.toml")) .expect("Cannot deserialize config"); + let vm_config = RuskVmConfig::new().with_block_gas_limit(BLOCK_GAS_LIMIT); - new_state(dir, &snapshot, VM_CONFIG) + new_state(dir, &snapshot, vm_config) } /// Stakes an amount Dusk and produces a block with this single transaction, diff --git a/rusk/tests/services/unspendable.rs b/rusk/tests/services/unspendable.rs index 1ef140c48..0b57fdaf1 100644 --- a/rusk/tests/services/unspendable.rs +++ b/rusk/tests/services/unspendable.rs @@ -27,8 +27,6 @@ use crate::common::wallet::{ const BLOCK_HEIGHT: u64 = 1; const BLOCK_GAS_LIMIT: u64 = 1_000_000_000_000; -const VM_CONFIG: RuskVmConfig = - RuskVmConfig::new().with_block_gas_limit(BLOCK_GAS_LIMIT); const INITIAL_BALANCE: u64 = 10_000_000_000; const GAS_LIMIT_0: u64 = 20_000_000; // Enough to spend, but OOG during ICC @@ -41,8 +39,9 @@ const DEPOSIT: u64 = 0; fn initial_state>(dir: P) -> Result { let snapshot = toml::from_str(include_str!("../config/unspendable.toml")) .expect("Cannot deserialize config"); + let vm_config = RuskVmConfig::new().with_block_gas_limit(BLOCK_GAS_LIMIT); - new_state(dir, &snapshot, VM_CONFIG) + new_state(dir, &snapshot, vm_config) } const SENDER_INDEX_0: u8 = 0;