Skip to content

Commit

Permalink
address #226
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-forbes committed Apr 27, 2022
1 parent a7e59ea commit f3b543f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/process_proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ func (app *App) ProcessProposal(req abci.RequestProcessProposal) abci.ResponsePr

// extract the commitments from any MsgPayForDatas in the block
commitments := make(map[string]struct{})
// we have a separate counter so that identical messages also get counted
// also see https://github.com/celestiaorg/celestia-app/issues/226
commitmentCounter := 0
for _, rawTx := range req.BlockData.Txs {
tx, err := MalleatedTxDecoder(app.txConfig.TxDecoder())(rawTx)
if err != nil {
Expand All @@ -35,13 +38,19 @@ func (app *App) ProcessProposal(req abci.RequestProcessProposal) abci.ResponsePr
}

commitments[string(pfm.MessageShareCommitment)] = struct{}{}
commitmentCounter++
}

}

// quickly compare the number of PFMs and messages, if they aren't
// identical, then we already know this block is invalid
if len(commitments) != len(req.BlockData.Messages.MessagesList) {
if commitmentCounter != len(req.BlockData.Messages.MessagesList) {
app.Logger().Error(
rejectedPropBlockLog,
"reason",
"varying number of messages and payForData txs in the same block",
)
return abci.ResponseProcessProposal{
Result: abci.ResponseProcessProposal_REJECT,
}
Expand Down

0 comments on commit f3b543f

Please sign in to comment.