Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

rpc: Implement archive RPC API #12737

Closed
wants to merge 20 commits into from
Closed

rpc: Implement archive RPC API #12737

wants to merge 20 commits into from

Conversation

lexnv
Copy link
Contributor

@lexnv lexnv commented Nov 18, 2022

This PR implements the archive methods.

The archive methods include:

This PR also includes the unsubscribe methods.

Part of: #12071.

Testing Done

Manual Testing

archive_unstable_genesisHash: String("0x38c857c72005bf68bb1af4ac83405d94a9e2914850e33a4a3dfe8a5e5e2af8cd")
archive_unstable_hashByHeight on height=0 result: Ok(Object({"event": String("done"), "result": Array([String("0x38c857c72005bf68bb1af4ac83405d94a9e2914850e33a4a3dfe8a5e5e2af8cd")])}))
  archive_unstable_body hash="0x38c857c72005bf68bb1af4ac83405d94a9e2914850e33a4a3dfe8a5e5e2af8cd" result: Ok(Object({"event": String("done"), "result": String("0x00")}))
  archive_unstable_header hash="0x38c857c72005bf68bb1af4ac83405d94a9e2914850e33a4a3dfe8a5e5e2af8cd" result: Ok(Object({"event": String("done"), "result": String("0x000000000000000000000000000000000000000000000000000000000000000000483ec7c7e75d37442d10423ccef114efe2a4775125698d2d892113f85ee684c703170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c11131400")}))
archive_unstable_hashByHeight on height=1 result: Ok(Object({"event": String("done"), "result": Array([String("0xebcb7707bad09570beac92ca85abb47935574fe28515c9164e9a38df01ce2944")])}))
  archive_unstable_body hash="0xebcb7707bad09570beac92ca85abb47935574fe28515c9164e9a38df01ce2944" result: Ok(Object({"event": String("done"), "result": String("0x04280403000b98c6259b8401")}))
  archive_unstable_header hash="0xebcb7707bad09570beac92ca85abb47935574fe28515c9164e9a38df01ce2944" result: Ok(Object({"event": String("done"), "result": String("0x38c857c72005bf68bb1af4ac83405d94a9e2914850e33a4a3dfe8a5e5e2af8cd0418295f07a92d920bc1c281a5fee7531e9d0a71178e97a4747bc49be61677c528f7e7482f598e7e47123eda84423b8ee84328e023b6dd0209bc377c21f88d54e50c0642414245340200000000853a292100000000044241424529010104d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d01000000000000000000000000000000000000000000000000000000000000000000000000000000054241424501014c890f007ffa8c3f0ecae68d41ec23a19ac9ede57c02e38c7266dbb4ec1e2d6e617dcb9ab96a80399b33939f7c4229308806c39eb6b34046c17731a90e7dae8a")}))
archive_unstable_hashByHeight on height=2 result: Ok(Object({"event": String("done"), "result": Array([String("0x106c5d1e1049f01e0036dd40c0c50599e55df4c552ea87c5d93b637c46ad71ba")])}))
  archive_unstable_body hash="0x106c5d1e1049f01e0036dd40c0c50599e55df4c552ea87c5d93b637c46ad71ba" result: Ok(Object({"event": String("done"), "result": String("0x04280403000b51d2259b8401")}))
  archive_unstable_header hash="0x106c5d1e1049f01e0036dd40c0c50599e55df4c552ea87c5d93b637c46ad71ba" result: Ok(Object({"event": String("done"), "result": String("0xebcb7707bad09570beac92ca85abb47935574fe28515c9164e9a38df01ce294408cd89427a3c56994eedaf1fc721339cd1bb8b363fa3ee937f1304a2c29c417119e99e9e8aee3b0effeb81f7fbd2fa3f5aa5d42ab953dc45fbe0fabeb04b60d077080642414245b5010100000000863a2921000000001ca2bd43a3b0d6a88b5a83f91ce93aa8f341650a87c262b524daf268a55b4738f9effe0bff6f33df69d679d9da706a820cb5adaa9c74ddd261d2d3b660db1d0ccf6f92023f3504ee99ceb3b3494235c242f90ea794535745de4313ae7e707304054241424501011a17a5890c212be368aeb28502ff9088c06896e5eac47953bcc7e1d016cc162bb375b169f924ecfe77db82816fe5ca0961da3346e9d080bbee4dceb44c038e8c")}))
