From 0255c4c5233727f7678f480193d9352e8ed36109 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Fri, 6 Sep 2024 09:07:46 +0200 Subject: [PATCH] adding mix blockmaxbytes check and error log --- block/executor.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/block/executor.go b/block/executor.go index 9cca19e59..d6722d145 100644 --- a/block/executor.go +++ b/block/executor.go @@ -16,6 +16,8 @@ import ( "github.com/dymensionxyz/dymint/types" ) +const minBlockMaxBytes = 10000 + // Executor creates and applies blocks and maintains state. type Executor struct { localAddress []byte @@ -90,7 +92,13 @@ func (e *Executor) InitChain(genesis *tmtypes.GenesisDoc, valset []*tmtypes.Vali // CreateBlock reaps transactions from mempool and builds a block. func (e *Executor) CreateBlock(height uint64, lastCommit *types.Commit, lastHeaderHash, nextSeqHash [32]byte, state *types.State, maxBlockDataSizeBytes uint32) *types.Block { - if uint32(state.ConsensusParams.Block.MaxBytes) > 0 { + if uint32(state.ConsensusParams.Block.MaxBytes) < minBlockMaxBytes { + e.logger.Error("Block max bytes defined in consensus params too small. using minimum value: consensus param: %d min allowed: %d", state.ConsensusParams.Block.MaxBytes, minBlockMaxBytes) + } + if uint32(state.ConsensusParams.Block.MaxBytes) > maxBlockDataSizeBytes { + e.logger.Error("Block max bytes defined in consensus params bigger than max blob bytes allowed in DA. using max value. consensus param: %d max allowed: %d", state.ConsensusParams.Block.MaxBytes, maxBlockDataSizeBytes) + } + if uint32(state.ConsensusParams.Block.MaxBytes) >= minBlockMaxBytes { maxBlockDataSizeBytes = min(maxBlockDataSizeBytes, uint32(state.ConsensusParams.Block.MaxBytes)) } mempoolTxs := e.mempool.ReapMaxBytesMaxGas(int64(maxBlockDataSizeBytes), state.ConsensusParams.Block.MaxGas)