-
Notifications
You must be signed in to change notification settings - Fork 768
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
Fix nostd build of several crates #4060
Merged
Merged
Changes from 14 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
fc2869f
Remove wrong nostd
ggwpez 15a6851
Zepter: make nostd-deps optional
ggwpez dd6b1a5
Always enable scale feature
ggwpez c2e04c4
Always enable pallet-state-trie-migration
ggwpez db09175
Remove optional: these pallets are not optional at all
ggwpez a17f95e
Add use sp_std::vec stuff
ggwpez b18244a
Fix benchmarking crate
ggwpez 58c424d
Fix docs
ggwpez 8155936
add prdoc
ggwpez dddf1b0
Fix feature gates
ggwpez 0ee158e
Fix feature gate
ggwpez 430868e
Fix imports
ggwpez 1578135
Also fix crates FRAME and frame-try-runtime
ggwpez 4b8a29c
Fix more
ggwpez 06e8c43
Revert uapi feature changes
ggwpez a1cc2b1
Merge branch 'master' into oty-fix-nostd
ggwpez 83f5967
Use alloc instead of sp-std
ggwpez cecb8f4
ah-rococo: Enable V1 state trie migration
ggwpez c70875c
Revert changes to FRAME crate
ggwpez 0d32f27
FRAME crate: larger experimental warning
ggwpez 54552f3
Merge remote-tracking branch 'origin/master' into oty-fix-nostd
ggwpez 3d764a5
Merge remote-tracking branch 'origin/master' into oty-fix-nostd
ggwpez 3a2f964
Fix features
ggwpez 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
This file contains 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,42 @@ | ||
// 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. | ||
|
||
//! Benchmarking setup for pallet-session. | ||
|
||
use sp_std::{prelude::*, vec}; | ||
|
||
use frame_benchmarking::{benchmarks, whitelisted_caller}; | ||
use frame_system::RawOrigin; | ||
use pallet_session::*; | ||
use parity_scale_codec::Decode; | ||
pub struct Pallet<T: Config>(pallet_session::Pallet<T>); | ||
pub trait Config: pallet_session::Config {} | ||
|
||
benchmarks! { | ||
set_keys { | ||
let caller: T::AccountId = whitelisted_caller(); | ||
frame_system::Pallet::<T>::inc_providers(&caller); | ||
let keys = T::Keys::decode(&mut sp_runtime::traits::TrailingZeroInput::zeroes()).unwrap(); | ||
let proof: Vec<u8> = vec![0,1,2,3]; | ||
}: _(RawOrigin::Signed(caller), keys, proof) | ||
|
||
purge_keys { | ||
let caller: T::AccountId = whitelisted_caller(); | ||
frame_system::Pallet::<T>::inc_providers(&caller); | ||
let keys = T::Keys::decode(&mut sp_runtime::traits::TrailingZeroInput::zeroes()).unwrap(); | ||
let proof: Vec<u8> = vec![0,1,2,3]; | ||
let _t = pallet_session::Pallet::<T>::set_keys(RawOrigin::Signed(caller.clone()).into(), keys, proof); | ||
}: _(RawOrigin::Signed(caller)) | ||
} |
This file contains 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 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 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 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 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 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 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 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,56 @@ | ||
title: "Fix nostd build of several crates" | ||
|
||
doc: | ||
- audience: Runtime Dev | ||
description: | | ||
Fixes feature and dependency configuration of several crate. This should allow for better no-std build capabilities. | ||
|
||
crates: | ||
- name: cumulus-pallet-session-benchmarking | ||
bump: patch | ||
ggwpez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- name: asset-hub-rococo-runtime | ||
bump: patch | ||
- name: glutton-westend-runtime | ||
bump: patch | ||
- name: cumulus-primitives-parachain-inherent | ||
bump: patch | ||
- name: polkadot-primitives | ||
bump: patch | ||
- name: polkadot-runtime-parachains | ||
bump: patch | ||
- name: xcm-executor-integration-tests | ||
bump: patch | ||
- name: pallet-atomic-swap | ||
bump: patch | ||
- name: pallet-contracts | ||
bump: patch | ||
- name: pallet-election-provider-support-benchmarking | ||
bump: patch | ||
- name: pallet-dev-mode | ||
bump: patch | ||
- name: pallet-example-offchain-worker | ||
bump: patch | ||
- name: pallet-indices | ||
bump: patch | ||
- name: pallet-nomination-pools | ||
bump: patch | ||
- name: pallet-nomination-pools-benchmarking | ||
bump: patch | ||
- name: pallet-offences-benchmarking | ||
bump: patch | ||
- name: pallet-root-offences | ||
bump: patch | ||
- name: pallet-session-benchmarking | ||
bump: patch | ||
- name: frame-system-benchmarking | ||
bump: patch | ||
- name: sp-consensus-babe | ||
bump: patch | ||
- name: sp-consensus-babe | ||
bump: patch | ||
- name: sp-core | ||
bump: patch | ||
- name: sp-session | ||
bump: patch | ||
- name: sp-transaction-storage-proof | ||
bump: patch |
This file contains 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 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
89 changes: 89 additions & 0 deletions
89
substrate/frame/election-provider-support/benchmarking/src/inner.rs
This file contains 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,89 @@ | ||
// 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. | ||
|
||
//! Election provider support pallet benchmarking. | ||
//! This is separated into its own crate to avoid bloating the size of the runtime. | ||
|
||
use codec::Decode; | ||
use frame_benchmarking::v1::benchmarks; | ||
use frame_election_provider_support::{NposSolver, PhragMMS, SequentialPhragmen}; | ||
use sp_std::vec::Vec; | ||
|
||
pub struct Pallet<T: Config>(frame_system::Pallet<T>); | ||
pub trait Config: frame_system::Config {} | ||
|
||
const VOTERS: [u32; 2] = [1_000, 2_000]; | ||
const TARGETS: [u32; 2] = [500, 1_000]; | ||
const VOTES_PER_VOTER: [u32; 2] = [5, 16]; | ||
|
||
const SEED: u32 = 999; | ||
fn set_up_voters_targets<AccountId: Decode + Clone>( | ||
voters_len: u32, | ||
targets_len: u32, | ||
degree: usize, | ||
) -> (Vec<(AccountId, u64, impl IntoIterator<Item = AccountId>)>, Vec<AccountId>) { | ||
// fill targets. | ||
let mut targets = (0..targets_len) | ||
.map(|i| frame_benchmarking::account::<AccountId>("Target", i, SEED)) | ||
.collect::<Vec<_>>(); | ||
assert!(targets.len() > degree, "we should always have enough voters to fill"); | ||
targets.truncate(degree); | ||
|
||
// fill voters. | ||
let voters = (0..voters_len) | ||
.map(|i| { | ||
let voter = frame_benchmarking::account::<AccountId>("Voter", i, SEED); | ||
(voter, 1_000, targets.clone()) | ||
}) | ||
.collect::<Vec<_>>(); | ||
|
||
(voters, targets) | ||
} | ||
|
||
benchmarks! { | ||
phragmen { | ||
// number of votes in snapshot. | ||
let v in (VOTERS[0]) .. VOTERS[1]; | ||
// number of targets in snapshot. | ||
let t in (TARGETS[0]) .. TARGETS[1]; | ||
// number of votes per voter (ie the degree). | ||
let d in (VOTES_PER_VOTER[0]) .. VOTES_PER_VOTER[1]; | ||
|
||
let (voters, targets) = set_up_voters_targets::<T::AccountId>(v, t, d as usize); | ||
}: { | ||
assert!( | ||
SequentialPhragmen::<T::AccountId, sp_runtime::Perbill> | ||
::solve(d as usize, targets, voters).is_ok() | ||
); | ||
} | ||
|
||
phragmms { | ||
// number of votes in snapshot. | ||
let v in (VOTERS[0]) .. VOTERS[1]; | ||
// number of targets in snapshot. | ||
let t in (TARGETS[0]) .. TARGETS[1]; | ||
// number of votes per voter (ie the degree). | ||
let d in (VOTES_PER_VOTER[0]) .. VOTES_PER_VOTER[1]; | ||
|
||
let (voters, targets) = set_up_voters_targets::<T::AccountId>(v, t, d as usize); | ||
}: { | ||
assert!( | ||
PhragMMS::<T::AccountId, sp_runtime::Perbill> | ||
::solve(d as usize, targets, voters).is_ok() | ||
); | ||
} | ||
} |
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.
This should still be gated by the construct_runtime! feature gate. But i think that is not actually working, otherwise this change would not be needed 🤷♂️
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.
What?
Generally we don't need this anymore and the state migration should already have been finished.
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.
It is still deployed though, will double-check and remove it then.
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.
Uhf, did we really genesis the asset-hub-rococo with state_version 0?
I just queried
Core::version
of the 1.1 runtime and it returns state_version=0...Looks like it was copy&pasted from AHK. @cheme can you double-check please?
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.
Ouch https://github.com/polkadot-fellows/runtimes/blob/31ba26287ec752574244f0d690167f7ae8430c8b/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs#L153 . (kusuma is fine).
Statemint on rococo (I guess it is now assethub, not sure) was migrated IIRC or was it only on westend cc @PierreBesson ?
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.
I meant it here for the Asset-hub-rococo:
polkadot-sdk/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs
Line 110 in 5601f28
Not sure, since when i queried the runtime api it returned version 0. Maybe we can check with the RPC but the public node does not support it.
PS: Can you maybe create an issue to track the migration of the different runtimes? Or it already exists?
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.
maybe polkadot-fellows/runtimes#74