@agoric/cosmos 0.34.2-dev-7ffae88.0 → 0.34.2-orchestration-dev-096c4e8.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 (85) hide show
  1. package/Makefile +7 -0
  2. package/ante/ante.go +6 -5
  3. package/ante/fee.go +8 -7
  4. package/ante/inbound_test.go +3 -2
  5. package/ante/vm_admission.go +2 -1
  6. package/app/app.go +107 -59
  7. package/app/export.go +13 -6
  8. package/cmd/libdaemon/main_test.go +2 -1
  9. package/daemon/cmd/root.go +12 -5
  10. package/e2e_test/Makefile +29 -0
  11. package/e2e_test/README.md +100 -0
  12. package/e2e_test/go.mod +217 -0
  13. package/e2e_test/go.sum +1323 -0
  14. package/e2e_test/ibc_conformance_test.go +56 -0
  15. package/e2e_test/pfm_test.go +613 -0
  16. package/e2e_test/util.go +271 -0
  17. package/git-revision.txt +1 -1
  18. package/go.mod +15 -7
  19. package/go.sum +8 -5
  20. package/package.json +3 -3
  21. package/proto/agoric/vlocalchain/.clang-format +7 -0
  22. package/proto/agoric/vlocalchain/vlocalchain.proto +31 -0
  23. package/vm/action.go +5 -4
  24. package/vm/action_test.go +31 -11
  25. package/vm/controller.go +22 -1
  26. package/vm/server.go +1 -1
  27. package/x/swingset/abci.go +10 -10
  28. package/x/swingset/client/cli/tx.go +4 -0
  29. package/x/swingset/handler.go +2 -1
  30. package/x/swingset/keeper/keeper.go +6 -12
  31. package/x/swingset/keeper/msg_server.go +18 -18
  32. package/x/swingset/keeper/proposal.go +13 -3
  33. package/x/swingset/keeper/querier.go +12 -11
  34. package/x/swingset/keeper/swing_store_exports_handler.go +7 -3
  35. package/x/swingset/proposal_handler.go +2 -1
  36. package/x/swingset/types/expected_keepers.go +3 -2
  37. package/x/swingset/types/msgs.go +25 -24
  38. package/x/swingset/types/params.go +2 -1
  39. package/x/swingset/types/proposal.go +5 -4
  40. package/x/vbank/handler.go +2 -1
  41. package/x/vbank/keeper/querier.go +4 -3
  42. package/x/vbank/vbank.go +3 -3
  43. package/x/vibc/alias.go +3 -0
  44. package/x/vibc/handler.go +16 -9
  45. package/x/vibc/keeper/keeper.go +102 -65
  46. package/x/vibc/keeper/triggers.go +101 -0
  47. package/x/vibc/module.go +4 -2
  48. package/x/vibc/types/expected_keepers.go +13 -0
  49. package/x/vibc/types/ibc_module.go +335 -0
  50. package/x/vibc/types/receiver.go +160 -0
  51. package/x/vlocalchain/alias.go +19 -0
  52. package/x/vlocalchain/handler.go +20 -0
  53. package/x/vlocalchain/keeper/keeper.go +279 -0
  54. package/x/vlocalchain/keeper/keeper_test.go +32 -0
  55. package/x/vlocalchain/types/codec.go +34 -0
  56. package/x/vlocalchain/types/key.go +27 -0
  57. package/x/vlocalchain/types/msgs.go +16 -0
  58. package/x/vlocalchain/types/vlocalchain.pb.go +1072 -0
  59. package/x/vlocalchain/vlocalchain.go +109 -0
  60. package/x/vlocalchain/vlocalchain_test.go +305 -0
  61. package/x/vstorage/handler.go +2 -1
  62. package/x/vstorage/keeper/keeper.go +5 -4
  63. package/x/vstorage/keeper/querier.go +6 -5
  64. package/x/vstorage/keeper/querier_test.go +4 -3
  65. package/proto/agoric/lien/genesis.proto +0 -25
  66. package/proto/agoric/lien/lien.proto +0 -25
  67. package/x/lien/alias.go +0 -17
  68. package/x/lien/genesis.go +0 -58
  69. package/x/lien/genesis_test.go +0 -101
  70. package/x/lien/keeper/account.go +0 -290
  71. package/x/lien/keeper/keeper.go +0 -255
  72. package/x/lien/keeper/keeper_test.go +0 -623
  73. package/x/lien/lien.go +0 -205
  74. package/x/lien/lien_test.go +0 -533
  75. package/x/lien/module.go +0 -115
  76. package/x/lien/spec/01_concepts.md +0 -146
  77. package/x/lien/spec/02_messages.md +0 -96
  78. package/x/lien/types/accountkeeper.go +0 -81
  79. package/x/lien/types/accountstate.go +0 -27
  80. package/x/lien/types/expected_keepers.go +0 -18
  81. package/x/lien/types/genesis.pb.go +0 -567
  82. package/x/lien/types/key.go +0 -25
  83. package/x/lien/types/lien.pb.go +0 -403
  84. package/x/vibc/ibc.go +0 -394
  85. /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
