Skip to content

Commit

Permalink
add expected blocktime to pallet_async_backing (#30)
Browse files Browse the repository at this point in the history
* add expected blocktime

* add commit
  • Loading branch information
girazoki committed Mar 14, 2024
1 parent a567ea5 commit 1bb7b65
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pallets/async-backing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ pub mod pallet {

/// A way to get the current parachain slot and verify it's validity against the relay slot.
type GetAndVerifySlot: GetAndVerifySlot;

/// Purely informative, but used by mocking tools like chospticks to allow knowing how to mock
/// blocks
#[pallet::constant]
type ExpectedBlockTime: Get<Self::Moment>;
}

/// First tuple element is the highest slot that has been seen in the history of this chain.
Expand Down
1 change: 1 addition & 0 deletions pallets/async-backing/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ impl pallet_timestamp::Config for Test {
parameter_types! {
pub const AllowMultipleBlocksPerSlot: bool = true;
pub const SlotDuration: u64 = 12000;
type ExpectedBlockTime = ConstU64<1>;
}

impl async_backing::Config for Test {
Expand Down
5 changes: 5 additions & 0 deletions template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -638,9 +638,14 @@ impl pallet_author_slot_filter::Config for Runtime {
type WeightInfo = ();
}

parameter_types! {
pub const ExpectedBlockTime: u64 = MILLISECS_PER_BLOCK;
}

impl pallet_async_backing::Config for Runtime {
type AllowMultipleBlocksPerSlot = ConstBool<false>;
type GetAndVerifySlot = pallet_async_backing::RelaySlot;
type ExpectedBlockTime = ExpectedBlockTime;
}

parameter_types! {
Expand Down

0 comments on commit 1bb7b65

Please sign in to comment.