Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Expose GRANDPA round state through RPC #4921

Closed
andresilva opened this issue Feb 13, 2020 · 3 comments
Closed

Expose GRANDPA round state through RPC #4921

andresilva opened this issue Feb 13, 2020 · 3 comments
Assignees
Labels
J0-enhancement An additional feature request. Z2-medium Can be fixed by a coder with good Rust knowledge but little knowledge of the codebase.

Comments

@andresilva
Copy link
Member

We should be able to inspect the current GRANDPA round state externally, this is particularly useful in situations where finality is stalled (e.g. due to some voters being offline).

I propose we add an RPC method grandpa_roundState that returns something like:

{
  "setId": 361,
  "round": 1283,
  "total_weight": 100,
  "thresholdWeight": 67,
  "prevotes": {
    "currentWeight": 79,
    "missing": [
      // list of addresses of authorities missing votes
    ]
  },
  "precommits": {
    "currentWeight": 12,
    "missing": [
      // list of addresses of authorities missing votes
    ]
  }
}

Currently this data is not exposed by the finality-grandpa crate, there's paritytech/finality-grandpa#55 which should be tackled as part of this issue as well.

Regarding the addresses of validators that are missing votes it is a bit tricky. Ideally we'd like to expose the addresses of the stash account since these represent the main "identity" of a validator. But the client GRANDPA code only deals with session keys and it isn't trivial to fetch the associated stash keys.

cc @rphmeier

@andresilva andresilva added J0-enhancement An additional feature request. M4-core Z2-medium Can be fixed by a coder with good Rust knowledge but little knowledge of the codebase. labels Feb 13, 2020
@rphmeier
Copy link
Contributor

rphmeier commented Feb 14, 2020

It's probably easier to just identify missing votes by grandpa pubkey. The stash key relies on state which may have been pruned, in the case that we are catching up or finality is lagging.

Also, we may have multiple live rounds at once. Which one should roundState tell us about? Maybe we should have a grandpa_liveRounds() and grandpa_roundState(set_id, round). The drawback is that it's racy with round advancement. Alternatively, we could return roundState for all live rounds.

@andresilva
Copy link
Member Author

Yes, I was going to suggest that we return the round state for all currently live rounds, something like:

{
  "setId": 361,
  "best": {
    "round": 1283,
    "total_weight": 100,
    "thresholdWeight": 67,
    "prevotes": {
      "currentWeight": 79,
      "missing": [
        // list of addresses of authorities missing votes
      ]
    },
    "precommits": {
      "currentWeight": 12,
      "missing": [
        // list of addresses of authorities missing votes
      ]
    }
  },
  "background": [
    {
      "round": 1282,
      // ... same fields as above
    },
    ...
  ]
}

@andresilva
Copy link
Member Author

Done in #5375.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
J0-enhancement An additional feature request. Z2-medium Can be fixed by a coder with good Rust knowledge but little knowledge of the codebase.
Projects
None yet
Development

No branches or pull requests

3 participants