- 7ffae88
1
+ 096c4e8
package/go.mod CHANGED
@@ -3,9 +3,11 @@ 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
10
+ github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6 v6.1.1
9
11
  github.com/cosmos/ibc-go/v6 v6.2.1
10
12
  github.com/gogo/protobuf v1.3.3
11
13
  github.com/golang/protobuf v1.5.3
@@ -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,6 +99,7 @@ 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
104
  github.com/inconshreveable/mousetrap v1.0.1 // indirect
104
105
  github.com/jmespath/go-jmespath v0.4.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.1
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,23 @@ 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
191
+
192
+ // Async version negotiation
193
+ github.com/cosmos/ibc-go/v6 => github.com/agoric-labs/ibc-go/v6 v6.2.1-alpha.agoric.3
187
194
 
188
195
  // use cometbft
189
196
  // Use our fork at least until post-v0.34.14 is released with
190
197
  // https://github.com/tendermint/tendermint/issue/6899 resolved.
191
198
  github.com/tendermint/tendermint => github.com/agoric-labs/cometbft v0.34.30-alpha.agoric.1
192
199
 
193
- // For testing against a local cosmos-sdk or tendermint
200
+ // For testing against a local cosmos-sdk, ibc-go, or cometbft
194
201
  // github.com/cosmos/cosmos-sdk => ../../../forks/cosmos-sdk
195
- // github.com/tendermint/tendermint => ../../../forks/tendermint
202
+ // github.com/cosmos/ibc-go/v6 => ../../../forks/ibc-go/v6
203
+ // github.com/tendermint/tendermint => ../../../forks/cometbft
196
204
  )
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.1 h1:TOSWh36rYtSjbImlfGuviakCeIlX9f8OROglct35z1Y=
236
- github.com/agoric-labs/cosmos-sdk v0.46.16-alpha.agoric.1/go.mod h1:zUe5lsg/X7SeSO1nGkzOh9EGKO295szfrxIxYmeLYic=
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=
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.2.1-alpha.agoric.3 h1:YqvVwK+Lg/ZsuwyVm9UbPs8K55fg00R3Y9KnmaTBdgc=
240
+ github.com/agoric-labs/ibc-go/v6 v6.2.1-alpha.agoric.3/go.mod h1:V9NOCRS9RPkSJNJQIPRAjZn/lo2mCAAKOSv3/83ISDY=
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=
@@ -378,8 +380,8 @@ github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4
378
380
  github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw=
379
381
  github.com/cosmos/iavl v0.19.6 h1:XY78yEeNPrEYyNCKlqr9chrwoeSDJ0bV2VjocTk//OU=
380
382
  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=
383
+ github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6 v6.1.1 h1:2geCtV4PoNPeRnVc0HMAcRcv+7W3Mvk2nmASkGkOdzE=
384
+ github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6 v6.1.1/go.mod h1:ovYRGX7P7Vq0D54JIVlIm/47STEKgWJfw9frvL0AWGQ=
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,6 +726,8 @@ 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=
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@agoric/cosmos",
3
- "version": "0.34.2-dev-7ffae88.0+7ffae88",
3
+ "version": "0.34.2-orchestration-dev-096c4e8.0+096c4e8",
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
10
  "node": ">=14.15.0"
11
11
  },
@@ -38,5 +38,5 @@
38
38
  "typeCoverage": {
39
39
  "atLeast": 0
40
40
  },
41
- "gitHead": "7ffae88ae37df782d5ffe3cf92261a498b0f636c"
41
+ "gitHead": "096c4e8fce80e9a509b0e1a30fda11736c4570e1"
42
42
  }
