Endblocker
EndBlocker
EndBlocker is the function that calls at the end of each block. In x/gov module it is responsible for handling
proposals, especially changing their states and execute them if needed. For OversightCommittee flow we are going to
change the stages when the Proposal is about to be executed.
Normally, when VotingPeriod is ended and there are enough VotingPower to move the Proposal to the execution stage,
EndBlocker makes next phases:
- Vote routine
- Execution routine
Vote routine
Vote routine includes all the voting steps and calculations, like:
- Remove all the
Votesrelated to theProposalfrom the state. TallyResultis calculated on this phase.
Execution routine
Execution routine is responsible for the following:
- Execute messages, attached to the
Proposal, by passing them toMsgRouter - Mark
ProposalasPASSEDin case of successful execution orFAILEDin case of unsuccessful.
Proposal status delayed
For OversightCommittee flow we are introducing another state for the Proposal - ProposalStatusDelayed. It includes
all the previous steps, except real message execution and moving Proposal to final states, like PASSED or FAILED.
The main points, regarding new state:
- All the steps from Voting routine are done
- Actions related to deposit are executed, like
burn depositorreturn to proposer.
Having this modified EndBlocker changes Proposal's status to ProposalStatusDelayed and returns it back into
ActiveProposalsQueue but with shifted VotingPeriodEnd by Grace Period from OversightCommitteeParams.
When the shifted VotingPeriodEnd is reached, the Proposal goes to the Execution routine.
The AfterProposalVotingPeriodEnded hook fires once per Proposal, on the pass that tallies it and moves it to
ProposalStatusDelayed. The later execution pass does not fire it again.
While the Proposal is delayed:
- An
OversightCommitteeveto marks itREJECTEDand removes it from theActiveProposalsQueue, so theEndBlockernever tallies or executes it again. TheFinalTallyResultrecorded at the end of the voting period is kept. - A message that fails during the execution routine marks the
ProposalasFAILEDwith the error inFailedReason. As in upstreamx/gov, this is not anEndBlockererror and does not halt the chain.
Events and logs
The EndBlocker reports each pass over a Proposal twice: once in the upstream active_proposal event, once in a
typed dgov event that carries the structured data the string event cannot.
active_proposal is emitted on every pass, exactly as in upstream x/gov. Its proposal_result attribute tells the
passes apart:
| Pass | proposal_result |
|---|---|
| Voting period ended, proposal passed | proposal_delayed |
| Voting period ended, proposal rejected | proposal_rejected |
| Expedited threshold missed | expedited_proposal_rejected (converted to a regular one) |
| Grace period ended | proposal_passed or proposal_failed |
As upstream already emits several active_proposal events for an expedited proposal, consumers must key on
proposal_result rather than on the event type. proposal_delayed is the only value added by dgov.
The typed events are:
d.dgov.v1.EventProposalTallied, emitted once per tally, on the pass that ends a voting period. It carries theresultof the pass (same values asproposal_resultabove), theTallyResultthat is stored on the proposal asFinalTallyResult, and the two totals the verdict was derived from:total_voting_power, the power that actually voted (the quorum numerator), andtotal_val_power, the power of the whole bonded validator set at tally time (the quorum denominator). Without them turnout and vote shares cannot be reconstructed later.d.dgov.v1.EventProposalExecuted, emitted once, on the pass that ends the grace period.resultisproposal_passedorproposal_failed, andfailed_reasoncarries the handler error when the execution failed.
The log lines follow the same split: proposal tallied on the tally pass and proposal executed on the execution pass.
Neither event nor log is allowed to fail the block: an error from emitting a typed event is logged and ignored.