Skip to content

Commit

Permalink
store/bigtable: fix range limits
Browse files Browse the repository at this point in the history
go mod
  • Loading branch information
Tangui-Bitfly committed Oct 30, 2024
1 parent 34ce72c commit 02926ed
Show file tree
Hide file tree
Showing 5 changed files with 164 additions and 138 deletions.
2 changes: 1 addition & 1 deletion db2/raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (db RawStore) parseRow(chainID uint64, number int64, data map[string][]byte
}

func (db RawStore) ReadBlocksByNumber(chainID uint64, start, end int64) ([]*FullBlockRawData, error) {
rows, err := db.store.GetRowsRange(blockKey(chainID, start-1), blockKey(chainID, end))
rows, err := db.store.GetRowsRange(blockKey(chainID, start), blockKey(chainID, end))
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion db2/store/bigtable.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func (b BigTableStore) GetRowsRange(table, high, low string) (map[string]map[str
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()

rowRange := bigtable.NewRange(low, high)
rowRange := bigtable.NewClosedRange(low, high)
data := make(map[string]map[string][]byte)
err := tbl.ReadRows(ctx, rowRange, func(row bigtable.Row) bool {
data[row.Key()] = make(map[string][]byte)
Expand Down
21 changes: 21 additions & 0 deletions db2/store/bigtable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,24 @@ func TestBigTableStore(t *testing.T) {
t.Errorf("cannot close db: %v", err)
}
}

func TestRangeIncludeLimits(t *testing.T) {
tables := map[string][]string{"testTable": {"testFamily"}}
client, admin := storetest.NewBigTable(t)
store, err := NewBigTableWithClient(context.Background(), client, admin, tables)
if err != nil {
t.Fatal(err)
}
db := Wrap(store, "testTable", "testFamily")

db.Add("1:999999999999", "", []byte("0"), false)
db.Add("1:999999999998", "", []byte("1"), false)

rows, err := db.GetRowsRange("1:999999999999", "1:999999999998")
if err != nil {
t.Fatal(err)
}
if got, want := len(rows), 2; got != want {
t.Errorf("got %v want %v", got, want)
}
}
86 changes: 45 additions & 41 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ go 1.21
toolchain go1.22.0

require (
cloud.google.com/go/bigtable v1.16.0
cloud.google.com/go/secretmanager v1.11.5
cloud.google.com/go/bigtable v1.33.0
cloud.google.com/go/secretmanager v1.14.0
firebase.google.com/go/v4 v4.14.1
github.com/Gurpartap/storekit-go v0.0.0-20201205024111-36b6cd5c6a21
github.com/alexedwards/scs/redisstore v0.0.0-20230217120314-6b1bedc0f08c
Expand Down Expand Up @@ -67,13 +67,13 @@ require (
github.com/wealdtech/go-eth2-types/v2 v2.8.1
github.com/wealdtech/go-eth2-util v1.8.1
github.com/zesik/proxyaddr v0.0.0-20161218060608-ec32c535184d
golang.org/x/crypto v0.21.0
golang.org/x/sync v0.6.0
golang.org/x/text v0.14.0
golang.org/x/time v0.5.0
google.golang.org/api v0.170.0
google.golang.org/grpc v1.62.1
google.golang.org/protobuf v1.33.0
golang.org/x/crypto v0.27.0
golang.org/x/sync v0.8.0
golang.org/x/text v0.18.0
golang.org/x/time v0.6.0
google.golang.org/api v0.197.0
google.golang.org/grpc v1.66.2
google.golang.org/protobuf v1.34.2
gopkg.in/yaml.v3 v3.0.1
)

Expand All @@ -84,11 +84,14 @@ require (
)

require (
cloud.google.com/go v0.112.1 // indirect
cloud.google.com/go/compute v1.24.0 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/iam v1.1.7 // indirect
cloud.google.com/go/longrunning v0.5.5 // indirect
cel.dev/expr v0.16.0 // indirect
cloud.google.com/go v0.115.1 // indirect
cloud.google.com/go/auth v0.9.3 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.4 // indirect
cloud.google.com/go/compute/metadata v0.5.0 // indirect
cloud.google.com/go/iam v1.2.1 // indirect
cloud.google.com/go/longrunning v0.6.1 // indirect
cloud.google.com/go/monitoring v1.21.1 // indirect
github.com/DataDog/zstd v1.5.2 // indirect
github.com/MicahParks/keyfunc v1.9.0 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
Expand All @@ -109,8 +112,7 @@ require (
github.com/bits-and-blooms/bitset v1.11.0 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/census-instrumentation/opencensus-proto v0.4.1 // indirect
github.com/cncf/udpa/go v0.0.0-20220112060539-c52dc94e7fbe // indirect
github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa // indirect
github.com/cncf/xds/go v0.0.0-20240822171458-6449f94b4d59 // indirect
github.com/cockroachdb/errors v1.9.1 // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 // indirect
Expand All @@ -124,22 +126,22 @@ require (
github.com/deckarep/golang-set/v2 v2.5.0 // indirect
github.com/dgraph-io/ristretto v0.1.1 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/envoyproxy/go-control-plane v0.12.0 // indirect
github.com/envoyproxy/protoc-gen-validate v1.0.4 // indirect
github.com/envoyproxy/go-control-plane v0.13.0 // indirect
github.com/envoyproxy/protoc-gen-validate v1.1.0 // indirect
github.com/ethereum/c-kzg-4844 v0.4.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect
github.com/getsentry/sentry-go v0.18.0 // indirect
github.com/glendc/go-external-ip v0.1.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/btree v1.1.2 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/google/btree v1.1.3 // indirect
github.com/google/s2a-go v0.1.8 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.4 // indirect
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
github.com/holiman/uint256 v1.2.4 // indirect
github.com/huandu/go-clone v1.6.0 // indirect
Expand Down Expand Up @@ -176,6 +178,7 @@ require (
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
github.com/polydawn/refmt v0.89.0 // indirect
github.com/protolambda/zssz v0.1.5 // indirect
github.com/prysmaticlabs/fastssz v0.0.0-20221107182844-78142813af44 // indirect
Expand All @@ -189,33 +192,35 @@ require (
github.com/whyrusleeping/cbor-gen v0.0.0-20230126041949-52956bd4c9aa // indirect
github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect
go.opentelemetry.io/otel v1.29.0 // indirect
go.opentelemetry.io/otel/metric v1.29.0 // indirect
go.opentelemetry.io/otel/sdk v1.29.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.29.0 // indirect
go.opentelemetry.io/otel/trace v1.29.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/mod v0.15.0 // indirect
golang.org/x/mod v0.17.0 // indirect
google.golang.org/appengine/v2 v2.0.2 // indirect
google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240314234333-6e1732d8331c // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240311132316-a219d84964c2 // indirect
google.golang.org/genproto v0.0.0-20240903143218-8af14fe29dc1 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
lukechampine.com/blake3 v1.2.1 // indirect
rsc.io/binaryregexp v0.2.0 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)

require (
cloud.google.com/go/firestore v1.15.0 // indirect
cloud.google.com/go/storage v1.40.0 // indirect
cloud.google.com/go/firestore v1.16.0 // indirect
cloud.google.com/go/storage v1.43.0 // indirect
github.com/BurntSushi/toml v1.2.1 // indirect
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/attestantio/go-eth2-client v0.19.9
github.com/beorn7/perks v1.0.1 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/coocood/freecache v1.2.3
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/fatih/color v1.16.0 // indirect
Expand All @@ -227,11 +232,11 @@ require (
github.com/go-openapi/spec v0.20.14 // indirect
github.com/go-openapi/swag v0.22.9 // indirect
github.com/goccy/go-yaml v1.10.0 // indirect
github.com/golang/glog v1.2.0 // indirect
github.com/golang/glog v1.2.1 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
github.com/google/uuid v1.6.0
github.com/googleapis/gax-go/v2 v2.12.3 // indirect
github.com/googleapis/gax-go/v2 v2.13.0 // indirect
github.com/gorilla/securecookie v1.1.1 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 // indirect
github.com/hashicorp/go-version v1.6.0
Expand Down Expand Up @@ -262,12 +267,11 @@ require (
github.com/tklauser/go-sysconf v0.3.13 // indirect
github.com/tklauser/numcpus v0.7.0 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/net v0.23.0
golang.org/x/oauth2 v0.18.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/tools v0.18.0 // indirect
golang.org/x/net v0.29.0
golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
google.golang.org/appengine v1.6.8 // indirect
gopkg.in/cenkalti/backoff.v1 v1.1.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
Loading

0 comments on commit 02926ed

Please sign in to comment.