@@ -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
+ }
package/vm/action.go CHANGED
@@ -18,7 +18,7 @@ var (
18
18
  type Jsonable interface{}
19
19
 
20
20
  type Action interface {
21
- GetActionHeader() ActionHeader
21
+ GetActionHeader() *ActionHeader
22
22
  }
23
23
 
24
24
  // ActionPusher enqueues data for later consumption by the controller.
@@ -27,14 +27,14 @@ type ActionPusher func(ctx sdk.Context, action Action) error
27
27
  // ActionHeader should be embedded in all actions. It is populated by PopulateAction.
28
28
  type ActionHeader struct {
29
29
  // Type defaults to the `actionType:"..."` tag of the embedder's ActionHeader field.
30
- Type string `json:"type"`
30
+ Type string `json:"type,omitempty"`
31
31
  // BlockHeight defaults to sdk.Context.BlockHeight().
32
32
  BlockHeight int64 `json:"blockHeight,omitempty"`
33
33
  // BlockTime defaults to sdk.Context.BlockTime().Unix().
34
34
  BlockTime int64 `json:"blockTime,omitempty"`
35
35
  }
36
36
 
37
- func (ah ActionHeader) GetActionHeader() ActionHeader {
37
+ func (ah *ActionHeader) GetActionHeader() *ActionHeader {
38
38
  return ah
39
39
  }
40
40
 
@@ -129,5 +129,6 @@ func PopulateAction(ctx sdk.Context, action Action) Action {
129
129
  }
130
130
  }
131
131
  }
132
- return newActionDesc.Interface().(Action)
132
+
133
+ return newActionDescPtr.Interface().(Action)
133
134
  }
package/vm/action_test.go CHANGED
@@ -10,9 +10,11 @@ import (
10
10
  )
11
11
 
12
12
  var (
13
- _ vm.Action = &Trivial{}
13
+ _ vm.Action = Defaults{}
14
14
  _ vm.Action = &Defaults{}
15
+ _ vm.Action = dataAction{}
15
16
  _ vm.Action = &dataAction{}
17
+ _ vm.Action = &Trivial{}
16
18
  )
17
19
 
