This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
slots: incrementally backoff claiming slots if finality lags behind #7186
Merged
Merged
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 d531efa
babe: move backoff authoring params to default constructor
octol b060e9b
babe: deduplicate the test a bit
octol 0f95c44
babe: set backoff constants in service
octol df1951c
babe: use better names for backoff authoring block parameters
octol c17ca03
babe: remove last unwrap
octol 2892da0
babe: slight style tweak
octol 01f1ac3
babe: fix comment
octol 9794ffa
slots: move backoff block authorship logic to SimpleSlotWorker
octol d2ee780
aura: append SlotInfo in on_slot
octol 026a8d0
slots: use the correct types for parameters
octol f428a35
Merge branch 'master' into jon/incremental-backoff-on-finality
octol 6903837
slots: fix review comments
octol 4a6b8b7
Merge branch 'master' into jon/incremental-backoff-on-finality
octol 92b506a
aura: add missing backoff authoring blocks parameters
octol cda5150
slots: add comments for default values
octol 62f97dc
slots: add additional checks in test
octol 7fa2084
Merge remote-tracking branch 'upstream/master' into jon/incremental-b…
octol af8d30b
slots: update implementation for new master
octol 76b745a
slots: revert the change to SlotInfo
octol dafd2e5
Merge remote-tracking branch 'upstream/master' into jon/incremental-b…
octol dc04a1f
Merge remote-tracking branch 'upstream/master' into jon/incremental-b…
octol cb6d24c
Fix review comments
octol 55827c3
slots: rework unit tests for backing off claiming slots
octol 83538f0
slots: add test for asymptotic behaviour for slot claims
octol c87145d
Merge remote-tracking branch 'upstream/master' into jon/incremental-b…
octol 0435142
slots: address review comments
octol 38e61e5
slots: add test for max_interval
octol 1228aef
slots: add assertion for intervals between between claimed slots
octol f7b8c76
slots: remove rustfmt directive
octol 9790f60
slots: another attempt at explaining authoring_rate
octol f95225a
Merge remote-tracking branch 'upstream/master' into jon/incremental-b…
octol 461d5f9
slots: up unfinalized_slack to 50 by default
octol 796baf7
slots: add tests for time to reach max_interval
octol 0d11df5
slots: fix typo in comments
octol 9a968c6
Apply suggestions from code review
octol a607bc4
slots: additional tweaks to comments and info calls
octol bc32a7c
slots: rename to BackoffAuthoringOnFinalizedHeadLagging
octol eb45ed7
slots: make the backing off strategy generic
octol 5a40da8
Merge remote-tracking branch 'upstream/master' into jon/incremental-b…
octol 4f44b62
Apply suggestions from code review
octol 1423649
slots: implement backoff trait for () for simplicity
octol 44de2cf
slots: move logging inside backing off function to make it more specific
octol 90d0ad3
Merge remote-tracking branch 'upstream/master' into jon/incremental-b…
octol b6435ff
aura: add missing function parameter
octol File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
slots: use the correct types for parameters
- Loading branch information
commit 026a8d04f8887336f381e1354e8c31f55cb291ce
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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> { | ||
andresilva marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| /// 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. | ||
|
||
| 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 | ||
| { | ||
|
|
@@ -626,14 +626,15 @@ where | |
| slot_now: u64, | ||
| ) -> bool { | ||
andresilva marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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 | ||
| } | ||
| } | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.