Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Companion PR for substrate PR 8072 - Add a config field to babe epochs #2467

Merged
25 commits merged into from
Mar 10, 2021
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
37d0af2
Add a config field to babe epochs
expenses Feb 17, 2021
6aff871
Merge remote-tracking branch 'origin/master' into ashley-change-babe-…
expenses Feb 18, 2021
e20860a
Fix test
expenses Feb 18, 2021
e99e958
Merge remote-tracking branch 'origin/master' into ashley-change-babe-…
expenses Feb 22, 2021
e752f11
Add BABE_GENESIS_EPOCH_CONFIG consts
expenses Feb 22, 2021
9f53c73
Use PrimaryAndSecondaryVRFSlots and remove newlines
expenses Feb 24, 2021
ca36203
Merge remote-tracking branch 'origin/master' into ashley-change-babe-…
expenses Feb 24, 2021
60e7e3f
Merge remote-tracking branch 'origin/master' into ashley-change-babe-…
expenses Feb 25, 2021
316f242
Make epoch_configs Some
expenses Feb 25, 2021
9a436d8
Fix tests
expenses Feb 25, 2021
9ea0f71
Fix test service tests
expenses Feb 26, 2021
93fdc59
Add a BabeEpochConfigMigrations OnRuntimeUpgrade
expenses Mar 1, 2021
ad5c7d8
Merge remote-tracking branch 'origin/master' into ashley-change-babe-…
expenses Mar 3, 2021
8399429
Apply suggestions
expenses Mar 3, 2021
30dd81c
Merge remote-tracking branch 'origin/master' into ashley-change-babe-…
expenses Mar 3, 2021
3c78c7a
Use PrimaryAndSecondaryPlainSlots in kusama
expenses Mar 3, 2021
a9550e6
Remove migration from test runtime and rococo
expenses Mar 5, 2021
a467317
Merge remote-tracking branch 'origin/master' into ashley-change-babe-…
expenses Mar 9, 2021
1fdd426
Add HasPalletPrefix
expenses Mar 9, 2021
8cf8910
Rename to BabePalletPrefix and change BabeApi -> Babe
expenses Mar 9, 2021
c21ae7d
"Update Substrate"
Mar 10, 2021
0072f6c
Update substrate
expenses Mar 10, 2021
deea094
Merge branch 'ashley-change-babe-epoch' of github.com:paritytech/polk…
expenses Mar 10, 2021
c3a4fd3
Merge remote-tracking branch 'origin/master' into ashley-change-babe-…
expenses Mar 10, 2021
c5a6cfb
Resolve parantheses errors
expenses Mar 10, 2021
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
3 changes: 3 additions & 0 deletions node/core/approval-voting/src/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1351,6 +1351,7 @@ mod tests {
duration: 200,
authorities: vec![(Sr25519Keyring::Alice.public().into(), 1)],
randomness: [0u8; 32],
config: Default::default(),
}));
}
);
Expand Down Expand Up @@ -1456,6 +1457,7 @@ mod tests {
duration: 200,
authorities: vec![(Sr25519Keyring::Alice.public().into(), 1)],
randomness: [0u8; 32],
config: Default::default(),
}));
}
);
Expand Down Expand Up @@ -1707,6 +1709,7 @@ mod tests {
duration: 200,
authorities: vec![(Sr25519Keyring::Alice.public().into(), 1)],
randomness: [0u8; 32],
config: Default::default(),
}));
}
);
Expand Down
1 change: 1 addition & 0 deletions node/core/runtime-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,7 @@ mod tests {
duration: 10,
authorities: Vec::new(),
randomness: [1u8; 32],
config: Default::default(),
};
runtime_api.babe_epoch = Some(epoch.clone());
let runtime_api = Arc::new(runtime_api);
Expand Down
40 changes: 32 additions & 8 deletions node/service/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,10 @@ fn polkadot_staging_testnet_config_genesis(wasm_binary: &[u8]) -> polkadot::Gene
phantom: Default::default(),
}),
pallet_membership_Instance1: Some(Default::default()),
pallet_babe: Some(Default::default()),
pallet_babe: Some(polkadot::BabeConfig {
authorities: Default::default(),
epoch_config: polkadot::BABE_GENESIS_EPOCH_CONFIG,
}),
pallet_grandpa: Some(Default::default()),
pallet_im_online: Some(Default::default()),
pallet_authority_discovery: Some(polkadot::AuthorityDiscoveryConfig { keys: vec![] }),
Expand Down Expand Up @@ -448,7 +451,10 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi
slash_reward_fraction: Perbill::from_percent(10),
..Default::default()
}),
pallet_babe: Some(Default::default()),
pallet_babe: Some(westend::BabeConfig {
authorities: Default::default(),
epoch_config: westend::BABE_GENESIS_EPOCH_CONFIG,
}),
pallet_grandpa: Some(Default::default()),
pallet_im_online: Some(Default::default()),
pallet_authority_discovery: Some(westend::AuthorityDiscoveryConfig { keys: vec![] }),
Expand Down Expand Up @@ -644,7 +650,10 @@ fn kusama_staging_testnet_config_genesis(wasm_binary: &[u8]) -> kusama::GenesisC
phantom: Default::default(),
}),
pallet_membership_Instance1: Some(Default::default()),
pallet_babe: Some(Default::default()),
pallet_babe: Some(kusama::BabeConfig {
authorities: Default::default(),
epoch_config: kusama::BABE_GENESIS_EPOCH_CONFIG,
}),
pallet_grandpa: Some(Default::default()),
pallet_im_online: Some(Default::default()),
pallet_authority_discovery: Some(kusama::AuthorityDiscoveryConfig { keys: vec![] }),
Expand Down Expand Up @@ -850,7 +859,10 @@ fn rococo_staging_testnet_config_genesis(wasm_binary: &[u8]) -> rococo_runtime::
),
)).collect::<Vec<_>>(),
}),
pallet_babe: Some(Default::default()),
pallet_babe: Some(rococo_runtime::BabeConfig {
authorities: Default::default(),
epoch_config: rococo_runtime::BABE_GENESIS_EPOCH_CONFIG,
}),
pallet_grandpa: Some(Default::default()),
pallet_im_online: Some(Default::default()),
pallet_authority_discovery: Some(rococo_runtime::AuthorityDiscoveryConfig {
Expand Down Expand Up @@ -1130,7 +1142,10 @@ pub fn polkadot_testnet_genesis(
phantom: Default::default(),
}),
pallet_membership_Instance1: Some(Default::default()),
pallet_babe: Some(Default::default()),
pallet_babe: Some(polkadot::BabeConfig {
authorities: Default::default(),
epoch_config: polkadot::BABE_GENESIS_EPOCH_CONFIG,
}),
pallet_grandpa: Some(Default::default()),
pallet_im_online: Some(Default::default()),
pallet_authority_discovery: Some(polkadot::AuthorityDiscoveryConfig { keys: vec![] }),
Expand Down Expand Up @@ -1225,7 +1240,10 @@ pub fn kusama_testnet_genesis(
phantom: Default::default(),
}),
pallet_membership_Instance1: Some(Default::default()),
pallet_babe: Some(Default::default()),
pallet_babe: Some(kusama::BabeConfig {
authorities: Default::default(),
epoch_config: kusama::BABE_GENESIS_EPOCH_CONFIG,
}),
pallet_grandpa: Some(Default::default()),
pallet_im_online: Some(Default::default()),
pallet_authority_discovery: Some(kusama::AuthorityDiscoveryConfig { keys: vec![] }),
Expand Down Expand Up @@ -1309,7 +1327,10 @@ pub fn westend_testnet_genesis(
slash_reward_fraction: Perbill::from_percent(10),
..Default::default()
}),
pallet_babe: Some(Default::default()),
pallet_babe: Some(westend::BabeConfig {
authorities: Default::default(),
epoch_config: westend::BABE_GENESIS_EPOCH_CONFIG,
}),
pallet_grandpa: Some(Default::default()),
pallet_im_online: Some(Default::default()),
pallet_authority_discovery: Some(westend::AuthorityDiscoveryConfig { keys: vec![] }),
Expand Down Expand Up @@ -1363,7 +1384,10 @@ pub fn rococo_testnet_genesis(
),
)).collect::<Vec<_>>(),
}),
pallet_babe: Some(Default::default()),
pallet_babe: Some(rococo_runtime::BabeConfig {
authorities: Default::default(),
epoch_config: rococo_runtime::BABE_GENESIS_EPOCH_CONFIG,
}),
pallet_grandpa: Some(Default::default()),
pallet_im_online: Some(Default::default()),
pallet_authority_discovery: Some(rococo_runtime::AuthorityDiscoveryConfig {
Expand Down
11 changes: 9 additions & 2 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
transaction_version: 4,
};

/// The BABE epoch configuration at genesis.
pub const BABE_GENESIS_EPOCH_CONFIG: babe_primitives::BabeEpochConfiguration =
babe_primitives::BabeEpochConfiguration {
c: PRIMARY_PROBABILITY,
allowed_slots: babe_primitives::AllowedSlots::PrimaryAndSecondaryVRFSlots
expenses marked this conversation as resolved.
Show resolved Hide resolved
};

/// Native version.
#[cfg(any(feature = "std", test))]
pub fn native_version() -> NativeVersion {
Expand Down Expand Up @@ -1237,10 +1244,10 @@ sp_api::impl_runtime_apis! {
babe_primitives::BabeGenesisConfiguration {
slot_duration: Babe::slot_duration(),
epoch_length: EpochDuration::get(),
c: PRIMARY_PROBABILITY,
c: BABE_GENESIS_EPOCH_CONFIG.c,
genesis_authorities: Babe::authorities(),
randomness: Babe::randomness(),
allowed_slots: babe_primitives::AllowedSlots::PrimaryAndSecondaryVRFSlots,
allowed_slots: BABE_GENESIS_EPOCH_CONFIG.allowed_slots,
Copy link
Member

Choose a reason for hiding this comment

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

I assume this is only called at genesis?

@andresilva ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, that's fine. The migration has the correct value PrimaryAndSecondaryPlainSlots.

}
}

Expand Down
11 changes: 9 additions & 2 deletions runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
transaction_version: 6,
};

/// The BABE epoch configuration at genesis.
pub const BABE_GENESIS_EPOCH_CONFIG: babe_primitives::BabeEpochConfiguration =
babe_primitives::BabeEpochConfiguration {
c: PRIMARY_PROBABILITY,
allowed_slots: babe_primitives::AllowedSlots::PrimaryAndSecondaryVRFSlots
};

/// Native version.
#[cfg(any(feature = "std", test))]
pub fn native_version() -> NativeVersion {
Expand Down Expand Up @@ -1232,10 +1239,10 @@ sp_api::impl_runtime_apis! {
babe_primitives::BabeGenesisConfiguration {
slot_duration: Babe::slot_duration(),
epoch_length: EpochDuration::get(),
c: PRIMARY_PROBABILITY,
c: BABE_GENESIS_EPOCH_CONFIG.c,
genesis_authorities: Babe::authorities(),
randomness: Babe::randomness(),
allowed_slots: babe_primitives::AllowedSlots::PrimaryAndSecondaryVRFSlots,
allowed_slots: BABE_GENESIS_EPOCH_CONFIG.allowed_slots,
}
}

Expand Down
11 changes: 9 additions & 2 deletions runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
transaction_version: 0,
};

/// The BABE epoch configuration at genesis.
pub const BABE_GENESIS_EPOCH_CONFIG: babe_primitives::BabeEpochConfiguration =
expenses marked this conversation as resolved.
Show resolved Hide resolved
babe_primitives::BabeEpochConfiguration {
c: PRIMARY_PROBABILITY,
allowed_slots: babe_primitives::AllowedSlots::PrimaryAndSecondaryVRFSlots
};

/// Native version.
#[cfg(any(feature = "std", test))]
pub fn native_version() -> NativeVersion {
Expand Down Expand Up @@ -804,10 +811,10 @@ sp_api::impl_runtime_apis! {
babe_primitives::BabeGenesisConfiguration {
slot_duration: Babe::slot_duration(),
epoch_length: EpochDurationInBlocks::get().into(),
c: PRIMARY_PROBABILITY,
c: BABE_GENESIS_EPOCH_CONFIG.c,
genesis_authorities: Babe::authorities(),
randomness: Babe::randomness(),
allowed_slots: babe_primitives::AllowedSlots::PrimaryAndSecondaryVRFSlots,
allowed_slots: BABE_GENESIS_EPOCH_CONFIG.allowed_slots,
}
}

Expand Down
11 changes: 9 additions & 2 deletions runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
transaction_version: 4,
};

/// The BABE epoch configuration at genesis.
pub const BABE_GENESIS_EPOCH_CONFIG: babe_primitives::BabeEpochConfiguration =
babe_primitives::BabeEpochConfiguration {
c: PRIMARY_PROBABILITY,
allowed_slots: babe_primitives::AllowedSlots::PrimaryAndSecondaryVRFSlots
};

/// Native version.
#[cfg(any(feature = "std", test))]
pub fn native_version() -> NativeVersion {
Expand Down Expand Up @@ -952,10 +959,10 @@ sp_api::impl_runtime_apis! {
babe_primitives::BabeGenesisConfiguration {
slot_duration: Babe::slot_duration(),
epoch_length: EpochDuration::get(),
c: PRIMARY_PROBABILITY,
c: BABE_GENESIS_EPOCH_CONFIG.c,
genesis_authorities: Babe::authorities(),
randomness: Babe::randomness(),
allowed_slots: babe_primitives::AllowedSlots::PrimaryAndSecondaryVRFSlots,
allowed_slots: BABE_GENESIS_EPOCH_CONFIG.allowed_slots,
}
}

Expand Down