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

Add endpoint to chain_api that reports active (and pending if different) finalizer policies and each finalizers last tracked vote #453

Merged
merged 31 commits into from
Aug 2, 2024

Conversation

linh2931
Copy link
Member

@linh2931 linh2931 commented Jul 31, 2024

Provide a chain_api RPC endpoint get_finalizer_info that reports

  • active finalizer policy,
  • pending finalizer policy if different from the active finalizer policy
  • last tracked vote associated with each finalizer in the active (an pending if exist) policy, including the timestamp, block ID, block number of that block it last voted on, whether that vote was strong or weak, and the generation number of the policy it voted as part of.

Resolves #419

A sample output of the endpoint from a test run:

{
  "code": 200,
  "payload": {
    "active_finalizer_policy": {
      "generation": 1,
      "threshold": 3,
      "finalizers": [
        {
          "description": "finalizer #1",
          "weight": 1,
          "public_key": "PUB_BLS_GzRFeCxWX8vtIEW9ll-tU9lDOo8c5YK-rUJcihzyGDDT9Qr_WXnnZrh4J0vdZjwViyZTXT6x73MhQ3z849MGi1LHVXVtcLYWuFZV1aXJ21Ms7kTkCZ15RfZCObszcS8YT4DUJw"
        },
        {
          "description": "finalizer #2",
          "weight": 1,
          "public_key": "PUB_BLS_7OxmIgNcXRwhzfrpO7-qdjMTmlDIIkndWnVQBT_7SfeZy2Vhe9xG-KjcUqSniYEGfs5wth8BdPXIh2ooUxvcgFyYP2AJs8WgOrcUxSmaDeApERGbjGZAckSV5QgRCJkZ68nygQ"
        },
        {
          "description": "finalizer #3",
          "weight": 1,
          "public_key": "PUB_BLS_JUmRKdx4pWijSy5iuy3p3jvTRVqF6McpYIPUH5BF2XcUeyo8ZjJCGqfKK8rV61wXwlI_qQRTKvHKx59pihxCVq0NLD0Wd9NVE06ka_GEHx5kl-ra6kBfaor7gDv7rTcTZuCQNA"
        },
        {
          "description": "finalizer #4",
          "weight": 1,
          "public_key": "PUB_BLS_qVbh4IjYZpRGo8U_0spBUM-u-r_G0fMo4MzLZRsKWmm5uyeQTp74YFaMN9IDWPoVVT5rj_Tw1gvps6K9_OZ6sabkJJzug3uGfjA6qiaLbLh5Fnafwv-nVgzzzBlU2kwRrcHc8Q"
        }
      ]
    },
    "pending_finalizer_policy": "None",
    "last_tracked_votes": [
      {
        "description": "finalizer #1",
        "public_key": "PUB_BLS_GzRFeCxWX8vtIEW9ll-tU9lDOo8c5YK-rUJcihzyGDDT9Qr_WXnnZrh4J0vdZjwViyZTXT6x73MhQ3z849MGi1LHVXVtcLYWuFZV1aXJ21Ms7kTkCZ15RfZCObszcS8YT4DUJw",
        "is_vote_strong": "True",
        "finalizer_policy_generation": 1,
        "voted_for_block_id": "000000437e6f3004e6b7bab061ff04dfae4b7b6dfabe625fca3226d77e1b7bf1",
        "voted_for_block_num": 67,
        "voted_for_block_timestamp": "2024-08-02T01:16:18.500"
      },
      {
        "description": "finalizer #2",
        "public_key": "PUB_BLS_7OxmIgNcXRwhzfrpO7-qdjMTmlDIIkndWnVQBT_7SfeZy2Vhe9xG-KjcUqSniYEGfs5wth8BdPXIh2ooUxvcgFyYP2AJs8WgOrcUxSmaDeApERGbjGZAckSV5QgRCJkZ68nygQ",
        "is_vote_strong": "True",
        "finalizer_policy_generation": 1,
        "voted_for_block_id": "000000437e6f3004e6b7bab061ff04dfae4b7b6dfabe625fca3226d77e1b7bf1",
        "voted_for_block_num": 67,
        "voted_for_block_timestamp": "2024-08-02T01:16:18.500"
      },
      {
        "description": "finalizer #3",
        "public_key": "PUB_BLS_JUmRKdx4pWijSy5iuy3p3jvTRVqF6McpYIPUH5BF2XcUeyo8ZjJCGqfKK8rV61wXwlI_qQRTKvHKx59pihxCVq0NLD0Wd9NVE06ka_GEHx5kl-ra6kBfaor7gDv7rTcTZuCQNA",
        "is_vote_strong": "True",
        "finalizer_policy_generation": 1,
        "voted_for_block_id": "000000437e6f3004e6b7bab061ff04dfae4b7b6dfabe625fca3226d77e1b7bf1",
        "voted_for_block_num": 67,
        "voted_for_block_timestamp": "2024-08-02T01:16:18.500"
      },
      {
        "description": "finalizer #4",
        "public_key": "PUB_BLS_qVbh4IjYZpRGo8U_0spBUM-u-r_G0fMo4MzLZRsKWmm5uyeQTp74YFaMN9IDWPoVVT5rj_Tw1gvps6K9_OZ6sabkJJzug3uGfjA6qiaLbLh5Fnafwv-nVgzzzBlU2kwRrcHc8Q",
        "is_vote_strong": "True",
        "finalizer_policy_generation": 1,
        "voted_for_block_id": "000000437e6f3004e6b7bab061ff04dfae4b7b6dfabe625fca3226d77e1b7bf1",
        "voted_for_block_num": 67,
        "voted_for_block_timestamp": "2024-08-02T01:16:18.500"
      }
    ]
  }
}

