mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 08:11:04 +00:00
Delay session changes' effects on parachains by 1 block (#1354)
* note that the initializer is responsible for buffering session changes * amend initializer definition to include session change buffering * support buffered changes before `on_initialize` * implement and test session buffering * Update roadmap/implementors-guide/src/runtime/README.md Co-authored-by: Bernhard Schuster <bernhard@ahoi.io> * expand on how this affects misbehavior reports * fix typo Co-authored-by: Bernhard Schuster <bernhard@ahoi.io>
This commit is contained in:
committed by
GitHub
parent
a4fa71ed17
commit
8130d8210e
@@ -1,16 +1,23 @@
|
||||
# Initializer Module
|
||||
|
||||
This module is responsible for initializing the other modules in a deterministic order. It also has one other purpose as described above: accepting and forwarding session change notifications.
|
||||
This module is responsible for initializing the other modules in a deterministic order. It also has one other purpose as described in the overview of the runtime: accepting and forwarding session change notifications.
|
||||
|
||||
## Storage
|
||||
|
||||
```rust
|
||||
HasInitialized: bool
|
||||
HasInitialized: bool;
|
||||
// buffered session changes along with the block number at which they should be applied.
|
||||
//
|
||||
// typically this will be empty or one element long. ordered ascending by BlockNumber and insertion
|
||||
// order.
|
||||
BufferedSessionChanges: Vec<(BlockNumber, ValidatorSet, ValidatorSet)>;
|
||||
```
|
||||
|
||||
## Initialization
|
||||
|
||||
The other modules are initialized in this order:
|
||||
Before initializing modules, remove all changes from the `BufferedSessionChanges` with number less than or equal to the current block number, and apply the last one. The session change is applied to all modules in the same order as initialization.
|
||||
|
||||
The other parachains modules are initialized in this order:
|
||||
|
||||
1. Configuration
|
||||
1. Paras
|
||||
@@ -25,8 +32,7 @@ Set `HasInitialized` to true.
|
||||
|
||||
## Session Change
|
||||
|
||||
If `HasInitialized` is true, throw an unrecoverable error (panic).
|
||||
Otherwise, forward the session change notification to other modules in initialization order.
|
||||
Store the session change information in `BufferedSessionChange` along with the block number at which it was submitted, plus one. Although the expected operational parameters of the block authorship system should prevent more than one change from being buffered at any time, it may occur. Regardless, we always need to track the block number at which the session change can be applied so as to remain flexible over session change notifications being issued before or after initialization of the current block.
|
||||
|
||||
## Finalization
|
||||
|
||||
|
||||
Reference in New Issue
Block a user