state: synchronize the ProcessProposal implementation with the latest version of the spec (#7961)

This change implements the spec for `ProcessProposal`. It first calls the Tendermint block validation logic to check that all of the proposed block fields are well formed and do not violate any of the rules for Tendermint to consider the block valid and then passes the validated block the `ProcessProposal`.

This change also adds additional fixtures to test the change. It adds the `baseMock` types that holds a mock as well as a reference to `BaseApplication`. If the function was not setup by the test on the contained mock Application, the type delegates to the `BaseApplication` and returns what `BaseApplication` returns. 

The change also switches the `makeState` helper to take an arg struct so that an ABCI application can be plumbed through when needed.

closes: #7656
This commit is contained in:
William Banfield
2022-02-25 18:56:34 +00:00
committed by GitHub
parent 89dbebd1c5
commit c80734e5af
16 changed files with 3553 additions and 585 deletions
+12
View File
@@ -303,6 +303,18 @@ func (app *Application) PrepareProposal(req abci.RequestPrepareProposal) abci.Re
return abci.ResponsePrepareProposal{BlockData: req.BlockData}
}
// ProcessProposal implements part of the Application interface.
// It accepts any proposal that does not contain a malformed transaction.
func (app *Application) ProcessProposal(req abci.RequestProcessProposal) abci.ResponseProcessProposal {
for _, tx := range req.Txs {
_, _, err := parseTx(tx)
if err != nil {
return abci.ResponseProcessProposal{Accept: false}
}
}
return abci.ResponseProcessProposal{Accept: true}
}
func (app *Application) Rollback() error {
app.mu.Lock()
defer app.mu.Unlock()