Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pallet-revive] Fix caller_is_root return value #7086

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions prdoc/pr_7086.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
title: '[pallet-revive] Fix `caller_is_root` return value'
doc:
- audience: Runtime Dev
description: The return type of the host function `caller_is_root` was denoted as `u32`
in `pallet_revive_uapi`. This PR fixes the return type to `bool`. As a drive-by, the
PR re-exports `pallet_revive::exec::Origin` to extend what can be tested externally.
crates:
- name: pallet-revive
bump: minor
- name: pallet-revive-uapi
bump: major
2 changes: 1 addition & 1 deletion substrate/frame/revive/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ pub trait Ext: sealing::Sealed {
/// Returns `Err(InvalidImmutableAccess)` if called from a constructor.
fn get_immutable_data(&mut self) -> Result<ImmutableData, DispatchError>;

/// Set the the immutable data of the current contract.
/// Set the immutable data of the current contract.
///
/// Returns `Err(InvalidImmutableAccess)` if not called from a constructor.
///
Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/revive/src/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub struct RefTimeLeft(u64);

/// Resource that needs to be synced to the executor.
///
/// Wrapped to make sure that the resource will be synced back the the executor.
/// Wrapped to make sure that the resource will be synced back to the executor.
#[must_use]
pub struct Syncable(polkavm::Gas);

Expand Down
4 changes: 2 additions & 2 deletions substrate/frame/revive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub mod weights;

use crate::{
evm::{runtime::GAS_PRICE, GenericTransaction},
exec::{AccountIdOf, ExecError, Executable, Ext, Key, Origin, Stack as ExecStack},
exec::{AccountIdOf, ExecError, Executable, Ext, Key, Stack as ExecStack},
gas::GasMeter,
storage::{meter::Meter as StorageMeter, ContractInfo, DeletionQueueManager},
wasm::{CodeInfo, RuntimeCosts, WasmBlob},
Expand Down Expand Up @@ -81,7 +81,7 @@ use sp_runtime::{
pub use crate::{
address::{create1, create2, AccountId32Mapper, AddressMapper},
debug::Tracing,
exec::MomentOf,
exec::{MomentOf, Origin},
pallet::*,
};
pub use primitives::*;
Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/revive/uapi/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ pub trait HostFn: private::Sealed {
/// A return value of `true` indicates that this contract is being called by a root origin,
/// and `false` indicates that the caller is a signed origin.
#[unstable_hostfn]
fn caller_is_root() -> u32;
fn caller_is_root() -> bool;

/// Clear the value at the given key in the contract storage.
///
Expand Down
5 changes: 3 additions & 2 deletions substrate/frame/revive/uapi/src/host/riscv64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,9 @@ impl HostFn for HostFnImpl {
}

#[unstable_hostfn]
fn caller_is_root() -> u32 {
unsafe { sys::caller_is_root() }.into_u32()
fn caller_is_root() -> bool {
let ret_val = unsafe { sys::caller_is_root() };
ret_val.into_bool()
}

#[unstable_hostfn]
Expand Down
Loading