Skip to content

Commit

Permalink
Refactor availability-recovery strategies (#1457)
Browse files Browse the repository at this point in the history
Refactors availability-recovery strategies to allow for easily adding
new hotpaths and failover mechanisms.

The new interface allows for chaining multiple `RecoveryStrategy`-es
together, to cleanly express the relationship between them and share
state and code where neccessary/possible:

This was done in order to aid in implementing new hotpaths like
[systematic chunks
recovery](#598) and
[fetching from approval
checkers](#575).

Thanks to this design, intermediate state can be shared between the
strategies. For example, if the systematic chunks recovery retrieved
less than the needed amount of chunks, pass them over to the next
FetchChunks strategy, which will only need to recover the remaining
number of chunks.

Draft example of how a systematic chunk recovery strategy would look:
667d870
(notice how easy it was to add and reuse code)

Note that this PR doesn't itself add any new strategy, it should fully
preserve backwards compatiblity in terms of functionality. Follow-up PRs
to add new strategies will come.
  • Loading branch information
alindima authored Sep 20, 2023
1 parent 771c3fb commit 6f00edb
Show file tree
Hide file tree
Showing 5 changed files with 953 additions and 754 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions polkadot/node/network/availability-recovery/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ schnellru = "0.2.1"
rand = "0.8.5"
fatality = "0.0.6"
thiserror = "1.0.48"
async-trait = "0.1.73"
gum = { package = "tracing-gum", path = "../../gum" }

polkadot-erasure-coding = { path = "../../../erasure-coding" }
Expand Down
Loading

0 comments on commit 6f00edb

Please sign in to comment.