Skip to content
This repository was archived by the owner on Aug 15, 2025. It is now read-only.

Commit 68ab248

Browse files
claravanstadenclaravanstaden
authored andcommitted
Merge branch 'master' into snowbridge
2 parents 0893dad + 69cc7f2 commit 68ab248

File tree

21 files changed

+2212
-3087
lines changed

21 files changed

+2212
-3087
lines changed

cumulus/parachains/chain-specs/people-westend.json

Lines changed: 192 additions & 21 deletions
Large diffs are not rendered by default.

polkadot/node/network/statement-distribution/src/v2/cluster.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ impl ClusterTracker {
442442
target: LOG_TARGET,
443443
pending_statements = ?self.pending,
444444
?parent_hash,
445-
"Cluster has too many pending statements, something wrong with our connection to our group peers \n
445+
"Cluster has too many pending statements, something wrong with our connection to our group peers
446446
Restart might be needed if validator gets 0 backing rewards for more than 3-4 consecutive sessions"
447447
);
448448
}

polkadot/runtime/parachains/src/runtime_api_impl/vstaging.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,22 @@
1818
1919
use crate::scheduler;
2020
use primitives::{CoreIndex, Id as ParaId};
21-
use sp_std::collections::{btree_map::BTreeMap, vec_deque::VecDeque};
21+
use sp_runtime::traits::One;
22+
use sp_std::{
23+
collections::{btree_map::BTreeMap, vec_deque::VecDeque},
24+
vec::Vec,
25+
};
2226

