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

Moved presets to the testnet runtimes #5327

Merged
merged 40 commits into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
501a331
Set `get_preset` for AssetHubRococo
bkontur Jul 19, 2024
ba2b0eb
Set `get_preset` for AssetHubWestend
bkontur Aug 12, 2024
82c12d4
Set `get_preset` for BridgeHubRococo
bkontur Aug 12, 2024
41d6a83
".git/.scripts/commands/fmt/fmt.sh"
Sep 2, 2024
43d5163
Re-use `sp_genesis_builder::DEV_RUNTIME_PRESET`
bkontur Sep 2, 2024
be4954c
Set `get_preset` for `BridgeHubWestend` and `CollectivesWestend`
bkontur Sep 10, 2024
9174c81
Nits and clean up
bkontur Sep 10, 2024
c14e4cc
Why is rococo missing here?
bkontur Sep 11, 2024
1a8be47
Missing `#[serde(skip)]` for `assigned_slots` pallet
bkontur Sep 11, 2024
5903828
More nits for rococo-runtime
bkontur Sep 11, 2024
ff8b96d
Fix Rococo benchmark for `polkadot_runtime_parachains::paras_inherent`
bkontur Sep 11, 2024
b4a96d0
prdoc
bkontur Sep 11, 2024
406c471
prdoc
bkontur Sep 11, 2024
40b24a4
change wococo to rococo for `0001-dispute-valid-block.toml`
bkontur Sep 12, 2024
070dca2
change wococo to westend for `0001-dispute-valid-block.toml` (rococo …
bkontur Sep 12, 2024
504ba34
Revert rococo fix for benchmarks
bkontur Sep 12, 2024
8d25336
fix bench range should contain 2 iters
ordian Sep 12, 2024
14e3658
prdoc
bkontur Sep 12, 2024
1618975
Fix or remove?
bkontur Sep 12, 2024
55ee989
Removed `wococo` leftovers
bkontur Sep 13, 2024
52d8180
clippy + prdoc
bkontur Sep 13, 2024
e6ea5da
More wococo clean up + prdoc
bkontur Sep 13, 2024
3ff66f2
Add `get_preset` for westend + polkadot-node-service deps clean up
bkontur Sep 13, 2024
0e398a3
Fix deps
bkontur Sep 13, 2024
ba2fb3d
Fix import
bkontur Sep 13, 2024
ea855a1
Some fixes around `get_account_id_from_seed`
bkontur Sep 13, 2024
42fce72
Revert and re-export
bkontur Sep 13, 2024
4424567
Merge remote-tracking branch 'origin/master' into bko-get_preset-for-…
bkontur Sep 13, 2024
aa9bfcc
prdoc
bkontur Sep 13, 2024
8f33808
Merge branch 'master' into bko-get_preset-for-testnets
bkontur Sep 16, 2024
e28bf03
Merge remote-tracking branch 'origin/master' into bko-get_preset-for-…
bkontur Sep 17, 2024
faab276
Merge remote-tracking branch 'origin/master' into bko-get_preset-for-…
bkontur Sep 18, 2024
e8f3bbb
prdoc
bkontur Sep 18, 2024
beded8e
Refactor presets for `LOCAL_TESTNET_RUNTIME_PRESET`
bkontur Sep 18, 2024
b60c89a
Update substrate/primitives/genesis-builder/src/lib.rs
bkontur Sep 18, 2024
5308200
prdoc
bkontur Sep 18, 2024
992af98
Merge remote-tracking branch 'origin/master' into bko-get_preset-for-…
bkontur Sep 18, 2024
8a499e0
Merge remote-tracking branch 'origin/master' into bko-get_preset-for-…
bkontur Sep 19, 2024
87ac7ad
Nits
bkontur Sep 22, 2024
1724235
Merge remote-tracking branch 'origin/master' into bko-get_preset-for-…
bkontur Sep 22, 2024
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
25 changes: 8 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,69 +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 @@ -144,10 +133,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 +148,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 +166,7 @@ pub fn preset_names() -> Vec<PresetId> {
use preset_names::*;
vec![
PresetId::from(PRESET_GENESIS),
PresetId::from(PRESET_DEVELOPMENT),
PresetId::from(sp_genesis_builder::DEV_RUNTIME_PRESET),
PresetId::from(PRESET_LOCAL),
]
}
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