Skip to content

Commit

Permalink
upgrade cometbft to 0.37.2 and fix int64 to *big.Int issues (cosmos#1123
Browse files Browse the repository at this point in the history
)

<!--
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>
  • Loading branch information
gupadhyaya and Ganesha Upadhyaya authored Aug 2, 2023
1 parent 509d0b1 commit 6e417e2
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/celestiaorg/nmt v0.17.0
github.com/celestiaorg/rsmt2d v0.9.0
github.com/celestiaorg/utils v0.1.0
github.com/cometbft/cometbft v0.37.1
github.com/cometbft/cometbft v0.37.2
github.com/creachadair/taskgroup v0.3.2
github.com/dgraph-io/badger/v3 v3.2103.5
github.com/go-kit/kit v0.12.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWH
github.com/cncf/xds/go v0.0.0-20211130200136-a8f946100490/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
github.com/cometbft/cometbft v0.37.1 h1:KLxkQTK2hICXYq21U2hn1W5hOVYUdQgDQ1uB+90xPIg=
github.com/cometbft/cometbft v0.37.1/go.mod h1:Y2MMMN//O5K4YKd8ze4r9jmk4Y7h0ajqILXbH5JQFVs=
github.com/cometbft/cometbft v0.37.2 h1:XB0yyHGT0lwmJlFmM4+rsRnczPlHoAKFX6K8Zgc2/Jc=
github.com/cometbft/cometbft v0.37.2/go.mod h1:Y2MMMN//O5K4YKd8ze4r9jmk4Y7h0ajqILXbH5JQFVs=
github.com/cometbft/cometbft-db v0.8.0 h1:vUMDaH3ApkX8m0KZvOFFy9b5DZHBAjsnEuo9AKVZpjo=
github.com/cometbft/cometbft-db v0.8.0/go.mod h1:6ASCP4pfhmrCBpfk01/9E1SI29nD3HfVHrY4PG8x5c0=
github.com/containerd/cgroups v0.0.0-20201119153540-4cbc285b3327/go.mod h1:ZJeTFisyysqgcCdecO57Dj79RfL0LNeGiFUqLYQRYLE=
Expand Down
7 changes: 4 additions & 3 deletions state/indexer/block/kv/kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"math/big"
"sort"
"strconv"
"strings"
Expand Down Expand Up @@ -258,13 +259,13 @@ func (idx *BlockerIndexer) matchRange(
continue
}

if _, ok := qr.AnyBound().(int64); ok {
if _, ok := qr.AnyBound().(*big.Int); ok {
include := true
if lowerBound != nil && v < lowerBound.(int64) {
if lowerBound != nil && v < lowerBound.(*big.Int).Int64() {
include = false
}

if upperBound != nil && v > upperBound.(int64) {
if upperBound != nil && v > upperBound.(*big.Int).Int64() {
include = false
}

Expand Down
3 changes: 2 additions & 1 deletion state/indexer/block/kv/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package kv
import (
"encoding/binary"
"fmt"
"math/big"
"strconv"
"strings"

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

Expand Down
9 changes: 7 additions & 2 deletions state/indexer/query_range.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package indexer

import (
"math/big"
"time"

"github.com/cometbft/cometbft/libs/pubsub/query"
Expand Down Expand Up @@ -43,7 +44,9 @@ func (qr QueryRange) LowerBoundValue() interface{} {
switch t := qr.LowerBound.(type) {
case int64:
return t + 1

case *big.Int:
tmp := new(big.Int)
return tmp.Add(t, big.NewInt(1))
case time.Time:
return t.Unix() + 1

Expand All @@ -66,7 +69,9 @@ func (qr QueryRange) UpperBoundValue() interface{} {
switch t := qr.UpperBound.(type) {
case int64:
return t - 1

case *big.Int:
tmp := new(big.Int)
return tmp.Sub(t, big.NewInt(1))
case time.Time:
return t.Unix() - 1

Expand Down
9 changes: 5 additions & 4 deletions state/txindex/kv/kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/hex"
"fmt"
"math/big"
"strconv"
"strings"

Expand Down Expand Up @@ -300,7 +301,7 @@ func lookForHash(conditions []query.Condition) (hash []byte, ok bool, err error)
func lookForHeight(conditions []query.Condition) (height int64) {
for _, c := range conditions {
if c.CompositeKey == types.TxHeightKey && c.Op == query.OpEqual {
return c.Operand.(int64)
return c.Operand.(*big.Int).Int64()
}
}
return 0
Expand Down Expand Up @@ -480,18 +481,18 @@ LOOP:
continue
}

if _, ok := qr.AnyBound().(int64); ok {
if _, ok := qr.AnyBound().(*big.Int); ok {
v, err := strconv.ParseInt(extractValueFromKey([]byte(result.Entry.Key)), 10, 64)
if err != nil {
continue LOOP
}

include := true
if lowerBound != nil && v < lowerBound.(int64) {
if lowerBound != nil && v < lowerBound.(*big.Int).Int64() {
include = false
}

if upperBound != nil && v > upperBound.(int64) {
if upperBound != nil && v > upperBound.(*big.Int).Int64() {
include = false
}

Expand Down

0 comments on commit 6e417e2

Please sign in to comment.