Skip to content

Commit

Permalink
adding mix blockmaxbytes check and error log
Browse files Browse the repository at this point in the history
  • Loading branch information
srene committed Sep 6, 2024
1 parent 7ed416e commit 0255c4c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion block/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 0255c4c

Please sign in to comment.