@linh2931 linh2931 requested review from heifner and greg7mdp July 31, 2024 19:09
libraries/chain/include/eosio/chain/controller.hpp Outdated Show resolved Hide resolved
libraries/chain/controller.cpp Outdated Show resolved Hide resolved
libraries/chain/include/eosio/chain/finality/qc.hpp Outdated Show resolved Hide resolved
plugins/chain_plugin/tracked_votes.cpp Outdated Show resolved Hide resolved
plugins/chain_plugin/tracked_votes.cpp Outdated Show resolved Hide resolved
plugins/chain_plugin/tracked_votes.cpp Outdated Show resolved Hide resolved
plugins/chain_plugin/chain_plugin.cpp Outdated Show resolved Hide resolved
plugins/chain_plugin/tracked_votes.cpp Outdated Show resolved Hide resolved
@heifner
Copy link
Member

heifner commented Aug 1, 2024

I believe we wanted cleos support for this endpoint.

Comment on lines 32 to 34
chain::block_id_type voted_block_id;
uint32_t voted_block_num{0};
fc::time_point voted_block_timestamp;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do these identify the block which was voted on
OR
Do these identify the block that contained the vote

Copy link
Member

Choose a reason for hiding this comment

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

The block that was voted on.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll add a comment to the code.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done by 76d123d

@linh2931
Copy link
Member Author

linh2931 commented Aug 1, 2024

I believe we wanted cleos support for this endpoint.

I will do a separate PR for it #464

libraries/chain/finality/qc.cpp Outdated Show resolved Hide resolved
libraries/chain/include/eosio/chain/finality/qc.hpp Outdated Show resolved Hide resolved
@ericpassmore
Copy link
Contributor

Note:start
group: PROTOCOL
category: HTTP
summary: New chain api get_finalizer_info with information on finalizers and last votes.
Note:end

@greg7mdp
Copy link
Contributor

greg7mdp commented Aug 1, 2024

      {
        "public_key": "PUB_BLS_qVbh4IjYZpRGo8U_0spBUM-u-r_G0fMo4MzLZRsKWmm5uyeQTp74YFaMN9IDWPoVVT5rj_Tw1gvps6K9_OZ6sabkJJzug3uGfjA6qiaLbLh5Fnafwv-nVgzzzBlU2kwRrcHc8Q",
        "description": "finalizer #4",
        "is_vote_strong": "True",
        "voted_policy_generation": 1,
        "voted_block_id": "00000042827068ee5e2f42b781a77c6732f17a3c708a450d6497dc8ab36ffc05",
        "voted_block_num": 66,
        "voted_block_timestamp": "2024-08-01T13:21:25.500"
      }

I'd would suggest changing:

voted_policy_generation -> finalizer_policy_generation
voted_ -> voted_on_ or voted_for_

Also, could we sort the list of votes according to description?

libraries/chain/finality/qc.cpp Outdated Show resolved Hide resolved
@linh2931
Copy link
Member Author

linh2931 commented Aug 2, 2024

      {
        "public_key": "PUB_BLS_qVbh4IjYZpRGo8U_0spBUM-u-r_G0fMo4MzLZRsKWmm5uyeQTp74YFaMN9IDWPoVVT5rj_Tw1gvps6K9_OZ6sabkJJzug3uGfjA6qiaLbLh5Fnafwv-nVgzzzBlU2kwRrcHc8Q",
        "description": "finalizer #4",
        "is_vote_strong": "True",
        "voted_policy_generation": 1,
        "voted_block_id": "00000042827068ee5e2f42b781a77c6732f17a3c708a450d6497dc8ab36ffc05",
        "voted_block_num": 66,
        "voted_block_timestamp": "2024-08-01T13:21:25.500"
      }

I'd would suggest changing:

voted_policy_generation -> finalizer_policy_generation voted_ -> voted_on_ or voted_for_

Also, could we sort the list of votes according to description?

Thanks! I have renamed them as you suggest. I also place description as the first field for easier identification and sort them.

Done by f5a5022

@greg7mdp
Copy link
Contributor

greg7mdp commented Aug 2, 2024

Thanks! I have renamed them as you suggest. I also place description as the first field for easier identification and sort them.

Done by f5a5022

Awesome, thanks Lin!

@linh2931 linh2931 merged commit 732a1d7 into main Aug 2, 2024
36 checks passed
@linh2931 linh2931 deleted the get_finalizers_info_rpc branch August 2, 2024 02:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants