From 7609c4b0aaa46687a4640299e082ce364eacd1b7 Mon Sep 17 00:00:00 2001 From: Robert van Eerdewijk Date: Fri, 12 Dec 2025 12:27:10 +0100 Subject: [PATCH 01/11] added sr25519Verify to System precompile --- .../fixtures/contracts/S25519Verify.sol | 18 ++++++ .../revive/src/precompiles/builtin/system.rs | 8 +++ .../frame/revive/src/tests/sol/system.rs | 55 +++++++++++++++++++ substrate/frame/revive/uapi/sol/ISystem.sol | 12 ++++ 4 files changed, 93 insertions(+) create mode 100644 substrate/frame/revive/fixtures/contracts/S25519Verify.sol diff --git a/substrate/frame/revive/fixtures/contracts/S25519Verify.sol b/substrate/frame/revive/fixtures/contracts/S25519Verify.sol new file mode 100644 index 0000000000000..4fcac10806a4d --- /dev/null +++ b/substrate/frame/revive/fixtures/contracts/S25519Verify.sol @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.30; + +import "@revive/ISystem.sol"; + +contract Sr25519Verify { + function verify(uint8[64] calldata signature, bytes calldata message, bytes32 publicKey) external returns (bool) { + bytes memory data = abi.encodeWithSelector(ISystem.sr25519Verify.selector, signature, message, publicKey); + (bool success, bytes memory returnData) = SYSTEM_ADDR.call(data); + if (!success) { + assembly { + revert(add(returnData, 0x20), mload(returnData)) + } + } + bool ok = abi.decode(returnData, (bool)); + return ok; + } +} \ No newline at end of file diff --git a/substrate/frame/revive/src/precompiles/builtin/system.rs b/substrate/frame/revive/src/precompiles/builtin/system.rs index e465fcbfadf12..663fbf5d20141 100644 --- a/substrate/frame/revive/src/precompiles/builtin/system.rs +++ b/substrate/frame/revive/src/precompiles/builtin/system.rs @@ -100,6 +100,14 @@ impl BuiltinPrecompile for System { env.terminate_caller(&h160).map_err(Error::try_to_revert::)?; Ok(Vec::new()) }, + ISystemCalls::sr25519Verify(ISystem::sr25519VerifyCall { + signature, + message, + publicKey, + }) => { + let ok = env.sr25519_verify(signature, message, publicKey); + Ok(ok.abi_encode()) + }, } } } diff --git a/substrate/frame/revive/src/tests/sol/system.rs b/substrate/frame/revive/src/tests/sol/system.rs index 5f7a2e4c67872..ce12bdf3beadf 100644 --- a/substrate/frame/revive/src/tests/sol/system.rs +++ b/substrate/frame/revive/src/tests/sol/system.rs @@ -19,10 +19,15 @@ use crate::{ evm::fees::InfoT, + precompiles::alloy::sol_types::{ + sol_data::{Bool, FixedBytes}, + SolType, + }, test_utils::{builder::Contract, deposit_limit, ALICE, ALICE_ADDR, WEIGHT_LIMIT}, tests::{builder, Contracts, ExtBuilder, Test}, Code, Config, ExecConfig, TransactionLimits, TransactionMeter, U256, }; + use alloy_core::sol_types::{Revert, SolCall, SolConstructor, SolError}; use frame_support::traits::fungible::{Balanced, Mutate}; use pallet_revive_fixtures::{ @@ -342,3 +347,53 @@ fn constructor_with_argument_works(fixture_type: FixtureType) { assert_eq!(result.data, Revert::from(expected_message).abi_encode()); }); } + +// #[test_case(FixtureType::Solc)] +#[test_case(FixtureType::Resolc)] +fn sr25519_verify(fixture_type: FixtureType) { + use pallet_revive_fixtures::Sr25519Verify; + let (binary, _) = compile_module_with_type("Sr25519Verify", fixture_type).unwrap(); + + ExtBuilder::default().build().execute_with(|| { + let _ = ::Currency::set_balance(&ALICE, 100_000_000_000); + + // Instantiate the first contract + let Contract { addr: contract_addr, .. } = + builder::bare_instantiate(Code::Upload(binary)).build_and_unwrap_contract(); + + let call_with = |message: &[u8; 11]| { + // Alice's signature for "hello world" + #[rustfmt::skip] + let signature: [u8; 64] = [ + 184, 49, 74, 238, 78, 165, 102, 252, 22, 92, 156, 176, 124, 118, 168, 116, 247, + 99, 0, 94, 2, 45, 9, 170, 73, 222, 182, 74, 60, 32, 75, 64, 98, 174, 69, 55, 83, + 85, 180, 98, 208, 75, 231, 57, 205, 62, 4, 105, 26, 136, 172, 17, 123, 99, 90, 255, + 228, 54, 115, 63, 30, 207, 205, 131, + ]; + + // Alice's public key + #[rustfmt::skip] + let public_key: [u8; 32] = [ + 212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, + 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125, + ]; + + let result = builder::bare_call(contract_addr) + .data( + Sr25519Verify::verifyCall { + signature: signature.into(), + message: message.clone().into(), + publicKey: public_key.into(), + } + .abi_encode(), + ) + .build_and_unwrap_result(); + assert!(!result.did_revert()); + result + }; + let result = Bool::abi_decode(&call_with(&b"hello world").data).expect("decoding failed"); + assert!(result); + let result = Bool::abi_decode(&call_with(&b"hello worlD").data).expect("decoding failed"); + assert!(!result); + }); +} diff --git a/substrate/frame/revive/uapi/sol/ISystem.sol b/substrate/frame/revive/uapi/sol/ISystem.sol index be79f98129858..c30c62ef7f2de 100644 --- a/substrate/frame/revive/uapi/sol/ISystem.sol +++ b/substrate/frame/revive/uapi/sol/ISystem.sol @@ -51,4 +51,16 @@ interface ISystem { /// - called from delegate context /// - the contract introduced balance locks function terminate(address beneficiary) external; + + /// Verify a sr25519 signature + /// + /// # Parameters + /// + /// - `signature`: The signature bytes. + /// - `message`: The message bytes. + /// + /// # Errors + /// + /// - [Sr25519VerifyFailed][`crate::ReturnErrorCode::Sr25519VerifyFailed] + function sr25519Verify(uint8[64] calldata signature, bytes memory message, bytes32 publicKey) external view returns (bool); } From da4db79c7910b7e6f8f4950500ce7c9180603f2c Mon Sep 17 00:00:00 2001 From: Robert van Eerdewijk Date: Fri, 12 Dec 2025 12:30:38 +0100 Subject: [PATCH 02/11] removed sr25519_verify from host functions --- .../fixtures/contracts/sr25519_verify.rs | 48 ------------------- substrate/frame/revive/src/tests/pvm.rs | 45 ----------------- substrate/frame/revive/uapi/src/host.rs | 13 ----- .../frame/revive/uapi/src/host/riscv64.rs | 19 -------- 4 files changed, 125 deletions(-) delete mode 100644 substrate/frame/revive/fixtures/contracts/sr25519_verify.rs diff --git a/substrate/frame/revive/fixtures/contracts/sr25519_verify.rs b/substrate/frame/revive/fixtures/contracts/sr25519_verify.rs deleted file mode 100644 index 8ef39848c53fe..0000000000000 --- a/substrate/frame/revive/fixtures/contracts/sr25519_verify.rs +++ /dev/null @@ -1,48 +0,0 @@ -// 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. - -#![no_std] -#![no_main] -include!("../panic_handler.rs"); - -use uapi::{input, 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() { - input!( - signature: [u8; 64], - pub_key: [u8; 32], - msg: [u8; 11], - ); - - let exit_status = match api::sr25519_verify( - &signature.try_into().unwrap(), - msg, - &pub_key.try_into().unwrap(), - ) { - Ok(_) => 0u32, - Err(code) => code as u32, - }; - - // Exit with success and take transfer return code to the output buffer. - api::return_value(uapi::ReturnFlags::empty(), &exit_status.to_le_bytes()); -} diff --git a/substrate/frame/revive/src/tests/pvm.rs b/substrate/frame/revive/src/tests/pvm.rs index d3a1545a46330..14c1367a9e9ba 100644 --- a/substrate/frame/revive/src/tests/pvm.rs +++ b/substrate/frame/revive/src/tests/pvm.rs @@ -1916,51 +1916,6 @@ fn call_runtime_reentrancy_guarded() { }); } -#[test] -fn sr25519_verify() { - let (binary, _code_hash) = compile_module("sr25519_verify").unwrap(); - - ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let _ = ::Currency::set_balance(&ALICE, 1_000_000); - - // Instantiate the sr25519_verify contract. - let Contract { addr, .. } = builder::bare_instantiate(Code::Upload(binary)) - .native_value(100_000) - .build_and_unwrap_contract(); - - let call_with = |message: &[u8; 11]| { - // Alice's signature for "hello world" - #[rustfmt::skip] - let signature: [u8; 64] = [ - 184, 49, 74, 238, 78, 165, 102, 252, 22, 92, 156, 176, 124, 118, 168, 116, 247, - 99, 0, 94, 2, 45, 9, 170, 73, 222, 182, 74, 60, 32, 75, 64, 98, 174, 69, 55, 83, - 85, 180, 98, 208, 75, 231, 57, 205, 62, 4, 105, 26, 136, 172, 17, 123, 99, 90, 255, - 228, 54, 115, 63, 30, 207, 205, 131, - ]; - - // Alice's public key - #[rustfmt::skip] - let public_key: [u8; 32] = [ - 212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, - 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125, - ]; - - let mut params = vec![]; - params.extend_from_slice(&signature); - params.extend_from_slice(&public_key); - params.extend_from_slice(message); - - builder::bare_call(addr).data(params).build_and_unwrap_result() - }; - - // verification should succeed for "hello world" - assert_return_code!(call_with(&b"hello world"), RuntimeReturnCode::Success); - - // verification should fail for other messages - assert_return_code!(call_with(&b"hello worlD"), RuntimeReturnCode::Sr25519VerifyFailed); - }); -} - #[test] fn upload_code_works() { let (binary, code_hash) = compile_module("dummy").unwrap(); diff --git a/substrate/frame/revive/uapi/src/host.rs b/substrate/frame/revive/uapi/src/host.rs index b2d3c65e8c86c..4bd89486be72d 100644 --- a/substrate/frame/revive/uapi/src/host.rs +++ b/substrate/frame/revive/uapi/src/host.rs @@ -491,19 +491,6 @@ pub trait HostFn: private::Sealed { /// - [EcdsaRecoveryFailed][`crate::ReturnErrorCode::EcdsaRecoveryFailed] #[unstable_hostfn] fn ecdsa_to_eth_address(pubkey: &[u8; 33], output: &mut [u8; 20]) -> Result; - - /// Verify a sr25519 signature - /// - /// # Parameters - /// - /// - `signature`: The signature bytes. - /// - `message`: The message bytes. - /// - /// # Errors - /// - /// - [Sr25519VerifyFailed][`crate::ReturnErrorCode::Sr25519VerifyFailed] - #[unstable_hostfn] - fn sr25519_verify(signature: &[u8; 64], message: &[u8], pub_key: &[u8; 32]) -> Result; } mod private { diff --git a/substrate/frame/revive/uapi/src/host/riscv64.rs b/substrate/frame/revive/uapi/src/host/riscv64.rs index 3eb8bf33656cb..53ac4412c3701 100644 --- a/substrate/frame/revive/uapi/src/host/riscv64.rs +++ b/substrate/frame/revive/uapi/src/host/riscv64.rs @@ -126,12 +126,6 @@ mod sys { pub fn block_hash(block_number_ptr: *const u8, out_ptr: *mut u8); pub fn block_author(out_ptr: *mut u8); pub fn hash_keccak_256(input_ptr: *const u8, input_len: u32, out_ptr: *mut u8); - pub fn sr25519_verify( - signature_ptr: *const u8, - pub_key_ptr: *const u8, - message_len: u32, - message_ptr: *const u8, - ) -> ReturnCode; pub fn ecdsa_to_eth_address(key_ptr: *const u8, out_ptr: *mut u8) -> ReturnCode; pub fn instantiation_nonce() -> u64; pub fn return_data_size() -> u64; @@ -517,17 +511,4 @@ impl HostFn for HostFnImpl { let ret_code = unsafe { sys::ecdsa_to_eth_address(pubkey.as_ptr(), output.as_mut_ptr()) }; ret_code.into() } - - #[unstable_hostfn] - fn sr25519_verify(signature: &[u8; 64], message: &[u8], pub_key: &[u8; 32]) -> Result { - let ret_code = unsafe { - sys::sr25519_verify( - signature.as_ptr(), - pub_key.as_ptr(), - message.len() as u32, - message.as_ptr(), - ) - }; - ret_code.into() - } } From 61377c69c439d5eacc296796b21f8ad0c78b3f67 Mon Sep 17 00:00:00 2001 From: "cmd[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 12 Dec 2025 11:35:05 +0000 Subject: [PATCH 03/11] Update from github-actions[bot] running command 'prdoc --audience runtime_dev --bump patch' --- prdoc/pr_10635.prdoc | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 prdoc/pr_10635.prdoc diff --git a/prdoc/pr_10635.prdoc b/prdoc/pr_10635.prdoc new file mode 100644 index 0000000000000..4bd527985a816 --- /dev/null +++ b/prdoc/pr_10635.prdoc @@ -0,0 +1,11 @@ +title: '[pallet-revive] remove unstable host function sr25519_verify' +doc: +- audience: Runtime Dev + description: fixes part of https://github.com/paritytech/polkadot-sdk/issues/8572 +crates: +- name: pallet-revive-fixtures + bump: patch +- name: pallet-revive + bump: patch +- name: pallet-revive-uapi + bump: patch From 3ad2eaf84c84143d958d6672c3c4953f5926ab1d Mon Sep 17 00:00:00 2001 From: Robert van Eerdewijk Date: Fri, 12 Dec 2025 12:35:52 +0100 Subject: [PATCH 04/11] newline --- substrate/frame/revive/fixtures/contracts/S25519Verify.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/frame/revive/fixtures/contracts/S25519Verify.sol b/substrate/frame/revive/fixtures/contracts/S25519Verify.sol index 4fcac10806a4d..b73d773c8c11f 100644 --- a/substrate/frame/revive/fixtures/contracts/S25519Verify.sol +++ b/substrate/frame/revive/fixtures/contracts/S25519Verify.sol @@ -15,4 +15,4 @@ contract Sr25519Verify { bool ok = abi.decode(returnData, (bool)); return ok; } -} \ No newline at end of file +} From 7bb6b66f2f39061acacd83d4aef5f93f65e547a3 Mon Sep 17 00:00:00 2001 From: Robert van Eerdewijk Date: Fri, 12 Dec 2025 15:40:55 +0100 Subject: [PATCH 05/11] enable solc test --- substrate/frame/revive/src/tests/sol/system.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/frame/revive/src/tests/sol/system.rs b/substrate/frame/revive/src/tests/sol/system.rs index ce12bdf3beadf..81d77ddd32084 100644 --- a/substrate/frame/revive/src/tests/sol/system.rs +++ b/substrate/frame/revive/src/tests/sol/system.rs @@ -348,7 +348,7 @@ fn constructor_with_argument_works(fixture_type: FixtureType) { }); } -// #[test_case(FixtureType::Solc)] +#[test_case(FixtureType::Solc)] #[test_case(FixtureType::Resolc)] fn sr25519_verify(fixture_type: FixtureType) { use pallet_revive_fixtures::Sr25519Verify; From c5cee6a2d364e28533e5779be8d5a81bcb3d9187 Mon Sep 17 00:00:00 2001 From: Robert van Eerdewijk Date: Fri, 12 Dec 2025 15:44:17 +0100 Subject: [PATCH 06/11] fix comment --- substrate/frame/revive/uapi/sol/ISystem.sol | 4 ---- 1 file changed, 4 deletions(-) diff --git a/substrate/frame/revive/uapi/sol/ISystem.sol b/substrate/frame/revive/uapi/sol/ISystem.sol index c30c62ef7f2de..f1600772b40af 100644 --- a/substrate/frame/revive/uapi/sol/ISystem.sol +++ b/substrate/frame/revive/uapi/sol/ISystem.sol @@ -58,9 +58,5 @@ interface ISystem { /// /// - `signature`: The signature bytes. /// - `message`: The message bytes. - /// - /// # Errors - /// - /// - [Sr25519VerifyFailed][`crate::ReturnErrorCode::Sr25519VerifyFailed] function sr25519Verify(uint8[64] calldata signature, bytes memory message, bytes32 publicKey) external view returns (bool); } From 3171b68c71b3b7aecc2ce201027417bcddb8c0fa Mon Sep 17 00:00:00 2001 From: Robert van Eerdewijk Date: Fri, 12 Dec 2025 15:58:58 +0100 Subject: [PATCH 07/11] fix ci --- substrate/frame/revive/src/tests/sol/system.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/substrate/frame/revive/src/tests/sol/system.rs b/substrate/frame/revive/src/tests/sol/system.rs index 81d77ddd32084..d6cd79d3ed01b 100644 --- a/substrate/frame/revive/src/tests/sol/system.rs +++ b/substrate/frame/revive/src/tests/sol/system.rs @@ -19,10 +19,7 @@ use crate::{ evm::fees::InfoT, - precompiles::alloy::sol_types::{ - sol_data::{Bool, FixedBytes}, - SolType, - }, + precompiles::alloy::sol_types::{sol_data::Bool, SolType}, test_utils::{builder::Contract, deposit_limit, ALICE, ALICE_ADDR, WEIGHT_LIMIT}, tests::{builder, Contracts, ExtBuilder, Test}, Code, Config, ExecConfig, TransactionLimits, TransactionMeter, U256, From 02a18f21e034798fad2862f999df337a98e916d0 Mon Sep 17 00:00:00 2001 From: Robert van Eerdewijk Date: Sat, 13 Dec 2025 07:56:24 +0100 Subject: [PATCH 08/11] clippy --- substrate/frame/revive/src/tests/sol/system.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/frame/revive/src/tests/sol/system.rs b/substrate/frame/revive/src/tests/sol/system.rs index d6cd79d3ed01b..0ff5ed50438b9 100644 --- a/substrate/frame/revive/src/tests/sol/system.rs +++ b/substrate/frame/revive/src/tests/sol/system.rs @@ -379,7 +379,7 @@ fn sr25519_verify(fixture_type: FixtureType) { .data( Sr25519Verify::verifyCall { signature: signature.into(), - message: message.clone().into(), + message: (*message).into(), publicKey: public_key.into(), } .abi_encode(), From 3f3b9f981ac2cae0c098a2ac9de03cfd62bb3ccb Mon Sep 17 00:00:00 2001 From: Robert van Eerdewijk Date: Wed, 17 Dec 2025 11:10:02 +0100 Subject: [PATCH 09/11] moved sr25519_verify test into the precompile source file --- .../fixtures/contracts/S25519Verify.sol | 18 ------- .../revive/src/precompiles/builtin/system.rs | 41 +++++++++++++++ .../frame/revive/src/tests/sol/system.rs | 51 ------------------- 3 files changed, 41 insertions(+), 69 deletions(-) delete mode 100644 substrate/frame/revive/fixtures/contracts/S25519Verify.sol diff --git a/substrate/frame/revive/fixtures/contracts/S25519Verify.sol b/substrate/frame/revive/fixtures/contracts/S25519Verify.sol deleted file mode 100644 index b73d773c8c11f..0000000000000 --- a/substrate/frame/revive/fixtures/contracts/S25519Verify.sol +++ /dev/null @@ -1,18 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.30; - -import "@revive/ISystem.sol"; - -contract Sr25519Verify { - function verify(uint8[64] calldata signature, bytes calldata message, bytes32 publicKey) external returns (bool) { - bytes memory data = abi.encodeWithSelector(ISystem.sr25519Verify.selector, signature, message, publicKey); - (bool success, bytes memory returnData) = SYSTEM_ADDR.call(data); - if (!success) { - assembly { - revert(add(returnData, 0x20), mload(returnData)) - } - } - bool ok = abi.decode(returnData, (bool)); - return ok; - } -} diff --git a/substrate/frame/revive/src/precompiles/builtin/system.rs b/substrate/frame/revive/src/precompiles/builtin/system.rs index 663fbf5d20141..dceed2f76cc98 100644 --- a/substrate/frame/revive/src/precompiles/builtin/system.rs +++ b/substrate/frame/revive/src/precompiles/builtin/system.rs @@ -198,4 +198,45 @@ mod tests { ); }) } + #[test] + fn sr25519_verify() { + use crate::test_utils::ALICE; + use crate::precompiles::alloy::sol_types::sol_data::Bool; + ExtBuilder::default().build().execute_with(|| { + let _ = ::Currency::set_balance(&ALICE, 100_000_000_000); + + let mut call_setup = CallSetup::::default(); + let (mut ext, _) = call_setup.ext(); + + let mut call_with = |message: &[u8; 11]| { + // Alice's signature for "hello world" + #[rustfmt::skip] + let signature: [u8; 64] = [ + 184, 49, 74, 238, 78, 165, 102, 252, 22, 92, 156, 176, 124, 118, 168, 116, 247, + 99, 0, 94, 2, 45, 9, 170, 73, 222, 182, 74, 60, 32, 75, 64, 98, 174, 69, 55, 83, + 85, 180, 98, 208, 75, 231, 57, 205, 62, 4, 105, 26, 136, 172, 17, 123, 99, 90, 255, + 228, 54, 115, 63, 30, 207, 205, 131, + ]; + + // Alice's public key + #[rustfmt::skip] + let public_key: [u8; 32] = [ + 212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, + 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125, + ]; + + let input = ISystem::ISystemCalls::sr25519Verify(ISystem::sr25519VerifyCall { + signature, + message: (*message).into(), + publicKey: public_key.into(), + }); + >::call(&>::MATCHER.base_address(), &input, &mut ext) + .unwrap() + }; + let result = Bool::abi_decode(&call_with(&b"hello world")).expect("decoding failed"); + assert!(result); + let result = Bool::abi_decode(&call_with(&b"hello worlD")).expect("decoding failed"); + assert!(!result); + }); + } } diff --git a/substrate/frame/revive/src/tests/sol/system.rs b/substrate/frame/revive/src/tests/sol/system.rs index 0ff5ed50438b9..56aaf8a254427 100644 --- a/substrate/frame/revive/src/tests/sol/system.rs +++ b/substrate/frame/revive/src/tests/sol/system.rs @@ -19,7 +19,6 @@ use crate::{ evm::fees::InfoT, - precompiles::alloy::sol_types::{sol_data::Bool, SolType}, test_utils::{builder::Contract, deposit_limit, ALICE, ALICE_ADDR, WEIGHT_LIMIT}, tests::{builder, Contracts, ExtBuilder, Test}, Code, Config, ExecConfig, TransactionLimits, TransactionMeter, U256, @@ -344,53 +343,3 @@ fn constructor_with_argument_works(fixture_type: FixtureType) { assert_eq!(result.data, Revert::from(expected_message).abi_encode()); }); } - -#[test_case(FixtureType::Solc)] -#[test_case(FixtureType::Resolc)] -fn sr25519_verify(fixture_type: FixtureType) { - use pallet_revive_fixtures::Sr25519Verify; - let (binary, _) = compile_module_with_type("Sr25519Verify", fixture_type).unwrap(); - - ExtBuilder::default().build().execute_with(|| { - let _ = ::Currency::set_balance(&ALICE, 100_000_000_000); - - // Instantiate the first contract - let Contract { addr: contract_addr, .. } = - builder::bare_instantiate(Code::Upload(binary)).build_and_unwrap_contract(); - - let call_with = |message: &[u8; 11]| { - // Alice's signature for "hello world" - #[rustfmt::skip] - let signature: [u8; 64] = [ - 184, 49, 74, 238, 78, 165, 102, 252, 22, 92, 156, 176, 124, 118, 168, 116, 247, - 99, 0, 94, 2, 45, 9, 170, 73, 222, 182, 74, 60, 32, 75, 64, 98, 174, 69, 55, 83, - 85, 180, 98, 208, 75, 231, 57, 205, 62, 4, 105, 26, 136, 172, 17, 123, 99, 90, 255, - 228, 54, 115, 63, 30, 207, 205, 131, - ]; - - // Alice's public key - #[rustfmt::skip] - let public_key: [u8; 32] = [ - 212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, - 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125, - ]; - - let result = builder::bare_call(contract_addr) - .data( - Sr25519Verify::verifyCall { - signature: signature.into(), - message: (*message).into(), - publicKey: public_key.into(), - } - .abi_encode(), - ) - .build_and_unwrap_result(); - assert!(!result.did_revert()); - result - }; - let result = Bool::abi_decode(&call_with(&b"hello world").data).expect("decoding failed"); - assert!(result); - let result = Bool::abi_decode(&call_with(&b"hello worlD").data).expect("decoding failed"); - assert!(!result); - }); -} From 7ba774efd0d17157b9c0bf7972f35628294eea4d Mon Sep 17 00:00:00 2001 From: 0xRVE Date: Wed, 17 Dec 2025 11:19:13 +0100 Subject: [PATCH 10/11] Update substrate/frame/revive/uapi/sol/ISystem.sol MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alexander Theißen --- substrate/frame/revive/uapi/sol/ISystem.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/frame/revive/uapi/sol/ISystem.sol b/substrate/frame/revive/uapi/sol/ISystem.sol index f1600772b40af..e82e56292c6a0 100644 --- a/substrate/frame/revive/uapi/sol/ISystem.sol +++ b/substrate/frame/revive/uapi/sol/ISystem.sol @@ -58,5 +58,5 @@ interface ISystem { /// /// - `signature`: The signature bytes. /// - `message`: The message bytes. - function sr25519Verify(uint8[64] calldata signature, bytes memory message, bytes32 publicKey) external view returns (bool); + function sr25519Verify(uint8[64] calldata signature, bytes calldata message, bytes32 publicKey) external view returns (bool); } From 1d166c27f63f06430ae5143da4f211f7eca1efb2 Mon Sep 17 00:00:00 2001 From: Robert van Eerdewijk Date: Wed, 17 Dec 2025 11:48:09 +0100 Subject: [PATCH 11/11] format --- substrate/frame/revive/src/precompiles/builtin/system.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/substrate/frame/revive/src/precompiles/builtin/system.rs b/substrate/frame/revive/src/precompiles/builtin/system.rs index dceed2f76cc98..7a3e92d72a8b6 100644 --- a/substrate/frame/revive/src/precompiles/builtin/system.rs +++ b/substrate/frame/revive/src/precompiles/builtin/system.rs @@ -200,8 +200,7 @@ mod tests { } #[test] fn sr25519_verify() { - use crate::test_utils::ALICE; - use crate::precompiles::alloy::sol_types::sol_data::Bool; + use crate::{precompiles::alloy::sol_types::sol_data::Bool, test_utils::ALICE}; ExtBuilder::default().build().execute_with(|| { let _ = ::Currency::set_balance(&ALICE, 100_000_000_000);