-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[pallet-revive] Migrate various getters to System pre-compile
#9517
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
Merged
athei
merged 74 commits into
paritytech:master
from
use-ink:cmichi-migrate-revive-getters-to-system-precompile
Sep 17, 2025
Merged
Changes from all commits
Commits
Show all changes
74 commits
Select commit
Hold shift + click to select a range
8012f45
Reflect `block_hash` already being stable in `uapi`
cmichi db9f6c5
Remove `call_chain_extension` from `uapi`
cmichi 1b69351
Implement getters
cmichi cc83058
Remove `address` arg
cmichi 085a84e
Migrate calls to delegate_calls
cmichi 8568190
Rename pre-compile weights
cmichi 077bede
Migrate benchmarks
cmichi 54cd40b
Remove unused functionality
cmichi 7e2b99d
Clean up code
cmichi ec00d2a
Fix `unused_parens`
cmichi dd607ef
Migrate benchmark for `weight_left`
cmichi 66799e3
Add prdoc file
cmichi 64f680f
Code cleanups
cmichi c4c34be
Apply `taplo` suggestions
cmichi ccdaa48
Update function signatures
cmichi 860b65e
Make CI happy
cmichi 19ca21e
Import `vec`
cmichi 61fd201
Adapt semver changes based on CI check
cmichi 7bfd2fc
Update semver
cmichi dbf6845
Merge remote-tracking branch 'origin/master' into cmichi-migrate-revi…
cmichi 202b1df
Revert lockfile changes
cmichi 0b41ce0
Revert merge changes
cmichi 72979fd
Fix merge issues
cmichi eb35a38
Merge remote-tracking branch 'origin/master' into cmichi-migrate-revi…
cmichi 121eb93
Apply git diff
cmichi 284456c
Merge remote-tracking branch 'origin/master' into cmichi-migrate-revi…
cmichi f9e1034
Simplify variable naming
cmichi 0f6e7ed
Fix test
cmichi 4dc44be
Allow pre-compiles access to `convert_native_to_evm`
cmichi 80c58a3
Encode as Solidity types
cmichi bde818c
Merge remote-tracking branch 'origin/master' into cmichi-migrate-revi…
cmichi d4e0b5c
Follow-up to `master` merge
cmichi 8576e7f
Remove dead code
cmichi bc1b6f6
Merge remote-tracking branch 'origin/master' into cmichi-migrate-revi…
cmichi 64e145b
Resolve merge test failures
cmichi 0816676
Merge remote-tracking branch 'origin/master' into cmichi-migrate-revi…
cmichi 8e46866
Merge remote-tracking branch 'origin/master' into cmichi-migrate-revi…
cmichi f7ff425
Merge remote-tracking branch 'origin/master' into cmichi-migrate-revi…
cmichi 6b1263f
Rollback ext removals
cmichi 24f6f08
Rollback removal of `to_account_id`
cmichi 3faa774
Add tests
cmichi e6a04ed
Use `to_account_id` from `Ext` in pre-compile
cmichi a71467c
Revert "Add tests"
cmichi ebf0365
Move `ISystem` to `pallet-revive-uapi`
cmichi a1a01e0
Merge remote-tracking branch 'origin/master' into cmichi-migrate-revi…
cmichi b7d75dc
Rename feature `precompiles` to `precompiles-sol-interfaces`
cmichi b865371
Improve comment
cmichi 10420b8
Revert introduction of `convert_native_to_evm`
cmichi 6ba7f58
Use `call` over `delegate_call`
cmichi bf48062
Rename `precompile-sol-interfaces` to `precompiles-sol-interfaces`
cmichi 6fc1398
Use `READ_ONLY` for calling getters on pre-compile
cmichi ab717db
Fix `call_diverging_out_len`
cmichi 118aea7
Update substrate/frame/revive/src/benchmarking.rs
cmichi fc94aff
Remove unused dep
cmichi 5e6fc4e
Merge remote-tracking branch 'origin/master' into cmichi-migrate-revi…
cmichi 41ebb98
Use `delegate_call` for `own_code_hash` + `caller_is_root`
cmichi ddf9d08
Use `delegate_call` for `caller_is_origin`
cmichi 76361a8
Simplify `System` precompile
cmichi 45f106c
Use Solidity ABI encoding for `own_code_hash` return value
cmichi 869f690
Allow dead code for `ExtInfo::own_code_hash`
cmichi 55a30fe
Remove unused imports
cmichi 5923c69
Drive-by fix: ink! URL
cmichi 2ac798a
Apply `taplo` toml format
cmichi 6d92b70
Revert unrelated `taplo` change
cmichi cbfd780
Make `own_code_hash` callable via `call`
cmichi 5d39e84
Reflect calling convention in comments
cmichi 78131c8
Use caller of caller for `System::caller_is_origin` + `System::caller…
cmichi 1793c1d
Use `clone()` over `to_owned()`
cmichi 1862e0d
Name unused variable
cmichi 6922bc7
Make CI happy
cmichi a89bf30
Make CI happy
cmichi ab766e4
Merge remote-tracking branch 'origin/master' into cmichi-migrate-revi…
cmichi 7778632
Apply CI recommended changes to toml files
cmichi 23124e4
Apply CI recommended changes to toml files
cmichi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| title: '[pallet-revive] Migrate various getters to `System` pre-compile' | ||
| doc: | ||
| - audience: Runtime Dev | ||
| description: Migrates `own_code_hash`, `caller_is_origin`, `caller_is_root`, | ||
| `weight_left`, `minimum_balance`. Contains minor other fixes (removing leftovers | ||
| from deprecating chain extensions, stabilizing `block_hash` in overlooked crates, …). | ||
| crates: | ||
| - name: pallet-revive | ||
| bump: patch | ||
| - name: pallet-revive-fixtures | ||
| bump: major | ||
| - name: pallet-revive-uapi | ||
| bump: major | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
substrate/frame/revive/fixtures/contracts/call_caller_is_origin.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| // This file is part of Substrate. | ||
|
|
||
| // Copyright (C) Parity Technologies (UK) Ltd. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| //! This fixture calls the `callerIsOrigin` function on the | ||
| //! `System` pre-compile. | ||
|
|
||
| #![no_std] | ||
| #![no_main] | ||
| include!("../panic_handler.rs"); | ||
|
|
||
| use uapi::{HostFn, HostFnImpl as api}; | ||
|
|
||
| #[no_mangle] | ||
| #[polkavm_derive::polkavm_export] | ||
| pub extern "C" fn deploy() {} | ||
|
|
||
| #[no_mangle] | ||
| #[polkavm_derive::polkavm_export] | ||
| pub extern "C" fn call() { | ||
| let mut output = [0u8; 32]; | ||
| let _ = api::call( | ||
| uapi::CallFlags::READ_ONLY, | ||
| &uapi::SYSTEM_PRECOMPILE_ADDR, | ||
| u64::MAX, // How much ref_time to devote for the execution. u64::MAX = use all. | ||
| u64::MAX, // How much proof_size to devote for the execution. u64::MAX = use all. | ||
| &[u8::MAX; 32], // No deposit limit. | ||
| &[0u8; 32], // Value transferred to the contract. | ||
| &uapi::solidity_selector("callerIsOrigin()"), | ||
| Some(&mut &mut output[..]), | ||
| ).unwrap(); | ||
|
|
||
| api::return_value(uapi::ReturnFlags::empty(), &output); | ||
| } |
47 changes: 47 additions & 0 deletions
47
substrate/frame/revive/fixtures/contracts/call_caller_is_root.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| // This file is part of Substrate. | ||
|
|
||
| // Copyright (C) Parity Technologies (UK) Ltd. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| //! This fixture calls the `callerIsRoot` function on the | ||
| //! `System` pre-compile. | ||
|
|
||
| #![no_std] | ||
| #![no_main] | ||
| include!("../panic_handler.rs"); | ||
|
|
||
| use uapi::{HostFn, HostFnImpl as api}; | ||
|
|
||
| #[no_mangle] | ||
| #[polkavm_derive::polkavm_export] | ||
| pub extern "C" fn deploy() {} | ||
|
|
||
| #[no_mangle] | ||
| #[polkavm_derive::polkavm_export] | ||
| pub extern "C" fn call() { | ||
| let mut output = [0u8; 32]; | ||
| let _ = api::call( | ||
| uapi::CallFlags::READ_ONLY, | ||
| &uapi::SYSTEM_PRECOMPILE_ADDR, | ||
| u64::MAX, // How much ref_time to devote for the execution. u64::MAX = use all. | ||
| u64::MAX, // How much proof_size to devote for the execution. u64::MAX = use all. | ||
| &[u8::MAX; 32], // No deposit limit. | ||
| &[0u8; 32], // Value transferred to the contract. | ||
| &uapi::solidity_selector("callerIsRoot()"), | ||
| Some(&mut &mut output[..]), | ||
| ).unwrap(); | ||
|
|
||
| api::return_value(uapi::ReturnFlags::empty(), &output); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
substrate/frame/revive/fixtures/contracts/call_own_code_hash.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| // This file is part of Substrate. | ||
|
|
||
| // Copyright (C) Parity Technologies (UK) Ltd. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| //! This fixture calls the `ownCodeHash` function on the | ||
| //! `System` pre-compile. | ||
|
|
||
| #![allow(unused_imports)] | ||
| #![no_std] | ||
| #![no_main] | ||
| include!("../panic_handler.rs"); | ||
|
|
||
| use core::num::NonZero; | ||
| use uapi::{HostFn, HostFnImpl as api, u256_bytes}; | ||
| use hex_literal::hex; | ||
|
|
||
| #[no_mangle] | ||
| #[polkavm_derive::polkavm_export] | ||
| pub extern "C" fn deploy() { } | ||
|
|
||
| #[no_mangle] | ||
| #[polkavm_derive::polkavm_export] | ||
| pub extern "C" fn call() { | ||
| let mut output_buf = [0u8; 32]; | ||
| let output = &mut &mut output_buf[..]; | ||
| let _ = api::call( | ||
| uapi::CallFlags::READ_ONLY, | ||
| &uapi::SYSTEM_PRECOMPILE_ADDR, | ||
| u64::MAX, // How much ref_time to devote for the execution. u64::MAX = use all. | ||
| u64::MAX, // How much proof_size to devote for the execution. u64::MAX = use all. | ||
| &[u8::MAX; 32], // No deposit limit. | ||
| &[0u8; 32], // Value transferred to the contract. | ||
| &uapi::solidity_selector("ownCodeHash()"), | ||
| Some(output), | ||
| ).unwrap(); | ||
| assert_ne!(output_buf, [0u8; 32]); | ||
| api::return_value(uapi::ReturnFlags::empty(), &output_buf); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 0 additions & 66 deletions
66
substrate/frame/revive/fixtures/contracts/chain_extension_temp_storage.rs
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CI check for correct semver is going a bit haywire here. This is what it came up with:
I believe more correct is:
pallet-revive: patch, as the interface doesn't change.pallet-revive-fixtures: major, as the contracts itself changed, there were also renamings.pallet-revive-uapi: major, in line with the other pre-compile migrations ([pallet-revive] Moveto_account_idhost function toSystempre-compile #9455).