Skip to content

Commit

Permalink
some bikeshedding
Browse files Browse the repository at this point in the history
Signed-off-by: xermicus <cyrill@parity.io>
  • Loading branch information
xermicus committed Sep 20, 2024
1 parent 0eb213c commit 68e989b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions substrate/frame/revive/fixtures/contracts/return_data_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ pub extern "C" fn deploy() {}
pub extern "C" fn call() {
input!(code_hash: &[u8; 32],);

recursion_guard();

// we didn't do anything yet; return data size should be 0
assert_return_data_size_of(0);

recursion_guard();

let mut address_buf = [0; 20];
let construct_input = |exit_flag| {
let mut input = INPUT_DATA;
Expand Down
10 changes: 5 additions & 5 deletions substrate/frame/revive/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,10 @@ pub trait Ext: sealing::Sealed {
/// Check if running in read-only context.
fn is_read_only(&self) -> bool;

/// Returns an immutable reference to saved output of the last executed call frame.
/// Returns an immutable reference to the output of the last executed call frame.
fn last_frame_output(&self) -> &ExecReturnValue;

/// Returns a mutable reference to saved output of the last executed call frame.
/// Returns a mutable reference to the output of the last executed call frame.
fn last_frame_output_mut(&mut self) -> &mut ExecReturnValue;
}

Expand Down Expand Up @@ -549,7 +549,7 @@ struct Frame<T: Config> {
read_only: bool,
/// The caller of the currently executing frame which was spawned by `delegate_call`.
delegate_caller: Option<Origin<T>>,
/// The output of the last call frame
/// The output of the last executed call frame.
last_frame_output: ExecReturnValue,
}

Expand Down Expand Up @@ -1274,10 +1274,10 @@ where
T::Currency::reducible_balance(who, Preservation::Preserve, Fortitude::Polite).into()
}

/// Replaces the last frame output with the default value, dropping it.
/// Replaces the `last_frame_output` of the **caller** frame with the default value.
fn take_caller_output(&mut self) {
let len = self.frames.len();
core::mem::take(match len {
mem::take(match len {
0 => return,
1 => &mut self.first_frame.last_frame_output,
_ => &mut self.frames.get_mut(len - 2).expect("len >= 2; qed").last_frame_output,
Expand Down
10 changes: 5 additions & 5 deletions substrate/frame/revive/src/wasm/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use crate::{
};
use alloc::{boxed::Box, vec, vec::Vec};
use codec::{Decode, DecodeLimit, Encode, MaxEncodedLen};
use core::{fmt, marker::PhantomData};
use core::{mem, fmt, marker::PhantomData};
use frame_support::{
dispatch::DispatchInfo, ensure, pallet_prelude::DispatchResultWithPostInfo, parameter_types,
traits::Get, weights::Weight,
Expand Down Expand Up @@ -1026,7 +1026,7 @@ impl<'a, E: Ext, M: ?Sized + Memory<E::T>> Runtime<'a, E, M> {
},
};

let output = core::mem::take(self.ext.last_frame_output_mut());
let output = mem::take(self.ext.last_frame_output_mut());
match call_outcome {
// `TAIL_CALL` only matters on an `OK` result. Otherwise the call stack comes to
// a halt anyways without anymore code being executed.
Expand Down Expand Up @@ -1088,7 +1088,7 @@ impl<'a, E: Ext, M: ?Sized + Memory<E::T>> Runtime<'a, E, M> {
salt.as_ref(),
) {
Ok(address) => {
let output = core::mem::take(self.ext.last_frame_output_mut());
let output = mem::take(self.ext.last_frame_output_mut());
if !output.flags.contains(ReturnFlags::REVERT) {
self.write_fixed_sandbox_output(
memory,
Expand Down Expand Up @@ -1992,7 +1992,7 @@ pub mod env {
)?)
}

/// Stores data returned by the last call starting from `offset` into the supplied buffer.
/// Stores data returned by the last call, starting from `offset`, into the supplied buffer.
/// See [`pallet_revive_uapi::HostFn::return_data`].
#[api_version(0)]
fn return_data_copy(
Expand All @@ -2002,7 +2002,7 @@ pub mod env {
out_len_ptr: u32,
offset: u32,
) -> Result<(), TrapReason> {
let output = core::mem::take(self.ext.last_frame_output_mut());
let output = mem::take(self.ext.last_frame_output_mut());
if offset as usize > output.data.len() {
return Err(Error::<E::T>::OutOfBounds.into());
}
Expand Down

0 comments on commit 68e989b

Please sign in to comment.