diff --git a/prdoc/pr_7086.prdoc b/prdoc/pr_7086.prdoc new file mode 100644 index 0000000000000000000000000000000000000000..55fed9bca3e6c6e1f7df0c641dac73db4c6aa185 --- /dev/null +++ b/prdoc/pr_7086.prdoc @@ -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 diff --git a/substrate/frame/revive/src/exec.rs b/substrate/frame/revive/src/exec.rs index a6a2591497683af65cfa6ed1a4b1a7de2802bb2e..478e96dc994d37877bb8d212aef3c06f2c3e272b 100644 --- a/substrate/frame/revive/src/exec.rs +++ b/substrate/frame/revive/src/exec.rs @@ -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. /// diff --git a/substrate/frame/revive/src/gas.rs b/substrate/frame/revive/src/gas.rs index 9aad84e69201e4991679f7b1e57590598760415e..5c30a0a510095c66ff831c2dbce3c2ee75f92af8 100644 --- a/substrate/frame/revive/src/gas.rs +++ b/substrate/frame/revive/src/gas.rs @@ -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); diff --git a/substrate/frame/revive/src/lib.rs b/substrate/frame/revive/src/lib.rs index 04bce264a188c1b55f1a9c53398903a9a9e55545..bdb4b92edd9e62c5d13cfb154ce42887b5b103e5 100644 --- a/substrate/frame/revive/src/lib.rs +++ b/substrate/frame/revive/src/lib.rs @@ -45,7 +45,7 @@ use crate::{ runtime::{gas_from_fee, GAS_PRICE}, GasEncoder, 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}, @@ -84,7 +84,7 @@ use sp_runtime::{ pub use crate::{ address::{create1, create2, AccountId32Mapper, AddressMapper}, debug::Tracing, - exec::MomentOf, + exec::{MomentOf, Origin}, pallet::*, }; pub use primitives::*; diff --git a/substrate/frame/revive/uapi/src/host.rs b/substrate/frame/revive/uapi/src/host.rs index eced4843b5522a6d0cbf98f18ee9ba06abbfb4b6..d90c0f45205d8921767077abb93b6a05628c1812 100644 --- a/substrate/frame/revive/uapi/src/host.rs +++ b/substrate/frame/revive/uapi/src/host.rs @@ -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. /// diff --git a/substrate/frame/revive/uapi/src/host/riscv64.rs b/substrate/frame/revive/uapi/src/host/riscv64.rs index 6fdda86892d53000e50c3f5c9dfb7be56081e062..c83be942a9708a65ef54f09f6304a7f29a27c5d5 100644 --- a/substrate/frame/revive/uapi/src/host/riscv64.rs +++ b/substrate/frame/revive/uapi/src/host/riscv64.rs @@ -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]