gno icon indicating copy to clipboard operation
gno copied to clipboard

feat: add valset injection through `r/sys/vals`

Open zivkovicmilos opened this issue 8 months ago • 1 comments

Description

This PR introduces an EndBlocker system for applying validator set changes protocol level, based on on-chain events (from the /r/sys/vals realm).

I've utilized an already existing system:

  • validator set changes still stay managed protocol-level in ConsensusState -> refactoring this is not a small feat, and saying this is an understatement
  • event switch utilized by the node that dumps new block / new transaction events

The way this flow essentially works is the following:

  1. An on-chain event happens that indicates a change in the validator set (added / removed)
  2. These events (ABCI events) are parsed as soon as they end up in a transaction result (are pushed to the event system of the SDK). The top-level ABCI event type needs to beEventTx (indicating it's a new TX result). The underlying tx GnoVM events (GnoEvent) need to be from the /r/sys/vals Realm, and be a validator addition / removal (type defined in the Realm)
  3. Events are parsed down into abci.ValidatorUpdates, which are returned as a result of EndBlocker
  4. This EndBlocker result is later read by the ConsensusState, and the validator set changes are applied for the upcoming block in a series of existing callbacks. This also keeps proposer priority logic in check.

Blocked by #2130 Closes #1823

Related: https://github.com/gnolang/gno/pull/1945

Contributors' checklist...
  • [ ] Added new tests, or not needed, or not feasible
  • [ ] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory
  • [ ] Updated the official documentation or not needed
  • [ ] No breaking changes were made, or a BREAKING CHANGE: xxx message was included in the description
  • [ ] Added references to related issues and PRs
  • [ ] Provided any useful hints for running manual tests
  • [ ] Added new benchmarks to generated graphs, if any. More info here.

zivkovicmilos avatar May 28 '24 11:05 zivkovicmilos