gno
gno copied to clipboard
feat: add valset injection through `r/sys/vals`
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:
- An on-chain event happens that indicates a change in the validator set (added / removed)
- 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 be
EventTx
(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) - Events are parsed down into
abci.ValidatorUpdates
, which are returned as a result ofEndBlocker
- This
EndBlocker
result is later read by theConsensusState
, 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.