Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
250fbeb
babe: backoff authoring blocks when finality lags
octol Sep 16, 2020
d531efa
babe: move backoff authoring params to default constructor
octol Sep 22, 2020
b060e9b
babe: deduplicate the test a bit
octol Sep 22, 2020
0f95c44
babe: set backoff constants in service
octol Sep 23, 2020
df1951c
babe: use better names for backoff authoring block parameters
octol Sep 23, 2020
c17ca03
babe: remove last unwrap
octol Sep 23, 2020
2892da0
babe: slight style tweak
octol Sep 23, 2020
01f1ac3
babe: fix comment
octol Sep 23, 2020
9794ffa
slots: move backoff block authorship logic to SimpleSlotWorker
octol Sep 28, 2020
d2ee780
aura: append SlotInfo in on_slot
octol Sep 30, 2020
026a8d0
slots: use the correct types for parameters
octol Sep 30, 2020
f428a35
Merge branch 'master' into jon/incremental-backoff-on-finality
octol Oct 14, 2020
6903837
slots: fix review comments
octol Oct 23, 2020
4a6b8b7
Merge branch 'master' into jon/incremental-backoff-on-finality
octol Oct 23, 2020
92b506a
aura: add missing backoff authoring blocks parameters
octol Oct 23, 2020
cda5150
slots: add comments for default values
octol Oct 27, 2020
62f97dc
slots: add additional checks in test
octol Oct 27, 2020
7fa2084
Merge remote-tracking branch 'upstream/master' into jon/incremental-b…
octol Oct 28, 2020
af8d30b
slots: update implementation for new master
octol Oct 28, 2020
76b745a
slots: revert the change to SlotInfo
octol Oct 28, 2020
dafd2e5
Merge remote-tracking branch 'upstream/master' into jon/incremental-b…
octol Oct 28, 2020
dc04a1f
Merge remote-tracking branch 'upstream/master' into jon/incremental-b…
octol Oct 29, 2020
cb6d24c
Fix review comments
octol Oct 30, 2020
55827c3
slots: rework unit tests for backing off claiming slots
octol Nov 2, 2020
83538f0
slots: add test for asymptotic behaviour for slot claims
octol Nov 3, 2020
c87145d
Merge remote-tracking branch 'upstream/master' into jon/incremental-b…
octol Nov 3, 2020
0435142
slots: address review comments
octol Nov 4, 2020
38e61e5
slots: add test for max_interval
octol Nov 4, 2020
1228aef
slots: add assertion for intervals between between claimed slots
octol Nov 4, 2020
f7b8c76
slots: remove rustfmt directive
octol Nov 4, 2020
9790f60
slots: another attempt at explaining authoring_rate
octol Nov 4, 2020
f95225a
Merge remote-tracking branch 'upstream/master' into jon/incremental-b…
octol Nov 4, 2020
461d5f9
slots: up unfinalized_slack to 50 by default
octol Nov 6, 2020
796baf7
slots: add tests for time to reach max_interval
octol Nov 6, 2020
0d11df5
slots: fix typo in comments
octol Nov 6, 2020
9a968c6
Apply suggestions from code review
octol Nov 10, 2020
a607bc4
slots: additional tweaks to comments and info calls
octol Nov 10, 2020
bc32a7c
slots: rename to BackoffAuthoringOnFinalizedHeadLagging
octol Nov 10, 2020
eb45ed7
slots: make the backing off strategy generic
octol Nov 10, 2020
5a40da8
Merge remote-tracking branch 'upstream/master' into jon/incremental-b…
octol Nov 10, 2020
4f44b62
Apply suggestions from code review
octol Nov 10, 2020
1423649
slots: implement backoff trait for () for simplicity
octol Nov 10, 2020
44de2cf
slots: move logging inside backing off function to make it more specific
octol Nov 11, 2020
90d0ad3
Merge remote-tracking branch 'upstream/master' into jon/incremental-b…
octol Nov 11, 2020
b6435ff
aura: add missing function parameter
octol Nov 11, 2020
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
Prev Previous commit
Next Next commit
slots: use the correct types for parameters
  • Loading branch information
octol committed Sep 30, 2020
commit 026a8d04f8887336f381e1354e8c31f55cb291ce
1 change: 0 additions & 1 deletion bin/node/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ pub fn new_full_base(
let can_author_with =
sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone());