18
20
  type Trivial struct {
@@ -29,8 +31,8 @@ type Defaults struct {
29
31
  Any interface{}
30
32
  }
31
33
 
32
- func (d Defaults) GetActionHeader() vm.ActionHeader {
33
- return vm.ActionHeader{}
34
+ func (d Defaults) GetActionHeader() *vm.ActionHeader {
35
+ return &vm.ActionHeader{}
34
36
  }
35
37
 
36
38
  type dataAction struct {
@@ -52,6 +54,10 @@ func TestActionContext(t *testing.T) {
52
54
  &Trivial{Abc: 123, def: "zot"},
53
55
  &Trivial{Abc: 123, def: "zot"},
54
56
  },
57
+ {"not a pointer", emptyCtx,
58
+ &Trivial{Abc: 123, def: "zot"},
59
+ Trivial{Abc: 123, def: "zot"},
60
+ },
55
61
  {"block height",
56
62
  emptyCtx.WithBlockHeight(998),
57
63
  &Trivial{Abc: 123, def: "zot"},
@@ -67,6 +73,20 @@ func TestActionContext(t *testing.T) {
67
73
  &Defaults{},
68
74
  &Defaults{"abc", 123, 4.56, true, nil},
69
75
  },
76
+ {"data action no pointer",
77
+ emptyCtx,
78
+ dataAction{},
79
+ dataAction{
80
+ ActionHeader: &vm.ActionHeader{Type: "DATA_ACTION"},
81
+ },
82
+ },
83
+ {"data action pointer",
84
+ emptyCtx,
85
+ &dataAction{},
86
+ &dataAction{
87
+ ActionHeader: &vm.ActionHeader{Type: "DATA_ACTION"},
88
+ },
89
+ },
70
90
  {"data action defaults",
71
91
  emptyCtx.WithBlockHeight(998).WithBlockTime(time.UnixMicro(1_000_000)),
72
92
  &dataAction{Data: []byte("hello")},
@@ -75,30 +95,30 @@ func TestActionContext(t *testing.T) {
75
95
  },
76
96
  {"data action override Type",
77
97
  emptyCtx.WithBlockHeight(998).WithBlockTime(time.UnixMicro(1_000_000)),
78
- &dataAction{Data: []byte("hello2"),
98
+ dataAction{Data: []byte("hello2"),
79
99
  ActionHeader: &vm.ActionHeader{Type: "DATA_ACTION2"}},
80
- &dataAction{Data: []byte("hello2"),
100
+ dataAction{Data: []byte("hello2"),
81
101
  ActionHeader: &vm.ActionHeader{Type: "DATA_ACTION2", BlockHeight: 998, BlockTime: 1}},
82
102
  },
83
103
  {"data action override BlockHeight",
84
104
  emptyCtx.WithBlockHeight(998).WithBlockTime(time.UnixMicro(1_000_000)),
85
- &dataAction{Data: []byte("hello2"),
105
+ dataAction{Data: []byte("hello2"),
86
106
  ActionHeader: &vm.ActionHeader{BlockHeight: 999}},
87
- &dataAction{Data: []byte("hello2"),
107
+ dataAction{Data: []byte("hello2"),
88
108
  ActionHeader: &vm.ActionHeader{Type: "DATA_ACTION", BlockHeight: 999, BlockTime: 1}},
89
109
  },
90
110
  {"data action override BlockTime",
91
111
  emptyCtx.WithBlockHeight(998).WithBlockTime(time.UnixMicro(1_000_000)),
92
- &dataAction{Data: []byte("hello2"),
112
+ dataAction{Data: []byte("hello2"),
93
113
  ActionHeader: &vm.ActionHeader{BlockTime: 2}},
94
- &dataAction{Data: []byte("hello2"),
114
+ dataAction{Data: []byte("hello2"),
95
115
  ActionHeader: &vm.ActionHeader{Type: "DATA_ACTION", BlockHeight: 998, BlockTime: 2}},
96
116
  },
97
117
  {"data action override all defaults",
98
118
  emptyCtx.WithBlockHeight(998).WithBlockTime(time.UnixMicro(1_000_000)),
99
- &dataAction{Data: []byte("hello2"),
119
+ dataAction{Data: []byte("hello2"),
100
120
  ActionHeader: &vm.ActionHeader{Type: "DATA_ACTION2", BlockHeight: 999, BlockTime: 2}},
101
- &dataAction{Data: []byte("hello2"),
121
+ dataAction{Data: []byte("hello2"),
102
122
  ActionHeader: &vm.ActionHeader{Type: "DATA_ACTION2", BlockHeight: 999, BlockTime: 2}},
103
123
  },
104
124
  }
package/vm/controller.go CHANGED
@@ -2,6 +2,7 @@ package vm
2
2
 
3
3
  import (
4
4
  "context"
5
+ "fmt"
5
6
 
6
7
  sdk "github.com/cosmos/cosmos-sdk/types"
7
8
  )
@@ -34,6 +35,26 @@ var portToName = make(map[int]string)
34
35
  var nameToPort = make(map[string]int)
35
36
  var lastPort = 0
36
37
 
38
+ type protectedPortHandler struct {
39
+ inner PortHandler
40
+ }
41
+
42
+ func (h protectedPortHandler) Receive(ctx context.Context, str string) (ret string, err error) {
43
+ defer func() {
44
+ if r := recover(); r != nil {
45
+ // Propagate just the string, not the error stack or we will invite
46
+ // nondeterminism.
47
+ err = fmt.Errorf("panic: %s", r)
48
+ }
49
+ }()
50
+ ret, err = h.inner.Receive(ctx, str)
51
+ return
52
+ }
53
+
54
+ func NewProtectedPortHandler(inner PortHandler) PortHandler {
55
+ return protectedPortHandler{inner}
56
+ }
57
+
37
58
  func SetControllerContext(ctx sdk.Context) func() {
38
59
  // We are only called by the controller, so we assume that it is billing its
39
60
  // own meter usage.
@@ -49,7 +70,7 @@ func GetPort(name string) int {
49
70
 
50
71
  func RegisterPortHandler(name string, portHandler PortHandler) int {
51
72
  lastPort++
52
- portToHandler[lastPort] = portHandler
73
+ portToHandler[lastPort] = NewProtectedPortHandler(portHandler)
53
74
  portToName[lastPort] = name
54
75
  nameToPort[name] = lastPort
55
76
  return lastPort
package/vm/server.go CHANGED
@@ -4,7 +4,7 @@ import (
4
4
  "fmt"
5
5
  )
6
6
 
7
- type AgdServer struct {}
7
+ type AgdServer struct{}
8
8
 
9
9
  func NewAgdServer() *AgdServer {
10
10
  return &AgdServer{}