Skip to content

Commit 93826ea

Browse files
authoredMay 9, 2024··
chore: increase the data commitment blocks limit in the API (Backport #1268) (#1353)
## Description This is done to support 33 hours batches of attestations in the API without having to make a breaking change
1 parent 52f84ef commit 93826ea

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed
 

‎pkg/consts/consts.go

+2
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,7 @@ var (
4141
NewBaseHashFunc = sha256.New
4242

4343
// DataCommitmentBlocksLimit is the limit to the number of blocks we can generate a data commitment for.
44+
// Deprecated: this is no longer used as we're moving towards Blobstream X. However, we're leaving it
45+
// here for backwards compatibility purpose until it's removed in the next breaking release.
4446
DataCommitmentBlocksLimit = 1000
4547
)

‎rpc/core/blocks.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"github.com/tendermint/tendermint/libs/bytes"
1212
cmtmath "github.com/tendermint/tendermint/libs/math"
1313
cmtquery "github.com/tendermint/tendermint/libs/pubsub/query"
14-
"github.com/tendermint/tendermint/pkg/consts"
1514
ctypes "github.com/tendermint/tendermint/rpc/core/types"
1615
rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types"
1716
blockidxnull "github.com/tendermint/tendermint/state/indexer/block/null"
@@ -333,6 +332,10 @@ func EncodeDataRootTuple(height uint64, dataRoot [32]byte) ([]byte, error) {
333332
return append(paddedHeight, dataRoot[:]...), nil
334333
}
335334

335+
// dataCommitmentBlocksLimit The maximum number of blocks to be used to create a data commitment.
336+
// It's a local parameter to protect the API from creating unnecessarily large commitments.
337+
const dataCommitmentBlocksLimit = 10_000 // ~33 hours of blocks assuming 12-second blocks.
338+
336339
// validateDataCommitmentRange runs basic checks on the asc sorted list of
337340
// heights that will be used subsequently in generating data commitments over
338341
// the defined set of heights.
@@ -342,8 +345,8 @@ func validateDataCommitmentRange(start uint64, end uint64) error {
342345
}
343346
env := GetEnvironment()
344347
heightsRange := end - start
345-
if heightsRange > uint64(consts.DataCommitmentBlocksLimit) {
346-
return fmt.Errorf("the query exceeds the limit of allowed blocks %d", consts.DataCommitmentBlocksLimit)
348+
if heightsRange > uint64(dataCommitmentBlocksLimit) {
349+
return fmt.Errorf("the query exceeds the limit of allowed blocks %d", dataCommitmentBlocksLimit)
347350
}
348351
if heightsRange == 0 {
349352
return fmt.Errorf("cannot create the data commitments for an empty set of blocks")

0 commit comments

Comments
 (0)
Please sign in to comment.