@agoric/cosmos 0.35.0-upgrade-14-dev-c8f9e7b.0 → 0.35.0-upgrade-16a-dev-fb592e4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/CHANGELOG.md +121 -77
  2. package/MAINTAINERS.md +3 -0
  3. package/Makefile +36 -26
  4. package/ante/ante.go +7 -9
  5. package/ante/inbound_test.go +3 -2
  6. package/ante/vm_admission.go +2 -1
  7. package/app/app.go +212 -140
  8. package/app/upgrade.go +76 -0
  9. package/cmd/agd/agvm.go +42 -0
  10. package/cmd/agd/main.go +130 -11
  11. package/cmd/libdaemon/main.go +64 -53
  12. package/cmd/libdaemon/main_test.go +2 -1
  13. package/daemon/cmd/root.go +171 -74
  14. package/daemon/cmd/root_test.go +189 -1
  15. package/daemon/main.go +4 -2
  16. package/e2e_test/Makefile +29 -0
  17. package/e2e_test/README.md +100 -0
  18. package/e2e_test/go.mod +217 -0
  19. package/e2e_test/go.sum +1323 -0
  20. package/e2e_test/ibc_conformance_test.go +56 -0
  21. package/e2e_test/pfm_test.go +613 -0
  22. package/e2e_test/util.go +271 -0
  23. package/git-revision.txt +1 -1
  24. package/go.mod +22 -11
  25. package/go.sum +17 -13
  26. package/package.json +9 -5
  27. package/proto/agoric/swingset/genesis.proto +4 -0
  28. package/proto/agoric/swingset/swingset.proto +1 -1
  29. package/proto/agoric/vlocalchain/.clang-format +7 -0
  30. package/proto/agoric/vlocalchain/vlocalchain.proto +31 -0
  31. package/proto/agoric/vtransfer/genesis.proto +18 -0
  32. package/scripts/protocgen.sh +7 -8
  33. package/types/kv_entry_helpers.go +42 -0
  34. package/upgradegaia.sh +8 -8
  35. package/vm/action.go +5 -4
  36. package/vm/action_test.go +31 -11
  37. package/vm/client.go +113 -0
  38. package/vm/client_test.go +182 -0
  39. package/vm/controller.go +17 -40
  40. package/vm/core_proposals.go +22 -2
  41. package/vm/jsonrpcconn/jsonrpcconn.go +160 -0
  42. package/vm/jsonrpcconn/jsonrpcconn_test.go +126 -0
  43. package/vm/proto_json.go +38 -0
  44. package/vm/proto_json_test.go +103 -0
  45. package/vm/server.go +124 -0
  46. package/x/swingset/abci.go +10 -10
  47. package/x/swingset/alias.go +2 -0
  48. package/x/swingset/client/cli/tx.go +4 -0
  49. package/x/swingset/genesis.go +84 -24
  50. package/x/swingset/handler.go +2 -1
  51. package/x/swingset/keeper/extension_snapshotter.go +2 -2
  52. package/x/swingset/keeper/keeper.go +13 -25
  53. package/x/swingset/keeper/msg_server.go +18 -18
  54. package/x/swingset/keeper/proposal.go +3 -3
  55. package/x/swingset/keeper/querier.go +12 -11
  56. package/x/swingset/keeper/swing_store_exports_handler.go +21 -6
  57. package/x/swingset/keeper/test_utils.go +16 -0
  58. package/x/swingset/module.go +7 -7
  59. package/x/swingset/proposal_handler.go +2 -1
  60. package/x/swingset/testing/queue.go +17 -0
  61. package/x/swingset/types/default-params.go +1 -1
  62. package/x/swingset/types/expected_keepers.go +3 -2
  63. package/x/swingset/types/genesis.pb.go +78 -25
  64. package/x/swingset/types/msgs.go +44 -24
  65. package/x/swingset/types/params.go +2 -1
  66. package/x/swingset/types/proposal.go +5 -4
  67. package/x/swingset/types/swingset.pb.go +1 -1
  68. package/x/vbank/genesis.go +0 -2
  69. package/x/vbank/handler.go +2 -1
  70. package/x/vbank/keeper/querier.go +4 -3
  71. package/x/vbank/module.go +0 -5
  72. package/x/vbank/types/msgs.go +0 -12
  73. package/x/vbank/vbank.go +9 -9
  74. package/x/vbank/vbank_test.go +2 -2
  75. package/x/vibc/alias.go +3 -0
  76. package/x/vibc/handler.go +16 -9
  77. package/x/vibc/keeper/keeper.go +102 -65
  78. package/x/vibc/keeper/triggers.go +101 -0
  79. package/x/vibc/module.go +5 -8
  80. package/x/vibc/types/expected_keepers.go +13 -0
  81. package/x/vibc/types/ibc_module.go +336 -0
  82. package/x/vibc/types/receiver.go +170 -0
  83. package/x/vlocalchain/alias.go +19 -0
  84. package/x/vlocalchain/handler.go +21 -0
  85. package/x/vlocalchain/keeper/keeper.go +279 -0
  86. package/x/vlocalchain/keeper/keeper_test.go +97 -0
  87. package/x/vlocalchain/types/codec.go +34 -0
  88. package/x/vlocalchain/types/key.go +27 -0
  89. package/x/vlocalchain/types/msgs.go +16 -0
  90. package/x/vlocalchain/types/vlocalchain.pb.go +1072 -0
  91. package/x/vlocalchain/vlocalchain.go +114 -0
  92. package/x/vlocalchain/vlocalchain_test.go +434 -0
  93. package/x/vstorage/handler.go +2 -1
  94. package/x/vstorage/keeper/grpc_query.go +0 -1
  95. package/x/vstorage/keeper/keeper.go +13 -20
  96. package/x/vstorage/keeper/querier.go +6 -5
  97. package/x/vstorage/keeper/querier_test.go +4 -3
  98. package/x/vstorage/module.go +0 -5
  99. package/x/vstorage/testing/queue.go +27 -0
  100. package/x/vtransfer/alias.go +13 -0
  101. package/x/vtransfer/genesis.go +39 -0
  102. package/x/vtransfer/genesis_test.go +12 -0
  103. package/x/vtransfer/handler.go +20 -0
  104. package/x/vtransfer/ibc_middleware.go +186 -0
  105. package/x/vtransfer/ibc_middleware_test.go +448 -0
  106. package/x/vtransfer/keeper/keeper.go +281 -0
  107. package/x/vtransfer/module.go +124 -0
  108. package/x/vtransfer/types/expected_keepers.go +38 -0
  109. package/x/vtransfer/types/genesis.pb.go +327 -0
  110. package/x/vtransfer/types/key.go +9 -0
  111. package/x/vtransfer/types/msgs.go +9 -0
  112. package/ante/fee.go +0 -96
  113. package/proto/agoric/lien/genesis.proto +0 -25
  114. package/proto/agoric/lien/lien.proto +0 -25
  115. package/x/lien/alias.go +0 -17
  116. package/x/lien/genesis.go +0 -58
  117. package/x/lien/genesis_test.go +0 -101
  118. package/x/lien/keeper/account.go +0 -290
  119. package/x/lien/keeper/keeper.go +0 -255
  120. package/x/lien/keeper/keeper_test.go +0 -623
  121. package/x/lien/lien.go +0 -205
  122. package/x/lien/lien_test.go +0 -533
  123. package/x/lien/module.go +0 -115
  124. package/x/lien/spec/01_concepts.md +0 -146
  125. package/x/lien/spec/02_messages.md +0 -96
  126. package/x/lien/types/accountkeeper.go +0 -81
  127. package/x/lien/types/accountstate.go +0 -27
  128. package/x/lien/types/expected_keepers.go +0 -18
  129. package/x/lien/types/genesis.pb.go +0 -567
  130. package/x/lien/types/key.go +0 -25
  131. package/x/lien/types/lien.pb.go +0 -403
  132. package/x/vibc/ibc.go +0 -394
  133. /package/{src/index.cjs → index.cjs} +0 -0
@@ -0,0 +1,271 @@
1
+ package e2etest
2
+
3
+ import (
4
+ "context"
5
+ "fmt"
6
+ "os"
7
+ "strconv"
8
+ "strings"
9
+ "testing"
10
+
11
+ "github.com/agoric-labs/interchaintest/v6"
12
+ "github.com/agoric-labs/interchaintest/v6/chain/cosmos"
13
+ "github.com/agoric-labs/interchaintest/v6/ibc"
14
+ "github.com/agoric-labs/interchaintest/v6/relayer"
15
+ "github.com/agoric-labs/interchaintest/v6/testutil"
16
+
17
+ "go.uber.org/zap/zaptest"
18
+ )
19
+
20
+ const CHAIN_AGORIC = "agoric"
21
+ const CHAIN_GAIA = "gaia"
22
+
23
+ const RELAYER_COSMOS = "cosmos"
24
+ const RELAYER_HERMES = "hermes"
25
+
26
+ const DEFAULT_CHAINIMAGE_AGORIC = "agoric:heighliner-agoric"
27
+ const DEFAULT_BLOCKS_TO_WAIT = 25
28
+
29
+ const FMT_ENV_CHAINNAME = "E2ETEST_CHAINNAME%d"
30
+ const ENV_CHAINIMAGE_AGORIC = "E2ETEST_CHAINIMAGE_AGORIC"
31
+ const ENV_RELAYERNAME = "E2ETEST_RELAYERNAME"
32
+ const ENV_BLOCKS_TO_WAIT = "E2ETEST_BLOCKS_TO_WAIT"
33
+
34
+ // newHermesFactory creates a hermes relayer
35
+ func newHermesFactory(t *testing.T) interchaintest.RelayerFactory {
36
+ return interchaintest.NewBuiltinRelayerFactory(
37
+ ibc.Hermes,
38
+ zaptest.NewLogger(t),
39
+ )
40
+ }
41
+
42
+ // newCosmosRlyFactory creates a cosmos relayer
43
+ func newCosmosRlyFactory(t *testing.T) interchaintest.RelayerFactory {
44
+
45
+ // TODO: At one point was using latest docker image for relyaer but disabling
46
+ // to remove variables while debugging heighliner builds of agoric chain are failing
47
+ //
48
+ IBCRelayerImage := "ghcr.io/cosmos/relayer"
49
+ IBCRelayerVersion := "latest"
50
+ image := relayer.CustomDockerImage(IBCRelayerImage, IBCRelayerVersion, "100:1000")
51
+
52
+ return interchaintest.NewBuiltinRelayerFactory(
53
+ ibc.CosmosRly,
54
+ zaptest.NewLogger(t),
55
+ image,
56
+ )
57
+ }
58
+
59
+ // newCosmosHubChainSpec creates a chainspec for a gaia instance compatible with these tests
60
+ // TODO: replacing the v13.0.01 version with latest has not been tested.
61
+ func newCosmosHubChainSpec(chainUniqueName string, chainID string, numOfValidators int, numOfFullNodes int) *interchaintest.ChainSpec {
62
+ ret := &interchaintest.ChainSpec{
63
+ Name: "gaia",
64
+ ChainName: chainUniqueName,
65
+ Version: "v13.0.1", // This version of gaiad has the interface interchaintestv6 needs
66
+ NumValidators: &numOfValidators,
67
+ NumFullNodes: &numOfFullNodes,
68
+ }
69
+
70
+ ret.ChainConfig.ChainID = chainID
71
+ return ret
72
+ }
73
+
74
+ // newUnknownCosmosChainSpec creates any cosmos chain where interchaintest has a built in definition
75
+ // NB: In many cases these images will not work due to issues outside the scope of Agoric's project
76
+ func newUnknownCosmosChainSpec(chain string, chainUniqueName string, chainID string, numOfValidators int, numOfFullNodes int) *interchaintest.ChainSpec {
77
+ ret := &interchaintest.ChainSpec{
78
+ Name: chain,
79
+ ChainName: chainUniqueName,
80
+ Version: "latest",
81
+ NumValidators: &numOfValidators,
82
+ NumFullNodes: &numOfFullNodes,
83
+ }
84
+
85
+ ret.ChainConfig.ChainID = chainID
86
+ return ret
87
+ }
88
+
89
+ // newAgoricChainSpec fully specifies the details necessary to launch an Agoric chain image built from
90
+ // - https://github.com/strangelove-ventures/heighliner/pull/211
91
+ // - NoCrisisModule is a flag added in the agoric-labs fork of interchaintest
92
+ func newAgoricChainSpec(chainUniqueName string, chainID string, chainImage ibc.DockerImage, numOfValidators int, numOfFullNodes int) *interchaintest.ChainSpec {
93
+ coinDecimals := int64(6)
94
+ gasAdjustment := 1.3
95
+ noHostMount := false
96
+
97
+ return &interchaintest.ChainSpec{
98
+ Name: "agoric",
99
+ ChainName: chainUniqueName,
100
+ Version: chainImage.Version,
101
+ GasAdjustment: &gasAdjustment,
102
+ NoHostMount: &noHostMount,
103
+ ChainConfig: ibc.ChainConfig{
104
+ Type: "cosmos",
105
+ Name: "agoric",
106
+ ChainID: chainID,
107
+ Images: []ibc.DockerImage{
108
+ chainImage,
109
+ },
110
+ Bin: "agd",
111
+ Bech32Prefix: "agoric",
112
+ Denom: "ubld",
113
+ CoinType: "564",
114
+ // interchaintest is super flaky when gas is enabled
115
+ GasPrices: "0.0ubld",
116
+ GasAdjustment: 1.3,
117
+ TrustingPeriod: "672h",
118
+ NoHostMount: false,
119
+ NoCrisisModule: true,
120
+ SkipGenTx: false,
121
+ CoinDecimals: &coinDecimals,
122
+ },
123
+ NumValidators: &numOfValidators,
124
+ NumFullNodes: &numOfFullNodes,
125
+ }
126
+ }
127
+
128
+ // getChainImage will build a docker image from the environment variable value
129
+ // E2ETEST_CHAINIMAGE_AGORIC. The value of this env var
130
+ // must be in the form "repo/image:version"
131
+ func getChainImageAgoric(t *testing.T) ibc.DockerImage {
132
+ ret := ibc.DockerImage{
133
+ UidGid: "1025:1025",
134
+ }
135
+
136
+ chainImage, present := os.LookupEnv(ENV_CHAINIMAGE_AGORIC)
137
+ if !present {
138
+ chainImage = DEFAULT_CHAINIMAGE_AGORIC
139
+ }
140
+
141
+ parts := strings.Split(chainImage, ":")
142
+ if len(parts) == 2 {
143
+ ret.Repository = parts[0]
144
+ ret.Version = parts[1]
145
+ } else {
146
+ t.Fatalf("Invalid value for %s[%s]. Must be of the format 'repository:version'", ENV_CHAINIMAGE_AGORIC, chainImage)
147
+ }
148
+
149
+ t.Logf("ChainImages: %s[%s:%s]", ENV_CHAINIMAGE_AGORIC, ret.Repository, ret.Version)
150
+
151
+ return ret
152
+ }
153
+
154
+ // getChainNames reads the environment variables FMT_ENV_CHAINNAME0, FMT_ENV_CHAINNAME1, FMT_ENV_CHAINNAME2, FMT_ENV_CHAINNAME3
155
+ func getChainNames(t *testing.T) [4]string {
156
+
157
+ ret := [4]string{
158
+ CHAIN_AGORIC, CHAIN_AGORIC, CHAIN_AGORIC, CHAIN_AGORIC,
159
+ }
160
+
161
+ for i := 0; i < 4; i++ {
162
+ envVar := fmt.Sprintf(FMT_ENV_CHAINNAME, i)
163
+ chainName, present := os.LookupEnv(envVar)
164
+ if present {
165
+ ret[i] = chainName
166
+ }
167
+ }
168
+
169
+ t.Logf("ChainNames: %s[%s] %s[%s] %s[%s] %s[%s]",
170
+ fmt.Sprintf(FMT_ENV_CHAINNAME, 0), ret[0],
171
+ fmt.Sprintf(FMT_ENV_CHAINNAME, 1), ret[1],
172
+ fmt.Sprintf(FMT_ENV_CHAINNAME, 2), ret[2],
173
+ fmt.Sprintf(FMT_ENV_CHAINNAME, 3), ret[3])
174
+
175
+ return ret
176
+ }
177
+
178
+ // getChainSpec reads environment variables and builds a full ChainSpec
179
+ func getChainSpec(t *testing.T) []*interchaintest.ChainSpec {
180
+ nv := 1
181
+ nf := 0
182
+
183
+ chainNames := getChainNames(t)
184
+ chainImage := getChainImageAgoric(t)
185
+
186
+ ret := make([]*interchaintest.ChainSpec, 4)
187
+
188
+ for index, chainName := range chainNames {
189
+ chainId := fmt.Sprintf("%s%d", chainName, index)
190
+ chainUniqueName := chainId
191
+
192
+ switch chainName {
193
+ case CHAIN_AGORIC:
194
+ ret[index] = newAgoricChainSpec(chainUniqueName, chainId, chainImage, nv, nf)
195
+ case CHAIN_GAIA:
196
+ ret[index] = newCosmosHubChainSpec(chainUniqueName, chainId, nv, nf)
197
+ default:
198
+ ret[index] = newUnknownCosmosChainSpec(chainName, chainUniqueName, chainId, nv, nf)
199
+ }
200
+ }
201
+
202
+ return ret
203
+ }
204
+
205
+ // getRelayerFactory reads environment variables and builds the correct RelayerFactory
206
+ func getRelayerFactory(t *testing.T) interchaintest.RelayerFactory {
207
+ relayerName, present := os.LookupEnv(ENV_RELAYERNAME)
208
+ if !present {
209
+ relayerName = RELAYER_COSMOS
210
+ }
211
+
212
+ var ret interchaintest.RelayerFactory
213
+
214
+ switch relayerName {
215
+ case RELAYER_COSMOS:
216
+ ret = newCosmosRlyFactory(t)
217
+ case RELAYER_HERMES:
218
+ ret = newHermesFactory(t)
219
+ default:
220
+ t.Fatalf("Invalid value for %s[%s]. Valid values are [%s] or [%s]", ENV_RELAYERNAME, relayerName, RELAYER_COSMOS, RELAYER_HERMES)
221
+ }
222
+
223
+ t.Logf("RelayerNmae: %s[%s]", ENV_RELAYERNAME, relayerName)
224
+
225
+ return ret
226
+ }
227
+
228
+ // sendIBCTransferWithWait performs cosmos.CosmosChain.SendIBCTransfer
229
+ // - Automatically waits to confirm TX is ACK'd
230
+ // - Automatically waits for results to settle
231
+ // - The environment variable E2ETEST_BLOCKS_TO_WAIT controls how many blocks to wait for ACK and settlement
232
+ func sendIBCTransferWithWait(
233
+ c *cosmos.CosmosChain,
234
+ ctx context.Context,
235
+ channelID string,
236
+ keyName string,
237
+ amount ibc.WalletAmount,
238
+ options ibc.TransferOptions,
239
+ ) (tx ibc.Tx, err error) {
240
+ blocksToWait := DEFAULT_BLOCKS_TO_WAIT
241
+
242
+ blocksAsStr, present := os.LookupEnv(ENV_BLOCKS_TO_WAIT)
243
+ if present {
244
+ blocksToWait, err = strconv.Atoi(blocksAsStr)
245
+ if err != nil {
246
+ return tx, err
247
+ }
248
+ }
249
+
250
+ chainAHeight, err := c.Height(ctx)
251
+ if err != nil {
252
+ return tx, err
253
+ }
254
+
255
+ tx, err = c.SendIBCTransfer(ctx, channelID, keyName, amount, options)
256
+ if err != nil {
257
+ return tx, err
258
+ }
259
+
260
+ _, err = testutil.PollForAck(ctx, c, chainAHeight, chainAHeight+30, tx.Packet)
261
+ if err != nil {
262
+ return tx, err
263
+ }
264
+
265
+ err = testutil.WaitForBlocks(ctx, blocksToWait, c)
266
+ if err != nil {
267
+ return tx, err
268
+ }
269
+
270
+ return tx, err
271
+ }
package/git-revision.txt CHANGED
@@ -1 +1 @@
1
- c8f9e7b
1
+ fb592e4
package/go.mod CHANGED
@@ -3,10 +3,12 @@ module github.com/Agoric/agoric-sdk/golang/cosmos
3
3
  go 1.20
4
4
 
5
5
  require (
6
+ cosmossdk.io/errors v1.0.0-beta.7
6
7
  cosmossdk.io/math v1.0.0-rc.0
7
8
  github.com/armon/go-metrics v0.4.1
8
9
  github.com/cosmos/cosmos-sdk v0.46.16
9
- github.com/cosmos/ibc-go/v6 v6.2.1
10
+ github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6 v6.1.2
11
+ github.com/cosmos/ibc-go/v6 v6.3.1
10
12
  github.com/gogo/protobuf v1.3.3
11
13
  github.com/golang/protobuf v1.5.3
12
14
  github.com/gorilla/mux v1.8.0
@@ -14,9 +16,9 @@ require (
14
16
  github.com/pkg/errors v0.9.1
15
17
  github.com/rakyll/statik v0.1.7
16
18
  github.com/spf13/cast v1.5.0
17
- github.com/spf13/cobra v1.6.1
19
+ github.com/spf13/cobra v1.7.0
18
20
  github.com/spf13/viper v1.14.0
19
- github.com/stretchr/testify v1.8.2
21
+ github.com/stretchr/testify v1.8.4
20
22
  github.com/tendermint/tendermint v0.34.29
21
23
  github.com/tendermint/tm-db v0.6.7
22
24
  google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98
@@ -30,7 +32,6 @@ require (
30
32
  cloud.google.com/go/compute/metadata v0.2.3 // indirect
31
33
  cloud.google.com/go/iam v1.1.1 // indirect
32
34
  cloud.google.com/go/storage v1.30.1 // indirect
33
- cosmossdk.io/errors v1.0.0-beta.7 // indirect
34
35
  filippo.io/edwards25519 v1.0.0-rc.1 // indirect
35
36
  github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
36
37
  github.com/99designs/keyring v1.2.1 // indirect
@@ -79,7 +80,6 @@ require (
79
80
  github.com/golang/snappy v0.0.4 // indirect
80
81
  github.com/google/btree v1.1.2 // indirect
81
82
  github.com/google/go-cmp v0.5.9 // indirect
82
- github.com/google/gofuzz v1.2.0 // indirect
83
83
  github.com/google/orderedcode v0.0.1 // indirect
84
84
  github.com/google/s2a-go v0.1.4 // indirect
85
85
  github.com/google/uuid v1.3.0 // indirect
@@ -99,8 +99,9 @@ require (
99
99
  github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
100
100
  github.com/hashicorp/hcl v1.0.0 // indirect
101
101
  github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 // indirect
102
+ github.com/iancoleman/orderedmap v0.2.0 // indirect
102
103
  github.com/improbable-eng/grpc-web v0.15.0 // indirect
103
- github.com/inconshreveable/mousetrap v1.0.1 // indirect
104
+ github.com/inconshreveable/mousetrap v1.1.0 // indirect
104
105
  github.com/jmespath/go-jmespath v0.4.0 // indirect
105
106
  github.com/jmhodges/levigo v1.0.0 // indirect
106
107
  github.com/klauspost/compress v1.16.0 // indirect
@@ -168,9 +169,6 @@ replace (
168
169
 
169
170
  github.com/confio/ics23/go => github.com/agoric-labs/cosmos-sdk/ics23/go v0.8.0-alpha.agoric.1
170
171
 
171
- // We need a fork of cosmos-sdk until all of the differences are merged.
172
- github.com/cosmos/cosmos-sdk => github.com/agoric-labs/cosmos-sdk v0.46.16-alpha.agoric.2
173
-
174
172
  // https://pkg.go.dev/vuln/GO-2023-2409
175
173
  github.com/dvsekhvalnov/jose2go => github.com/dvsekhvalnov/jose2go v1.5.1-0.20231206184617-48ba0b76bc88
176
174
 
@@ -184,13 +182,26 @@ replace (
184
182
 
185
183
  // replace broken goleveldb.
186
184
  github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
185
+ )
186
+
187
+ // Agoric-specific replacements:
188
+ replace (
189
+ // We need a fork of cosmos-sdk until all of the differences are merged.
190
+ github.com/cosmos/cosmos-sdk => github.com/agoric-labs/cosmos-sdk v0.46.16-alpha.agoric.2.4
191
+
192
+ // Pick up an IAVL race fix.
193
+ github.com/cosmos/iavl => github.com/cosmos/iavl v0.19.7
194
+
195
+ // Use a version of ibc-go that is compatible with the above forks.
196
+ github.com/cosmos/ibc-go/v6 => github.com/agoric-labs/ibc-go/v6 v6.3.1-alpha.agoric.2
187
197
 
188
198
  // use cometbft
189
199
  // Use our fork at least until post-v0.34.14 is released with
190
200
  // https://github.com/tendermint/tendermint/issue/6899 resolved.
191
201
  github.com/tendermint/tendermint => github.com/agoric-labs/cometbft v0.34.30-alpha.agoric.1
192
202
 
193
- // For testing against a local cosmos-sdk or tendermint
203
+ // For testing against a local cosmos-sdk, ibc-go, or cometbft
194
204
  // github.com/cosmos/cosmos-sdk => ../../../forks/cosmos-sdk
195
- // github.com/tendermint/tendermint => ../../../forks/tendermint
205
+ // github.com/cosmos/ibc-go/v6 => ../../../forks/ibc-go/v6
206
+ // github.com/tendermint/tendermint => ../../../forks/cometbft
196
207
  )
package/go.sum CHANGED
@@ -232,10 +232,12 @@ github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBA
232
232
  github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c=
233
233
  github.com/agoric-labs/cometbft v0.34.30-alpha.agoric.1 h1:tqCNL72pQXdUmBzgv1md5SN2U3K/PaYQ4qZ5pFv8v6w=
234
234
  github.com/agoric-labs/cometbft v0.34.30-alpha.agoric.1/go.mod h1:myvkihZD8eg9jKE3WFaugkNoL5nvEqlP7Jbjg98pCek=
235
- github.com/agoric-labs/cosmos-sdk v0.46.16-alpha.agoric.2 h1:iHHqpYC0JzMbH4UYnQrcwVjLyHJuQphB0ogHbuLz44c=
236
- github.com/agoric-labs/cosmos-sdk v0.46.16-alpha.agoric.2/go.mod h1:zUe5lsg/X7SeSO1nGkzOh9EGKO295szfrxIxYmeLYic=
235
+ github.com/agoric-labs/cosmos-sdk v0.46.16-alpha.agoric.2.4 h1:i5IgChQjTyWulV/y5NpVBB5qBJETQ59hYglod6vhok0=
236
+ github.com/agoric-labs/cosmos-sdk v0.46.16-alpha.agoric.2.4/go.mod h1:d7e4h+w7FNBNmE6ysp6duBVuQg67pqMtvsLwpT9ca3E=
237
237
  github.com/agoric-labs/cosmos-sdk/ics23/go v0.8.0-alpha.agoric.1 h1:2jvHI/2d+psWAZy6FQ0vXJCHUtfU3ZbbW+pQFL04arQ=
238
238
  github.com/agoric-labs/cosmos-sdk/ics23/go v0.8.0-alpha.agoric.1/go.mod h1:E45NqnlpxGnpfTWL/xauN7MRwEE28T4Dd4uraToOaKg=
239
+ github.com/agoric-labs/ibc-go/v6 v6.3.1-alpha.agoric.2 h1:vEzy4JaExzlWNHV3ZSVXEVZcRE9loEFUjieE2TXwDdI=
240
+ github.com/agoric-labs/ibc-go/v6 v6.3.1-alpha.agoric.2/go.mod h1:L1xcBjCLIHN7Wd9j6cAQvZertn56pq+eRGFZjRO5bsY=
239
241
  github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw=
240
242
  github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
241
243
  github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
@@ -376,10 +378,10 @@ github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY
376
378
  github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw=
377
379
  github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4Y=
378
380
  github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw=
379
- github.com/cosmos/iavl v0.19.6 h1:XY78yEeNPrEYyNCKlqr9chrwoeSDJ0bV2VjocTk//OU=
380
- github.com/cosmos/iavl v0.19.6/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw=
381
- github.com/cosmos/ibc-go/v6 v6.2.1 h1:NiaDXTRhKwf3n9kELD4VRIe5zby1yk1jBvaz9tXTQ6k=
382
- github.com/cosmos/ibc-go/v6 v6.2.1/go.mod h1:XLsARy4Y7+GtAqzMcxNdlQf6lx+ti1e8KcMGv5NIK7A=
381
+ github.com/cosmos/iavl v0.19.7 h1:ij32FaEnwxfEurtK0QKDNhTWFnz6NUmrI5gky/WnoY0=
382
+ github.com/cosmos/iavl v0.19.7/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw=
383
+ github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6 v6.1.2 h1:Hz4nkpStoXIHrC77CIEyu2mRiN2qysGEZPFRf0fpv7w=
384
+ github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6 v6.1.2/go.mod h1:Jo934o/sW7fNxuOa/TjCalSalz+1Fd649eLyANaJx8g=
383
385
  github.com/cosmos/keyring v1.2.0 h1:8C1lBP9xhImmIabyXW4c3vFjjLiBdGCmfLUfeZlV1Yo=
384
386
  github.com/cosmos/keyring v1.2.0/go.mod h1:fc+wB5KTk9wQ9sDx0kFXB3A0MaeGHM9AwRStKOQ5vOA=
385
387
  github.com/cosmos/ledger-cosmos-go v0.12.4 h1:drvWt+GJP7Aiw550yeb3ON/zsrgW0jgh5saFCr7pDnw=
@@ -598,7 +600,6 @@ github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSN
598
600
  github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
599
601
  github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
600
602
  github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
601
- github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
602
603
  github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no=
603
604
  github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
604
605
  github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
@@ -725,13 +726,15 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO
725
726
  github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
726
727
  github.com/huin/goupnp v1.0.3-0.20220313090229-ca81a64b4204/go.mod h1:ZxNlw5WqJj6wSsRK5+YfflQGXYfccj5VgQsMNixHM7Y=
727
728
  github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3iZrZfqZzyLl6l7F3c6L1oWn7OICBi6o=
729
+ github.com/iancoleman/orderedmap v0.2.0 h1:sq1N/TFpYH++aViPcaKjys3bDClUEU7s5B+z6jq8pNA=
730
+ github.com/iancoleman/orderedmap v0.2.0/go.mod h1:N0Wam8K1arqPXNWjMo21EXnBPOPp36vB07FNRdD2geA=
728
731
  github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
729
732
  github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
730
733
  github.com/improbable-eng/grpc-web v0.15.0 h1:BN+7z6uNXZ1tQGcNAuaU1YjsLTApzkjt2tzCixLaUPQ=
731
734
  github.com/improbable-eng/grpc-web v0.15.0/go.mod h1:1sy9HKV4Jt9aEs9JSnkWlRJPuPtwNr0l57L4f878wP8=
732
735
  github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
733
- github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc=
734
- github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
736
+ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
737
+ github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
735
738
  github.com/influxdata/flux v0.65.1/go.mod h1:J754/zds0vvpfwuq7Gc2wRdVwEodfpCFM7mYlOw2LqY=
736
739
  github.com/influxdata/influxdb v1.8.3/go.mod h1:JugdFhsvvI8gadxOI6noqNeeBHvWNTbfYGtiAn+2jhI=
737
740
  github.com/influxdata/influxdb-client-go/v2 v2.4.0/go.mod h1:vLNHdxTJkIf2mSLvGrpj8TCcISApPoXkaxP8g9uRlW8=
@@ -1057,8 +1060,8 @@ github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w=
1057
1060
  github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU=
1058
1061
  github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
1059
1062
  github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
1060
- github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=
1061
- github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY=
1063
+ github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
1064
+ github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
1062
1065
  github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
1063
1066
  github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
1064
1067
  github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
@@ -1088,8 +1091,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
1088
1091
  github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
1089
1092
  github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
1090
1093
  github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
1091
- github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
1092
- github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
1094
+ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
1095
+ github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
1093
1096
  github.com/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs=
1094
1097
  github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
1095
1098
  github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY=
@@ -1165,6 +1168,7 @@ go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqe
1165
1168
  go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
1166
1169
  go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
1167
1170
  go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
1171
+ go.uber.org/mock v0.2.0 h1:TaP3xedm7JaAgScZO7tlvlKrqT0p7I6OsdGB5YNSMDU=
1168
1172
  go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
1169
1173
  go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4=
1170
1174
  go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@agoric/cosmos",
3
- "version": "0.35.0-upgrade-14-dev-c8f9e7b.0+c8f9e7b",
3
+ "version": "0.35.0-upgrade-16a-dev-fb592e4.0+fb592e4",
4
4
  "description": "Connect JS to the Cosmos blockchain SDK",
5
5
  "parsers": {
6
6
  "js": "mjs"
7
7
  },
8
- "main": "src/index.cjs",
8
+ "main": "index.cjs",
9
9
  "engines": {
10
- "node": ">=14.15.0"
10
+ "node": "^18.12 || ^20.9"
11
11
  },
12
+ "packageManager": "yarn@1.22.19",
12
13
  "scripts": {
13
14
  "test": "exit 0",
14
15
  "build:all": "make",
@@ -19,7 +20,7 @@
19
20
  "postpack": "git clean -f git-revision.txt",
20
21
  "build": "exit 0",
21
22
  "lint-fix": "yarn lint:eslint --fix",
22
- "lint": "eslint '**/*.{cjs,js}'"
23
+ "lint": "exit 0"
23
24
  },
24
25
  "dependencies": {
25
26
  "bindings": "^1.2.1",
@@ -35,5 +36,8 @@
35
36
  "publishConfig": {
36
37
  "access": "public"
37
38
  },
38
- "gitHead": "c8f9e7be1645e0be23f47de197409a7d4874add5"
39
+ "typeCoverage": {
40
+ "atLeast": 0
41
+ },
42
+ "gitHead": "fb592e448de7252d92f7ed65b05f7d49a35403fd"
39
43
  }
@@ -17,6 +17,10 @@ message GenesisState {
17
17
  repeated SwingStoreExportDataEntry swing_store_export_data = 4 [
18
18
  (gogoproto.jsontag) = "swingStoreExportData"
19
19
  ];
20
+
21
+ string swing_store_export_data_hash = 5 [
22
+ (gogoproto.jsontag) = "swingStoreExportDataHash"
23
+ ];
20
24
  }
21
25
 
22
26
  // A SwingStore "export data" entry.
@@ -8,7 +8,7 @@ option go_package = "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/types
8
8
 
9
9
  // CoreEvalProposal is a gov Content type for evaluating code in the SwingSet
10
10
  // core.
11
- // See `agoric-sdk/packages/vats/src/core/eval.js`.
11
+ // See `bridgeCoreEval` in agoric-sdk packages/vats/src/core/chain-behaviors.js.
12
12
  message CoreEvalProposal {
13
13
  option (gogoproto.goproto_getters) = false;
14
14
 
@@ -0,0 +1,7 @@
1
+ ---
2
+ Language: Proto
3
+ BasedOnStyle: Google
4
+ AlignConsecutiveDeclarations: true
5
+ AlignConsecutiveAssignments: true
6
+ ColumnLimit: 0
7
+ IndentWidth: 4
@@ -0,0 +1,31 @@
1
+ syntax = "proto3";
2
+ package agoric.vlocalchain;
3
+
4
+ import "google/protobuf/any.proto";
5
+
6
+ option go_package = "github.com/Agoric/agoric-sdk/golang/cosmos/x/vlocalchain/types";
7
+
8
+ // CosmosTx contains a list of sdk.Msg's. It should be used when sending
9
+ // transactions to a local chain.
10
+ message CosmosTx {
11
+ repeated google.protobuf.Any messages = 1;
12
+ }
13
+
14
+ // QueryRequest is used internally to describe a query for the local chain.
15
+ message QueryRequest {
16
+ string full_method = 1;
17
+ google.protobuf.Any request = 2;
18
+ string reply_type = 3;
19
+ }
20
+
21
+ // QueryResponse is used internally to describe a response from the local chain.
22
+ message QueryResponse {
23
+ int64 height = 1;
24
+ google.protobuf.Any reply = 2;
25
+ string error = 3;
26
+ }
27
+
28
+ // QueryResponses is used to group multiple QueryResponse messages.
29
+ message QueryResponses {
30
+ repeated QueryResponse responses = 1;
31
+ }
@@ -0,0 +1,18 @@
1
+ syntax = "proto3";
2
+ package agoric.vtransfer;
3
+
4
+ import "gogoproto/gogo.proto";
5
+
6
+ option go_package = "github.com/Agoric/agoric-sdk/golang/cosmos/x/vtransfer/types";
7
+
8
+ // The initial and exported module state.
9
+ message GenesisState {
10
+ option (gogoproto.equal) = false;
11
+
12
+ // The list of account addresses that are being watched by the VM.
13
+ repeated bytes watched_addresses = 1 [
14
+ (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress",
15
+ (gogoproto.jsontag) = "watched_addresses",
16
+ (gogoproto.moretags) = "yaml:\"watched_addresses\""
17
+ ];
18
+ }
@@ -3,12 +3,12 @@
3
3
  set -eo pipefail
4
4
 
5
5
  protoc_gen_gocosmos() {
6
- if ! grep "github.com/gogo/protobuf => github.com/regen-network/protobuf" go.mod &>/dev/null ; then
6
+ if ! grep "github.com/gogo/protobuf => github.com/regen-network/protobuf" go.mod &> /dev/null; then
7
7
  echo -e "\tPlease run this command from somewhere inside the ibc-go folder."
8
8
  return 1
9
9
  fi
10
10
 
11
- go get github.com/regen-network/cosmos-proto/protoc-gen-gocosmos@latest 2>/dev/null
11
+ go get github.com/regen-network/cosmos-proto/protoc-gen-gocosmos@latest 2> /dev/null
12
12
  }
13
13
 
14
14
  protoc_gen_gocosmos
@@ -19,12 +19,11 @@ for dir in $proto_dirs; do
19
19
  # allow_colon_final_segments=true
20
20
  # as per https://grpc-ecosystem.github.io/grpc-gateway/docs/development/grpc-gateway_v2_migration_guide/#withlastmatchwins-and-allow_colon_final_segmentstrue-is-now-default-behaviour
21
21
  protoc \
22
- -I proto \
23
- -I third_party/proto \
24
- --gocosmos_out=plugins=grpc,\
25
- Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types:. \
26
- --grpc-gateway_out=logtostderr=true,allow_colon_final_segments=true:. \
27
- $(find "${dir}" -maxdepth 1 -name '*.proto')
22
+ -I proto \
23
+ -I third_party/proto \
24
+ --gocosmos_out=plugins=grpc,Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types:. \
25
+ --grpc-gateway_out=logtostderr=true,allow_colon_final_segments=true:. \
26
+ $(find "${dir}" -maxdepth 1 -name '*.proto')
28
27
  done
29
28
 
30
29
  # move proto files to the right places
@@ -232,3 +232,45 @@ func EncodeKVEntryReaderToJsonl(reader KVEntryReader, bytesWriter io.Writer) (er
232
232
  }
233
233
  }
234
234
  }
235
+
236
+ var _ KVEntryReader = &kvHookingReader{}
237
+
238
+ // kvHookingReader is a KVEntryReader backed by another KVEntryReader which
239
+ // provides callbacks for read and close
240
+ type kvHookingReader struct {
241
+ reader KVEntryReader
242
+ onRead func(entry KVEntry) error
243
+ onClose func() error
244
+ }
245
+
246
+ // NewKVHookingReader returns a KVEntryReader backed by another KVEntryReader
247
+ func NewKVHookingReader(reader KVEntryReader, onRead func(entry KVEntry) error, onClose func() error) KVEntryReader {
248
+ return &kvHookingReader{
249
+ reader,
250
+ onRead,
251
+ onClose,
252
+ }
253
+ }
254
+
255
+ // Read yields the next KVEntry from the source reader
256
+ // Implements KVEntryReader
257
+ func (hr kvHookingReader) Read() (next KVEntry, err error) {
258
+ next, err = hr.reader.Read()
259
+
260
+ if err == nil {
261
+ err = hr.onRead(next)
262
+ }
263
+
264
+ return next, err
265
+ }
266
+
267
+ // Close releases the underlying source reader
268
+ // Implements KVEntryReader
269
+ func (hr kvHookingReader) Close() error {
270
+ err := hr.reader.Close()
271
+ if err == nil {
272
+ err = hr.onClose()
273
+ }
274
+
275
+ return err
276
+ }