archive_unstable_hashByHeight on height=3 result: Ok(Object({"event": String("done"), "result": Array([String("0x0b674621222e81a8db5b67386dffd6c24504c93d9080e6186149370226f7184a")])}))
  archive_unstable_body hash="0x0b674621222e81a8db5b67386dffd6c24504c93d9080e6186149370226f7184a" result: Ok(Object({"event": String("done"), "result": String("0x04280403000b08de259b8401")}))
  archive_unstable_header hash="0x0b674621222e81a8db5b67386dffd6c24504c93d9080e6186149370226f7184a" result: Ok(Object({"event": String("done"), "result": String("0x106c5d1e1049f01e0036dd40c0c50599e55df4c552ea87c5d93b637c46ad71ba0ca77e4418b7a1455bf8093fa79c6def40c595de82702d260b6a3507b0e45451d82e9e88b179af804e16c274917c4621e3deceea3e347a34fd5725df3407c03585080642414245b5010100000000873a2921000000002e99d1d4296672f4333e220c190666a08907925de0d10ed9c27a54789e20e76d896fb97d45a9c83d5b8bf760a3b93d3278b801f673663ffbd9fbb5782655990b8464470519e7d2ef9f7415ce75c67e12bc13c701e94981cb45d84b48e55dcb0d054241424501017c05029ba1a55026d41e70b755c08b345417b6e10875193a7447a52fc7659b19d5fcb9d09fa0990d4d6e42f157eecc6219b63dd19bb28e1c90b9c7f67601158b")}))

Unit Tests

./src/archive/event.rs

Integration Tests

./src/archive/tests.rs

CC: @paritytech/tools-team.

lexnv added 10 commits November 18, 2022 16:34
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>
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>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
…l heights

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
@lexnv lexnv added A0-please_review Pull request needs code review. B3-apinoteworthy C1-low PR touches the given topic and has a low impact on builders. labels Nov 18, 2022
@lexnv lexnv self-assigned this Nov 18, 2022
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
…ical heights

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>
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 changed the title [wip] rpc: Implement archive RPC API rpc: Implement archive RPC API Nov 21, 2022
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
@lexnv lexnv mentioned this pull request Dec 19, 2022
4 tasks
Copy link
Contributor

@melekes melekes left a comment

Choose a reason for hiding this comment

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

👍 (code-wise; don't know enough to reason about business logic)

return
}

let finalized_hash = client.info().finalized_hash;
Copy link
Contributor

Choose a reason for hiding this comment

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

what's the point of returning finalized blocks here if that's not what the client has asked for? shouldn't we return an error instead saying that "the block with the given height has not been finalized yet"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for having a look at this!
I seem to have lost this in notifications, the archive class is not really necessary for light-client integrations and there are a few things to decide before moving forward with this:
paritytech/json-rpc-interface-spec#26, paritytech/json-rpc-interface-spec#27, paritytech/json-rpc-interface-spec#30, paritytech/json-rpc-interface-spec#29

Regarding this, we are also exploring adding another method archive_finalizedBlock to make sure users are aware they can make queries to ancestor blocks of finalized. IIRC, I placed this to make sure they are not making a call to any children of the finalized.

@@ -528,7 +528,7 @@ where
keystore.clone(),
system_rpc_tx.clone(),
&config,
backend.offchain_storage(),
backend.clone(),
Copy link
Contributor

Choose a reason for hiding this comment

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

so previously we're only accessing offchain storage and now we need full storage, right?

@stale
Copy link

stale bot commented Jan 27, 2023

Hey, is anyone still working on this? Due to the inactivity this issue has been automatically marked as stale. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the A5-stale Pull request did not receive any updates in a long time. No review needed at this stage. Close it. label Jan 27, 2023
@stale stale bot removed A5-stale Pull request did not receive any updates in a long time. No review needed at this stage. Close it. labels Jan 27, 2023
@the-right-joyce the-right-joyce added B1-note_worthy Changes should be noted in the release notes T2-API This PR/Issue is related to APIs. and removed B3-apinoteworthy labels Feb 13, 2023
@stale
Copy link

stale bot commented Mar 16, 2023

Hey, is anyone still working on this? Due to the inactivity this issue has been automatically marked as stale. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. A3-stale B1-note_worthy Changes should be noted in the release notes C1-low PR touches the given topic and has a low impact on builders. T2-API This PR/Issue is related to APIs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants