From a23ace6ef0631c4d0b4fdd028f079af394cc4612 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Wed, 8 Jan 2025 11:49:04 +0100 Subject: [PATCH 1/6] Fix `caller_is_root` return value --- substrate/frame/revive/uapi/src/host.rs | 2 +- substrate/frame/revive/uapi/src/host/riscv64.rs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/substrate/frame/revive/uapi/src/host.rs b/substrate/frame/revive/uapi/src/host.rs index eced4843b552..d90c0f45205d 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 6fdda86892d5..c83be942a970 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] From e4e7d3e2823ff303a185e57c10282dcb2b172bc8 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Wed, 8 Jan 2025 11:48:11 +0100 Subject: [PATCH 2/6] Fix typos --- substrate/frame/revive/src/exec.rs | 2 +- substrate/frame/revive/src/gas.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/substrate/frame/revive/src/exec.rs b/substrate/frame/revive/src/exec.rs index a6a259149768..478e96dc994d 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; - /// 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 9aad84e69201..bec036cc37b6 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 the executor. #[must_use] pub struct Syncable(polkavm::Gas); From e839c65046c3c8d5f075bb8dff7b9004d779eeaa Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Wed, 8 Jan 2025 11:50:02 +0100 Subject: [PATCH 3/6] Re-export `exec::Origin` --- substrate/frame/revive/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/substrate/frame/revive/src/lib.rs b/substrate/frame/revive/src/lib.rs index b9a39e7ce4d3..31f046f96958 100644 --- a/substrate/frame/revive/src/lib.rs +++ b/substrate/frame/revive/src/lib.rs @@ -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}, @@ -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::*; From e53c1bb8d61230b8f598170ff4c7638f1bad7eb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Wed, 8 Jan 2025 13:08:22 +0100 Subject: [PATCH 4/6] Update substrate/frame/revive/src/gas.rs Co-authored-by: Cyrill Leutwiler --- substrate/frame/revive/src/gas.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/frame/revive/src/gas.rs b/substrate/frame/revive/src/gas.rs index bec036cc37b6..5c30a0a51009 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 executor. +/// Wrapped to make sure that the resource will be synced back to the executor. #[must_use] pub struct Syncable(polkavm::Gas); From ebd8932865513ed4c384a6417dd22d3eb293a2ba Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Wed, 8 Jan 2025 14:57:21 +0100 Subject: [PATCH 5/6] Add `prdoc` file --- prdoc/pr_7086.prdoc | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 prdoc/pr_7086.prdoc diff --git a/prdoc/pr_7086.prdoc b/prdoc/pr_7086.prdoc new file mode 100644 index 000000000000..8bedcdaa8af9 --- /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: major +- name: pallet-revive-uapi + bump: major From 66ca692fbedbf828ea6184c9cb06a603a333e9d9 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Wed, 8 Jan 2025 14:58:25 +0100 Subject: [PATCH 6/6] Update `prdoc` file --- prdoc/pr_7086.prdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prdoc/pr_7086.prdoc b/prdoc/pr_7086.prdoc index 8bedcdaa8af9..55fed9bca3e6 100644 --- a/prdoc/pr_7086.prdoc +++ b/prdoc/pr_7086.prdoc @@ -6,6 +6,6 @@ doc: PR re-exports `pallet_revive::exec::Origin` to extend what can be tested externally. crates: - name: pallet-revive - bump: major + bump: minor - name: pallet-revive-uapi bump: major