2327
/// Returns the claimqueue from the scheduler
2428
pub fn claim_queue<T: scheduler::Config>() -> BTreeMap<CoreIndex, VecDeque<ParaId>> {
29+
let now = <frame_system::Pallet<T>>::block_number() + One::one();
30+
31+
// This explicit update is only strictly required for session boundaries:
32+
//
33+
// At the end of a session we clear the claim queues: Without this update call, nothing would be
34+
// scheduled to the client.
35+
<scheduler::Pallet<T>>::free_cores_and_fill_claimqueue(Vec::new(), now);
36+
2537
scheduler::ClaimQueue::<T>::get()
2638
.into_iter()
2739
.map(|(core_index, entries)| {

prdoc/pr_3789.prdoc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
2+
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json
3+
4+
title: "[pallet-contracts] Benchmarks improvements"
5+
6+
doc:
7+
- audience: Runtime Dev
8+
description: Reuse wasmi module when validating the wasm code.
9+
crates:
10+
- name: pallet-contracts
11+
bump: patch
12+

prdoc/pr_3915.prdoc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
2+
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json
3+
4+
title: "[pallet-contracts] Weights update"
5+
6+
doc:
7+
- audience: Runtime Dev
8+
description: |
9+
Update Host functions benchmarks, instead of benchmarking the whole call extrinsic, this PR solely benchmark the execution of the Host function.
10+
Previously, some benchmarks would overestimate the weight as both the parsing and execution of the contract were included in the benchmark.
11+
12+
crates:
13+
- name: pallet-contracts
14+
bump: patch

prdoc/pr_4072.prdoc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
title: "Amend chainspecs for people-westend and add IBP bootnodes"
2+
3+
doc:
4+
- audience: Node Operator
5+
description: |
6+
Fixes the people-westend chain spec.
7+
8+
crates:
9+
- name: polkadot-parachain-bin
10+
bump: patch

substrate/client/network/sync/src/strategy/chain_sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,7 @@ where
10631063
let peer = if let Some(peer) = self.peers.get_mut(&peer_id) {
10641064
peer
10651065
} else {
1066-
error!(target: LOG_TARGET, "💔 Called `on_validated_block_announce` with a bad peer ID");
1066+
error!(target: LOG_TARGET, "💔 Called `on_validated_block_announce` with a bad peer ID {peer_id}");
10671067
return Some((hash, number))
10681068
};
10691069

substrate/frame/contracts/fixtures/contracts/return_with_data.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ pub extern "C" fn call() {
3838
output: [u8],
3939
);
4040

41+
// Burn some PoV, clear_storage consumes some PoV as in order to clear the storage we need to we
42+
// need to read its size first.
43+
api::clear_storage_v1(b"");
44+
4145
let exit_status = uapi::ReturnFlags::from_bits(exit_status[0] as u32).unwrap();
4246
api::return_value(exit_status, output);
4347
}
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
// This file is part of Substrate.
2+
3+
// Copyright (C) Parity Technologies (UK) Ltd.
4+
// SPDX-License-Identifier: Apache-2.0
5+
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
18+
use crate::{
19+
benchmarking::{Contract, WasmModule},
20+
exec::Stack,
21+
storage::meter::Meter,
22+
wasm::Runtime,
23+
BalanceOf, Config, DebugBufferVec, Determinism, ExecReturnValue, GasMeter, Origin, Schedule,
24+
TypeInfo, WasmBlob, Weight,
25+
};
26+
use codec::{Encode, HasCompact};
27+
use core::fmt::Debug;
28+
use sp_core::Get;
29+
use sp_std::prelude::*;
30+
31+
type StackExt<'a, T> = Stack<'a, T, WasmBlob<T>>;
32+
33+
/// A prepared contract call ready to be executed.
34+
pub struct PreparedCall<'a, T: Config> {
35+
func: wasmi::Func,
36+
store: wasmi::Store<Runtime<'a, StackExt<'a, T>>>,
37+
}
38+
39+
impl<'a, T: Config> PreparedCall<'a, T> {
40+
pub fn call(mut self) -> ExecReturnValue {
41+
let result = self.func.call(&mut self.store, &[], &mut []);
42+
WasmBlob::<T>::process_result(self.store, result).unwrap()
43+
}
44+
}
45+
46+
/// A builder used to prepare a contract call.
47+
pub struct CallSetup<T: Config> {
48+
contract: Contract<T>,
49+
dest: T::AccountId,
50+
origin: Origin<T>,
51+
gas_meter: GasMeter<T>,
52+
storage_meter: Meter<T>,
53+
schedule: Schedule<T>,
54+
value: BalanceOf<T>,
55+
debug_message: Option<DebugBufferVec<T>>,
56+
determinism: Determinism,
57+
data: Vec<u8>,
58+
}
59+
60+
impl<T> CallSetup<T>
61+
where
62+
T: Config + pallet_balances::Config,
63+
<BalanceOf<T> as HasCompact>::Type: Clone + Eq + PartialEq + Debug + TypeInfo + Encode,
64+
{
65+
/// Setup a new call for the given module.
66+
pub fn new(module: WasmModule<T>) -> Self {
67+
let contract = Contract::<T>::new(module.clone(), vec![]).unwrap();
68+
let dest = contract.account_id.clone();
69+
let origin = Origin::from_account_id(contract.caller.clone());
70+
71+
let storage_meter = Meter::new(&origin, None, 0u32.into()).unwrap();
72+
73+
Self {
74+
contract,
75+
dest,
76+
origin,
77+
gas_meter: GasMeter::new(Weight::MAX),
78+
storage_meter,
79+
schedule: T::Schedule::get(),
80+
value: 0u32.into(),
81+
debug_message: None,
82+
determinism: Determinism::Enforced,
83+
data: vec![],
84+
}
85+
}
86+
87+
/// Set the meter's storage deposit limit.
88+
pub fn set_storage_deposit_limit(&mut self, balance: BalanceOf<T>) {
89+
self.storage_meter = Meter::new(&self.origin, Some(balance), 0u32.into()).unwrap();
90+
}
91+
92+
/// Set the call's origin.
93+
pub fn set_origin(&mut self, origin: Origin<T>) {
94+
self.origin = origin;
95+
}
96+
97+
/// Set the contract's balance.
98+
pub fn set_balance(&mut self, value: BalanceOf<T>) {
99+
self.contract.set_balance(value);
100+
}
101+
102+
/// Set the call's input data.
103+
pub fn set_data(&mut self, value: Vec<u8>) {
104+
self.data = value;
105+
}
106+
107+
/// Set the debug message.
108+
pub fn enable_debug_message(&mut self) {
109+
self.debug_message = Some(Default::default());
110+
}
111+
112+
/// Get the debug message.
113+
pub fn debug_message(&self) -> Option<DebugBufferVec<T>> {
114+
self.debug_message.clone()
115+
}
116+
117+
/// Get the call's input data.
118+
pub fn data(&self) -> Vec<u8> {
119+
self.data.clone()
120+
}
121+
122+
/// Get the call's contract.
123+
pub fn contract(&self) -> Contract<T> {
124+
self.contract.clone()
125+
}
126+
127+
/// Build the call stack.
128+
pub fn ext(&mut self) -> (StackExt<'_, T>, WasmBlob<T>) {
129+
StackExt::bench_new_call(
130+
self.dest.clone(),
131+
self.origin.clone(),
132+
&mut self.gas_meter,
133+
&mut self.storage_meter,
134+
&self.schedule,
135+
self.value,
136+
self.debug_message.as_mut(),
137+
self.determinism,
138+
)
139+
}
140+
141+
/// Prepare a call to the module.
142+
pub fn prepare_call<'a>(
143+
ext: &'a mut StackExt<'a, T>,
144+
module: WasmBlob<T>,
145+
input: Vec<u8>,
146+
) -> PreparedCall<'a, T> {
147+
let (func, store) = module.bench_prepare_call(ext, input);
148+
PreparedCall { func, store }
149+
}
150+
}
151+
152+
#[macro_export]
153+
macro_rules! call_builder(
154+
($func: ident, $module:expr) => {
155+
$crate::call_builder!($func, _contract, $module);
156+
};
157+
($func: ident, $contract: ident, $module:expr) => {
158+
let mut setup = CallSetup::<T>::new($module);
159+
$crate::call_builder!($func, $contract, setup: setup);
160+
};
161+
($func:ident, setup: $setup: ident) => {
162+
$crate::call_builder!($func, _contract, setup: $setup);
163+
};
164+
($func:ident, $contract: ident, setup: $setup: ident) => {
165+
let data = $setup.data();
166+
let $contract = $setup.contract();
167+
let (mut ext, module) = $setup.ext();
168+
let $func = CallSetup::<T>::prepare_call(&mut ext, module, data);
169+
};
170+
);

0 commit comments

Comments
 (0)