Skip to content

Commit 02926ed

Browse files
committed
store/bigtable: fix range limits
go mod
1 parent 34ce72c commit 02926ed

File tree

5 files changed

+164
-138
lines changed

5 files changed

+164
-138
lines changed

db2/raw.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func (db RawStore) parseRow(chainID uint64, number int64, data map[string][]byte
131131
}
132132

133133
func (db RawStore) ReadBlocksByNumber(chainID uint64, start, end int64) ([]*FullBlockRawData, error) {
134-
rows, err := db.store.GetRowsRange(blockKey(chainID, start-1), blockKey(chainID, end))
134+
rows, err := db.store.GetRowsRange(blockKey(chainID, start), blockKey(chainID, end))
135135
if err != nil {
136136
return nil, err
137137
}

db2/store/bigtable.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ func (b BigTableStore) GetRowsRange(table, high, low string) (map[string]map[str
263263
ctx, cancel := context.WithTimeout(context.Background(), timeout)
264264
defer cancel()
265265

266-
rowRange := bigtable.NewRange(low, high)
266+
rowRange := bigtable.NewClosedRange(low, high)
267267
data := make(map[string]map[string][]byte)
268268
err := tbl.ReadRows(ctx, rowRange, func(row bigtable.Row) bool {
269269
data[row.Key()] = make(map[string][]byte)

db2/store/bigtable_test.go

+21
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,24 @@ func TestBigTableStore(t *testing.T) {
169169
t.Errorf("cannot close db: %v", err)
170170
}
171171
}
172+
173+
func TestRangeIncludeLimits(t *testing.T) {
174+
tables := map[string][]string{"testTable": {"testFamily"}}
175+
client, admin := storetest.NewBigTable(t)
176+
store, err := NewBigTableWithClient(context.Background(), client, admin, tables)
177+
if err != nil {
178+
t.Fatal(err)
179+
}
180+
db := Wrap(store, "testTable", "testFamily")
181+
182+
db.Add("1:999999999999", "", []byte("0"), false)
183+
db.Add("1:999999999998", "", []byte("1"), false)
184+
185+
rows, err := db.GetRowsRange("1:999999999999", "1:999999999998")
186+
if err != nil {
187+
t.Fatal(err)
188+
}
189+
if got, want := len(rows), 2; got != want {
190+
t.Errorf("got %v want %v", got, want)
191+
}
192+
}

go.mod

+45-41
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ go 1.21
55
toolchain go1.22.0
66

77
require (
8-
cloud.google.com/go/bigtable v1.16.0
9-
cloud.google.com/go/secretmanager v1.11.5
8+
cloud.google.com/go/bigtable v1.33.0
9+
cloud.google.com/go/secretmanager v1.14.0
1010
firebase.google.com/go/v4 v4.14.1
1111
github.com/Gurpartap/storekit-go v0.0.0-20201205024111-36b6cd5c6a21
1212
github.com/alexedwards/scs/redisstore v0.0.0-20230217120314-6b1bedc0f08c
@@ -67,13 +67,13 @@ require (
6767
github.com/wealdtech/go-eth2-types/v2 v2.8.1
6868
github.com/wealdtech/go-eth2-util v1.8.1
6969
github.com/zesik/proxyaddr v0.0.0-20161218060608-ec32c535184d
70-
golang.org/x/crypto v0.21.0
71-
golang.org/x/sync v0.6.0
72-
golang.org/x/text v0.14.0
73-
golang.org/x/time v0.5.0
74-
google.golang.org/api v0.170.0
75-
google.golang.org/grpc v1.62.1
76-
google.golang.org/protobuf v1.33.0
70+
golang.org/x/crypto v0.27.0
71+
golang.org/x/sync v0.8.0
72+
golang.org/x/text v0.18.0
73+
golang.org/x/time v0.6.0
74+
google.golang.org/api v0.197.0
75+
google.golang.org/grpc v1.66.2
76+
google.golang.org/protobuf v1.34.2
7777
gopkg.in/yaml.v3 v3.0.1
7878
)
7979

@@ -84,11 +84,14 @@ require (
8484
)
8585

8686
require (
87-
cloud.google.com/go v0.112.1 // indirect
88-
cloud.google.com/go/compute v1.24.0 // indirect
89-
cloud.google.com/go/compute/metadata v0.2.3 // indirect
90-
cloud.google.com/go/iam v1.1.7 // indirect
91-
cloud.google.com/go/longrunning v0.5.5 // indirect
87+
cel.dev/expr v0.16.0 // indirect
88+
cloud.google.com/go v0.115.1 // indirect
89+
cloud.google.com/go/auth v0.9.3 // indirect
90+
cloud.google.com/go/auth/oauth2adapt v0.2.4 // indirect
91+
cloud.google.com/go/compute/metadata v0.5.0 // indirect
92+
cloud.google.com/go/iam v1.2.1 // indirect
93+
cloud.google.com/go/longrunning v0.6.1 // indirect
94+
cloud.google.com/go/monitoring v1.21.1 // indirect
9295
github.com/DataDog/zstd v1.5.2 // indirect
9396
github.com/MicahParks/keyfunc v1.9.0 // indirect
9497
github.com/Microsoft/go-winio v0.6.1 // indirect
@@ -109,8 +112,7 @@ require (
109112
github.com/bits-and-blooms/bitset v1.11.0 // indirect
110113
github.com/blang/semver/v4 v4.0.0 // indirect
111114
github.com/census-instrumentation/opencensus-proto v0.4.1 // indirect
112-
github.com/cncf/udpa/go v0.0.0-20220112060539-c52dc94e7fbe // indirect
113-
github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa // indirect
115+
github.com/cncf/xds/go v0.0.0-20240822171458-6449f94b4d59 // indirect
114116
github.com/cockroachdb/errors v1.9.1 // indirect
115117
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
116118
github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 // indirect
@@ -124,22 +126,22 @@ require (
124126
github.com/deckarep/golang-set/v2 v2.5.0 // indirect
125127
github.com/dgraph-io/ristretto v0.1.1 // indirect
126128
github.com/dustin/go-humanize v1.0.1 // indirect
127-
github.com/envoyproxy/go-control-plane v0.12.0 // indirect
128-
github.com/envoyproxy/protoc-gen-validate v1.0.4 // indirect
129+
github.com/envoyproxy/go-control-plane v0.13.0 // indirect
130+
github.com/envoyproxy/protoc-gen-validate v1.1.0 // indirect
129131
github.com/ethereum/c-kzg-4844 v0.4.0 // indirect
130132
github.com/felixge/httpsnoop v1.0.4 // indirect
131133
github.com/fsnotify/fsnotify v1.6.0 // indirect
132134
github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect
133135
github.com/getsentry/sentry-go v0.18.0 // indirect
134136
github.com/glendc/go-external-ip v0.1.0 // indirect
135-
github.com/go-logr/logr v1.4.1 // indirect
137+
github.com/go-logr/logr v1.4.2 // indirect
136138
github.com/go-logr/stdr v1.2.2 // indirect
137139
github.com/goccy/go-json v0.10.2 // indirect
138140
github.com/gofrs/flock v0.8.1 // indirect
139141
github.com/gogo/protobuf v1.3.2 // indirect
140-
github.com/google/btree v1.1.2 // indirect
141-
github.com/google/s2a-go v0.1.7 // indirect
142-
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
142+
github.com/google/btree v1.1.3 // indirect
143+
github.com/google/s2a-go v0.1.8 // indirect
144+
github.com/googleapis/enterprise-certificate-proxy v0.3.4 // indirect
143145
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
144146
github.com/holiman/uint256 v1.2.4 // indirect
145147
github.com/huandu/go-clone v1.6.0 // indirect
@@ -176,6 +178,7 @@ require (
176178
github.com/olekukonko/tablewriter v0.0.5 // indirect
177179
github.com/opentracing/opentracing-go v1.2.0 // indirect
178180
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
181+
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
179182
github.com/polydawn/refmt v0.89.0 // indirect
180183
github.com/protolambda/zssz v0.1.5 // indirect
181184
github.com/prysmaticlabs/fastssz v0.0.0-20221107182844-78142813af44 // indirect
@@ -189,33 +192,35 @@ require (
189192
github.com/whyrusleeping/cbor-gen v0.0.0-20230126041949-52956bd4c9aa // indirect
190193
github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f // indirect
191194
github.com/yusufpapurcu/wmi v1.2.3 // indirect
192-
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect
193-
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
194-
go.opentelemetry.io/otel v1.24.0 // indirect
195-
go.opentelemetry.io/otel/metric v1.24.0 // indirect
196-
go.opentelemetry.io/otel/trace v1.24.0 // indirect
195+
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0 // indirect
196+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect
197+
go.opentelemetry.io/otel v1.29.0 // indirect
198+
go.opentelemetry.io/otel/metric v1.29.0 // indirect
199+
go.opentelemetry.io/otel/sdk v1.29.0 // indirect
200+
go.opentelemetry.io/otel/sdk/metric v1.29.0 // indirect
201+
go.opentelemetry.io/otel/trace v1.29.0 // indirect
197202
go.uber.org/atomic v1.10.0 // indirect
198203
go.uber.org/multierr v1.11.0 // indirect
199204
go.uber.org/zap v1.27.0 // indirect
200-
golang.org/x/mod v0.15.0 // indirect
205+
golang.org/x/mod v0.17.0 // indirect
201206
google.golang.org/appengine/v2 v2.0.2 // indirect
202-
google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect
203-
google.golang.org/genproto/googleapis/api v0.0.0-20240314234333-6e1732d8331c // indirect
204-
google.golang.org/genproto/googleapis/rpc v0.0.0-20240311132316-a219d84964c2 // indirect
207+
google.golang.org/genproto v0.0.0-20240903143218-8af14fe29dc1 // indirect
208+
google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect
209+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
205210
lukechampine.com/blake3 v1.2.1 // indirect
206211
rsc.io/binaryregexp v0.2.0 // indirect
207212
rsc.io/tmplfunc v0.0.3 // indirect
208213
)
209214

210215
require (
211-
cloud.google.com/go/firestore v1.15.0 // indirect
212-
cloud.google.com/go/storage v1.40.0 // indirect
216+
cloud.google.com/go/firestore v1.16.0 // indirect
217+
cloud.google.com/go/storage v1.43.0 // indirect
213218
github.com/BurntSushi/toml v1.2.1 // indirect
214219
github.com/KyleBanks/depth v1.2.1 // indirect
215220
github.com/attestantio/go-eth2-client v0.19.9
216221
github.com/beorn7/perks v1.0.1 // indirect
217222
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
218-
github.com/cespare/xxhash/v2 v2.2.0 // indirect
223+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
219224
github.com/coocood/freecache v1.2.3
220225
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
221226
github.com/fatih/color v1.16.0 // indirect
@@ -227,11 +232,11 @@ require (
227232
github.com/go-openapi/spec v0.20.14 // indirect
228233
github.com/go-openapi/swag v0.22.9 // indirect
229234
github.com/goccy/go-yaml v1.10.0 // indirect
230-
github.com/golang/glog v1.2.0 // indirect
235+
github.com/golang/glog v1.2.1 // indirect
231236
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
232237
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
233238
github.com/google/uuid v1.6.0
234-
github.com/googleapis/gax-go/v2 v2.12.3 // indirect
239+
github.com/googleapis/gax-go/v2 v2.13.0 // indirect
235240
github.com/gorilla/securecookie v1.1.1 // indirect
236241
github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 // indirect
237242
github.com/hashicorp/go-version v1.6.0
@@ -262,12 +267,11 @@ require (
262267
github.com/tklauser/go-sysconf v0.3.13 // indirect
263268
github.com/tklauser/numcpus v0.7.0 // indirect
264269
go.opencensus.io v0.24.0 // indirect
265-
golang.org/x/net v0.23.0
266-
golang.org/x/oauth2 v0.18.0 // indirect
267-
golang.org/x/sys v0.18.0 // indirect
268-
golang.org/x/tools v0.18.0 // indirect
270+
golang.org/x/net v0.29.0
271+
golang.org/x/oauth2 v0.23.0 // indirect
272+
golang.org/x/sys v0.25.0 // indirect
273+
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
269274
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
270-
google.golang.org/appengine v1.6.8 // indirect
271275
gopkg.in/cenkalti/backoff.v1 v1.1.0 // indirect
272276
gopkg.in/ini.v1 v1.67.0 // indirect
273277
gopkg.in/yaml.v2 v2.4.0 // indirect

0 commit comments

Comments
 (0)