Skip to content

Commit

Permalink
add logic to disallow blocks on consecutive relay slots
Browse files Browse the repository at this point in the history
Signed-off-by: Charles Ferrell <charlie@manta.network>
  • Loading branch information
ferrell-code committed Apr 9, 2024
1 parent 63d95c7 commit 0a73df3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions runtime/calamari/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1340,6 +1340,11 @@ impl_runtime_apis! {
fn can_author(author: NimbusId, relay_parent: u32, parent_header: &<Block as BlockT>::Header) -> bool {
let next_block_number = parent_header.number + 1;
let slot = relay_parent;
if cumulus_pallet_parachain_system::Pallet::<Self>::last_relay_block_number() + 1 == relay_parent {
log::debug!("Cannot Author blocks on consecutive slots");
return false
}

// Because the staking solution calculates the next staking set at the beginning
// of the first block in the new round, the only way to accurately predict the
// authors is to compute the selection during prediction.
Expand Down
5 changes: 5 additions & 0 deletions runtime/manta/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1261,6 +1261,11 @@ impl_runtime_apis! {
fn can_author(author: NimbusId, relay_parent: u32, parent_header: &<Block as BlockT>::Header) -> bool {
let next_block_number = parent_header.number + 1;
let slot = relay_parent;
if cumulus_pallet_parachain_system::Pallet::<Self>::last_relay_block_number() + 1 == relay_parent {
log::debug!("Cannot Author blocks on consecutive slots");
return false
}

// Because the staking solution calculates the next staking set at the beginning
// of the first block in the new round, the only way to accurately predict the
// authors is to compute the selection during prediction.
Expand Down

0 comments on commit 0a73df3

Please sign in to comment.