Skip to content

Commit

Permalink
backing: improve session buffering for runtime information (#6284)
Browse files Browse the repository at this point in the history
## Issue
[[#3421] backing: improve session buffering for runtime
information](#3421)

## Description
In the current implementation of the backing module, certain pieces of
information, which remain unchanged throughout a session, are fetched
multiple times via runtime API calls. The goal of this task was to
introduce a local cache to store such session-stable information and
perform the runtime API call only once per session.

This PR implements caching specifically for the validators list, node
features, executor parameters, minimum backing votes threshold, and
validator-to-group mapping, which were previously fetched from the
runtime or computed each time `PerRelayParentState` was built. Now, this
information is cached and reused within the session.

## TODO
* [X] Create a separate struct for per-session caches;
* [X] Cache validators list;
* [X] Cache node features;
* [X] Cache executor parameters;
* [X] Cache minimum backing votes threshold;
* [X] Cache validator-to-group mapping;
* [X] Update tests to reflect these changes;
* [X] Add prdoc.

## For the next PR
Cache validator groups and any other session-stable data (if present).
  • Loading branch information
sw10pa authored Nov 13, 2024
1 parent a84f259 commit e617d1d
Show file tree
Hide file tree
Showing 5 changed files with 405 additions and 221 deletions.
3 changes: 3 additions & 0 deletions polkadot/node/core/backing/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ pub enum Error {

#[error("Availability store error")]
StoreAvailableData(#[source] StoreAvailableDataError),

#[error("Runtime API returned None for executor params")]
MissingExecutorParams,
}

/// Utility for eating top level errors and log them.
Expand Down
Loading

0 comments on commit e617d1d

Please sign in to comment.