paritytech / paritytech/json-rpc-interface-spec

`system_accountNextIndex` alternative?

Open
#156 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
No language data
Stars
37
Forks
6
PR merge metrics
No merged PRs in 30d

Description

The legacy JSON-RPC API provides the system_accountNextIndex RPC endpoint, which considers the transactions present in the pool.

Additionally, PJS offers a useful shorthand allowing users to pass -1 as the nonce. This signals PJS to obtain the nonce from the system_accountNextIndex endpoint.

Using the new JSON-RPC API, we can utilize the AccountNonceApi_account_nonce runtime call against the most recently seen block to get the latest nonce. However, if there are transactions in the pool, the resulting transaction will eventually become invalid because it won't have the latest nonce.

I am concerned that there is no way to accomplish the same with the new JSON-RPC API. As a library author trying to provide an alternative to PJS, my users are experiencing issues because they must manually track the latest nonce when sending multiple transactions in parallel.

I am seeking advice on the following:

  1. Should polkadot-api attempt to provide similar functionality by keeping track of currently broadcasted transactions from this client? This approach seems somewhat hacky and risky.
  2. Are there any other options or ideas that I may not have considered?

Any guidance or suggestions would be greatly appreciated.

cc: @tomaka @jsdw @bkchr

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the legacy system_accountNextIndex endpoint, the new AccountNonceApi_account_nonce runtime call, and the PJS nonce shorthand described in the issue. The work is complete when the project has a decided, documented approach for handling pending transactions through the new JSON-RPC API.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.