diff --git a/CHANGELOG.md b/CHANGELOG.md index 6563f6120d..a92b2da3db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,10 +6,20 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] -- [#514](https://github.com/FuelLabs/fuel-vm/pull/514/): Add `ClientId` and `GasCosts` to `ConsensusParameters`. +### Changed + +#### Breaking + +- [#514](https://github.com/FuelLabs/fuel-vm/pull/514/): Add `ChainId` and `GasCosts` to `ConsensusParameters`. Break down `ConsensusParameters` into sub-structs to match usage. Change signatures of functions to ask for necessary fields only. +### Fixed + +#### Breaking + +- [#527](https://github.com/FuelLabs/fuel-vm/pull/527): The balances are empty during predicate estimation/verification. + ## [Version 0.35.1] ### Added diff --git a/fuel-tx/src/builder.rs b/fuel-tx/src/builder.rs index 5ac0035a02..ac51b58555 100644 --- a/fuel-tx/src/builder.rs +++ b/fuel-tx/src/builder.rs @@ -201,14 +201,11 @@ impl TransactionBuilder { let should_prepare_predicate = false; let sign_keys = HashMap::new(); - // TODO: What is a default chain id? - let chain_id = ChainId::default(); - Self { tx, should_prepare_script, should_prepare_predicate, - params: ConsensusParameters::standard(chain_id), + params: ConsensusParameters::standard(), sign_keys, } } diff --git a/fuel-tx/src/tests/offset.rs b/fuel-tx/src/tests/offset.rs index 3fa8605cf1..c236cde346 100644 --- a/fuel-tx/src/tests/offset.rs +++ b/fuel-tx/src/tests/offset.rs @@ -469,8 +469,7 @@ fn iow_offset() { let bytes = tx.to_bytes(); let mut tx_p = tx.clone(); - let chain_id = ChainId::default(); - tx_p.precompute(&chain_id) + tx_p.precompute(&ChainId::default()) .expect("Should be able to calculate cache"); tx.inputs().iter().enumerate().for_each(|(x, i)| { diff --git a/fuel-tx/src/tests/valid_cases/input.rs b/fuel-tx/src/tests/valid_cases/input.rs index ed9692092c..5b63a03490 100644 --- a/fuel-tx/src/tests/valid_cases/input.rs +++ b/fuel-tx/src/tests/valid_cases/input.rs @@ -156,10 +156,7 @@ fn coin_signed() { let block_height = rng.gen(); let err = tx - .check( - block_height, - &ConsensusParameters::standard(Default::default()), - ) + .check(block_height, &ConsensusParameters::standard()) .expect_err("Expected failure"); assert_eq!(CheckError::InputWitnessIndexBounds { index: 0 }, err); @@ -212,8 +209,7 @@ fn coin_predicate() { let txhash: Bytes32 = rng.gen(); let predicate = generate_nonempty_padded_bytes(rng); - let chain_id = ChainId::default(); - let owner = Input::predicate_owner(&predicate, &chain_id); + let owner = Input::predicate_owner(&predicate, &ChainId::default()); Input::coin_predicate( rng.gen(), @@ -238,8 +234,7 @@ fn coin_predicate() { .unwrap(); let predicate = vec![]; - let chain_id = ChainId::default(); - let owner = Input::predicate_owner(&predicate, &chain_id); + let owner = Input::predicate_owner(&predicate, &ChainId::default()); let err = Input::coin_predicate( rng.gen(), @@ -420,13 +415,12 @@ fn message_metadata() { let block_height = rng.gen(); let err = tx - .check(block_height, &ConsensusParameters::standard(chain_id)) + .check(block_height, &ConsensusParameters::standard()) .expect_err("Expected failure"); assert_eq!(CheckError::InputWitnessIndexBounds { index: 0 }, err,); let mut predicate = generate_nonempty_padded_bytes(rng); - let chain_id = ChainId::default(); let recipient = Input::predicate_owner(&predicate, &chain_id); predicate[0] = predicate[0].wrapping_add(1); @@ -588,14 +582,13 @@ fn message_message_coin() { let block_height = rng.gen(); let err = tx - .check(block_height, &ConsensusParameters::standard(chain_id)) + .check(block_height, &ConsensusParameters::standard()) .expect_err("Expected failure"); assert_eq!(CheckError::InputWitnessIndexBounds { index: 0 }, err,); let mut predicate = generate_nonempty_padded_bytes(rng); - let chain_id = ChainId::default(); - let recipient = Input::predicate_owner(&predicate, &chain_id); + let recipient = Input::predicate_owner(&predicate, &ChainId::default()); predicate[0] = predicate[0].wrapping_add(1); let err = Input::message_coin_predicate( @@ -699,10 +692,7 @@ fn transaction_with_duplicate_coin_inputs_is_invalid() { .add_input(b) .add_witness(rng.gen()) .finalize() - .check_without_signatures( - Default::default(), - &ConsensusParameters::standard(ChainId::default()), - ) + .check_without_signatures(Default::default(), &ConsensusParameters::standard()) .expect_err("Expected checkable failure"); assert_eq!(err, CheckError::DuplicateInputUtxoId { utxo_id }); @@ -739,7 +729,7 @@ fn transaction_with_duplicate_message_inputs_is_invalid() { .finalize() .check_without_signatures( Default::default(), - &ConsensusParameters::standard(ChainId::default()), + &ConsensusParameters::standard(), ) .expect_err("Expected checkable failure"); @@ -773,10 +763,7 @@ fn transaction_with_duplicate_contract_inputs_is_invalid() { .add_output(o) .add_output(p) .finalize() - .check_without_signatures( - Default::default(), - &ConsensusParameters::standard(ChainId::default()), - ) + .check_without_signatures(Default::default(), &ConsensusParameters::standard()) .expect_err("Expected checkable failure"); assert_eq!(err, CheckError::DuplicateInputContractId { contract_id }); @@ -810,9 +797,6 @@ fn transaction_with_duplicate_contract_utxo_id_is_valid() { .add_output(p) .add_witness(rng.gen()) .finalize() - .check_without_signatures( - Default::default(), - &ConsensusParameters::standard(ChainId::default()), - ) + .check_without_signatures(Default::default(), &ConsensusParameters::standard()) .expect("Duplicated UTXO id is valid for contract input"); } diff --git a/fuel-tx/src/transaction/consensus_parameters.rs b/fuel-tx/src/transaction/consensus_parameters.rs index 1e388d6254..85a677efd5 100644 --- a/fuel-tx/src/transaction/consensus_parameters.rs +++ b/fuel-tx/src/transaction/consensus_parameters.rs @@ -32,13 +32,26 @@ pub struct ConsensusParameters { impl Default for ConsensusParameters { fn default() -> Self { - Self::standard(ChainId::default()) + Self::standard() } } impl ConsensusParameters { - /// Constructor for the `ConsensusParameters` with Standard values - pub fn standard(chain_id: ChainId) -> Self { + /// Constructor for the `ConsensusParameters` with Standard values. + pub fn standard() -> Self { + Self { + tx_params: TxParameters::DEFAULT, + predicate_params: PredicateParameters::DEFAULT, + script_params: ScriptParameters::DEFAULT, + contract_params: ContractParameters::DEFAULT, + fee_params: FeeParameters::DEFAULT, + chain_id: ChainId::default(), + gas_costs: GasCosts::default(), + } + } + + /// Constructor for the `ConsensusParameters` with Standard values around `ChainId`. + pub fn standard_with_id(chain_id: ChainId) -> Self { Self { tx_params: TxParameters::DEFAULT, predicate_params: PredicateParameters::DEFAULT, diff --git a/fuel-tx/src/transaction/types/create.rs b/fuel-tx/src/transaction/types/create.rs index b711d662d0..efe6c435c4 100644 --- a/fuel-tx/src/transaction/types/create.rs +++ b/fuel-tx/src/transaction/types/create.rs @@ -932,7 +932,7 @@ mod tests { tx.storage_slots.reverse(); let err = tx - .check(0.into(), &ConsensusParameters::standard(ChainId::default())) + .check(0.into(), &ConsensusParameters::standard()) .expect_err("Expected erroneous transaction"); assert_eq!(CheckError::TransactionCreateStorageSlotOrder, err); @@ -952,7 +952,7 @@ mod tests { ) .add_random_fee_input() .finalize() - .check(0.into(), &ConsensusParameters::standard(ChainId::default())) + .check(0.into(), &ConsensusParameters::standard()) .expect_err("Expected erroneous transaction"); assert_eq!(CheckError::TransactionCreateStorageSlotOrder, err); diff --git a/fuel-tx/src/transaction/types/script.rs b/fuel-tx/src/transaction/types/script.rs index 5141c34fb4..0b24643740 100644 --- a/fuel-tx/src/transaction/types/script.rs +++ b/fuel-tx/src/transaction/types/script.rs @@ -1,6 +1,7 @@ use crate::{ transaction::{ compute_transaction_id, + consensus_parameters::TxParameters, field::{ GasLimit, GasPrice, @@ -42,7 +43,6 @@ use fuel_types::{ Word, }; -use crate::transaction::consensus_parameters::TxParameters; #[cfg(feature = "alloc")] use alloc::vec::Vec; #[cfg(feature = "std")] diff --git a/fuel-tx/src/transaction/validity.rs b/fuel-tx/src/transaction/validity.rs index 6844a1d237..6aac7b2f2d 100644 --- a/fuel-tx/src/transaction/validity.rs +++ b/fuel-tx/src/transaction/validity.rs @@ -303,9 +303,7 @@ impl FormatValidityChecks for Transaction { pub(crate) fn check_common_part( tx: &T, block_height: BlockHeight, - // tx_params: &TxParameters, - // predicate_params: &PredicateParameters, ) -> Result<(), CheckError> where diff --git a/fuel-vm/src/checked_transaction.rs b/fuel-vm/src/checked_transaction.rs index d847989217..b366fd5e6a 100644 --- a/fuel-vm/src/checked_transaction.rs +++ b/fuel-vm/src/checked_transaction.rs @@ -30,15 +30,8 @@ pub mod types; pub use types::*; use crate::{ - checked_transaction::balances::{ - initial_free_balances, - AvailableBalances, - }, error::PredicateVerificationFailed, - interpreter::{ - CheckedMetadata as CheckedMetadataAccessTrait, - InitialBalances, - }, + interpreter::CheckedMetadata as CheckedMetadataAccessTrait, prelude::*, }; @@ -140,10 +133,7 @@ where { fn default() -> Self { Tx::default() - .into_checked( - Default::default(), - &ConsensusParameters::standard(ChainId::default()), - ) + .into_checked(Default::default(), &ConsensusParameters::standard()) .expect("default tx should produce a valid fully checked transaction") } } @@ -232,17 +222,13 @@ pub struct CheckPredicateParams { impl Default for CheckPredicateParams { fn default() -> Self { - CheckPredicateParams { - gas_costs: Default::default(), - chain_id: Default::default(), - max_gas_per_predicate: PredicateParameters::DEFAULT.max_gas_per_predicate, - max_gas_per_tx: TxParameters::DEFAULT.max_gas_per_tx, - max_inputs: TxParameters::DEFAULT.max_inputs, - contract_max_size: ContractParameters::DEFAULT.contract_max_size, - max_message_data_length: PredicateParameters::DEFAULT.max_message_data_length, - tx_offset: TxParameters::DEFAULT.tx_offset(), - fee_params: Default::default(), - } + CheckPredicateParams::from(&ConsensusParameters::standard()) + } +} + +impl From for CheckPredicateParams { + fn from(value: ConsensusParameters) -> Self { + CheckPredicateParams::from(&value) } } @@ -360,19 +346,7 @@ impl EstimatePredicates for T &mut self, params: &CheckPredicateParams, ) -> Result<(), CheckError> { - // validate fees and compute free balances - let AvailableBalances { - non_retryable_balances, - retryable_balance, - .. - } = initial_free_balances(self, ¶ms.fee_params)?; - - let balances: InitialBalances = InitialBalances { - non_retryable: NonRetryableFreeBalances(non_retryable_balances), - retryable: Some(RetryableAmount(retryable_balance)), - }; - - Interpreter::::estimate_predicates(self, balances, params)?; + Interpreter::::estimate_predicates(self, params)?; Ok(()) } @@ -383,22 +357,8 @@ impl EstimatePredicates for T where E: ParallelExecutor, { - // validate fees and compute free balances - let AvailableBalances { - non_retryable_balances, - retryable_balance, - .. - } = initial_free_balances(self, ¶ms.fee_params)?; - - let balances: InitialBalances = InitialBalances { - non_retryable: NonRetryableFreeBalances(non_retryable_balances), - retryable: Some(RetryableAmount(retryable_balance)), - }; - - Interpreter::::estimate_predicates_async::<_, E>( - self, balances, params, - ) - .await?; + Interpreter::::estimate_predicates_async::<_, E>(self, params) + .await?; Ok(()) } @@ -662,6 +622,18 @@ mod tests { SeedableRng, }; + fn params(factor: u64) -> ConsensusParameters { + ConsensusParameters::new( + TxParameters::default(), + PredicateParameters::default(), + ScriptParameters::default(), + ContractParameters::default(), + FeeParameters::default().with_gas_price_factor(factor), + Default::default(), + Default::default(), + ) + } + #[test] fn checked_tx_accepts_valid_tx() { // simple smoke test that valid txs can be checked @@ -674,10 +646,7 @@ mod tests { let checked = tx .clone() - .into_checked( - Default::default(), - &ConsensusParameters::standard(Default::default()), - ) + .into_checked(Default::default(), &ConsensusParameters::standard()) .expect("Expected valid transaction"); // verify transaction getter works @@ -699,10 +668,7 @@ mod tests { let tx = signed_message_coin_tx(rng, gas_price, gas_limit, input_amount); let checked = tx - .into_checked( - Default::default(), - &ConsensusParameters::standard(Default::default()), - ) + .into_checked(Default::default(), &ConsensusParameters::standard()) .expect("Expected valid transaction"); // verify available balance was decreased by max fee @@ -722,10 +688,7 @@ mod tests { let tx = signed_message_coin_tx(rng, gas_price, gas_limit, input_amount); let checked = tx - .into_checked( - Default::default(), - &ConsensusParameters::standard(Default::default()), - ) + .into_checked(Default::default(), &ConsensusParameters::standard()) .expect("Expected valid transaction"); // verify available balance was decreased by max fee @@ -751,10 +714,7 @@ mod tests { .finalize(); let err = tx - .into_checked( - Default::default(), - &ConsensusParameters::standard(Default::default()), - ) + .into_checked(Default::default(), &ConsensusParameters::standard()) .expect_err("Expected valid transaction"); // verify available balance was decreased by max fee @@ -792,10 +752,7 @@ mod tests { .finalize(); let err = tx - .into_checked( - Default::default(), - &ConsensusParameters::standard(Default::default()), - ) + .into_checked(Default::default(), &ConsensusParameters::standard()) .expect_err("Expected valid transaction"); // verify available balance was decreased by max fee @@ -958,10 +915,7 @@ mod tests { .finalize(); let checked = tx - .into_checked( - Default::default(), - &ConsensusParameters::standard(Default::default()), - ) + .into_checked(Default::default(), &ConsensusParameters::standard()) .expect_err("Expected invalid transaction"); // assert that tx without base input assets fails @@ -985,21 +939,7 @@ mod tests { let transaction = base_asset_tx(rng, input_amount, gas_price, gas_limit); - let tx_params = TxParameters::default(); - let predicate_params = PredicateParameters::default(); - let script_params = ScriptParameters::default(); - let contract_params = ContractParameters::default(); - let fee_params = FeeParameters::default().with_gas_price_factor(factor); - - let consensus_params = ConsensusParameters::new( - tx_params, - predicate_params, - script_params, - contract_params, - fee_params, - Default::default(), - Default::default(), - ); + let consensus_params = params(factor); let err = transaction .into_checked(Default::default(), &consensus_params) @@ -1025,21 +965,7 @@ mod tests { let transaction = base_asset_tx(rng, input_amount, gas_price, gas_limit); - let tx_params = TxParameters::default(); - let predicate_params = PredicateParameters::default(); - let script_params = ScriptParameters::default(); - let contract_params = ContractParameters::default(); - let fee_params = FeeParameters::default().with_gas_price_factor(factor); - - let consensus_params = ConsensusParameters::new( - tx_params, - predicate_params, - script_params, - contract_params, - fee_params, - Default::default(), - Default::default(), - ); + let consensus_params = params(factor); let err = transaction .into_checked(Default::default(), &consensus_params) @@ -1062,21 +988,7 @@ mod tests { let gas_limit = 0; // ensure only bytes are included in fee let transaction = base_asset_tx(rng, input_amount, gas_price, gas_limit); - let tx_params = TxParameters::default(); - let predicate_params = PredicateParameters::default(); - let script_params = ScriptParameters::default(); - let contract_params = ContractParameters::default(); - let fee_params = FeeParameters::default().with_gas_price_factor(1); - - let consensus_params = ConsensusParameters::new( - tx_params, - predicate_params, - script_params, - contract_params, - fee_params, - Default::default(), - Default::default(), - ); + let consensus_params = params(1); let err = transaction .into_checked(Default::default(), &consensus_params) @@ -1094,21 +1006,7 @@ mod tests { let transaction = base_asset_tx(rng, input_amount, gas_price, gas_limit); - let tx_params = TxParameters::default(); - let predicate_params = PredicateParameters::default(); - let script_params = ScriptParameters::default(); - let contract_params = ContractParameters::default(); - let fee_params = FeeParameters::default().with_gas_price_factor(1); - - let consensus_params = ConsensusParameters::new( - tx_params, - predicate_params, - script_params, - contract_params, - fee_params, - Default::default(), - Default::default(), - ); + let consensus_params = params(1); let err = transaction .into_checked(Default::default(), &consensus_params) @@ -1150,10 +1048,7 @@ mod tests { .finalize(); let checked = tx - .into_checked( - Default::default(), - &ConsensusParameters::standard(Default::default()), - ) + .into_checked(Default::default(), &ConsensusParameters::standard()) .expect_err("Expected valid transaction"); assert_eq!( @@ -1173,10 +1068,7 @@ mod tests { let tx = Transaction::default_test_tx(); // Sets Checks::Basic let checked = tx - .into_checked_basic( - block_height, - &ConsensusParameters::standard(Default::default()), - ) + .into_checked_basic(block_height, &ConsensusParameters::standard()) .unwrap(); assert!(checked.checks().contains(Checks::Basic)); } @@ -1192,7 +1084,7 @@ mod tests { // Sets Checks::Basic .into_checked( block_height, - &ConsensusParameters::standard(chain_id), + &ConsensusParameters::standard_with_id(chain_id), ) .unwrap() // Sets Checks::Signatures @@ -1214,7 +1106,7 @@ mod tests { let consensus_params = ConsensusParameters { gas_costs, - ..ConsensusParameters::standard(Default::default()) + ..ConsensusParameters::standard() }; let check_predicate_params = CheckPredicateParams::from(&consensus_params); diff --git a/fuel-vm/src/interpreter.rs b/fuel-vm/src/interpreter.rs index b1099c28d7..5781e6a0f5 100644 --- a/fuel-vm/src/interpreter.rs +++ b/fuel-vm/src/interpreter.rs @@ -2,6 +2,7 @@ use crate::{ call::CallFrame, + checked_transaction::CheckPredicateParams, constraints::reg_key::*, consts::*, context::Context, @@ -23,16 +24,19 @@ use fuel_tx::{ Chargeable, CheckError, ConsensusParameters, + ContractParameters, Create, Executable, FeeParameters, GasCosts, Output, + PredicateParameters, Receipt, Script, Transaction, TransactionFee, TransactionRepr, + TxParameters, UniqueIdentifier, }; use fuel_types::{ @@ -117,7 +121,7 @@ pub struct Interpreter { } /// Interpreter parameters -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct InterpreterParams { /// Gas costs pub gas_costs: GasCosts, @@ -135,6 +139,26 @@ pub struct InterpreterParams { pub fee_params: FeeParameters, } +impl Default for InterpreterParams { + fn default() -> Self { + Self { + gas_costs: Default::default(), + max_inputs: TxParameters::DEFAULT.max_inputs, + contract_max_size: ContractParameters::DEFAULT.contract_max_size, + tx_offset: TxParameters::DEFAULT.tx_offset(), + max_message_data_length: PredicateParameters::DEFAULT.max_message_data_length, + chain_id: ChainId::default(), + fee_params: FeeParameters::default(), + } + } +} + +impl From for InterpreterParams { + fn from(value: ConsensusParameters) -> Self { + InterpreterParams::from(&value) + } +} + impl From<&ConsensusParameters> for InterpreterParams { fn from(value: &ConsensusParameters) -> Self { InterpreterParams { @@ -149,6 +173,20 @@ impl From<&ConsensusParameters> for InterpreterParams { } } +impl From for InterpreterParams { + fn from(params: CheckPredicateParams) -> Self { + InterpreterParams { + gas_costs: params.gas_costs, + max_inputs: params.max_inputs, + contract_max_size: params.contract_max_size, + tx_offset: params.tx_offset, + max_message_data_length: params.max_message_data_length, + chain_id: params.chain_id, + fee_params: params.fee_params, + } + } +} + /// Sometimes it is possible to add some additional context information /// regarding panic reasons to simplify debugging. // TODO: Move this enum into `fuel-tx` and use it inside of the `Receipt::Panic` as meta diff --git a/fuel-vm/src/interpreter/constructors.rs b/fuel-vm/src/interpreter/constructors.rs index d339018d5e..4bc06de70b 100644 --- a/fuel-vm/src/interpreter/constructors.rs +++ b/fuel-vm/src/interpreter/constructors.rs @@ -15,13 +15,6 @@ use crate::{ state::Debugger, storage::MemoryStorage, }; -use fuel_tx::{ - ContractParameters, - FeeParameters, - PredicateParameters, - TxParameters, -}; -use fuel_types::ChainId; #[cfg(feature = "profile-any")] use crate::profiler::ProfileReceiver; @@ -85,16 +78,7 @@ where Tx: ExecutableTransaction, { fn default() -> Self { - let params = InterpreterParams { - gas_costs: Default::default(), - max_inputs: TxParameters::DEFAULT.max_inputs, - contract_max_size: ContractParameters::DEFAULT.contract_max_size, - tx_offset: TxParameters::default().tx_offset(), - max_message_data_length: PredicateParameters::DEFAULT.max_message_data_length, - chain_id: ChainId::default(), - fee_params: FeeParameters::default(), - }; - Self::with_storage(Default::default(), params) + Self::with_storage(Default::default(), InterpreterParams::default()) } } diff --git a/fuel-vm/src/interpreter/debug.rs b/fuel-vm/src/interpreter/debug.rs index 12d8d3814d..3a3171fe99 100644 --- a/fuel-vm/src/interpreter/debug.rs +++ b/fuel-vm/src/interpreter/debug.rs @@ -65,7 +65,7 @@ fn breakpoint_script() { .into_iter() .collect(); - let consensus_params = ConsensusParameters::standard(Default::default()); + let consensus_params = ConsensusParameters::standard(); let tx = TransactionBuilder::script(script, vec![]) .gas_limit(gas_limit) @@ -137,7 +137,7 @@ fn single_stepping() { .into_iter() .collect(); - let consensus_params = ConsensusParameters::standard(Default::default()); + let consensus_params = ConsensusParameters::standard(); let tx = TransactionBuilder::script(script, vec![]) .gas_limit(gas_limit) diff --git a/fuel-vm/src/interpreter/diff.rs b/fuel-vm/src/interpreter/diff.rs index 911143e936..25bd9f0a86 100644 --- a/fuel-vm/src/interpreter/diff.rs +++ b/fuel-vm/src/interpreter/diff.rs @@ -482,7 +482,7 @@ where && self.initial_balances == other.initial_balances && self.context == other.context && self.balances == other.balances - && self.gas_costs() == other.gas_costs() + && self.interpreter_params == other.interpreter_params && self.panic_context == other.panic_context } } diff --git a/fuel-vm/src/interpreter/diff/tests.rs b/fuel-vm/src/interpreter/diff/tests.rs index d6319b99a5..abf6816c16 100644 --- a/fuel-vm/src/interpreter/diff/tests.rs +++ b/fuel-vm/src/interpreter/diff/tests.rs @@ -38,12 +38,10 @@ fn reset_vm_state() { } use crate::interpreter::InterpreterParams; -use fuel_types::ChainId; #[test] fn record_and_invert_storage() { - let interpreter_params = - InterpreterParams::from(&ConsensusParameters::standard(ChainId::default())); + let interpreter_params = InterpreterParams::from(&ConsensusParameters::standard()); let a = Interpreter::<_, Script>::with_storage( Record::new(MemoryStorage::default()), diff --git a/fuel-vm/src/interpreter/executors/instruction/tests/reserved_registers.rs b/fuel-vm/src/interpreter/executors/instruction/tests/reserved_registers.rs index 84b19fca43..5281df7476 100644 --- a/fuel-vm/src/interpreter/executors/instruction/tests/reserved_registers.rs +++ b/fuel-vm/src/interpreter/executors/instruction/tests/reserved_registers.rs @@ -1,14 +1,17 @@ use super::*; use crate::{ checked_transaction::IntoChecked, - prelude::FeeParameters, + interpreter::InterpreterParams, + prelude::{ + FeeParameters, + MemoryStorage, + }, }; use fuel_asm::PanicReason; use fuel_tx::{ ConsensusParameters, Finalizable, TransactionBuilder, - TxParameters, }; use quickcheck::TestResult; use quickcheck_macros::quickcheck; @@ -35,31 +38,24 @@ fn cant_write_to_reserved_registers(raw_random_instruction: u32) -> TestResult { _ => (), } - let mut vm = Interpreter::with_memory_storage(); + let fee_params = FeeParameters::default().with_gas_price_factor(1); + let consensus_params = ConsensusParameters { + fee_params, + ..Default::default() + }; + + let mut vm = Interpreter::with_storage( + MemoryStorage::default(), + InterpreterParams::from(&consensus_params), + ); - let tx_params = TxParameters::default(); let script = op::ret(0x10).to_bytes().to_vec(); let block_height = Default::default(); let tx = TransactionBuilder::script(script, vec![]) - .gas_limit(tx_params.max_gas_per_tx) + .gas_limit(consensus_params.tx_params.max_gas_per_tx) .add_random_fee_input() .finalize(); - let predicate_params = Default::default(); - let script_params = Default::default(); - let contract_params = Default::default(); - let fee_params = FeeParameters::default().with_gas_price_factor(1); - - let consensus_params = ConsensusParameters::new( - tx_params, - predicate_params, - script_params, - contract_params, - fee_params, - Default::default(), - vm.gas_costs().to_owned(), - ); - let tx = tx .into_checked(block_height, &consensus_params) .expect("failed to check tx"); diff --git a/fuel-vm/src/interpreter/executors/main.rs b/fuel-vm/src/interpreter/executors/main.rs index cd4530e2b2..a132b29016 100644 --- a/fuel-vm/src/interpreter/executors/main.rs +++ b/fuel-vm/src/interpreter/executors/main.rs @@ -124,8 +124,7 @@ impl Interpreter { ::Metadata: CheckedMetadata, { let tx = checked.transaction(); - let balances = checked.metadata().balances(); - Self::run_predicate(PredicateRunKind::Verifying(tx), balances, params) + Self::run_predicate(PredicateRunKind::Verifying(tx), params) } /// Initialize the VM with the provided transaction and check all predicates defined @@ -142,15 +141,11 @@ impl Interpreter { ::Metadata: CheckedMetadata, E: ParallelExecutor, { - let balances = checked.metadata().balances(); let tx = checked.transaction(); - let predicates_checked = Self::run_predicate_async::( - PredicateRunKind::Verifying(tx), - balances, - params, - ) - .await?; + let predicates_checked = + Self::run_predicate_async::(PredicateRunKind::Verifying(tx), params) + .await?; Ok(predicates_checked) } @@ -163,13 +158,12 @@ impl Interpreter { /// predicates. pub fn estimate_predicates( transaction: &mut Tx, - balances: InitialBalances, params: &CheckPredicateParams, ) -> Result<(), PredicateVerificationFailed> where Tx: ExecutableTransaction, { - Self::run_predicate(PredicateRunKind::Estimating(transaction), balances, params)?; + Self::run_predicate(PredicateRunKind::Estimating(transaction), params)?; Ok(()) } @@ -181,7 +175,6 @@ impl Interpreter { /// predicates. pub async fn estimate_predicates_async( transaction: &mut Tx, - balances: InitialBalances, params: &CheckPredicateParams, ) -> Result<(), PredicateVerificationFailed> where @@ -190,7 +183,6 @@ impl Interpreter { { Self::run_predicate_async::( PredicateRunKind::Estimating(transaction), - balances, params, ) .await?; @@ -200,7 +192,6 @@ impl Interpreter { async fn run_predicate_async( kind: PredicateRunKind<'_, Tx>, - balances: InitialBalances, params: &CheckPredicateParams, ) -> Result where @@ -217,14 +208,12 @@ impl Interpreter { RuntimePredicate::from_tx(kind.tx(), tx_offset, index) { let tx = kind.tx().clone(); - let balances = balances.clone(); let my_params = params.clone(); let verify_task = E::create_task(move || { Self::check_predicate( tx, index, - balances, predicate_action, predicate, my_params, @@ -242,7 +231,6 @@ impl Interpreter { fn run_predicate( kind: PredicateRunKind<'_, Tx>, - balances: InitialBalances, params: &CheckPredicateParams, ) -> Result where @@ -257,12 +245,9 @@ impl Interpreter { if let Some(predicate) = RuntimePredicate::from_tx(&tx, params.tx_offset, index) { - let balances = balances.clone(); - checks.push(Self::check_predicate( tx, index, - balances, predicate_action, predicate, params.clone(), @@ -281,7 +266,6 @@ impl Interpreter { fn check_predicate( tx: Tx, index: usize, - balances: InitialBalances, predicate_action: PredicateAction, predicate: RuntimePredicate, params: CheckPredicateParams, @@ -313,18 +297,11 @@ impl Interpreter { _ => {} } - let interpreter_params = InterpreterParams { - gas_costs: params.gas_costs, - max_inputs: params.max_inputs, - contract_max_size: params.contract_max_size, - tx_offset: params.tx_offset, - max_message_data_length: params.max_message_data_length, - chain_id: params.chain_id, - fee_params: params.fee_params, - }; + let max_gas_per_tx = params.max_gas_per_tx; + let max_gas_per_predicate = params.max_gas_per_predicate; + let interpreter_params = params.into(); - let mut vm = - Interpreter::with_storage(PredicateStorage::default(), interpreter_params); + let mut vm = Interpreter::with_storage(PredicateStorage {}, interpreter_params); let available_gas = match predicate_action { PredicateAction::Verifying => { @@ -336,15 +313,14 @@ impl Interpreter { return Err(PredicateVerificationFailed::GasNotSpecified) }; - vm.init_predicate(context, tx, balances, available_gas)?; + vm.init_predicate(context, tx, available_gas)?; available_gas } PredicateAction::Estimating => { let context = Context::PredicateEstimation { program: predicate }; - let available_gas = - core::cmp::min(params.max_gas_per_predicate, params.max_gas_per_tx); + let available_gas = core::cmp::min(max_gas_per_predicate, max_gas_per_tx); - vm.init_predicate(context, tx, balances, available_gas)?; + vm.init_predicate(context, tx, available_gas)?; available_gas } }; diff --git a/fuel-vm/src/interpreter/executors/main/tests.rs b/fuel-vm/src/interpreter/executors/main/tests.rs index 2e18e543f4..74e9d9cb73 100644 --- a/fuel-vm/src/interpreter/executors/main/tests.rs +++ b/fuel-vm/src/interpreter/executors/main/tests.rs @@ -13,18 +13,14 @@ use rand::{ }; use crate::{ - checked_transaction::{ - CheckPredicateParams, - CheckPredicates, - }, - interpreter::CheckedMetadata, + checked_transaction::CheckPredicates, prelude::*, }; #[test] fn estimate_gas_gives_proper_gas_used() { let rng = &mut StdRng::seed_from_u64(2322u64); - let params = CheckPredicateParams::default(); + let params = &ConsensusParameters::standard(); let gas_price = 1_000; let gas_limit = 1_000_000; @@ -56,7 +52,7 @@ fn estimate_gas_gives_proper_gas_used() { let transaction_without_predicate = builder .finalize_checked_basic(Default::default()) - .check_predicates(¶ms) + .check_predicates(¶ms.into()) .expect("Predicate check failed even if we don't have any predicates"); let mut client = MemoryClient::default(); @@ -94,35 +90,17 @@ fn estimate_gas_gives_proper_gas_used() { // unestimated transaction should fail as it's predicates are not estimated assert!(transaction .clone() - .into_checked( - Default::default(), - &ConsensusParameters::standard(Default::default()), - ) + .into_checked(Default::default(), params) .is_err()); - // create checked transaction to get access to balances from metadata - let unestimated_checked = transaction - .clone() - .into_checked_basic( - Default::default(), - &ConsensusParameters::standard(Default::default()), - ) - .expect("Should successfully create checked tranaction with predicate"); - - let balances = unestimated_checked.metadata().balances(); - Interpreter::::estimate_predicates( &mut transaction, - balances, - ¶ms, + ¶ms.into(), ) .expect("Should successfully estimate predicates"); // transaction should pass checking after estimation - let check_res = transaction.into_checked( - Default::default(), - &ConsensusParameters::standard(Default::default()), - ); + let check_res = transaction.into_checked(Default::default(), params); assert!(check_res.is_ok()); } diff --git a/fuel-vm/src/interpreter/initialization.rs b/fuel-vm/src/interpreter/initialization.rs index f725776bf7..a19a68fc5d 100644 --- a/fuel-vm/src/interpreter/initialization.rs +++ b/fuel-vm/src/interpreter/initialization.rs @@ -86,13 +86,12 @@ where &mut self, context: Context, mut tx: Tx, - balances: InitialBalances, gas_limit: Word, ) -> Result<(), InterpreterError> { self.context = context; tx.prepare_init_predicate(); - self.init_inner(tx, balances, gas_limit) + self.init_inner(tx, InitialBalances::default(), gas_limit) } } diff --git a/fuel-vm/src/interpreter/internal/tests.rs b/fuel-vm/src/interpreter/internal/tests.rs index ce6159af8a..4ef23c95f3 100644 --- a/fuel-vm/src/interpreter/internal/tests.rs +++ b/fuel-vm/src/interpreter/internal/tests.rs @@ -1,8 +1,11 @@ use crate::{ constraints::reg_key::RegMut, - interpreter::internal::{ - external_asset_id_balance_sub, - set_variable_output, + interpreter::{ + internal::{ + external_asset_id_balance_sub, + set_variable_output, + }, + InterpreterParams, }, prelude::*, }; @@ -95,7 +98,11 @@ fn external_balance() { fn variable_output_updates_in_memory() { let mut rng = StdRng::seed_from_u64(2322u64); - let mut vm = Interpreter::with_memory_storage(); + let consensus_params = ConsensusParameters::standard(); + let mut vm = Interpreter::with_storage( + MemoryStorage::default(), + InterpreterParams::from(&consensus_params), + ); let gas_limit = 1_000_000; let height = Default::default(); @@ -109,16 +116,6 @@ fn variable_output_updates_in_memory() { asset_id: rng.gen(), }; - let consensus_params = ConsensusParameters { - tx_params: Default::default(), - fee_params: Default::default(), - predicate_params: Default::default(), - script_params: Default::default(), - contract_params: Default::default(), - chain_id: Default::default(), - gas_costs: vm.gas_costs().to_owned(), - }; - let tx = TransactionBuilder::script(vec![], vec![]) .gas_limit(gas_limit) .add_random_fee_input() diff --git a/fuel-vm/src/interpreter/memory/tests.rs b/fuel-vm/src/interpreter/memory/tests.rs index 0d372f5f91..0b0b75cd62 100644 --- a/fuel-vm/src/interpreter/memory/tests.rs +++ b/fuel-vm/src/interpreter/memory/tests.rs @@ -1,35 +1,32 @@ use std::ops::Range; use super::*; -use crate::prelude::*; +use crate::{ + interpreter::InterpreterParams, + prelude::*, +}; use fuel_asm::op; use fuel_tx::ConsensusParameters; use test_case::test_case; #[test] fn memcopy() { - let mut vm = Interpreter::with_memory_storage(); let tx_params = TxParameters::default().with_max_gas_per_tx(Word::MAX / 2); + + let consensus_params = ConsensusParameters { + tx_params, + ..Default::default() + }; + + let mut vm = Interpreter::with_storage( + MemoryStorage::default(), + InterpreterParams::from(&consensus_params), + ); let tx = TransactionBuilder::script(op::ret(0x10).to_bytes().to_vec(), vec![]) .gas_limit(tx_params.max_gas_per_tx) .add_random_fee_input() .finalize(); - let predicate_params = Default::default(); - let script_params = Default::default(); - let contract_params = Default::default(); - let fee_params = &Default::default(); - - let consensus_params = ConsensusParameters::new( - tx_params, - predicate_params, - script_params, - contract_params, - *fee_params, - Default::default(), - vm.gas_costs().to_owned(), - ); - let tx = tx .into_checked(Default::default(), &consensus_params) .expect("default tx should produce a valid checked transaction"); @@ -88,10 +85,7 @@ fn memrange() { .gas_limit(1000000) .add_random_fee_input() .finalize() - .into_checked( - Default::default(), - &ConsensusParameters::standard(Default::default()), - ) + .into_checked(Default::default(), &ConsensusParameters::standard()) .expect("Empty script should be valid"); let mut vm = Interpreter::with_memory_storage(); vm.init_script(tx).expect("Failed to init VM"); @@ -121,10 +115,7 @@ fn stack_alloc_ownership() { .gas_limit(1000000) .add_random_fee_input() .finalize() - .into_checked( - Default::default(), - &ConsensusParameters::standard(Default::default()), - ) + .into_checked(Default::default(), &ConsensusParameters::standard()) .expect("Empty script should be valid"); vm.init_script(tx).expect("Failed to init VM"); diff --git a/fuel-vm/src/memory_client.rs b/fuel-vm/src/memory_client.rs index ca87f4ba7d..46adf3e674 100644 --- a/fuel-vm/src/memory_client.rs +++ b/fuel-vm/src/memory_client.rs @@ -10,16 +10,11 @@ use crate::{ use crate::interpreter::InterpreterParams; use fuel_tx::{ - ContractParameters, Create, - FeeParameters, GasCosts, - PredicateParameters, Receipt, Script, - TxParameters, }; -use fuel_types::ChainId; #[derive(Default, Debug)] /// Client implementation with in-memory storage backend. @@ -104,11 +99,6 @@ impl MemoryClient { self.as_mut().persist(); } - // /// Consensus parameters - // pub const fn params(&self) -> &ConsensusParameters { - // self.transactor.params() - // } - /// Tx memory offset pub fn tx_offset(&self) -> usize { self.transactor.tx_offset() @@ -122,16 +112,7 @@ impl MemoryClient { impl From for MemoryClient { fn from(s: MemoryStorage) -> Self { - let interpreter_params = InterpreterParams { - gas_costs: Default::default(), - max_inputs: TxParameters::DEFAULT.max_inputs, - contract_max_size: ContractParameters::DEFAULT.contract_max_size, - tx_offset: TxParameters::default().tx_offset(), - max_message_data_length: PredicateParameters::DEFAULT.max_message_data_length, - chain_id: ChainId::default(), - fee_params: FeeParameters::default(), - }; - Self::new(s, interpreter_params) + Self::new(s, InterpreterParams::default()) } } diff --git a/fuel-vm/src/predicate.rs b/fuel-vm/src/predicate.rs index fc75a97c2d..144b18b12b 100644 --- a/fuel-vm/src/predicate.rs +++ b/fuel-vm/src/predicate.rs @@ -131,7 +131,6 @@ fn from_tx_works() { program: Default::default() }, tx.transaction().clone(), - Default::default(), tx.transaction().limit() ) .is_ok()); diff --git a/fuel-vm/src/tests/blockchain.rs b/fuel-vm/src/tests/blockchain.rs index 9ceee3b281..2b4841ca43 100644 --- a/fuel-vm/src/tests/blockchain.rs +++ b/fuel-vm/src/tests/blockchain.rs @@ -291,7 +291,7 @@ fn load_external_contract_code() { let output0 = Output::contract_created(contract_id, state_root); let output1 = Output::contract(0, rng.gen(), rng.gen()); - let consensus_params = ConsensusParameters::standard(Default::default()); + let consensus_params = ConsensusParameters::standard(); let tx_create_target = TransactionBuilder::create(program.clone(), salt, vec![]) .gas_price(gas_price) @@ -400,25 +400,13 @@ fn ldc_reason_helper( let rng = &mut StdRng::seed_from_u64(2322u64); let salt: Salt = rng.gen(); - let tx_params = TxParameters::default(); - let predicate_params = PredicateParameters::default(); - let script_params = ScriptParameters::default(); - let contract_params = ContractParameters::default(); - let fee_params = FeeParameters::default(); - let chain_id = ChainId::default(); - // make gas costs free let gas_costs = GasCosts::free(); - let consensus_params = ConsensusParameters::new( - tx_params, - predicate_params, - script_params, - contract_params, - fee_params, - chain_id, + let consensus_params = ConsensusParameters { gas_costs, - ); + ..Default::default() + }; let interpreter_params = InterpreterParams::from(&consensus_params); @@ -1276,7 +1264,6 @@ fn smo_instruction_works() { { let mut client = MemoryClient::default(); let fee_params = FeeParameters::default(); - let chain_id = ChainId::default(); let gas_limit = 1_000_000; let maturity = Default::default(); @@ -1327,7 +1314,7 @@ fn smo_instruction_works() { tx.metadata().non_retryable_balances[&AssetId::BASE]; let retryable_balance: u64 = tx.metadata().retryable_balance.into(); - let txid = tx.transaction().id(&chain_id); + let txid = tx.transaction().id(&ChainId::default()); let receipts = client.transact(tx); let success = receipts.iter().any(|r| { diff --git a/fuel-vm/src/tests/contract.rs b/fuel-vm/src/tests/contract.rs index 1a4509cf0e..83954d5265 100644 --- a/fuel-vm/src/tests/contract.rs +++ b/fuel-vm/src/tests/contract.rs @@ -11,7 +11,6 @@ use fuel_tx::{ ConsensusParameters, Witness, }; -use fuel_types::ChainId; use rand::{ rngs::StdRng, Rng, @@ -68,9 +67,7 @@ fn prevent_contract_id_redeployment() { 1, ); - let chain_id = ChainId::default(); - - let consensus_params = ConsensusParameters::standard(chain_id); + let consensus_params = ConsensusParameters::standard(); let create = create .into_checked_basic(1.into(), &consensus_params) diff --git a/fuel-vm/src/tests/crypto.rs b/fuel-vm/src/tests/crypto.rs index 1dca649e1a..e9f4191d8e 100644 --- a/fuel-vm/src/tests/crypto.rs +++ b/fuel-vm/src/tests/crypto.rs @@ -140,7 +140,7 @@ fn ecrecover_tx_id() { tx.sign_inputs(&secret, &chain_id); - let consensus_params = ConsensusParameters::standard(Default::default()); + let consensus_params = ConsensusParameters::standard_with_id(chain_id); let tx = tx.into_checked(height, &consensus_params).unwrap(); let receipts = client.transact(tx); @@ -165,9 +165,7 @@ async fn recover_tx_id_predicate() { let public = secret.public_key(); let check_params = CheckPredicateParams::default(); - let chain_id = ChainId::default(); - - let consensus_params = ConsensusParameters::standard(chain_id); + let consensus_params = ConsensusParameters::standard(); #[rustfmt::skip] let predicate = vec![ diff --git a/fuel-vm/src/tests/gas_factor.rs b/fuel-vm/src/tests/gas_factor.rs index c98a976d94..b47401df39 100644 --- a/fuel-vm/src/tests/gas_factor.rs +++ b/fuel-vm/src/tests/gas_factor.rs @@ -1,7 +1,6 @@ use fuel_asm::op; use fuel_vm::prelude::*; -use crate::fuel_types::ChainId; use fuel_tx::{ field::Outputs, ConsensusParameters, @@ -43,7 +42,7 @@ fn gas_factor_rounds_correctly() { let consensus_params = ConsensusParameters { fee_params, - ..ConsensusParameters::standard(ChainId::default()) + ..ConsensusParameters::standard() }; let interpreter_params = InterpreterParams::from(&consensus_params); diff --git a/fuel-vm/src/tests/memory.rs b/fuel-vm/src/tests/memory.rs index be4dffc09f..20f356b8c5 100644 --- a/fuel-vm/src/tests/memory.rs +++ b/fuel-vm/src/tests/memory.rs @@ -6,7 +6,6 @@ use fuel_asm::{ RegId, }; use fuel_tx::Receipt; -use fuel_types::ChainId; use fuel_vm::{ consts::VM_MAX_RAM, interpreter::InterpreterParams, @@ -28,7 +27,7 @@ fn setup(program: Vec) -> Transactor { let maturity = Default::default(); let height = Default::default(); - let consensus_params = ConsensusParameters::standard(ChainId::default()); + let consensus_params = ConsensusParameters::standard(); let script = program.into_iter().collect(); diff --git a/fuel-vm/src/tests/metadata.rs b/fuel-vm/src/tests/metadata.rs index 0b48e9c4f7..501e1416ca 100644 --- a/fuel-vm/src/tests/metadata.rs +++ b/fuel-vm/src/tests/metadata.rs @@ -49,7 +49,7 @@ fn metadata() { let maturity = Default::default(); let height = Default::default(); - let consensus_params = ConsensusParameters::standard(ChainId::default()); + let consensus_params = ConsensusParameters::standard(); #[rustfmt::skip] let routine_metadata_is_caller_external = vec![ @@ -225,13 +225,8 @@ fn get_metadata_chain_id() { let chain_id: ChainId = rng.gen(); let interpreter_params = InterpreterParams { - gas_costs: Default::default(), - max_inputs: TxParameters::DEFAULT.max_inputs, - contract_max_size: ContractParameters::DEFAULT.contract_max_size, - tx_offset: TxParameters::DEFAULT.tx_offset(), - max_message_data_length: PredicateParameters::DEFAULT.max_message_data_length, chain_id, - fee_params: FeeParameters::default(), + ..Default::default() }; let mut client = MemoryClient::new(Default::default(), interpreter_params); @@ -242,7 +237,7 @@ fn get_metadata_chain_id() { op::ret(0x10), ]; - let consensus_params = ConsensusParameters::standard(chain_id); + let consensus_params = ConsensusParameters::standard_with_id(chain_id); let script = TransactionBuilder::script(get_chain_id.into_iter().collect(), vec![]) .gas_limit(gas_limit) @@ -275,7 +270,6 @@ fn get_transaction_fields() { let input = 10_000_000; let tx_params = TxParameters::default(); - let chain_id = ChainId::default(); let contract: Witness = vec![op::ret(0x01)].into_iter().collect::>().into(); let salt = rng.gen(); @@ -323,7 +317,7 @@ fn get_transaction_fields() { rng.fill(m_data.as_mut_slice()); rng.fill(m_predicate_data.as_mut_slice()); - let owner = Input::predicate_owner(&m_predicate, &chain_id); + let owner = Input::predicate_owner(&m_predicate, &ChainId::default()); let message_predicate = Input::message_data_predicate( rng.gen(), owner, diff --git a/fuel-vm/src/tests/predicate.rs b/fuel-vm/src/tests/predicate.rs index 69554161ef..1d82f1521f 100644 --- a/fuel-vm/src/tests/predicate.rs +++ b/fuel-vm/src/tests/predicate.rs @@ -72,10 +72,9 @@ where let tx_pointer = rng.gen(); let maturity = Default::default(); let height = Default::default(); - let chain_id = Default::default(); let predicate_gas_used = 0; - let owner = Input::predicate_owner(&predicate, &chain_id); + let owner = Input::predicate_owner(&predicate, &ChainId::default()); let input = Input::coin_predicate( utxo_id, owner, @@ -117,7 +116,7 @@ where let gas_costs = GasCosts::free(); let checked = transaction - .into_checked_basic(height, &ConsensusParameters::standard(ChainId::default())) + .into_checked_basic(height, &ConsensusParameters::standard()) .expect("Should successfully convert into Checked"); let params = CheckPredicateParams { @@ -268,10 +267,7 @@ async fn execute_gas_metered_predicates( .map_err(|_| ())?; let tx = async_tx - .into_checked_basic( - Default::default(), - &ConsensusParameters::standard(Default::default()), - ) + .into_checked_basic(Default::default(), &ConsensusParameters::standard()) .expect("Should successfully create checked tranaction with predicate"); Interpreter::::check_predicates_async::<_, TokioWithRayon>( @@ -286,10 +282,7 @@ async fn execute_gas_metered_predicates( transaction.estimate_predicates(¶ms).map_err(|_| ())?; let tx = transaction - .into_checked_basic( - Default::default(), - &ConsensusParameters::standard(Default::default()), - ) + .into_checked_basic(Default::default(), &ConsensusParameters::standard()) .expect("Should successfully create checked tranaction with predicate"); let seq_gas_used = Interpreter::::check_predicates(&tx, ¶ms) @@ -438,10 +431,7 @@ async fn gas_used_by_predicates_is_deducted_from_script_gas() { .expect("Predicate estimation failed"); let checked = transaction - .into_checked_basic( - Default::default(), - &ConsensusParameters::standard(Default::default()), - ) + .into_checked_basic(Default::default(), &ConsensusParameters::standard()) .expect("Should successfully create checked tranaction with predicate"); // parallel version @@ -577,10 +567,7 @@ async fn gas_used_by_predicates_causes_out_of_gas_during_script() { .expect("Predicate estimation failed"); let checked = transaction - .into_checked_basic( - Default::default(), - &ConsensusParameters::standard(Default::default()), - ) + .into_checked_basic(Default::default(), &ConsensusParameters::standard()) .expect("Should successfully create checked tranaction with predicate"); // parallel version diff --git a/fuel-vm/src/tests/test_helpers.rs b/fuel-vm/src/tests/test_helpers.rs index d2dc65adc8..1221dd1d70 100644 --- a/fuel-vm/src/tests/test_helpers.rs +++ b/fuel-vm/src/tests/test_helpers.rs @@ -22,7 +22,7 @@ pub fn run_script(script: Vec) -> Vec { let script = script.into_iter().collect(); let mut client = MemoryClient::default(); - let consensus_params = ConsensusParameters::standard(Default::default()); + let consensus_params = ConsensusParameters::standard(); let tx = TransactionBuilder::script(script, vec![]) .gas_price(0) diff --git a/fuel-vm/src/transactor.rs b/fuel-vm/src/transactor.rs index 9590db4f56..1124c500a3 100644 --- a/fuel-vm/src/transactor.rs +++ b/fuel-vm/src/transactor.rs @@ -22,16 +22,11 @@ use crate::{ use crate::interpreter::InterpreterParams; use fuel_tx::{ - ContractParameters, Create, - FeeParameters, GasCosts, - PredicateParameters, Receipt, Script, - TxParameters, }; -use fuel_types::ChainId; #[derive(Debug)] /// State machine to execute transactions and provide runtime entities on @@ -253,15 +248,6 @@ where Tx: ExecutableTransaction, { fn default() -> Self { - let interpreter_params = InterpreterParams { - gas_costs: Default::default(), - max_inputs: TxParameters::DEFAULT.max_inputs, - contract_max_size: ContractParameters::DEFAULT.contract_max_size, - tx_offset: TxParameters::default().tx_offset(), - max_message_data_length: PredicateParameters::DEFAULT.max_message_data_length, - chain_id: ChainId::default(), - fee_params: FeeParameters::default(), - }; - Self::new(S::default(), interpreter_params) + Self::new(S::default(), InterpreterParams::default()) } } diff --git a/fuel-vm/src/util.rs b/fuel-vm/src/util.rs index 32be9c1b61..5f31f0e55c 100644 --- a/fuel-vm/src/util.rs +++ b/fuel-vm/src/util.rs @@ -182,7 +182,7 @@ pub mod test_helpers { builder: TransactionBuilder::script(bytecode, vec![]), storage: MemoryStorage::default(), block_height: Default::default(), - consensus_params: ConsensusParameters::standard(ChainId::default()), + consensus_params: ConsensusParameters::standard(), } }