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

[rpcserver] Implement getblockchaininfo RPC. #1475

Closed
davecgh opened this issue Oct 1, 2018 · 11 comments · Fixed by #1479
Closed

[rpcserver] Implement getblockchaininfo RPC. #1475

davecgh opened this issue Oct 1, 2018 · 11 comments · Fixed by #1479
Assignees

Comments

@davecgh
Copy link
Member

davecgh commented Oct 1, 2018

In order to provide additional details about the current state of the blockchain, a new RPC named getblockchaininfo should be implemented.

The command for this RPC is already defined along with its result, however, it is not implemented in the dcrd RPC server and the current results don't contain all of the information pertinent to Decred.

The result struct should be modified to add the following fields:

  • initialblockdownload (bool) - Best guess as to whether the initial block download process is underway
  • chainwork (string) - Hexadecimal value that represents the total work in the current best chain
  • maxblocksize (uint32) - The maximum allowed block size

There should probably also be some additional information regarding the state of the various DCPs, but the best way to present that information needs to be thought through.

It should also be noted that the verificationprogress field currently has no code to determine it, so a best guess will need to be determined in the RPC server for now. In the future, this can be significantly improved through modification to the blockchain module, but that is beyond the scope of this issue.

Don't forget when working on this the JSON-RPC API documentation and RPC server help needs to be updated accordingly as well as bumping the RPC server version and potentially the dcrjson module version depending on what other changes have happened since the last module release.

@jrick
Copy link
Member

jrick commented Oct 1, 2018

Does initialblockdownload indicate whether this is the first sync, and the daemon has never been up to date with the network, or if it is behind the network and must catch up (perhaps after being down for maintenance)?

@davecgh
Copy link
Member Author

davecgh commented Oct 1, 2018

It indicates the latter. IBD is really more of a "catchup" mode as opposed to necessarily really being the first sync.

@davecgh
Copy link
Member Author

davecgh commented Oct 1, 2018

@dnldd Is implementing this.

@davecgh
Copy link
Member Author

davecgh commented Oct 1, 2018

In regards to showing the status of the DCPs, I suspect the following will do:

{
...,
"deployments": {
	"sdiffalgorithm": {
		"status": "active",
		"since": <blockheight of the first block to which the status applies>,
		"starttime": ...,
		"expiretime": ...,
	},
	"maxblocksize": {
		....,
	},
	"anotherdeployment": {
		...,
	},
 },
}

However, the exact fields will probably change depending on the status, such as if it's in progress, versus rejected, versus not started, etc.

@dmigwi
Copy link
Member

dmigwi commented Oct 1, 2018

I hope you guys don't plan to do away with the previous height implementation that returned the latest best block to be sync'd by dcrd. This new height implementation and the previous implementation are equally important but for different use case scenarios.

@dnldd
Copy link
Member

dnldd commented Oct 1, 2018

I hope you guys don't plan to do away with the previous height implementation that returned the latest best block to be sync'd by dcrd.

The height provided by this call will be sourced from the best chain state, that's not changing.

@davecgh
Copy link
Member Author

davecgh commented Oct 1, 2018

The existing RPCs getbestblock, getblockcount, and getbestblockhash are not going away.

@jrick
Copy link
Member

jrick commented Oct 2, 2018

@dmigwi which method are you referring to? The peer heights from getpeerinfo?

@dmigwi
Copy link
Member

dmigwi commented Oct 2, 2018

getbestblock is one of the most widely used rpc method in drcdata. I was worried that this new implementation of getblockchaininfo may end up replacing getbestblock which shouldn't happen.

@chappjc
Copy link
Member

chappjc commented Oct 2, 2018

Not to worry. That's probably one of the most widely used RPCs, period.

@dnldd
Copy link
Member

dnldd commented Oct 4, 2018

Sample response from simnet tests.

ctl getblockchaininfo                                                                                                                                                             
{
	"chain": "simnet",
	"blocks": 463,
	"headers": 463,
	"bestblockhash": "000043c89f6e227c9d90a5460aff98b662e503b9a394818942bdd60709cbb8aa",
	"difficulty": 520127421,
	"verificationprogress": 0,
	"chainwork": "0x23c0e40",
	"initialblockdownload": false,
	"maxblocksize": 1000000,
	"deployments": {
		"lnfeatures": {
			"status": "started",
			"since": 463,
			"starttime": 0,
			"expiretime": 9223372036854775807
		},
		"maxblocksize": {
			"status": "started",
			"since": 463,
			"starttime": 0,
			"expiretime": 9223372036854775807
		},
		"sdiffalgorithm": {
			"status": "started",
			"since": 463,
			"starttime": 0,
			"expiretime": 9223372036854775807
		}
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants