Skip to content

Commit de8f4c6

Browse files
authored
Merge branch 'main' into ma/key-rotation
2 parents bd91ed0 + ebb120a commit de8f4c6

70 files changed

Lines changed: 1967 additions & 887 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
4141
### Breaking Changes
4242

4343
* (modules) [#26421](https://github.com/cosmos/cosmos-sdk/pull/26421) Remove the `x/protocolpool` module and its API/proto surface from the SDK. Applications upgrading from v0.54 should include `protocolpool` in deleted store upgrades.
44+
* (genutils) [#26468](https://github.com/cosmos/cosmos-sdk/pull/26468) Consolidate ExportGenesisFileWithTime arguments to preserve consensus params.
4445

4546
### Features
4647

@@ -49,6 +50,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
4950
* (blockstm) [#25909](https://github.com/cosmos/cosmos-sdk/pull/25909) Cache pre-state to optimize value-based validation.
5051
* (deps) [#26388](https://github.com/cosmos/cosmos-sdk/pull/26388) Bump CometBFT version to v0.39.3.
5152
* (staking) [#26440](https://github.com/cosmos/cosmos-sdk/pull/26440) Add basic key rotation for validator consensus keys.
53+
* (crypto) [#26436](https://github.com/cosmos/cosmos-sdk/pull/26436) Add ML-DSA-65 (FIPS 204) post-quantum validator consensus key type, with SDK key wrappers, Amino + interface-registry registration, multisig support, and a `hd.MlDsa65Type` constant.
5254

5355
### Improvements
5456

@@ -173,6 +175,7 @@ This patch release contains only minor dependency bumps.
173175
* (x/group) [#25920](https://github.com/cosmos/cosmos-sdk/pull/25920) Expand voting period check to verify period is positive instead of nonzero.
174176
* (types/address) [#25944] (https://github.com/cosmos/cosmos-sdk/pull/25944) correct sort comparator in Compose to satisfy strict weak ordering.
175177
* (baseapp) [#26063](https://github.com/cosmos/cosmos-sdk/pull/26063) Fixes an issue where values embedded in context during ante handling were wiped after the handlers returned.
178+
* (collections/indexes) [#25942](https://github.com/cosmos/cosmos-sdk/pull/25942) handle iterator close errors in index helpers.
176179

177180
### Deprecated
178181

UPGRADING.md

Lines changed: 9 additions & 490 deletions
Large diffs are not rendered by default.

client/v2/go.mod

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ require (
1414
github.com/spf13/cobra v1.10.2
1515
github.com/spf13/pflag v1.0.10
1616
github.com/stretchr/testify v1.11.1
17-
google.golang.org/grpc v1.80.0
17+
google.golang.org/grpc v1.81.1
1818
google.golang.org/protobuf v1.36.11
1919
gotest.tools/v3 v3.5.2
2020
sigs.k8s.io/yaml v1.6.0
@@ -32,7 +32,7 @@ require (
3232
github.com/99designs/keyring v1.2.2 // indirect
3333
github.com/DataDog/datadog-go v3.2.0+incompatible // indirect
3434
github.com/DataDog/zstd v1.5.7 // indirect
35-
github.com/RoaringBitmap/roaring/v2 v2.18.0 // indirect
35+
github.com/RoaringBitmap/roaring/v2 v2.18.2 // indirect
3636
github.com/benbjohnson/clock v1.3.5 // indirect
3737
github.com/beorn7/perks v1.0.1 // indirect
3838
github.com/bgentry/speakeasy v0.2.0 // indirect
@@ -44,6 +44,7 @@ require (
4444
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
4545
github.com/cespare/xxhash/v2 v2.3.0 // indirect
4646
github.com/chzyer/readline v1.5.1 // indirect
47+
github.com/cloudflare/circl v1.6.3 // indirect
4748
github.com/cloudwego/base64x v0.1.7 // indirect
4849
github.com/cockroachdb/fifo v0.0.0-20240816210425-c5d0cb0b6fc0 // indirect
4950
github.com/cockroachdb/logtags v0.0.0-20241215232642-bb51bb14a506 // indirect
@@ -253,7 +254,7 @@ require (
253254
go.yaml.in/yaml/v2 v2.4.4 // indirect
254255
go.yaml.in/yaml/v3 v3.0.4 // indirect
255256
golang.org/x/arch v0.26.0 // indirect
256-
golang.org/x/crypto v0.51.0 // indirect
257+
golang.org/x/crypto v0.52.0 // indirect
257258
golang.org/x/exp v0.0.0-20260508232706-74f9aab9d74a // indirect
258259
golang.org/x/mod v0.36.0 // indirect
259260
golang.org/x/net v0.55.0 // indirect
@@ -274,3 +275,5 @@ require (
274275
)
275276

276277
replace github.com/cosmos/cosmos-sdk => ../..
278+
279+
replace github.com/cometbft/cometbft => github.com/cometbft/cometbft v0.39.0-rc1.0.20260527154549-606b4197148f

client/v2/go.sum

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERo
4040
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
4141
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw=
4242
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk=
43-
github.com/RoaringBitmap/roaring/v2 v2.18.0 h1:h7sS0VqCkfBMGgcHaudJFB4FE6Td71H6svRB2poRnGY=
44-
github.com/RoaringBitmap/roaring/v2 v2.18.0/go.mod h1:eq4wdNXxtJIS/oikeCzdX1rBzek7ANzbth041hrU8Q4=
43+
github.com/RoaringBitmap/roaring/v2 v2.18.2 h1:oPq3Cgx//iDuJQVp6xSInAKW34J9CEwE5GmLI2z+Eic=
44+
github.com/RoaringBitmap/roaring/v2 v2.18.2/go.mod h1:eq4wdNXxtJIS/oikeCzdX1rBzek7ANzbth041hrU8Q4=
4545
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
4646
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
4747
github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE=
@@ -79,8 +79,8 @@ github.com/bits-and-blooms/bitset v1.24.4 h1:95H15Og1clikBrKr/DuzMXkQzECs1M6hhoG
7979
github.com/bits-and-blooms/bitset v1.24.4/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
8080
github.com/btcsuite/btcd/btcec/v2 v2.3.6 h1:IzlsEr9olcSRKB/n7c4351F3xHKxS2lma+1UFGCYd4E=
8181
github.com/btcsuite/btcd/btcec/v2 v2.3.6/go.mod h1:m22FrOAiuxl/tht9wIqAoGHcbnCCaPWyauO8y2LGGtQ=
82-
github.com/btcsuite/btcd/btcutil v1.1.6 h1:zFL2+c3Lb9gEgqKNzowKUPQNb8jV7v5Oaodi/AYFd6c=
83-
github.com/btcsuite/btcd/btcutil v1.1.6/go.mod h1:9dFymx8HpuLqBnsPELrImQeTQfKBQqzqGbbV3jK55aE=
82+
github.com/btcsuite/btcd/btcutil v1.2.0 h1:p3+S2g3Q+7G5NOh4Ji+2UrBOrg5Z0Q4ykzShWG1Dhgs=
83+
github.com/btcsuite/btcd/btcutil v1.2.0/go.mod h1:/Taflm113pYjUpbWKKQEfa6XOtI/+WS8awxeMZpY75k=
8484
github.com/bytedance/gopkg v0.1.4 h1:oZnQwnX82KAIWb7033bEwtxvTqXcYMxDBaQxo5JJHWM=
8585
github.com/bytedance/gopkg v0.1.4/go.mod h1:v1zWfPm21Fb+OsyXN2VAHdL6TBb2L88anLQgdyje6R4=
8686
github.com/bytedance/sonic v1.15.1 h1:nJD5PmM0vY7J8CT6MxoqbVAAMhkSmV2HgRAUrrpLoOw=
@@ -114,6 +114,8 @@ github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6D
114114
github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I=
115115
github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE=
116116
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
117+
github.com/cloudflare/circl v1.6.3 h1:9GPOhQGF9MCYUeXyMYlqTR6a5gTrgR/fBLXvUgtVcg8=
118+
github.com/cloudflare/circl v1.6.3/go.mod h1:2eXP6Qfat4O/Yhh8BznvKnJ+uzEoTQ6jVKJRn81BiS4=
117119
github.com/cloudwego/base64x v0.1.7 h1:NppS+Fgzg5ovhn4NkUXaDT3x9jldgH5ToMCqzBSi2zI=
118120
github.com/cloudwego/base64x v0.1.7/go.mod h1:Cu1PV9zfrSf7ET2tIbWbbEy7jO7HHJ13q4X2SQ8aWYg=
119121
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
@@ -139,8 +141,8 @@ github.com/cockroachdb/redact v1.1.8/go.mod h1:GceHHpJ0rMDpYARL5In88Alq/xMBUtVlz
139141
github.com/cockroachdb/tokenbucket v0.0.0-20250429170803-42689b6311bb h1:3bCgBvB8PbJVMX1ouCcSIxvsqKPYM7gs72o0zC76n9g=
140142
github.com/cockroachdb/tokenbucket v0.0.0-20250429170803-42689b6311bb/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ=
141143
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
142-
github.com/cometbft/cometbft v0.39.3 h1:UegHXskZNomsijmm29nL5NkeXtnzkme6fg+q1hPQnEI=
143-
github.com/cometbft/cometbft v0.39.3/go.mod h1:PmNfvtw256BC41ad0FABts236CSZnvZ0kjPOciBwTdM=
144+
github.com/cometbft/cometbft v0.39.0-rc1.0.20260527154549-606b4197148f h1:1nLgMzeZtU58lSnohMEm/0nzavXTwaG6d4COWjMnke4=
145+
github.com/cometbft/cometbft v0.39.0-rc1.0.20260527154549-606b4197148f/go.mod h1:zWeUVU3xsmqCich61XL4yyh2s6AmuR3FWK7Y/hgWNz8=
144146
github.com/cometbft/cometbft-db v0.14.3 h1:foX2zuH/L6feyUSLDWg9YRLvt9w8iWVo883wGcyhdQk=
145147
github.com/cometbft/cometbft-db v0.14.3/go.mod h1:5CcpGc+0fgZh8ecKa38MwDHfmRAGiRgQg6bGNs1HA/g=
146148
github.com/containerd/continuity v0.4.5 h1:ZRoN1sXq9u7V6QoHMcVWGhOwDFqZ4B9i5H6un1Wh0x4=
@@ -972,8 +974,8 @@ golang.org/x/crypto v0.0.0-20200602180216-279210d13fed/go.mod h1:LzIPMQfyMNhhGPh
972974
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
973975
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
974976
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
975-
golang.org/x/crypto v0.51.0 h1:IBPXwPfKxY7cWQZ38ZCIRPI50YLeevDLlLnyC5wRGTI=
976-
golang.org/x/crypto v0.51.0/go.mod h1:8AdwkbraGNABw2kOX6YFPs3WM22XqI4EXEd8g+x7Oc8=
977+
golang.org/x/crypto v0.52.0 h1:RMs7fP2rXdep0CftQlK8Uf+kibLm7qkCcradZWYz988=
978+
golang.org/x/crypto v0.52.0/go.mod h1:1QgfPxDqh0T2M/elOJtp9RvuR95kVjir0e6/BvEmGbc=
977979
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
978980
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
979981
golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw=
@@ -1183,8 +1185,8 @@ google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTp
11831185
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
11841186
google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ=
11851187
google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI=
1186-
google.golang.org/grpc v1.80.0 h1:Xr6m2WmWZLETvUNvIUmeD5OAagMw3FiKmMlTdViWsHM=
1187-
google.golang.org/grpc v1.80.0/go.mod h1:ho/dLnxwi3EDJA4Zghp7k2Ec1+c2jqup0bFkw07bwF4=
1188+
google.golang.org/grpc v1.81.1 h1:VnnIIZ88UzOOKLukQi+ImGz8O1Wdp8nAGGnvOfEIWQQ=
1189+
google.golang.org/grpc v1.81.1/go.mod h1:xGH9GfzOyMTGIOXBJmXt+BX/V0kcdQbdcuwQ/zNw42I=
11881190
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
11891191
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
11901192
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=

collections/indexes/helpers.go

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,23 @@ func ScanKeyValues[K, V any, I iterator[K], Idx collections.Indexes[K, V]](
4242
iter I,
4343
do func(kv collections.KeyValue[K, V]) (stop bool),
4444
) (err error) {
45-
defer iter.Close()
45+
defer func() {
46+
if cerr := iter.Close(); cerr != nil && err == nil {
47+
err = cerr
48+
}
49+
}()
4650

51+
var (
52+
pk K
53+
value V
54+
)
4755
for ; iter.Valid(); iter.Next() {
48-
pk, err := iter.PrimaryKey()
56+
pk, err = iter.PrimaryKey()
4957
if err != nil {
5058
return err
5159
}
5260

53-
value, err := indexedMap.Get(ctx, pk)
61+
value, err = indexedMap.Get(ctx, pk)
5462
if err != nil {
5563
return err
5664
}
@@ -89,22 +97,29 @@ func ScanValues[K, V any, I iterator[K], Idx collections.Indexes[K, V]](
8997
indexedMap *collections.IndexedMap[K, V, Idx],
9098
iter I,
9199
f func(value V) (stop bool),
92-
) error {
93-
defer iter.Close()
100+
) (err error) {
101+
defer func() {
102+
if cerr := iter.Close(); cerr != nil && err == nil {
103+
err = cerr
104+
}
105+
}()
94106

107+
var (
108+
key K
109+
value V
110+
)
95111
for ; iter.Valid(); iter.Next() {
96-
key, err := iter.PrimaryKey()
112+
key, err = iter.PrimaryKey()
97113
if err != nil {
98114
return err
99115
}
100116

101-
value, err := indexedMap.Get(ctx, key)
117+
value, err = indexedMap.Get(ctx, key)
102118
if err != nil {
103119
return err
104120
}
105121

106-
stop := f(value)
107-
if stop {
122+
if f(value) {
108123
return nil
109124
}
110125
}

collections/indexes/helpers_test.go

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

33
import (
4+
"errors"
45
"testing"
56

67
"github.com/stretchr/testify/require"
@@ -87,3 +88,39 @@ func TestHelpers(t *testing.T) {
8788
})
8889
require.NoError(t, err)
8990
}
91+
92+
func TestCloseError(t *testing.T) {
93+
sk, ctx := deps()
94+
sb := collections.NewSchemaBuilder(sk)
95+
keyCodec := collections.PairKeyCodec(collections.StringKey, collections.StringKey)
96+
indexedMap := collections.NewIndexedMap(
97+
sb,
98+
collections.NewPrefix("balances"), "balances",
99+
keyCodec,
100+
collections.Uint64Value,
101+
balanceIndex{
102+
Denom: NewReversePair[Amount](sb, collections.NewPrefix("denom_index"), "denom_index", keyCodec),
103+
},
104+
)
105+
106+
closeErr := errors.New("close error")
107+
newMock := func() *mockEmptyIter { return &mockEmptyIter{closeErr: closeErr} }
108+
109+
err := ScanValues(ctx, indexedMap, newMock(), func(Amount) bool { return false })
110+
require.ErrorIs(t, err, closeErr)
111+
112+
err = ScanKeyValues(ctx, indexedMap, newMock(), func(collections.KeyValue[collections.Pair[Address, Denom], Amount]) bool { return false })
113+
require.ErrorIs(t, err, closeErr)
114+
}
115+
116+
// mockEmptyIter is an empty iterator whose Close returns an error.
117+
type mockEmptyIter struct {
118+
closeErr error
119+
}
120+
121+
func (m *mockEmptyIter) PrimaryKey() (collections.Pair[string, string], error) {
122+
return collections.Join("", ""), nil
123+
}
124+
func (m *mockEmptyIter) Next() {}
125+
func (m *mockEmptyIter) Valid() bool { return false }
126+
func (m *mockEmptyIter) Close() error { return m.closeErr }

collections/indexes/reverse_pair.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,19 @@ func (m ReversePairIterator[K2, K1]) PrimaryKey() (pair collections.Pair[K1, K2]
142142

143143
// PrimaryKeys returns all the primary keys contained in the iterator.
144144
func (m ReversePairIterator[K2, K1]) PrimaryKeys() (pairs []collections.Pair[K1, K2], err error) {
145-
defer m.Close()
145+
defer func() {
146+
if cerr := m.Close(); cerr != nil && err == nil {
147+
err = cerr
148+
}
149+
}()
146150
for ; m.Valid(); m.Next() {
147151
pair, err := m.PrimaryKey()
148152
if err != nil {
149153
return nil, err
150154
}
151155
pairs = append(pairs, pair)
152156
}
153-
return pairs, err
157+
return pairs, nil
154158
}
155159

156160
func (m ReversePairIterator[K2, K1]) FullKey() (p collections.Pair[K2, K1], err error) {

collections/indexes/reverse_pair_test.go

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package indexes
22

33
import (
4+
"context"
5+
"errors"
46
"testing"
57

68
"github.com/stretchr/testify/require"
79

810
"cosmossdk.io/collections"
11+
store "cosmossdk.io/collections/corecompat"
912
)
1013

1114
type (
@@ -72,6 +75,74 @@ func TestReversePair(t *testing.T) {
7275
require.Empty(t, pks)
7376
}
7477

78+
func TestReversePairIteratorPrimaryKeysCloseError(t *testing.T) {
79+
closeErr := errors.New("close error")
80+
sk, ctx := deps()
81+
82+
sb := collections.NewSchemaBuilder(sk)
83+
keyCodec := collections.PairKeyCodec(collections.StringKey, collections.StringKey)
84+
idxMap := collections.NewIndexedMap(
85+
sb, collections.NewPrefix("balances"), "balances",
86+
keyCodec, collections.Uint64Value,
87+
balanceIndex{Denom: NewReversePair[Amount](sb, collections.NewPrefix("denom_index"), "denom_index", keyCodec)},
88+
)
89+
_, err := sb.Build()
90+
require.NoError(t, err)
91+
require.NoError(t, idxMap.Set(ctx, collections.Join("address1", "osmo"), 100))
92+
93+
errSk := closeErrKVStoreService{KVStoreService: sk, closeErr: closeErr}
94+
sb2 := collections.NewSchemaBuilder(errSk)
95+
idxMap2 := collections.NewIndexedMap(
96+
sb2, collections.NewPrefix("balances"), "balances",
97+
keyCodec, collections.Uint64Value,
98+
balanceIndex{Denom: NewReversePair[Amount](sb2, collections.NewPrefix("denom_index"), "denom_index", keyCodec)},
99+
)
100+
_, err = sb2.Build()
101+
require.NoError(t, err)
102+
103+
iter, err := idxMap2.Indexes.Denom.MatchExact(ctx, "osmo")
104+
require.NoError(t, err)
105+
_, err = iter.PrimaryKeys()
106+
require.ErrorIs(t, err, closeErr)
107+
}
108+
109+
type closeErrKVStoreService struct {
110+
store.KVStoreService
111+
closeErr error
112+
}
113+
114+
func (s closeErrKVStoreService) OpenKVStore(ctx context.Context) store.KVStore {
115+
return closeErrKVStore{KVStore: s.KVStoreService.OpenKVStore(ctx), closeErr: s.closeErr}
116+
}
117+
118+
type closeErrKVStore struct {
119+
store.KVStore
120+
closeErr error
121+
}
122+
123+
func (s closeErrKVStore) Iterator(start, end []byte) (store.Iterator, error) {
124+
iter, err := s.KVStore.Iterator(start, end)
125+
if err != nil {
126+
return nil, err
127+
}
128+
return closeErrIter{Iterator: iter, closeErr: s.closeErr}, nil
129+
}
130+
131+
func (s closeErrKVStore) ReverseIterator(start, end []byte) (store.Iterator, error) {
132+
iter, err := s.KVStore.ReverseIterator(start, end)
133+
if err != nil {
134+
return nil, err
135+
}
136+
return closeErrIter{Iterator: iter, closeErr: s.closeErr}, nil
137+
}
138+
139+
type closeErrIter struct {
140+
store.Iterator
141+
closeErr error
142+
}
143+
144+
func (i closeErrIter) Close() error { return i.closeErr }
145+
75146
func TestUncheckedReversePair(t *testing.T) {
76147
sk, ctx := deps()
77148
sb := collections.NewSchemaBuilder(sk)

0 commit comments

Comments
 (0)