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

getblockchaininfo JSON-RPC method #3143

Closed
1 task done
Tracked by #3134
mpguerra opened this issue Dec 3, 2021 · 3 comments · Fixed by #3891
Closed
1 task done
Tracked by #3134

getblockchaininfo JSON-RPC method #3143

mpguerra opened this issue Dec 3, 2021 · 3 comments · Fixed by #3891
Assignees
Labels
lightwalletd any work associated with lightwalletd

Comments

@mpguerra
Copy link
Contributor

mpguerra commented Dec 3, 2021

Motivation

lightwalletd uses the getblockchaininfo JSON-RPC method.

Dependencies

Required Fields

The method is documented here: https://zcash.github.io/rpc/getblockchaininfo.html

But only the following fields are used by lightwalletd: https://github.com/zcash/lightwalletd/blob/master/common/common.go#L70

Field list:

{
  "chain": "xxxx",        (string) current network name as defined in BIP70 (main, test, regtest)
  "blocks": xxxxxx,         (numeric) the current number of blocks processed in the server
  "bestblockhash": "...", (string) the hash of the currently best block
  "estimatedheight": xxxx,  (numeric) if syncing, the estimated height of the chain, else the current best height
  "upgrades": {                (object) status of network upgrades
     "xxxx" : {                (string) branch ID of the upgrade, in lowercase hexadecimal
        "name": "xxxx",        (string) name of upgrade - unused by `lightwalletd`, but useful for debugging
        "activationheight": xxxxxx,  (numeric) block height of activation
        "status": "xxxx",      (string) status of upgrade: disabled/pending/active
     }, ...
  },
  "consensus": {               (object) branch IDs of the current and upcoming consensus rules
     "chaintip": "xxxxxxxx",   (string) branch ID used to validate the current chain tip, in lowercase hexadecimal
     "nextblock": "xxxxxxxx"   (string) branch ID that the next block will be validated under, in lowercase hexadecimal
  }
}

The zcashd code that generates the network upgrade JSON is here:
https://github.com/zcash/zcash/blob/6cd5b8792bbe0a3cc1064e1884914415f0c6e7d7/src/rpc/blockchain.cpp#L970

The lightwalletd code that parses the network upgrade JSON is here:
https://github.com/adityapk00/lightwalletd/blob/c1bab818a683e4de69cd952317000f9bb2932274/common/common.go#L195

Tasks

  • Implement the RPC method
  • Add RPC acceptance tests to CI
  • Test that the RPC method works with lightwalletd

API Reference

We plan to use jsonrpc_core with:

Example Code

Here are examples of:

@teor2345 teor2345 changed the title JSON-RPC method getblockchaininfo JSON-RPC method Dec 6, 2021
@ftm1000 ftm1000 added the S-needs-triage Status: A bug report needs triage label Feb 10, 2022
@ftm1000
Copy link

ftm1000 commented Feb 10, 2022

@oxarbitrage
Copy link
Contributor

I am unsure about the consensus object data regarding what should we return there.

I tried to get info from zcashd and i get all 00000 in that fields, however it was a not in sync chain. Anyone know what is the data that goes there ?

@teor2345
Copy link
Contributor

I am unsure about the consensus object data regarding what should we return there.

I tried to get info from zcashd and i get all 00000 in that fields, however it was a not in sync chain. Anyone know what is the data that goes there ?

consensus contains the ConsensusBranchId of the current tip block and the next block.

Something like:

let next_block_height = (height + 1).expect("valid chain tips are a lot less than Height::MAX");

consensus.chaintip = NetworkUpgrade::current(network, height).branch_id();
consensus.nextblock = NetworkUpgrade::current(network, next_block_height).branch_id();

@ftm1000 ftm1000 added the lightwalletd any work associated with lightwalletd label Mar 16, 2022
@mergify mergify bot closed this as completed in #3891 Mar 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lightwalletd any work associated with lightwalletd
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants