Skip to content

Commit 6e417e2

Browse files
gupadhyayaGanesha Upadhyaya
andauthored
upgrade cometbft to 0.37.2 and fix int64 to *big.Int issues (#1123)
<!-- Please read and fill out this form before submitting your PR. Please make sure you have reviewed our contributors guide before submitting your first PR. --> ## Overview <!-- Please provide an explanation of the PR, including the appropriate context, background, goal, and rationale. If there is an issue with this information, please provide a tl;dr and link the issue. --> ## Checklist <!-- Please complete the checklist to ensure that the PR is ready to be reviewed. IMPORTANT: PRs should be left in Draft until the below checklist is completed. --> - [ ] New and updated code has appropriate documentation - [ ] New and updated code has new and/or updated testing - [ ] Required CI checks are passing - [ ] Visual proof for any user facing features like CLI or documentation updates - [ ] Linked issues closed with keywords Co-authored-by: Ganesha Upadhyaya <gupadhyaya@Ganeshas-MacBook-Pro-2.local>
1 parent 509d0b1 commit 6e417e2

6 files changed

Lines changed: 21 additions & 13 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/celestiaorg/nmt v0.17.0
99
github.com/celestiaorg/rsmt2d v0.9.0
1010
github.com/celestiaorg/utils v0.1.0
11-
github.com/cometbft/cometbft v0.37.1
11+
github.com/cometbft/cometbft v0.37.2
1212
github.com/creachadair/taskgroup v0.3.2
1313
github.com/dgraph-io/badger/v3 v3.2103.5
1414
github.com/go-kit/kit v0.12.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,8 @@ github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWH
237237
github.com/cncf/xds/go v0.0.0-20211130200136-a8f946100490/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
238238
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
239239
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
240-
github.com/cometbft/cometbft v0.37.1 h1:KLxkQTK2hICXYq21U2hn1W5hOVYUdQgDQ1uB+90xPIg=
241-
github.com/cometbft/cometbft v0.37.1/go.mod h1:Y2MMMN//O5K4YKd8ze4r9jmk4Y7h0ajqILXbH5JQFVs=
240+
github.com/cometbft/cometbft v0.37.2 h1:XB0yyHGT0lwmJlFmM4+rsRnczPlHoAKFX6K8Zgc2/Jc=
241+
github.com/cometbft/cometbft v0.37.2/go.mod h1:Y2MMMN//O5K4YKd8ze4r9jmk4Y7h0ajqILXbH5JQFVs=
242242
github.com/cometbft/cometbft-db v0.8.0 h1:vUMDaH3ApkX8m0KZvOFFy9b5DZHBAjsnEuo9AKVZpjo=
243243
github.com/cometbft/cometbft-db v0.8.0/go.mod h1:6ASCP4pfhmrCBpfk01/9E1SI29nD3HfVHrY4PG8x5c0=
244244
github.com/containerd/cgroups v0.0.0-20201119153540-4cbc285b3327/go.mod h1:ZJeTFisyysqgcCdecO57Dj79RfL0LNeGiFUqLYQRYLE=

state/indexer/block/kv/kv.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"errors"
66
"fmt"
7+
"math/big"
78
"sort"
89
"strconv"
910
"strings"
@@ -258,13 +259,13 @@ func (idx *BlockerIndexer) matchRange(
258259
continue
259260
}
260261

261-
if _, ok := qr.AnyBound().(int64); ok {
262+
if _, ok := qr.AnyBound().(*big.Int); ok {
262263
include := true
263-
if lowerBound != nil && v < lowerBound.(int64) {
264+
if lowerBound != nil && v < lowerBound.(*big.Int).Int64() {
264265
include = false
265266
}
266267

267-
if upperBound != nil && v > upperBound.(int64) {
268+
if upperBound != nil && v > upperBound.(*big.Int).Int64() {
268269
include = false
269270
}
270271

state/indexer/block/kv/util.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package kv
33
import (
44
"encoding/binary"
55
"fmt"
6+
"math/big"
67
"strconv"
78
"strings"
89

@@ -57,7 +58,7 @@ func parseValueFromEventKey(key string) string {
5758
func lookForHeight(conditions []query.Condition) (int64, bool) {
5859
for _, c := range conditions {
5960
if c.CompositeKey == types.BlockHeightKey && c.Op == query.OpEqual {
60-
return c.Operand.(int64), true
61+
return c.Operand.(*big.Int).Int64(), true
6162
}
6263
}
6364

state/indexer/query_range.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package indexer
22

33
import (
4+
"math/big"
45
"time"
56

67
"github.com/cometbft/cometbft/libs/pubsub/query"
@@ -43,7 +44,9 @@ func (qr QueryRange) LowerBoundValue() interface{} {
4344
switch t := qr.LowerBound.(type) {
4445
case int64:
4546
return t + 1
46-
47+
case *big.Int:
48+
tmp := new(big.Int)
49+
return tmp.Add(t, big.NewInt(1))
4750
case time.Time:
4851
return t.Unix() + 1
4952

@@ -66,7 +69,9 @@ func (qr QueryRange) UpperBoundValue() interface{} {
6669
switch t := qr.UpperBound.(type) {
6770
case int64:
6871
return t - 1
69-
72+
case *big.Int:
73+
tmp := new(big.Int)
74+
return tmp.Sub(t, big.NewInt(1))
7075
case time.Time:
7176
return t.Unix() - 1
7277

state/txindex/kv/kv.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"encoding/hex"
66
"fmt"
7+
"math/big"
78
"strconv"
89
"strings"
910

@@ -300,7 +301,7 @@ func lookForHash(conditions []query.Condition) (hash []byte, ok bool, err error)
300301
func lookForHeight(conditions []query.Condition) (height int64) {
301302
for _, c := range conditions {
302303
if c.CompositeKey == types.TxHeightKey && c.Op == query.OpEqual {
303-
return c.Operand.(int64)
304+
return c.Operand.(*big.Int).Int64()
304305
}
305306
}
306307
return 0
@@ -480,18 +481,18 @@ LOOP:
480481
continue
481482
}
482483

483-
if _, ok := qr.AnyBound().(int64); ok {
484+
if _, ok := qr.AnyBound().(*big.Int); ok {
484485
v, err := strconv.ParseInt(extractValueFromKey([]byte(result.Entry.Key)), 10, 64)
485486
if err != nil {
486487
continue LOOP
487488
}
488489

489490
include := true
490-
if lowerBound != nil && v < lowerBound.(int64) {
491+
if lowerBound != nil && v < lowerBound.(*big.Int).Int64() {
491492
include = false
492493
}
493494

494-
if upperBound != nil && v > upperBound.(int64) {
495+
if upperBound != nil && v > upperBound.(*big.Int).Int64() {
495496
include = false
496497
}
497498

0 commit comments

Comments
 (0)