Skip to content

Commit

Permalink
fix
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 039c6b3 commit f198cf5
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions substrate/frame/revive/src/wasm/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1026,26 +1026,28 @@ impl<'a, E: Ext, M: ?Sized + Memory<E::T>> Runtime<'a, E, M> {
},
};

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.
Ok(_) if flags.contains(CallFlags::TAIL_CALL) => {
let output = mem::take(self.ext.last_frame_output_mut());
return Err(TrapReason::Return(ReturnData {
flags: output.flags.bits(),
data: output.data,
}));
},
Ok(_) => {
self.write_sandbox_output(
let output = mem::take(self.ext.last_frame_output_mut());
let write_result = self.write_sandbox_output(
memory,
output_ptr,
output_len_ptr,
&output.data,
true,
|len| Some(RuntimeCosts::CopyToContract(len)),
)?;
);
*self.ext.last_frame_output_mut() = output;
write_result?;
Ok(self.ext.last_frame_output().into())
},
Err(err) => Ok(Self::exec_error_into_return_code(err)?),
Expand Down Expand Up @@ -1088,8 +1090,7 @@ impl<'a, E: Ext, M: ?Sized + Memory<E::T>> Runtime<'a, E, M> {
salt.as_ref(),
) {
Ok(address) => {
let output = mem::take(self.ext.last_frame_output_mut());
if !output.flags.contains(ReturnFlags::REVERT) {
if !self.ext.last_frame_output().flags.contains(ReturnFlags::REVERT) {
self.write_fixed_sandbox_output(
memory,
address_ptr,
Expand All @@ -1098,15 +1099,17 @@ impl<'a, E: Ext, M: ?Sized + Memory<E::T>> Runtime<'a, E, M> {
already_charged,
)?;
}
self.write_sandbox_output(
let output = mem::take(self.ext.last_frame_output_mut());
let write_result = self.write_sandbox_output(
memory,
output_ptr,
output_len_ptr,
&output.data,
true,
|len| Some(RuntimeCosts::CopyToContract(len)),
)?;
);
*self.ext.last_frame_output_mut() = output;
write_result?;
Ok(self.ext.last_frame_output().into())
},
Err(err) => Ok(Self::exec_error_into_return_code(err)?),
Expand Down

0 comments on commit f198cf5

Please sign in to comment.