Skip to content

archive: Fetch body, genesisHash and header#1560

Merged
lexnv merged 8 commits into
masterfrom
lexnv/archive_body_genesis
Sep 19, 2023
Merged

archive: Fetch body, genesisHash and header#1560
lexnv merged 8 commits into
masterfrom
lexnv/archive_body_genesis

Conversation

@lexnv

@lexnv lexnv commented Sep 14, 2023

Copy link
Copy Markdown
Contributor

This PR lays the foundation for implementing the archive RPC methods.

The methods implemented by this PR:

  • archive_unstable_body: Fetch the block's body (a vector of hex-encoded scale-encoded extrinsics) from a given block hash
  • archive_unstable_genesisHash: Fetch the genesis hash
  • archive_unstable_header: Fetch the header from a given block hash

Added unit tests for the methods.

This PR is implementing the methods without exposing them to the RPC layer; which are to be exposed by a follow-up PR.

Closes: #1509
Closes: #1514

@paritytech/subxt-team

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
@lexnv lexnv added A0-needs_burnin Pull request needs to be tested on a live validator node before merge. DevOps is notified via matrix I5-enhancement An additional feature request. T3-RPC_API This PR/Issue is related to RPC APIs. D0-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder. labels Sep 14, 2023
@lexnv lexnv self-assigned this Sep 14, 2023
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
@lexnv lexnv changed the title archive: Implement archive_body and archive_genesisHash archive: Fetch body, genesisHash and header Sep 14, 2023
@lexnv lexnv requested review from jsdw and skunert September 14, 2023 10:09
Comment thread substrate/client/rpc-spec-v2/src/archive/archive.rs Outdated
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

@niklasad1 niklasad1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

///
/// This method is unstable and subject to change in the future.
#[method(name = "archive_unstable_genesisHash")]
fn archive_unstable_genesis_hash(&self) -> RpcResult<String>;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I raised paritytech/json-rpc-interface-spec#101 since I'd have thought we can remove this one :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the conclusion there is to keep it still :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, thanks for raising this. From my perspective, I forgot about the other discussions which removed similar genesis functions. And I would have opted to remove the archive_genesis.

I could see the benefit of this API not necessarily being implemented by nodes (light or full), but also by third-parties which may have access only to the underlying DB.

We'll keep this for now and keep an eye on the genesis discussion

@jsdw jsdw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me!

@lexnv lexnv merged commit f3061c1 into master Sep 19, 2023
@lexnv lexnv deleted the lexnv/archive_body_genesis branch September 19, 2023 11:29
lexnv added a commit that referenced this pull request Sep 28, 2023
This PR implements:
- `archive_unstable_finalized_height`: Get the height of the most recent
finalized block
- `archive_unstable_hash_by_height`: Get the hashes (possible empty) of
blocks from the given height
- `archive_unstable_call`: Call into the runtime of a block

Builds on top of: #1560

### Testing Done
- unit tests for the methods with custom block tree for different
heights / forks

Closes: #1510
Closes: #1513
Closes: #1511

@paritytech/subxt-team

---------

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Co-authored-by: Sebastian Kunert <skunert49@gmail.com>
bgallois pushed a commit to duniter/duniter-polkadot-sdk that referenced this pull request Mar 25, 2024
This PR lays the foundation for implementing the archive RPC methods.

The methods implemented by this PR:
- archive_unstable_body: Fetch the block's body (a vector of hex-encoded
scale-encoded extrinsics) from a given block hash
- archive_unstable_genesisHash: Fetch the genesis hash
- archive_unstable_header: Fetch the header from a given block hash

Added unit tests for the methods.

This PR is implementing the methods without exposing them to the RPC
layer; which are to be exposed by a follow-up PR.

Closes: paritytech#1509 
Closes: paritytech#1514

@paritytech/subxt-team

---------

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
bgallois pushed a commit to duniter/duniter-polkadot-sdk that referenced this pull request Mar 25, 2024
This PR implements:
- `archive_unstable_finalized_height`: Get the height of the most recent
finalized block
- `archive_unstable_hash_by_height`: Get the hashes (possible empty) of
blocks from the given height
- `archive_unstable_call`: Call into the runtime of a block

Builds on top of: paritytech#1560

### Testing Done
- unit tests for the methods with custom block tree for different
heights / forks

Closes: paritytech#1510
Closes: paritytech#1513
Closes: paritytech#1511

@paritytech/subxt-team

---------

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Co-authored-by: Sebastian Kunert <skunert49@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A0-needs_burnin Pull request needs to be tested on a live validator node before merge. DevOps is notified via matrix D0-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder. I5-enhancement An additional feature request. T3-RPC_API This PR/Issue is related to RPC APIs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RPC-Spec-V2] archive: Implement archive_unstable_header/genesisHash [RPC-Spec-V2] archive: Implement archive_unstable_body

5 participants