rpc-v2: Enable the archive class of methods (#3017)

The
[archive](https://github.com/paritytech/json-rpc-interface-spec/blob/main/src/api/archive.md)
API is unstable and subject to change.

This PR enables the `archive` class of the RPC-V2 spec to substrate
based chains.

The `archive` API is enabled for archive nodes: 
- the state of the blocks is in archive mode
- the block's bodies are in archive mode

While at it, this PR extends the `BlocksPrunning` enum with an
`is_archive` helper to check if the pruning mode keeps the block's
bodies for long enough.

Defaults used for the `archive` API:
- a maximum of 5 responses are provided for descendants queries (this is
similar to chainHead)
- a maximum of 8 item queries are accepted at a time

Before stabilizing the API we should look into these defaults and adjust
after collecting some data.

---------

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
Alexandru Vasile
2024-01-23 18:22:56 +02:00
committed by GitHub
parent b4dfad838c
commit 01ac54db29
6 changed files with 99 additions and 23 deletions
+10
View File
@@ -320,6 +320,16 @@ pub enum BlocksPruning {
Some(u32),
}
impl BlocksPruning {
/// True if this is an archive pruning mode (either KeepAll or KeepFinalized).
pub fn is_archive(&self) -> bool {
match *self {
BlocksPruning::KeepAll | BlocksPruning::KeepFinalized => true,
BlocksPruning::Some(_) => false,
}
}
}
/// Where to find the database..
#[derive(Debug, Clone)]
pub enum DatabaseSource {