// WIP: move these hardcoded parameters
let backoff_authoring_blocks = Some(sc_consensus_slots::SimpleBackoffAuthoringBlocksStrategy {
max_interval: 100,
unfinalized_slack: 5,
Expand Down
2 changes: 1 addition & 1 deletion client/consensus/aura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ impl<B, C, E, I, P, Error, SO> sc_consensus_slots::SimpleSlotWorker<B> for AuraW
type Proposer = E::Proposer;
type Claim = P::Public;
type EpochData = Vec<AuthorityId<P>>;
type BackoffAuthoringBlocksStrategy = sc_consensus_slots::SimpleBackoffAuthoringBlocksStrategy;
type BackoffAuthoringBlocksStrategy = sc_consensus_slots::SimpleBackoffAuthoringBlocksStrategy<B>;

fn logging_target(&self) -> &'static str {
"aura"
Expand Down
6 changes: 3 additions & 3 deletions client/consensus/babe/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ pub struct BabeParams<B: BlockT, C, E, I, SO, SC, CAW> {
pub force_authoring: bool,

/// Strategy and parameters for backing off block production if finality starts to lag behind.
pub backoff_authoring_blocks: Option<SimpleBackoffAuthoringBlocksStrategy>,
pub backoff_authoring_blocks: Option<SimpleBackoffAuthoringBlocksStrategy<B>>,

/// The source of timestamps for relative slots
pub babe_link: BabeLink<B>,
Expand Down Expand Up @@ -474,7 +474,7 @@ struct BabeSlotWorker<B: BlockT, C, E, I, SO> {
env: E,
sync_oracle: SO,
force_authoring: bool,
backoff_authoring_blocks: Option<SimpleBackoffAuthoringBlocksStrategy>,
backoff_authoring_blocks: Option<SimpleBackoffAuthoringBlocksStrategy<B>>,
keystore: KeyStorePtr,
epoch_changes: SharedEpochChanges<B, Epoch>,
slot_notification_sinks: SlotNotificationSinks<B>,
Expand Down Expand Up @@ -502,7 +502,7 @@ impl<B, C, E, I, Error, SO> sc_consensus_slots::SimpleSlotWorker<B> for BabeSlot
>>;
type Proposer = E::Proposer;
type BlockImport = I;
type BackoffAuthoringBlocksStrategy = sc_consensus_slots::SimpleBackoffAuthoringBlocksStrategy;
type BackoffAuthoringBlocksStrategy = sc_consensus_slots::SimpleBackoffAuthoringBlocksStrategy<B>;

fn logging_target(&self) -> &'static str {
"babe"
Expand Down
19 changes: 10 additions & 9 deletions client/consensus/slots/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -601,20 +601,20 @@ where
/// A simple default strategy for how to decide backing off authoring blocks if the number of
/// unfinalized blocks grows too large.
#[derive(Clone)]
pub struct SimpleBackoffAuthoringBlocksStrategy {
pub struct SimpleBackoffAuthoringBlocksStrategy<B: BlockT> {
/// The max interval to backoff when authoring blocks, regardless of delay in finality.
pub max_interval: u32,
pub max_interval: NumberFor<B>,
/// The number of unfinalized blocks allowed before starting to consider to backoff authoring
/// blocks. Note that depending on the value for `authoring_bias`, there might still be an
/// additional wait until block authorships starts getting declined.
pub unfinalized_slack: u32,
pub unfinalized_slack: NumberFor<B>,
/// How persistant block authorship is in the face of a growing unfinalized chain of blocks. A
/// small value for `authoring_bias` means to quickly start backing off block authorship as the
/// length of the unfinalized blocks grows.
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment is a bit hard to understand for me, I think it's easier to describe this value as relating to the periodicity at which we author blocks in the face of stalled finality.

pub authoring_bias: u32,
pub authoring_bias: NumberFor<B>,
}

impl<B> BackoffAuthoringBlocksStrategy<B> for SimpleBackoffAuthoringBlocksStrategy
impl<B> BackoffAuthoringBlocksStrategy<B> for SimpleBackoffAuthoringBlocksStrategy<B>
where
B: BlockT
{
Expand All @@ -626,14 +626,15 @@ where
slot_now: u64,
) -> bool {
let unfinalized_block_length = chain_head_number - finalized_number;
let interval = unfinalized_block_length.saturating_sub(self.unfinalized_slack.into())
/ self.authoring_bias.into();
let interval = interval.min(self.max_interval.into());
let interval = unfinalized_block_length.saturating_sub(self.unfinalized_slack)
/ self.authoring_bias;
let interval = interval.min(self.max_interval);

// We're doing arithmetic between block and slot numbers.
let interval = interval.unique_saturated_into();

// Backoff is the current slot isn't far enough ahead of the chain head.
// If interval is nonzero we backoff if the current slot isn't far enough ahead of the chain
// head.
u128::from(slot_now) <= u128::from(chain_head_slot) + interval
}
}
Expand Down