chainbound / bolt

Bolt: permissionless out-of-protocol proposer commitments.
https://chainbound.github.io/bolt-docs/
MIT License
27 stars 5 forks source link

Sidecar: `ConsensusState` container #58

Closed mempirate closed 22 hours ago

mempirate commented 1 month ago

Context

Just like we have execution state to validate commitment requests against, we should have a consensus state container. This consensus state will be used to validate commitments against the consensus state. The module should live in src/state/consensus.rs.

The consensus state should have access to a beacon client that it can use to query the beacon chain with. Just like ExecutionState, it should have a fn update_head(&mut self, head: ChainHead) that it will use to update its internal state with. We will have a separate HeadTracker actor that will initiate these update calls.

The validate_request method

To validate a request, we need to

If validate_request passes, we can continue validation on the execution state.

merklefruit commented 1 week ago

Proposer duties & lookahead window

Another useful part of the consensus state container is to keep an updated view of the lookahead at all times:

  1. have a notion of consensus Epoch with a start_slot property and its associated proposer_duties
  2. at the beginning of a new epoch, fetch its proposer duties to make sure we have always up to date info
  3. for every new slot (so when the update_head method is called on the ConsensusState) check if the current epoch is over. If it is, then fetch new proposer duties

In the future, this will also be cross-integrated with the on-chain Registry to make sure that we are registered before accepting commitments.