Closed
Description
Bug Report
The introductory go.md
and go-builtin.md
guides have a wrong example of prepareProposal
, as noted [here] (#1384 (comment))
func (app *KVStoreApplication) PrepareProposal(_ context.Context, proposal *abcitypes.RequestPrepareProposal) (*abcitypes.ResponsePrepareProposal, error) {
totalBytes := int64(0)
txs := make([]byte, 0)
for _, tx := range proposal.Txs {
totalBytes += int64(len(tx))
txs = append(txs, tx...)
if totalBytes > int64(proposal.MaxTxBytes) {
break
}
}
return &abcitypes.ResponsePrepareProposal{Txs: proposal.Txs}, nil
}
First, txs
should be a slice of slices.
Second, the overflow check should be done before appending the transaction to txs
.
The fix need to be back ported to 0.38 and 0.37.