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

[stable2409] Backport #5327 #5798

Merged
merged 3 commits into from
Sep 24, 2024
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
21 changes: 21 additions & 0 deletions .gitlab/pipeline/short-benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,27 @@ short-benchmark-westend: &short-bench
script:
- ./artifacts/polkadot benchmark pallet --chain $RUNTIME-dev --pallet "*" --extrinsic "*" --steps 2 --repeat 1

short-benchmark-rococo: &short-bench
stage: short-benchmarks
extends:
- .docker-env
- .common-refs
needs:
- job: build-short-benchmark
artifacts: true
variables:
RUNTIME: rococo
# Enable debug assertions since we are running optimized builds for testing
# but still want to have debug assertions.
RUSTFLAGS: "-C debug-assertions -D warnings"
RUST_BACKTRACE: "full"
WASM_BUILD_NO_COLOR: 1
WASM_BUILD_RUSTFLAGS: "-C debug-assertions -D warnings"
tags:
- benchmark
script:
- ./artifacts/polkadot benchmark pallet --chain $RUNTIME-dev --pallet "*" --extrinsic "*" --steps 2 --repeat 1

# run short-benchmarks for system parachain runtimes from cumulus

.short-benchmark-cumulus: &short-bench-cumulus
Expand Down
26 changes: 9 additions & 17 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion cumulus/parachains/common/src/genesis_config_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// limitations under the License.

//! Some common helpers for declaring runtime's presets
// note: copied from: cumulus/polkadot-parachain/src/chain_spec/mod.rs

use crate::{AccountId, Signature};
#[cfg(not(feature = "std"))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ pub fn genesis() -> Storage {
minimum_validator_count: 1,
stakers: validators::initial_authorities()
.iter()
.map(|x| {
(x.0.clone(), x.1.clone(), STASH, westend_runtime::StakerStatus::Validator)
})
.map(|x| (x.0.clone(), x.1.clone(), STASH, pallet_staking::StakerStatus::Validator))
.collect(),
invulnerables: validators::initial_authorities().iter().map(|x| x.0.clone()).collect(),
force_era: pallet_staking::Forcing::ForceNone,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,70 +15,58 @@

//! # Asset Hub Rococo Runtime genesis config presets

use crate::*;
use alloc::{vec, vec::Vec};
use cumulus_primitives_core::ParaId;
use hex_literal::hex;
use parachains_common::{genesis_config_helpers::*, AccountId, AuraId, Balance as AssetHubBalance};
use parachains_common::{genesis_config_helpers::*, AccountId, AuraId};
use sp_core::{crypto::UncheckedInto, sr25519};
use sp_genesis_builder::PresetId;
use testnet_parachains_constants::rococo::xcm_version::SAFE_XCM_VERSION;
use testnet_parachains_constants::rococo::{currency::UNITS as ROC, xcm_version::SAFE_XCM_VERSION};

const ASSET_HUB_ROCOCO_ED: AssetHubBalance = crate::ExistentialDeposit::get();

/// Generate the session keys from individual elements.
///
/// The input must be a tuple of individual keys (a single arg for now since we have just one key).
pub fn asset_hub_rococo_session_keys(keys: AuraId) -> crate::SessionKeys {
crate::SessionKeys { aura: keys }
}
const ASSET_HUB_ROCOCO_ED: Balance = ExistentialDeposit::get();

