ValidateProposal() fully validates a proposal in the form of a quorum certificate and resets back to begin block state
(rcBuildHeight uint64, qc *lib.QuorumCertificate, evidence *bft.ByzantineEvidence)
| 183 | |
| 184 | // ValidateProposal() fully validates a proposal in the form of a quorum certificate and resets back to begin block state |
| 185 | func (c *Controller) ValidateProposal(rcBuildHeight uint64, qc *lib.QuorumCertificate, evidence *bft.ByzantineEvidence) (blockResult *lib.BlockResult, err lib.ErrorI) { |
| 186 | // reset the mempool at the beginning of the function to preserve the state for CommitCertificate() |
| 187 | c.FSM.Reset() |
| 188 | // log the beginning of proposal validation |
| 189 | c.log.Debugf("Validating proposal from leader") |
| 190 | // configure the FSM in 'consensus mode' for validator proposals |
| 191 | resetProposalConfig := c.SetFSMInConsensusModeForProposals() |
| 192 | // once done proposing, 'reset' the proposal mode back to default to 'accept all' |
| 193 | defer resetProposalConfig() |
| 194 | // ensure the proposal inside the quorum certificate is valid at a stateless level |
| 195 | block, err := qc.CheckProposalBasic(c.FSM.Height(), c.Config.NetworkID, c.Config.ChainId) |
| 196 | if err != nil { |
| 197 | // exit with error |
| 198 | return |
| 199 | } |
| 200 | // validate the byzantine evidence portion of the proposal (bft is canopy controlled) |
| 201 | if err = c.Consensus.ValidateByzantineEvidence(qc.Results.SlashRecipients, evidence); err != nil { |
| 202 | // exit with error |
| 203 | return |
| 204 | } |
| 205 | // play the block against the state machine to generate a block result |
| 206 | blockResult, err = c.ApplyAndValidateBlock(block, false) |
| 207 | if err != nil { |
| 208 | // exit with error |
| 209 | return |
| 210 | } |
| 211 | // create a comparable certificate results (includes reward recipients, slash recipients, swap commands, etc) |
| 212 | compareResults := c.NewCertificateResults(c.FSM, block, blockResult, evidence, rcBuildHeight) |
| 213 | // ensure generated the same results |
| 214 | if !qc.Results.Equals(compareResults) { |
| 215 | // exit with error |
| 216 | return nil, fsm.ErrMismatchCertResults() |
| 217 | } |
| 218 | // exit |
| 219 | return |
| 220 | } |
| 221 | |
| 222 | // CommitCertificate() is executed after the quorum agrees on a block |
| 223 | // - applies block against the fsm |
nothing calls this directly
no test coverage detected