mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 06:21:02 +00:00
Chain API subsystem (#1498)
* chain-api subsystem skeleton * chain-api subsystem: draft impl * chain-api subsystem: mock testclient * chain-api subsystem: impl HeaderBacked for TestClient * chain-api subsystem: impl basic tests * chain-api subsystem: tiny guide * chain-api subsystem: rename ChainApiRequestMessage to ChainApiMessage * chain-api subsystem: add the page to the ToC * chain-api subsystem: proper error type * chain-api subsystem: impl ancestors request * chain-api subsystem: tests for ancestors request * guide: fix ancestor return type * runtime-api subsystem: remove unused dep * fix fmt * fix outdated comment * chain-api subsystem: s/format/to_string * lower-case subsystem names * chain-api subsystem: resolve Finalized todo * chain-api subsystem: remove TODO * extract request errors into a module * remove caching TODO * fix imports
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
- [Misbehavior Arbitration](node/utility/misbehavior-arbitration.md)
|
||||
- [Peer Set Manager](node/utility/peer-set-manager.md)
|
||||
- [Runtime API Requests](node/utility/runtime-api.md)
|
||||
- [Chain API Requests](node/utility/chain-api.md)
|
||||
- [Data Structures and Types](types/README.md)
|
||||
- [Candidate](types/candidate.md)
|
||||
- [Backing](types/backing.md)
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
# Chain API
|
||||
|
||||
The Chain API subsystem is responsible for providing a single point of access to chain state data via a set of pre-determined queries.
|
||||
|
||||
## Protocol
|
||||
|
||||
Input: [`ChainApiMessage`](../../types/overseer-protocol.md#chain-api-message)
|
||||
|
||||
Output: None
|
||||
|
||||
## Functionality
|
||||
|
||||
On receipt of `ChainApiMessage`, answer the request and provide the response to the side-channel embedded within the request.
|
||||
|
||||
Currently, the following requests are supported:
|
||||
* Block hash to number
|
||||
* Finalized block number to hash
|
||||
* Last finalized block number
|
||||
* Ancestors
|
||||
@@ -69,7 +69,7 @@ enum AvailabilityStoreMessage {
|
||||
/// Store a specific chunk of the candidate's erasure-coding by validator index, with an
|
||||
/// accompanying proof.
|
||||
StoreChunk(Hash, ValidatorIndex, AvailabilityChunkAndProof, ResponseChannel<Result<()>>),
|
||||
/// Store `AvailableData`. If `ValidatorIndex` is provided, also store this validator's
|
||||
/// Store `AvailableData`. If `ValidatorIndex` is provided, also store this validator's
|
||||
/// `AvailabilityChunkAndProof`.
|
||||
StoreAvailableData(Hash, Option<ValidatorIndex>, u32, AvailableData, ResponseChannel<Result<()>>),
|
||||
}
|
||||
@@ -126,6 +126,37 @@ enum CandidateSelectionMessage {
|
||||
}
|
||||
```
|
||||
|
||||
## Chain API Message
|
||||
|
||||
The Chain API subsystem is responsible for providing an interface to chain data.
|
||||
|
||||
```rust
|
||||
enum ChainApiMessage {
|
||||
/// Get the block number by hash.
|
||||
/// Returns `None` if a block with the given hash is not present in the db.
|
||||
BlockNumber(Hash, ResponseChannel<Result<Option<BlockNumber>, Error>>),
|
||||
/// Get the finalized block hash by number.
|
||||
/// Returns `None` if a block with the given number is not present in the db.
|
||||
/// Note: the caller must ensure the block is finalized.
|
||||
FinalizedBlockHash(BlockNumber, ResponseChannel<Result<Option<Hash>, Error>>),
|
||||
/// Get the last finalized block number.
|
||||
/// This request always succeeds.
|
||||
FinalizedBlockNumber(ResponseChannel<Result<BlockNumber, Error>>),
|
||||
/// Request the `k` ancestors block hashes of a block with the given hash.
|
||||
/// The response channel may return a `Vec` of size up to `k`
|
||||
/// filled with ancestors hashes with the following order:
|
||||
/// `parent`, `grandparent`, ...
|
||||
Ancestors {
|
||||
/// The hash of the block in question.
|
||||
hash: Hash,
|
||||
/// The number of ancestors to request.
|
||||
k: usize,
|
||||
/// The response channel.
|
||||
response_channel: ResponseChannel<Result<Vec<Hash>, Error>>,
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Collator Protocol Message
|
||||
|
||||
Messages received by the [Collator Protocol subsystem](../node/collators/collator-protocol.md)
|
||||
|
||||
Reference in New Issue
Block a user