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

use RuntimeGenesisConfig in genesis config presets #451

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Changelog for the runtimes governed by the Polkadot Fellowship.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased]

### Changed
- Genesis config presets: Make use of RuntimeGenesisConfig to construct genesis config values for all runtimes ([polkadot-fellows/runtimes#451](https://github.com/polkadot-fellows/runtimes/pull/451)).

## [1.3.2] 27.08.2024

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,41 +27,50 @@ fn asset_hub_kusama_genesis(
endowed_accounts: Vec<AccountId>,
id: ParaId,
) -> serde_json::Value {
serde_json::json!({
"balances": BalancesConfig {
let config = RuntimeGenesisConfig {
system: Default::default(),
balances: BalancesConfig {
balances: endowed_accounts
.iter()
.cloned()
.map(|k| (k, ASSET_HUB_KUSAMA_ED * 4096 * 4096))
.collect(),
},
"parachainInfo": ParachainInfoConfig {
parachain_id: id,
..Default::default()
},
"collatorSelection": CollatorSelectionConfig {
transaction_payment: Default::default(),
parachain_info: ParachainInfoConfig { parachain_id: id, ..Default::default() },
collator_selection: CollatorSelectionConfig {
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
candidacy_bond: ASSET_HUB_KUSAMA_ED * 16,
..Default::default()
},
"session": SessionConfig {
session: SessionConfig {
keys: invulnerables
.into_iter()
.map(|(acc, aura)| {
(
acc.clone(), // account id
acc, // validator id
SessionKeys { aura }, // session keys
acc.clone(), // account id
acc, // validator id
SessionKeys { aura }, // session keys
)
})
.collect(),
},
"polkadotXcm": {
"safeXcmVersion": Some(SAFE_XCM_VERSION),
},
// no need to pass anything to aura, in fact it will panic if we do. Session will take care
// of this. `aura: Default::default()`
})
aura: Default::default(),
aura_ext: Default::default(),
polkadot_xcm: PolkadotXcmConfig {
_config: Default::default(),
safe_xcm_version: Some(SAFE_XCM_VERSION),
},
assets: Default::default(),
foreign_assets: Default::default(),
parachain_system: Default::default(),
vesting: Default::default(),
pool_assets: Default::default(),
Comment on lines +61 to +71
Copy link
Contributor

@bkontur bkontur Sep 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dharjeezy Is it intentional to name all the genesis fields here? Could we just use ..Default::default(), for them? Every time we add a new pallet to the runtime, we would also need to add xyz = Default::default() here.

Suggested change
aura: Default::default(),
aura_ext: Default::default(),
polkadot_xcm: PolkadotXcmConfig {
_config: Default::default(),
safe_xcm_version: Some(SAFE_XCM_VERSION),
},
assets: Default::default(),
foreign_assets: Default::default(),
parachain_system: Default::default(),
vesting: Default::default(),
pool_assets: Default::default(),
polkadot_xcm: PolkadotXcmConfig {
_config: Default::default(),
safe_xcm_version: Some(SAFE_XCM_VERSION),
},
..Default::default(),

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michalkucharczyk wdyt here also?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

..Default::default() shall be used.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also adding link to related discussion: paritytech/polkadot-sdk#5327 (comment)

};

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

pub fn asset_hub_kusama_local_testnet_genesis(para_id: ParaId) -> serde_json::Value {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,41 +43,50 @@ fn asset_hub_polkadot_genesis(
endowed_accounts: Vec<AccountId>,
id: ParaId,
) -> serde_json::Value {
serde_json::json!({
"balances": BalancesConfig {
let config = RuntimeGenesisConfig {
system: Default::default(),
balances: BalancesConfig {
balances: endowed_accounts
.iter()
.cloned()
.map(|k| (k, ASSET_HUB_POLKADOT_ED * 4096 * 4096))
.collect(),
},
"parachainInfo": ParachainInfoConfig {
parachain_id: id,
..Default::default()
},
"collatorSelection": CollatorSelectionConfig {
transaction_payment: Default::default(),
parachain_info: ParachainInfoConfig { parachain_id: id, ..Default::default() },
collator_selection: CollatorSelectionConfig {
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
candidacy_bond: ASSET_HUB_POLKADOT_ED * 16,
..Default::default()
},
"session": SessionConfig {
session: SessionConfig {
keys: invulnerables
.into_iter()
.map(|(acc, aura)| {
(
acc.clone(), // account id
acc, // validator id
SessionKeys { aura }, // session keys
acc.clone(), // account id
acc, // validator id
SessionKeys { aura }, // session keys
)
})
.collect(),
},
"polkadotXcm": {
"safeXcmVersion": Some(SAFE_XCM_VERSION),
},
// no need to pass anything to aura, in fact it will panic if we do. Session will take care
// of this. `aura: Default::default()`
})
aura: Default::default(),
aura_ext: Default::default(),
polkadot_xcm: PolkadotXcmConfig {
_config: Default::default(),
safe_xcm_version: Some(SAFE_XCM_VERSION),
},
assets: Default::default(),
foreign_assets: Default::default(),
parachain_system: Default::default(),
vesting: Default::default(),
pool_assets: Default::default(),
};

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

pub fn asset_hub_polkadot_local_testnet_genesis(para_id: ParaId) -> serde_json::Value {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,41 +27,49 @@ fn bridge_hub_kusama_genesis(
endowed_accounts: Vec<AccountId>,
id: ParaId,
) -> serde_json::Value {
serde_json::json!({
"balances": BalancesConfig {
let config = RuntimeGenesisConfig {
system: Default::default(),
balances: BalancesConfig {
balances: endowed_accounts
.iter()
.cloned()
.map(|k| (k, BRIDGE_HUB_KUSAMA_ED * 4096 * 4096))
.collect(),
},
"parachainInfo": ParachainInfoConfig {
parachain_id: id,
..Default::default()
},
"collatorSelection": CollatorSelectionConfig {
parachain_info: ParachainInfoConfig { parachain_id: id, ..Default::default() },
collator_selection: CollatorSelectionConfig {
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
candidacy_bond: BRIDGE_HUB_KUSAMA_ED * 16,
..Default::default()
},
"session": SessionConfig {
session: SessionConfig {
keys: invulnerables
.into_iter()
.map(|(acc, aura)| {
(
acc.clone(), // account id
acc, // validator id
SessionKeys { aura }, // session keys
acc.clone(), // account id
acc, // validator id
SessionKeys { aura }, // session keys
)
})
.collect(),
},
"polkadotXcm": {
"safeXcmVersion": Some(SAFE_XCM_VERSION),
},
// no need to pass anything to aura, in fact it will panic if we do. Session will take care
// of this. `aura: Default::default()`
})
aura: Default::default(),
aura_ext: Default::default(),
polkadot_xcm: PolkadotXcmConfig {
_config: Default::default(),
safe_xcm_version: Some(SAFE_XCM_VERSION),
},
bridge_polkadot_grandpa: Default::default(),
bridge_polkadot_parachains: Default::default(),
parachain_system: Default::default(),
transaction_payment: Default::default(),
bridge_polkadot_messages: Default::default(),
};

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

pub fn bridge_hub_kusama_local_testnet_genesis(para_id: ParaId) -> serde_json::Value {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,46 +27,54 @@ fn bridge_hub_polkadot_genesis(
endowed_accounts: Vec<AccountId>,
id: ParaId,
) -> serde_json::Value {
serde_json::json!({
"balances": BalancesConfig {
let config = RuntimeGenesisConfig {
system: Default::default(),
balances: BalancesConfig {
balances: endowed_accounts
.iter()
.cloned()
.map(|k| (k, BRIDGE_HUB_POLKADOT_ED * 4096 * 4096))
.collect(),
},
"parachainInfo": ParachainInfoConfig {
parachain_id: id,
..Default::default()
},
"collatorSelection": CollatorSelectionConfig {
parachain_info: ParachainInfoConfig { parachain_id: id, ..Default::default() },
collator_selection: CollatorSelectionConfig {
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
candidacy_bond: BRIDGE_HUB_POLKADOT_ED * 16,
..Default::default()
},
"session": SessionConfig {
session: SessionConfig {
keys: invulnerables
.into_iter()
.map(|(acc, aura)| {
(
acc.clone(), // account id
acc, // validator id
acc.clone(), // account id
acc, // validator id
SessionKeys { aura }, // session keys
)
})
.collect(),
},
"polkadotXcm": {
"safeXcmVersion": Some(SAFE_XCM_VERSION),
aura: Default::default(),
aura_ext: Default::default(),
polkadot_xcm: PolkadotXcmConfig {
_config: Default::default(),
safe_xcm_version: Some(SAFE_XCM_VERSION),
},
"ethereumSystem": EthereumSystemConfig {
bridge_kusama_grandpa: Default::default(),
bridge_kusama_parachains: Default::default(),
bridge_kusama_messages: Default::default(),
ethereum_system: EthereumSystemConfig {
para_id: id,
asset_hub_para_id: polkadot_runtime_constants::system_parachain::ASSET_HUB_ID.into(),
..Default::default()
},
// no need to pass anything to aura, in fact it will panic if we do. Session will take care
// of this. `aura: Default::default()`
})
parachain_system: Default::default(),
transaction_payment: Default::default(),
};

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

pub fn bridge_hub_polkadot_local_testnet_genesis(para_id: ParaId) -> serde_json::Value {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,41 +27,50 @@ fn collectives_polkadot_genesis(
endowed_accounts: Vec<AccountId>,
id: ParaId,
) -> serde_json::Value {
serde_json::json!({
"balances": BalancesConfig {
let config = RuntimeGenesisConfig {
system: Default::default(),
balances: BalancesConfig {
balances: endowed_accounts
.iter()
.cloned()
.map(|k| (k, COLLECTIVES_POLKADOT_ED * 4096 * 4096))
.collect(),
},
"parachainInfo": ParachainInfoConfig {
parachain_id: id,
..Default::default()
},
"collatorSelection": CollatorSelectionConfig {
parachain_info: ParachainInfoConfig { parachain_id: id, ..Default::default() },
collator_selection: CollatorSelectionConfig {
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
candidacy_bond: COLLECTIVES_POLKADOT_ED * 16,
..Default::default()
},
"session": SessionConfig {
session: SessionConfig {
keys: invulnerables
.into_iter()
.map(|(acc, aura)| {
(
acc.clone(), // account id
acc, // validator id
SessionKeys { aura }, // session keys
acc.clone(), // account id
acc, // validator id
SessionKeys { aura }, // session keys
)
})
.collect(),
},
"polkadotXcm": {
"safeXcmVersion": Some(SAFE_XCM_VERSION),
},
// no need to pass anything to aura, in fact it will panic if we do. Session will take care
// of this. `aura: Default::default()`
})
aura: Default::default(),
aura_ext: Default::default(),
polkadot_xcm: PolkadotXcmConfig {
_config: Default::default(),
safe_xcm_version: Some(SAFE_XCM_VERSION),
},
alliance: Default::default(),
alliance_motion: Default::default(),
fellowship_treasury: Default::default(),
parachain_system: Default::default(),
transaction_payment: Default::default(),
ambassador_treasury: Default::default(),
};

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

pub fn collectives_polkadot_local_testnet_genesis(para_id: ParaId) -> serde_json::Value {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,22 @@ fn coretime_kusama_genesis(
endowed_accounts: Vec<AccountId>,
id: ParaId,
) -> serde_json::Value {
serde_json::json!({
"balances": BalancesConfig {
let config = RuntimeGenesisConfig {
system: Default::default(),
balances: BalancesConfig {
balances: endowed_accounts
.iter()
.cloned()
.map(|k| (k, CORETIME_KUSAMA_ED * 4096 * 4096))
.collect(),
},
"parachainInfo": ParachainInfoConfig {
parachain_id: id,
..Default::default()
},
"collatorSelection": CollatorSelectionConfig {
parachain_info: ParachainInfoConfig { parachain_id: id, ..Default::default() },
collator_selection: CollatorSelectionConfig {
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
candidacy_bond: CORETIME_KUSAMA_ED * 16,
..Default::default()
},
"session": SessionConfig {
session: SessionConfig {
keys: invulnerables
.into_iter()
.map(|(acc, aura)| {
Expand All @@ -58,12 +56,20 @@ fn coretime_kusama_genesis(
})
.collect(),
},
"polkadotXcm": {
"safeXcmVersion": Some(SAFE_XCM_VERSION),
},
// no need to pass anything to aura, in fact it will panic if we do. Session will take care
// of this. `aura: Default::default()`
})
aura: Default::default(),
aura_ext: Default::default(),
polkadot_xcm: PolkadotXcmConfig {
_config: Default::default(),
safe_xcm_version: Some(SAFE_XCM_VERSION),
},
parachain_system: Default::default(),
transaction_payment: Default::default(),
broker: Default::default(),
};

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

pub fn coretime_kusama_local_testnet_genesis(para_id: ParaId) -> serde_json::Value {
Expand Down
Loading
Loading