diff --git a/substrate/frame/revive/src/exec.rs b/substrate/frame/revive/src/exec.rs index ce8ca3f94a40..050b8e1449ea 100644 --- a/substrate/frame/revive/src/exec.rs +++ b/substrate/frame/revive/src/exec.rs @@ -563,7 +563,7 @@ pub struct Stack<'a, T: Config, E> { /// Transient storage used to store data, which is kept for the duration of a transaction. transient_storage: TransientStorage, /// Whether or not actual transfer of funds should be performed. - unchecked: bool, + skip_transfer: bool, /// No executable is held by the struct but influences its behaviour. _phantom: PhantomData, } @@ -779,7 +779,7 @@ where storage_meter: &'a mut storage::meter::Meter, value: U256, input_data: Vec, - unchecked: bool, + skip_transfer: bool, debug_message: Option<&'a mut DebugBuffer>, ) -> ExecResult { let dest = T::AddressMapper::to_account_id(&dest); @@ -789,7 +789,7 @@ where gas_meter, storage_meter, value, - unchecked, + skip_transfer, debug_message, )? { stack.run(executable, input_data).map(|_| stack.first_frame.last_frame_output) @@ -816,7 +816,7 @@ where value: U256, input_data: Vec, salt: Option<&[u8; 32]>, - unchecked: bool, + skip_transfer: bool, debug_message: Option<&'a mut DebugBuffer>, ) -> Result<(H160, ExecReturnValue), ExecError> { let (mut stack, executable) = Self::new( @@ -830,7 +830,7 @@ where gas_meter, storage_meter, value, - unchecked, + skip_transfer, debug_message, )? .expect(FRAME_ALWAYS_EXISTS_ON_INSTANTIATE); @@ -876,7 +876,7 @@ where gas_meter: &'a mut GasMeter, storage_meter: &'a mut storage::meter::Meter, value: U256, - unchecked: bool, + skip_transfer: bool, debug_message: Option<&'a mut DebugBuffer>, ) -> Result, ExecError> { origin.ensure_mapped()?; @@ -904,7 +904,7 @@ where frames: Default::default(), debug_message, transient_storage: TransientStorage::new(limits::TRANSIENT_STORAGE_BYTES), - unchecked, + skip_transfer, _phantom: Default::default(), }; @@ -1082,7 +1082,7 @@ where &frame.account_id, frame.contract_info.get(&frame.account_id), executable.code_info(), - self.unchecked, + self.skip_transfer, )?; // Needs to be incremented before calling into the code so that it is visible // in case of recursion. diff --git a/substrate/frame/revive/src/lib.rs b/substrate/frame/revive/src/lib.rs index 12a55004600c..efc0322b5f6c 100644 --- a/substrate/frame/revive/src/lib.rs +++ b/substrate/frame/revive/src/lib.rs @@ -1241,17 +1241,10 @@ where /// /// # Parameters /// - /// - `origin`: The origin of the call. - /// - `dest`: The destination address of the call. - /// - `value`: The EVM value to transfer. - /// - `input`: The input data. + /// - `tx`: The Ethereum transaction to simulate. /// - `gas_limit`: The gas limit enforced during contract execution. - /// - `storage_deposit_limit`: The maximum balance that can be charged to the caller for storage - /// usage. /// - `utx_encoded_size`: A function that takes a call and returns the encoded size of the /// unchecked extrinsic. - /// - `debug`: Debugging configuration. - /// - `collect_events`: Event collection configuration. pub fn bare_eth_transact( mut tx: GenericTransaction, gas_limit: Weight, @@ -1498,10 +1491,10 @@ where origin: T::AccountId, code: Vec, storage_deposit_limit: BalanceOf, - unchecked: bool, + skip_transfer: bool, ) -> Result<(WasmBlob, BalanceOf), DispatchError> { let mut module = WasmBlob::from_code(code, origin)?; - let deposit = module.store_code(unchecked)?; + let deposit = module.store_code(skip_transfer)?; ensure!(storage_deposit_limit >= deposit, >::StorageDepositLimitExhausted); Ok((module, deposit)) } diff --git a/substrate/frame/revive/src/storage/meter.rs b/substrate/frame/revive/src/storage/meter.rs index f068509c34f1..6eddf048be98 100644 --- a/substrate/frame/revive/src/storage/meter.rs +++ b/substrate/frame/revive/src/storage/meter.rs @@ -387,9 +387,9 @@ where pub fn try_into_deposit( self, origin: &Origin, - unchecked: bool, + skip_transfer: bool, ) -> Result, DispatchError> { - if !unchecked { + if !skip_transfer { // Only refund or charge deposit if the origin is not root. let origin = match origin { Origin::Root => return Ok(Deposit::Charge(Zero::zero())), @@ -437,14 +437,14 @@ impl> RawMeter { contract: &T::AccountId, contract_info: &mut ContractInfo, code_info: &CodeInfo, - unchecked: bool, + skip_transfer: bool, ) -> Result<(), DispatchError> { debug_assert!(matches!(self.contract_state(), ContractState::Alive)); // We need to make sure that the contract's account exists. let ed = Pallet::::min_balance(); self.total_deposit = Deposit::Charge(ed); - if unchecked { + if skip_transfer { T::Currency::set_balance(contract, ed); } else { T::Currency::transfer(origin, contract, ed, Preservation::Preserve)?; diff --git a/substrate/frame/revive/src/wasm/mod.rs b/substrate/frame/revive/src/wasm/mod.rs index 82aa67a1d678..6f6108dd1222 100644 --- a/substrate/frame/revive/src/wasm/mod.rs +++ b/substrate/frame/revive/src/wasm/mod.rs @@ -183,7 +183,7 @@ where } /// Puts the module blob into storage, and returns the deposit collected for the storage. - pub fn store_code(&mut self, unchecked: bool) -> Result, Error> { + pub fn store_code(&mut self, skip_transfer: bool) -> Result, Error> { let code_hash = *self.code_hash(); >::mutate(code_hash, |stored_code_info| { match stored_code_info { @@ -196,7 +196,7 @@ where None => { let deposit = self.code_info.deposit; - if !unchecked { + if !skip_transfer { T::Currency::hold( &HoldReason::CodeUploadDepositReserve.into(), &self.code_info.owner,