fn asset_hub_rococo_genesis(
invulnerables: Vec<(AccountId, AuraId)>,
endowed_accounts: Vec<AccountId>,
endowment: AssetHubBalance,
endowment: Balance,
id: ParaId,
) -> serde_json::Value {
serde_json::json!({
"balances": crate::BalancesConfig {
balances: endowed_accounts
.iter()
.cloned()
.map(|k| (k, endowment))
.collect(),
},
"parachainInfo": crate::ParachainInfoConfig {
parachain_id: id,
..Default::default()
let config = RuntimeGenesisConfig {
balances: BalancesConfig {
balances: endowed_accounts.iter().cloned().map(|k| (k, endowment)).collect(),
},
"collatorSelection": crate::CollatorSelectionConfig {
parachain_info: ParachainInfoConfig { parachain_id: id, ..Default::default() },
collator_selection: CollatorSelectionConfig {
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
candidacy_bond: ASSET_HUB_ROCOCO_ED * 16,
..Default::default()
},
"session": crate::SessionConfig {
session: SessionConfig {
keys: invulnerables
.into_iter()
.map(|(acc, aura)| {
(
acc.clone(), // account id
acc, // validator id
asset_hub_rococo_session_keys(aura), // session keys
acc.clone(), // account id
acc, // validator id
SessionKeys { aura }, // session keys
)
})
.collect(),
..Default::default()
},
"polkadotXcm": crate::PolkadotXcmConfig {
polkadot_xcm: PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
..Default::default()
}
})
},
..Default::default()
};

serde_json::to_value(config).expect("Could not build genesis config.")
}

/// Encapsulates names of predefined presets.
mod preset_names {
pub const PRESET_DEVELOPMENT: &str = "development";
pub const PRESET_LOCAL: &str = "local";
pub const PRESET_GENESIS: &str = "genesis";
}

Expand Down Expand Up @@ -118,7 +106,7 @@ pub fn get_preset(id: &PresetId) -> Option<Vec<u8>> {
ASSET_HUB_ROCOCO_ED * 524_288,
1000.into(),
),
Ok(PRESET_LOCAL) => asset_hub_rococo_genesis(
Ok(sp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET) => asset_hub_rococo_genesis(
// initial collators.
vec![
(
Expand All @@ -144,10 +132,10 @@ pub fn get_preset(id: &PresetId) -> Option<Vec<u8>> {
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
],
testnet_parachains_constants::rococo::currency::UNITS * 1_000_000,
ROC * 1_000_000,
1000.into(),
),
Ok(PRESET_DEVELOPMENT) => asset_hub_rococo_genesis(
Ok(sp_genesis_builder::DEV_RUNTIME_PRESET) => asset_hub_rococo_genesis(
// initial collators.
vec![(
get_account_id_from_seed::<sr25519::Public>("Alice"),
Expand All @@ -159,10 +147,10 @@ pub fn get_preset(id: &PresetId) -> Option<Vec<u8>> {
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
],
testnet_parachains_constants::rococo::currency::UNITS * 1_000_000,
ROC * 1_000_000,
1000.into(),
),
Err(_) | Ok(_) => return None,
_ => return None,
};

Some(
Expand All @@ -177,7 +165,7 @@ pub fn preset_names() -> Vec<PresetId> {
use preset_names::*;
vec![
PresetId::from(PRESET_GENESIS),
PresetId::from(PRESET_DEVELOPMENT),
PresetId::from(PRESET_LOCAL),
PresetId::from(sp_genesis_builder::DEV_RUNTIME_PRESET),
PresetId::from(sp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET),
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
use cumulus_primitives_core::AggregateMessageOrigin;
use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
use sp_genesis_builder::PresetId;
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
traits::{AccountIdConversion, BlakeTwo256, Block as BlockT, Saturating, Verify},
Expand Down Expand Up @@ -1759,11 +1758,11 @@ impl_runtime_apis! {
build_state::<RuntimeGenesisConfig>(config)
}

fn get_preset(id: &Option<PresetId>) -> Option<Vec<u8>> {
fn get_preset(id: &Option<sp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
get_preset::<RuntimeGenesisConfig>(id, &genesis_config_presets::get_preset)
}

fn preset_names() -> Vec<PresetId> {
fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
genesis_config_presets::preset_names()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ codec = { features = ["derive", "max-encoded-len"], workspace = true }
hex-literal = { workspace = true, default-features = true }
log = { workspace = true }
scale-info = { features = ["derive"], workspace = true }
serde_json = { features = ["alloc"], workspace = true }

# Substrate
frame-benchmarking = { optional = true, workspace = true }
Expand Down Expand Up @@ -233,6 +234,7 @@ std = [
"polkadot-runtime-common/std",
"primitive-types/std",
"scale-info/std",
"serde_json/std",
"snowbridge-router-primitives/std",
"sp-api/std",
"sp-block-builder/std",
Expand Down
Loading
Loading