-
Notifications
You must be signed in to change notification settings - Fork 666
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: wiring for bandwidth scheduler (#12234)
Add the wiring needed for the bandwidth scheduler algorithm. Changes: * Add a new `ProtocolFeature` - `BandwidthScheduler`, its protocol version is set to nightly * Add a struct that will keep the bandwidth requests generated by the shards * Propagate the bandwidth requests through the blockchain - put the generated bandwidth requests in the shard headers, pass the previous bandwidth requests to the runtime * Add a struct that represents the bandwidth scheduler state, it's stored in the trie and modified on every scheduler invocation. * Mock implementation of bandwidth scheduler - it takes the previous bandwidth requests and the state and mocks the scheduler algorithm. It activates the requests propagation logic and breaks some tests. ### Propagation of bandwidth requests The flow of bandwidth requests looks as follows: * A chunk is applied and generates bandwidth requests. They are put in `ApplyResult` and `ApplyChunkResult` * The requests are taken from the apply result and put in `ChunkExtra`. `ChunkExtra` is persisted in the database * During chunk production, Client fetches `ChunkExtra` of the previous chunk and puts the bandwidth requests in chunk header * The produced chunks are included in the block * The new chunks are applied, their `ApplyState` contains bandwidth requests taken from all the chunk headers in the block that contains the applied chunks. * During the application, bandwidth scheduler looks at the requests created at the previous height and grants banwidth * Receipts are sent out * Then the chunk generates new bandwidth requests * etc The flow is very similar to the one for congestion info. ### Scheduler state Bandwidth scheduler needs to keep some persistent state. In the future it'll be something like "how much every shard was granted lately", it'll be used to maintain fairness. For now it's just mock data. Scheduler state should always be the same on all shards. All shards start with the same scheduler state, apply the scheduler at the same heights with the same inputs and always end up with the same scheduler state. This means that the bandwidth scheduler also needs to be run for missing chunks. Luckily that can be easily achieved thanks to existing `apply_old_chunk` infrastructure (all missing chunk are applied, it counts as "implicit state transitions"). The `state_root` will now change at every height, even when there are no receipts to be processed. It breaks some tests which assumed that the state root wouldn't change. The pull request is meant to be reviewed commit-by-commit, I tried to make the commit history nice.
- Loading branch information
1 parent
b27295b
commit 55f21d5
Showing
69 changed files
with
1,108 additions
and
156 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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 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 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 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 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
Oops, something went wrong.