Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpc: Enable ChainSpec for polkadot-parachain #5205

Merged
merged 11 commits into from
Aug 2, 2024
Merged

Conversation

lexnv
Copy link
Contributor

@lexnv lexnv commented Aug 1, 2024

This PR enables the chainSpec_v1 class for the polkadot-parachian.
The chainSpec is part of the rpc-v2 which is spec-ed at: https://github.com/paritytech/json-rpc-interface-spec/blob/main/src/api/chainSpec.md.

This also paves the way for enabling a future chainSpec_unstable_spec on all nodes.

Closes: #5191

cc @paritytech/subxt-team

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
@lexnv lexnv added I5-enhancement An additional feature request. T3-RPC_API This PR/Issue is related to RPC APIs. T9-cumulus This PR/Issue is related to cumulus. D0-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder. labels Aug 1, 2024
@lexnv lexnv self-assigned this Aug 1, 2024
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
@lexnv lexnv requested a review from a team August 1, 2024 11:44
@dmitry-markin dmitry-markin requested a review from a team August 1, 2024 11:52
@@ -281,12 +282,13 @@ pub(crate) trait NodeSpec {
let transaction_pool = transaction_pool.clone();
let backend_for_rpc = backend.clone();

Box::new(move |deny_unsafe, _| {
Box::new(move |deny_unsafe: sc_rpc::DenyUnsafe, _| {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the type needed now in contrast to before?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I've hit the autocomplete by mistake :D No longer needed since I was able to obtain the same by moving the initialization to the substrate builder

This reverts commit cc90001.

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
@lexnv lexnv changed the title cumulus: Enable ChainSpec for polkadot-parachain rpc: Enable ChainSpec for polkadot-parachain Aug 1, 2024
@paritytech-cicd-pr
Copy link

The CI pipeline was cancelled due to failure one of the required jobs.
Job name: cargo-clippy
Logs: https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/6882564

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
@lexnv
Copy link
Contributor Author

lexnv commented Aug 1, 2024

Testing done:

  • with this patch
curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "rpc_methods", "params":[1]}' http://localhost:9944                                                                                                                            
{"jsonrpc":"2.0","result":{"methods":["account_nextIndex","...",".. ,"chainSpec_v1_chainName","chainSpec_v1_genesisHash","chainSpec_v1_properties",
  • without
{"jsonrpc":"2.0","result":{"methods":["account_nextIndex","author_hasKey","author_hasSessionKeys","author_insertKey","author_pendingExtrinsics","author_removeExtrinsic","author_rotateKeys","author_submitAndWatchExtrinsic","author_submitExtrinsic","author_unwatchExtrinsic","chainHead_v1_body","chainHead_v1_call","chainHead_v1_continue","chainHead_v1_follow","chainHead_v1_header","chainHead_v1_stopOperation","chainHead_v1_storage","chainHead_v1_unfollow","chainHead_v1_unpin","chain_getBlock","chain_getBlockHash","chain_getFinalisedHead","chain_getFinalizedHead","chain_getHead","chain_getHeader","chain_getRuntimeVersion","chain_subscribeAllHeads","chain_subscribeFinalisedHeads","chain_subscribeFinalizedHeads","chain_subscribeNewHead","chain_subscribeNewHeads","chain_subscribeRuntimeVersion","chain_unsubscribeAllHeads","chain_unsubscribeFinalisedHeads","chain_unsubscribeFinalizedHeads","chain_unsubscribeNewHead","chain_unsubscribeNewHeads","chain_unsubscribeRuntimeVersion","childstate_getKeys","childstate_getKeysPaged","childstate_getKeysPagedAt","childstate_getStorage","childstate_getStorageEntries","childstate_getStorageHash","childstate_getStorageSize","dev_getBlockStats","offchain_localStorageGet","offchain_localStorageSet","payment_queryFeeDetails","payment_queryInfo","rpc_methods","state_call","state_callAt","state_getChildReadProof","state_getKeys","state_getKeysPaged","state_getKeysPagedAt","state_getMetadata","state_getPairs","state_getReadProof","state_getRuntimeVersion","state_getStorage","state_getStorageAt","state_getStorageHash","state_getStorageHashAt","state_getStorageSize","state_getStorageSizeAt","state_queryStorage","state_queryStorageAt","state_subscribeRuntimeVersion","state_subscribeStorage","state_traceBlock","state_trieMigrationStatus","state_unsubscribeRuntimeVersion","state_unsubscribeStorage","subscribe_newHead","system_accountNextIndex","system_addLogFilter","system_addReservedPeer","system_chain","system_chainType","system_dryRun","system_dryRunAt","system_health","system_localListenAddresses","system_localPeerId","system_name","system_nodeRoles","system_peers","system_properties","system_removeReservedPeer","system_reservedPeers","system_resetLogFilter","system_syncState","system_unstable_networkState","system_version","transactionWatch_v1_submitAndWatch","transactionWatch_v1_unwatch","transaction_v1_broadcast","transaction_v1_stop","unsubscribe_newHead"]},"id":1}

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
@niklasad1
Copy link
Member

Nice one, with this refactor now all users of polkadot-sdk gets the entire rpc v2 API without having to use their own rpc extensions for it.

- Runtime Dev
- Node Dev
description: |
Enables the `chainSpec_v1` rpc-v2 API for polkadot-parachains.
Copy link
Member

Choose a reason for hiding this comment

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

I would like to re-phrase this as:

The substrate-service-builder now includes the entire rpc v2 API. The chainspec API was previously defined as rpc extension where for instance chains would need to enable it explicitly for it to be enabled which isn't the case anymore

Copy link
Member

@niklasad1 niklasad1 left a comment

Choose a reason for hiding this comment

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

Nice 👍

lexnv and others added 3 commits August 1, 2024 17:03
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
@lexnv lexnv added this pull request to the merge queue Aug 2, 2024
Merged via the queue into master with commit ce6938a Aug 2, 2024
154 of 161 checks passed
@lexnv lexnv deleted the lexnv/chain-spec-enable branch August 2, 2024 15:45
ordian added a commit that referenced this pull request Aug 6, 2024
* master: (51 commits)
  Remove unused feature gated code from the minimal template (#5237)
  make polkadot-parachain startup errors pretty (#5214)
  Coretime auto-renew (#4424)
  network/strategy: Backoff and ban overloaded peers to avoid submitting the same request multiple times (#5029)
  Fix frame crate usage doc (#5222)
  beefy: Tolerate pruned state on runtime API call (#5197)
  rpc: Enable ChainSpec for polkadot-parachain (#5205)
  Add an adapter for configuring AssetExchanger (#5130)
  Replace env_logger with sp_tracing (#5065)
  Adjust sync templates flow to use new release branch (#5182)
  litep2p/discovery: Publish authority records with external addresses only (#5176)
  Run UI tests in CI for some other crates (#5167)
  Remove `pallet::getter` usage from the pallet-balances (#4967)
  pallet-timestamp: `UnixTime::now` implementation logs error only if called at genesis (#5055)
  [CI] Cache try-runtime check (#5179)
  [Backport] version bumps and the prdocs reordering from stable2407 (#5178)
  [subsystem-benchmark] Update availability-distribution-regression-bench baseline after recent subsystem changes (#5180)
  Remove pallet::getter usage from proxy (#4963)
  Remove pallet::getter macro usage from pallet-election-provider-multi-phase (#4487)
  Review-bot@2.6.0 (#5177)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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. T9-cumulus This PR/Issue is related to cumulus.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cumulus rpc: add chainspec API
5 participants