MCPcopy Create free account
hub / github.com/DeAI-Artist/Linkis / CreateProposalBlock

Method CreateProposalBlock

state/execution.go:94–111  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

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.
94func (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.

Callers 5

TestCreateProposalBlockFunction · 0.95
TestMaxProposalBlockSizeFunction · 0.95
createProposalBlockMethod · 0.80
createProposalBlockMethod · 0.80

Calls 5

MaxDataBytesFunction · 0.92
MakeBlockMethod · 0.80
PendingEvidenceMethod · 0.65
SizeMethod · 0.65
ReapMaxBytesMaxGasMethod · 0.65

Tested by 3

TestCreateProposalBlockFunction · 0.76
TestMaxProposalBlockSizeFunction · 0.76