Creating a proposal
A block consists of a header, transactions, votes (the commit), and a list of evidence of malfeasance (eg. signing conflicting votes). Outstanding evidence items get priority over outstanding transactions in the mempool. All in all, the block MUST NOT exceedConsensusParams.Block.MaxBytes,
or 100MB if ConsensusParams.Block.MaxBytes == -1.
Reaping transactions from the mempool
When we reap transactions from the mempool, we calculate maximum data size by subtracting maximum header size (MaxHeaderBytes), the maximum
protobuf overhead for a block (MaxOverheadForBlock), the size of
the last commit (if present) and evidence (if present). While reaping
we account for protobuf overhead for each transaction.
ConsensusParams.Block.MaxBytes == -1, we reap all outstanding transactions from the mempool
Preparing the proposal
Once the transactions have been reaped from the mempool according to the rules described above, CometBFT callsPrepareProposal to the application with the transaction list that has just been reaped.
As part of this call the application can remove, add, or reorder transactions in the transaction list.
The RequestPrepareProposal contains two important fields:
MaxTxBytes, which contains the value returned byMaxDataBytesdescribed above. The application MUST NOT return a list of transactions whose size exceeds this number.Txs, which contains the list of reaped transactions.
PrepareProposal, please see the
relevant part of the spec