Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

add first_block_num for get_info command #10087

Merged
merged 4 commits into from
Feb 27, 2021
Merged

add first_block_num for get_info command #10087

merged 4 commits into from
Feb 27, 2021

Conversation

softprofe
Copy link
Contributor

@softprofe softprofe commented Feb 24, 2021

Change Description

Start 10087 description ......

EPE 737

add first_block_num to the result of get_info command, the first block num is fetched from block_log_imp object, and then fill this number to get info result.

End 10087 description ......

Change Type

Select ONE

  • Documentation
  • Stability bug fix
  • Other
  • Other - special case

Consensus Changes

  • Consensus Changes

API Changes

  • API Changes

Documentation Additions

  • Documentation Additions

@softprofe softprofe requested a review from heifner February 24, 2021 20:59
@@ -120,6 +120,7 @@ class read_only {
string server_version;
chain::chain_id_type chain_id;
uint32_t head_block_num = 0;
uint32_t first_block_num = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you test with an old cleos? I think you have to add this as an std::optional to the end.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will test old cleos.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually I think it is old nodeos with new cleos that will break.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After test, with old cleos, it works good only no first_block_num as below:
$ ./cleos get info
{
"server_version": "c5746b76",
"chain_id": "8a34ec7df1b8cd06ff4a8abbaa7cc50300823350cadc59ab296cb00d104d2b8f",
"head_block_num": 71774,
"last_irreversible_block_num": 71773,
"last_irreversible_block_id": "0001185d8e76bd53352ba97efaf74f94bf4801e4dbe4c460008697ff748fb58a",
"head_block_id": "0001185e94a9337fe51d885f5b74b5e4ac50932329b367508792c36f974be62a",
"head_block_time": "2021-02-26T01:49:12.000",
"head_block_producer": "eosio",
"virtual_block_cpu_limit": 200000000,
"virtual_block_net_limit": 1048576000,
"block_cpu_limit": 199900,
"block_net_limit": 1048576,
"server_version_string": "v2.1.0-rc1",
"fork_db_head_block_num": 71774,
"fork_db_head_block_id": "0001185e94a9337fe51d885f5b74b5e4ac50932329b367508792c36f974be62a",
"server_full_version_string": "v2.1.0-rc1-c5746b76b610dbf336cc61db78196deeda373d5d-dirty",
"last_irreversible_block_time": "2021-02-26T01:49:11.500"
}
while using new cleos, the first_block_num will appear as below:
$ ./cleos get info
{
"server_version": "c5746b76",
"chain_id": "8a34ec7df1b8cd06ff4a8abbaa7cc50300823350cadc59ab296cb00d104d2b8f",
"head_block_num": 71883,
"first_block_num": 1,
"last_irreversible_block_num": 71882,
"last_irreversible_block_id": "000118ca6ec45dd0064cc97f5d53bef4748f25642a03db735d455e674f93ffe6",
"head_block_id": "000118cbe3c8577c571159f8ab333e94046fa66a6266f77b9816cebdb5625cf4",
"head_block_time": "2021-02-26T01:50:06.500",
"head_block_producer": "eosio",
"virtual_block_cpu_limit": 200000000,
"virtual_block_net_limit": 1048576000,
"block_cpu_limit": 199900,
"block_net_limit": 1048576,
"server_version_string": "v2.1.0-rc1",
"fork_db_head_block_num": 71883,
"fork_db_head_block_id": "000118cbe3c8577c571159f8ab333e94046fa66a6266f77b9816cebdb5625cf4",
"server_full_version_string": "v2.1.0-rc1-c5746b76b610dbf336cc61db78196deeda373d5d-dirty",
"last_irreversible_block_time": "2021-02-26T01:50:06.000"
}

Copy link
Contributor

Choose a reason for hiding this comment

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

What about new cleos with version 2.0.x of nodeos?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what's the reason the user want update cleos but not update nodeos?

Copy link
Contributor

Choose a reason for hiding this comment

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

If you interact with a public nodeos API endpoint, you have no control on what version they are running. New cleos versions have to be backward compatible with old nodeos.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

New cleos with old nodeos doesn't break, but it print "first_block_num": 0, it will make user confused, so let me try solve it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After tested, compatible with old nodeos now.

libraries/chain/controller.cpp Outdated Show resolved Hide resolved
@softprofe softprofe requested a review from heifner February 26, 2021 02:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants