CreateProposalBlock calls state.MakeBlock with evidence from the evpool and txs from the mempool. The max bytes must be big enough to fit the commit. Up to 1/10th of the block space is allcoated for maximum sized evidence. The rest is given to txs, up to the max gas.
( height int64, state State, commit *types.Commit, proposerAddr []byte, )
| 92 | // Up to 1/10th of the block space is allcoated for maximum sized evidence. |
| 93 | // The rest is given to txs, up to the max gas. |
| 94 | func (blockExec *BlockExecutor) CreateProposalBlock( |
| 95 | height int64, |
| 96 | state State, commit *types.Commit, |
| 97 | proposerAddr []byte, |
| 98 | ) (*types.Block, *types.PartSet) { |
| 99 | |
| 100 | maxBytes := state.ConsensusParams.Block.MaxBytes |
| 101 | maxGas := state.ConsensusParams.Block.MaxGas |
| 102 | |
| 103 | evidence, evSize := blockExec.evpool.PendingEvidence(state.ConsensusParams.Evidence.MaxBytes) |
| 104 | |
| 105 | // Fetch a limited amount of valid txs |
| 106 | maxDataBytes := types.MaxDataBytes(maxBytes, evSize, state.Validators.Size()) |
| 107 | |
| 108 | txs := blockExec.mempool.ReapMaxBytesMaxGas(maxDataBytes, maxGas) |
| 109 | |
| 110 | return state.MakeBlock(height, txs, commit, evidence, proposerAddr) |
| 111 | } |
| 112 | |
| 113 | // ValidateBlock validates the given block against the given state. |
| 114 | // If the block is invalid, it returns an error. |