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

[pull] master from paritytech:master #69

Merged
merged 4 commits into from
Jan 17, 2025
Merged
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
6 changes: 3 additions & 3 deletions .github/workflows/command-inform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
comment:
runs-on: ubuntu-latest
# Temporary disable the bot until the new command bot works properly
if: github.event.issue.pull_request && startsWith(github.event.comment.body, 'bot ') && false # disabled for now, until tested
if: github.event.issue.pull_request && startsWith(github.event.comment.body, 'bot ')
steps:
- name: Inform that the new command exist
uses: actions/github-script@v7
Expand All @@ -18,5 +18,5 @@ jobs:
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'We have migrated the command bot to GHA<br/><br/>Please, see the new usage instructions <a href="https://github.com/paritytech/polkadot-sdk/blob/master/docs/contributor/commands-readme.md">here</a>. Soon the old commands will be disabled.'
})
body: 'We have migrated the command bot to GHA<br/><br/>Please, see the new usage instructions <a href="https://github.com/paritytech/polkadot-sdk/blob/master/docs/contributor/commands-readme.md">here</a> or <a href="https://forum.parity.io/t/streamlining-weight-generation-and-more-the-new-cmd-bot/2411">here</a>. Soon the old commands will be disabled.'
})
2 changes: 1 addition & 1 deletion .github/workflows/review-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
with:
artifact-name: pr_number
- name: "Evaluates PR reviews and assigns reviewers"
uses: paritytech/review-bot@v2.6.0
uses: paritytech/review-bot@v2.7.0
with:
repo-token: ${{ steps.app_token.outputs.token }}
team-token: ${{ steps.app_token.outputs.token }}
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,6 @@ impl pallet_revive::Config for Runtime {
type InstantiateOrigin = EnsureSigned<Self::AccountId>;
type RuntimeHoldReason = RuntimeHoldReason;
type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent;
type Debug = ();
type Xcm = pallet_xcm::Pallet<Self>;
type ChainId = ConstU64<420_420_421>;
type NativeToEthRatio = ConstU32<1_000_000>; // 10^(18 - 12) Eth is 10^18, Native is 10^12.
Expand Down
10 changes: 10 additions & 0 deletions polkadot/runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1087,6 +1087,7 @@ pub enum ProxyType {
CancelProxy,
Auction,
NominationPools,
ParaRegistration,
}
impl Default for ProxyType {
fn default() -> Self {
Expand Down Expand Up @@ -1183,6 +1184,15 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
RuntimeCall::Registrar(..) |
RuntimeCall::Slots(..)
),
ProxyType::ParaRegistration => matches!(
c,
RuntimeCall::Registrar(paras_registrar::Call::reserve { .. }) |
RuntimeCall::Registrar(paras_registrar::Call::register { .. }) |
RuntimeCall::Utility(pallet_utility::Call::batch { .. }) |
RuntimeCall::Utility(pallet_utility::Call::batch_all { .. }) |
RuntimeCall::Utility(pallet_utility::Call::force_batch { .. }) |
RuntimeCall::Proxy(pallet_proxy::Call::remove_proxy { .. })
),
}
}
fn is_superset(&self, o: &Self) -> bool {
Expand Down
14 changes: 14 additions & 0 deletions prdoc/pr_6995.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
title: added new proxy ParaRegistration to Westend
doc:
- audience: Runtime User
description: |-
This adds a new Proxy type to Westend Runtime called ParaRegistration. This is related to: https://github.com/polkadot-fellows/runtimes/pull/520.

This new proxy allows:
1. Reserve paraID
2. Register Parachain
3. Leverage Utilites pallet
4. Remove proxy.
crates:
- name: westend-runtime
bump: major
1 change: 0 additions & 1 deletion substrate/bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1491,7 +1491,6 @@ impl pallet_revive::Config for Runtime {
type InstantiateOrigin = EnsureSigned<Self::AccountId>;
type RuntimeHoldReason = RuntimeHoldReason;
type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent;
type Debug = ();
type Xcm = ();
type ChainId = ConstU64<420_420_420>;
type NativeToEthRatio = ConstU32<1_000_000>; // 10^(18 - 12) Eth is 10^18, Native is 10^12.
Expand Down
2 changes: 2 additions & 0 deletions substrate/frame/revive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ targets = ["x86_64-unknown-linux-gnu"]
codec = { features = ["derive", "max-encoded-len"], workspace = true }
derive_more = { workspace = true }
environmental = { workspace = true }
ethabi = { workspace = true }
ethereum-types = { workspace = true, features = ["codec", "rlp", "serialize"] }
hex = { workspace = true }
impl-trait-for-tuples = { workspace = true }
Expand Down Expand Up @@ -75,6 +76,7 @@ default = ["std"]
std = [
"codec/std",
"environmental/std",
"ethabi/std",
"ethereum-types/std",
"frame-benchmarking?/std",
"frame-support/std",
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/revive/fixtures/build/_Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ edition = "2021"
[dependencies]
uapi = { package = 'pallet-revive-uapi', path = "", features = ["unstable-hostfn"], default-features = false }
common = { package = 'pallet-revive-fixtures-common', path = "" }
hex-literal = { version = "0.4.1", default-features = false }
polkavm-derive = { version = "0.19.0" }

[profile.release]
Expand Down
75 changes: 75 additions & 0 deletions substrate/frame/revive/fixtures/contracts/tracing.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// 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 itself as many times as passed as argument.

#![no_std]
#![no_main]

use common::input;
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() {
input!(calls_left: u32, callee_addr: &[u8; 20],);
if calls_left == 0 {
return
}

let next_input = (calls_left - 1).to_le_bytes();
api::deposit_event(&[], b"before");

// Call the callee, ignore revert.
let _ = api::call(
uapi::CallFlags::empty(),
callee_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.
&next_input,
None,
);

api::deposit_event(&[], b"after");

// own address
let mut addr = [0u8; 20];
api::address(&mut addr);
let mut input = [0u8; 24];

input[..4].copy_from_slice(&next_input);
input[4..24].copy_from_slice(&callee_addr[..20]);

// recurse
api::call(
uapi::CallFlags::ALLOW_REENTRY,
&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.
&input,
None,
)
.unwrap();
}
45 changes: 45 additions & 0 deletions substrate/frame/revive/fixtures/contracts/tracing_callee.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// 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]

use common::input;
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() {
input!(id: u32, );

match id {
// Revert with message "This function always fails"
2 => {
let data = hex_literal::hex!(
"08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001a546869732066756e6374696f6e20616c77617973206661696c73000000000000"
);
api::return_value(uapi::ReturnFlags::REVERT, &data)
},
1 => {
panic!("booum");
},
_ => api::return_value(uapi::ReturnFlags::empty(), &id.to_le_bytes()),
};
}
46 changes: 3 additions & 43 deletions substrate/frame/revive/rpc/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ use crate::{
use jsonrpsee::types::{error::CALL_EXECUTION_FAILED_CODE, ErrorObjectOwned};
use pallet_revive::{
evm::{
Block, BlockNumberOrTag, BlockNumberOrTagOrHash, GenericTransaction, ReceiptInfo,
SyncingProgress, SyncingStatus, TransactionSigned, H160, H256, U256,
extract_revert_message, Block, BlockNumberOrTag, BlockNumberOrTagOrHash,
GenericTransaction, ReceiptInfo, SyncingProgress, SyncingStatus, TransactionSigned, H160,
H256, U256,
},
EthTransactError, EthTransactInfo,
};
Expand Down Expand Up @@ -83,47 +84,6 @@ fn unwrap_call_err(err: &subxt::error::RpcError) -> Option<ErrorObjectOwned> {
}
}

/// Extract the revert message from a revert("msg") solidity statement.
fn extract_revert_message(exec_data: &[u8]) -> Option<String> {
let error_selector = exec_data.get(0..4)?;

match error_selector {
// assert(false)
[0x4E, 0x48, 0x7B, 0x71] => {
let panic_code: u32 = U256::from_big_endian(exec_data.get(4..36)?).try_into().ok()?;

// See https://docs.soliditylang.org/en/latest/control-structures.html#panic-via-assert-and-error-via-require
let msg = match panic_code {
0x00 => "generic panic",
0x01 => "assert(false)",
0x11 => "arithmetic underflow or overflow",
0x12 => "division or modulo by zero",
0x21 => "enum overflow",
0x22 => "invalid encoded storage byte array accessed",
0x31 => "out-of-bounds array access; popping on an empty array",
0x32 => "out-of-bounds access of an array or bytesN",
0x41 => "out of memory",
0x51 => "uninitialized function",
code => return Some(format!("execution reverted: unknown panic code: {code:#x}")),
};

Some(format!("execution reverted: {msg}"))
},
// revert(string)
[0x08, 0xC3, 0x79, 0xA0] => {
let decoded = ethabi::decode(&[ethabi::ParamType::String], &exec_data[4..]).ok()?;
if let Some(ethabi::Token::String(msg)) = decoded.first() {
return Some(format!("execution reverted: {msg}"))
}
Some("execution reverted".to_string())
},
_ => {
log::debug!(target: LOG_TARGET, "Unknown revert function selector: {error_selector:?}");
Some("execution reverted".to_string())
},
}
}

/// The error type for the client.
#[derive(Error, Debug)]
pub enum ClientError {
Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/revive/src/benchmarking/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ mod benchmarks {
let mut setup = CallSetup::<T>::default();
let input = setup.data();
let (mut ext, _) = setup.ext();
ext.override_export(crate::debug::ExportedFunction::Constructor);
ext.override_export(crate::exec::ExportedFunction::Constructor);

let mut runtime = crate::wasm::Runtime::<_, [u8]>::new(&mut ext, input);

Expand Down
Loading
Loading