@agoric/cosmos 0.34.2-dev-3c8aafe.0 → 0.34.2-dev-74fbe43.0.74fbe43

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 (120) hide show
  1. package/Makefile +6 -2
  2. package/ante/ante.go +2 -2
  3. package/ante/inbound.go +1 -2
  4. package/ante/inbound_test.go +3 -1
  5. package/ante/vm_admission.go +1 -2
  6. package/app/app.go +256 -174
  7. package/app/encoding.go +6 -3
  8. package/app/export.go +50 -21
  9. package/app/genesis.go +7 -5
  10. package/app/params/encoding.go +1 -1
  11. package/app/params/proto.go +6 -4
  12. package/app/sim_test.go +11 -13
  13. package/app/txconfig/tx_config.go +169 -0
  14. package/app/upgrade.go +40 -90
  15. package/cmd/agd/agvm.go +1 -1
  16. package/cmd/agd/main.go +1 -1
  17. package/cmd/libdaemon/main.go +2 -2
  18. package/daemon/cmd/root.go +99 -30
  19. package/daemon/cmd/root_test.go +12 -27
  20. package/daemon/main.go +2 -9
  21. package/git-revision.txt +1 -1
  22. package/go.mod +130 -109
  23. package/go.sum +228 -469
  24. package/package.json +2 -2
  25. package/proto/agoric/swingset/msgs.proto +72 -9
  26. package/proto/agoric/swingset/swingset.proto +7 -2
  27. package/proto/agoric/vbank/vbank.proto +1 -1
  28. package/proto/agoric/vibc/msgs.proto +4 -0
  29. package/scripts/mockgen.sh +4 -0
  30. package/tests/e2e/vbank/vbank_test.go +172 -0
  31. package/tests/integrations/types/aminojson_test.go +214 -0
  32. package/tests/integrations/vbank/vbank_test.go +349 -0
  33. package/third_party/proto/amino/amino.proto +6 -1
  34. package/third_party/proto/cosmos/base/v1beta1/coin.proto +18 -5
  35. package/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto +4 -8
  36. package/third_party/proto/ibc/core/channel/v1/channel.proto +42 -17
  37. package/third_party/proto/ibc/core/client/v1/client.proto +48 -40
  38. package/types/address_hooks.go +2 -2
  39. package/types/address_hooks_test.go +3 -3
  40. package/types/ibc_packet.go +3 -3
  41. package/types/ibc_packet_test.go +3 -3
  42. package/types/kv_entry_helpers.go +3 -27
  43. package/types/kv_entry_helpers_test.go +2 -2
  44. package/types/legacy_address_encoder.go +58 -0
  45. package/vm/proto_json_test.go +1 -1
  46. package/vm/server.go +2 -1
  47. package/x/swingset/abci.go +2 -2
  48. package/x/swingset/client/cli/tx.go +16 -14
  49. package/x/swingset/config.go +1 -1
  50. package/x/swingset/genesis.go +2 -1
  51. package/x/swingset/handler.go +2 -1
  52. package/x/swingset/keeper/extension_snapshotter.go +14 -5
  53. package/x/swingset/keeper/extension_snapshotter_test.go +1 -1
  54. package/x/swingset/keeper/keeper.go +28 -23
  55. package/x/swingset/keeper/keeper_test.go +10 -7
  56. package/x/swingset/keeper/msg_server.go +52 -5
  57. package/x/swingset/keeper/msg_server_test.go +121 -0
  58. package/x/swingset/keeper/proposal.go +4 -0
  59. package/x/swingset/keeper/querier.go +1 -1
  60. package/x/swingset/keeper/swing_store_exports_handler.go +1 -1
  61. package/x/swingset/keeper/swing_store_exports_handler_test.go +1 -1
  62. package/x/swingset/keeper/test_utils.go +2 -2
  63. package/x/swingset/module.go +20 -22
  64. package/x/swingset/testing/queue.go +5 -2
  65. package/x/swingset/testutil/mocks.go +379 -0
  66. package/x/swingset/types/codec.go +10 -5
  67. package/x/swingset/types/default-params.go +13 -12
  68. package/x/swingset/types/expected_keepers.go +29 -4
  69. package/x/swingset/types/msgs.go +51 -36
  70. package/x/swingset/types/msgs.pb.go +561 -51
  71. package/x/swingset/types/params_test.go +21 -20
  72. package/x/swingset/types/swingset.pb.go +67 -61
  73. package/x/vbank/genesis.go +13 -9
  74. package/x/vbank/handler.go +2 -1
  75. package/x/vbank/keeper/grpc_query.go +4 -1
  76. package/x/vbank/keeper/keeper.go +108 -23
  77. package/x/vbank/keeper/querier.go +4 -1
  78. package/x/vbank/keeper/rewards.go +10 -5
  79. package/x/vbank/module.go +47 -75
  80. package/x/vbank/types/expected_keepers.go +15 -10
  81. package/x/vbank/types/key.go +3 -0
  82. package/x/vbank/types/params.go +4 -3
  83. package/x/vbank/types/vbank.pb.go +41 -40
  84. package/x/vbank/vbank.go +29 -11
  85. package/x/vbank/vbank_test.go +213 -154
  86. package/x/vibc/handler.go +2 -1
  87. package/x/vibc/keeper/keeper.go +10 -10
  88. package/x/vibc/keeper/migrations.go +1 -1
  89. package/x/vibc/keeper/triggers.go +1 -1
  90. package/x/vibc/module.go +5 -22
  91. package/x/vibc/types/codec.go +2 -1
  92. package/x/vibc/types/expected_keepers.go +7 -5
  93. package/x/vibc/types/ibc_module.go +5 -5
  94. package/x/vibc/types/msgs.go +30 -7
  95. package/x/vibc/types/msgs.pb.go +29 -25
  96. package/x/vibc/types/receiver.go +2 -2
  97. package/x/vlocalchain/handler.go +2 -1
  98. package/x/vlocalchain/keeper/keeper.go +17 -5
  99. package/x/vlocalchain/keeper/keeper_test.go +3 -2
  100. package/x/vlocalchain/types/expected_keepers.go +7 -4
  101. package/x/vlocalchain/vlocalchain_test.go +38 -26
  102. package/x/vstorage/genesis.go +10 -10
  103. package/x/vstorage/handler.go +2 -1
  104. package/x/vstorage/keeper/grpc_query.go +1 -1
  105. package/x/vstorage/keeper/keeper.go +72 -50
  106. package/x/vstorage/keeper/keeper_test.go +74 -54
  107. package/x/vstorage/keeper/querier.go +1 -1
  108. package/x/vstorage/module.go +27 -13
  109. package/x/vstorage/testing/queue.go +5 -3
  110. package/x/vstorage/vstorage.go +10 -9
  111. package/x/vstorage/vstorage_test.go +24 -18
  112. package/x/vtransfer/genesis.go +1 -3
  113. package/x/vtransfer/handler.go +3 -2
  114. package/x/vtransfer/ibc_middleware.go +5 -5
  115. package/x/vtransfer/ibc_middleware_test.go +43 -29
  116. package/x/vtransfer/keeper/keeper.go +35 -33
  117. package/x/vtransfer/module.go +8 -11
  118. package/x/vtransfer/types/expected_keepers.go +3 -3
  119. package/x/vtransfer/utils_test.go +26 -11
  120. package/daemon/cmd/testnet.go +0 -539
@@ -4,6 +4,7 @@ import (
4
4
  "context"
5
5
  "encoding/json"
6
6
 
7
+ "cosmossdk.io/core/appmodule"
7
8
  "github.com/grpc-ecosystem/grpc-gateway/runtime"
8
9
  "github.com/spf13/cobra"
9
10
 
@@ -15,14 +16,16 @@ import (
15
16
  cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
16
17
  "github.com/cosmos/cosmos-sdk/types/module"
17
18
 
18
- abci "github.com/cometbft/cometbft/abci/types"
19
19
  sdk "github.com/cosmos/cosmos-sdk/types"
20
20
  )
21
21
 
22
22
  // type check to ensure the interface is properly implemented
23
23
  var (
24
- _ module.AppModule = AppModule{}
25
- _ module.AppModuleBasic = AppModuleBasic{}
24
+ _ module.AppModule = AppModule{}
25
+ _ module.HasGenesis = AppModule{}
26
+ _ module.AppModuleBasic = AppModuleBasic{}
27
+ _ appmodule.HasBeginBlocker = AppModule{}
28
+ _ appmodule.HasEndBlocker = AppModule{}
26
29
  )
27
30
 
28
31
  // app module Basics object
@@ -75,6 +78,12 @@ type AppModule struct {
75
78
  keeper Keeper
76
79
  }
77
80
 
81
+ // IsAppModule implements the appmodule.AppModule interface.
82
+ func (am AppModule) IsAppModule() {}
83
+
84
+ // IsOnePerModuleType is a marker function just indicates that this is a one-per-module type.
85
+ func (am AppModule) IsOnePerModuleType() {}
86
+
78
87
  // NewAppModule creates a new AppModule Object
79
88
  func NewAppModule(k Keeper) AppModule {
80
89
  am := AppModule{
@@ -97,23 +106,28 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
97
106
 
98
107
  func (AppModule) ConsensusVersion() uint64 { return 1 }
99
108
 
100
- func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {
101
- am.keeper.NewChangeBatch(ctx)
109
+ func (am AppModule) BeginBlock(ctx context.Context) error {
110
+ return am.keeper.NewChangeBatch(sdk.UnwrapSDKContext(ctx))
102
111
  }
103
112
 
104
- func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate {
105
- am.keeper.FlushChangeEvents(ctx)
106
- // Prevent Cosmos SDK internal errors.
107
- return []abci.ValidatorUpdate{}
113
+ func (am AppModule) EndBlock(ctx context.Context) error {
114
+ return am.keeper.FlushChangeEvents(sdk.UnwrapSDKContext(ctx))
108
115
  }
109
116
 
110
- func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate {
117
+ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) {
111
118
  var genesisState types.GenesisState
112
- cdc.MustUnmarshalJSON(data, &genesisState)
113
- return InitGenesis(ctx, am.keeper, &genesisState)
119
+ if err := cdc.UnmarshalJSON(data, &genesisState); err != nil {
120
+ panic(err)
121
+ }
122
+ if err := InitGenesis(ctx, am.keeper, &genesisState); err != nil {
123
+ panic(err)
124
+ }
114
125
  }
115
126
 
116
127
  func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
117
- gs := ExportGenesis(ctx, am.keeper)
128
+ gs, err := ExportGenesis(ctx, am.keeper)
129
+ if err != nil {
130
+ panic(err)
131
+ }
118
132
  return cdc.MustMarshalJSON(gs)
119
133
  }
@@ -3,12 +3,14 @@ package testing
3
3
  import (
4
4
  "fmt"
5
5
 
6
+ sdkmath "cosmossdk.io/math"
7
+ storetypes "cosmossdk.io/store/types"
6
8
  keeper "github.com/Agoric/agoric-sdk/golang/cosmos/x/vstorage/keeper"
7
9
  sdk "github.com/cosmos/cosmos-sdk/types"
8
10
  )
9
11
 
10
12
  func GetQueueItems(ctx sdk.Context, vstorageKeeper keeper.Keeper, queuePath string) ([]string, error) {
11
- unlimitedCtx := ctx.WithGasMeter(sdk.NewInfiniteGasMeter())
13
+ unlimitedCtx := ctx.WithGasMeter(storetypes.NewInfiniteGasMeter())
12
14
  head, err := vstorageKeeper.GetIntValue(unlimitedCtx, queuePath+".head")
13
15
  if err != nil {
14
16
  return nil, err
@@ -21,14 +23,14 @@ func GetQueueItems(ctx sdk.Context, vstorageKeeper keeper.Keeper, queuePath stri
21
23
  values := make([]string, length)
22
24
  var i int64
23
25
  for i = 0; i < length; i++ {
24
- path := fmt.Sprintf("%s.%s", queuePath, head.Add(sdk.NewInt(i)).String())
26
+ path := fmt.Sprintf("%s.%s", queuePath, head.Add(sdkmath.NewInt(i)).String())
25
27
  values[i] = vstorageKeeper.GetEntry(unlimitedCtx, path).StringValue()
26
28
  }
27
29
  return values, nil
28
30
  }
29
31
 
30
32
  func ResetQueue(ctx sdk.Context, vstorageKeeper keeper.Keeper, queuePath string) error {
31
- unlimitedCtx := ctx.WithGasMeter(sdk.NewInfiniteGasMeter())
33
+ unlimitedCtx := ctx.WithGasMeter(storetypes.NewInfiniteGasMeter())
32
34
  vstorageKeeper.RemoveEntriesWithPrefix(unlimitedCtx, queuePath)
33
35
  return nil
34
36
  }
@@ -6,6 +6,7 @@ import (
6
6
  "errors"
7
7
  "fmt"
8
8
 
9
+ storetypes "cosmossdk.io/store/types"
9
10
  sdk "github.com/cosmos/cosmos-sdk/types"
10
11
 
11
12
  agoric "github.com/Agoric/agoric-sdk/golang/cosmos/types"
@@ -54,7 +55,7 @@ func (sh vstorageHandler) Receive(cctx context.Context, str string) (ret string,
54
55
  defer func() {
55
56
  if r := recover(); r != nil {
56
57
  switch rType := r.(type) {
57
- case sdk.ErrorOutOfGas:
58
+ case storetypes.ErrorOutOfGas:
58
59
  err = fmt.Errorf(
59
60
  "out of gas in location: %v; gasUsed: %d",
60
61
  rType.Descriptor, ctx.GasMeter().GasConsumed(),
@@ -176,10 +177,10 @@ func (sh vstorageHandler) Receive(cctx context.Context, str string) (ret string,
176
177
  return
177
178
  }
178
179
  children := keeper.GetChildren(ctx, path)
179
- if children.Children == nil {
180
+ if children == nil {
180
181
  return "[]", nil
181
182
  }
182
- bytes, err := json.Marshal(children.Children)
183
+ bytes, err := json.Marshal(children)
183
184
  if err != nil {
184
185
  return "", err
185
186
  }
@@ -192,8 +193,8 @@ func (sh vstorageHandler) Receive(cctx context.Context, str string) (ret string,
192
193
  return
193
194
  }
194
195
  children := keeper.GetChildren(ctx, path)
195
- entries := make([]agoric.KVEntry, len(children.Children))
196
- for i, child := range children.Children {
196
+ entries := make([]agoric.KVEntry, len(children))
197
+ for i, child := range children {
197
198
  entry := keeper.GetEntry(ctx, fmt.Sprintf("%s.%s", path, child))
198
199
  if !entry.HasValue() {
199
200
  entries[i] = agoric.NewKVEntryWithNoValue(child)
@@ -214,8 +215,8 @@ func (sh vstorageHandler) Receive(cctx context.Context, str string) (ret string,
214
215
  return
215
216
  }
216
217
  children := keeper.GetChildren(ctx, path)
217
- vals := make([]*string, len(children.Children))
218
- for i, child := range children.Children {
218
+ vals := make([]*string, len(children))
219
+ for i, child := range children {
219
220
  vals[i] = keeper.GetEntry(ctx, fmt.Sprintf("%s.%s", path, child)).Value()
220
221
  }
221
222
  bytes, err := json.Marshal(vals)
@@ -231,10 +232,10 @@ func (sh vstorageHandler) Receive(cctx context.Context, str string) (ret string,
231
232
  return
232
233
  }
233
234
  children := keeper.GetChildren(ctx, path)
234
- if children.Children == nil {
235
+ if children == nil {
235
236
  return "0", nil
236
237
  }
237
- return fmt.Sprint(len(children.Children)), nil
238
+ return fmt.Sprint(len(children)), nil
238
239
  }
239
240
 
240
241
  return "", errors.New("Unrecognized msg.Method " + msg.Method)
@@ -8,16 +8,19 @@ import (
8
8
  "strings"
9
9
  "testing"
10
10
 
11
+ storemetrics "cosmossdk.io/store/metrics"
12
+
11
13
  "github.com/Agoric/agoric-sdk/golang/cosmos/x/vstorage/types"
12
14
 
13
- "github.com/cosmos/cosmos-sdk/store"
14
- storetypes "github.com/cosmos/cosmos-sdk/store/types"
15
+ "cosmossdk.io/store"
16
+ storetypes "cosmossdk.io/store/types"
17
+ "github.com/cosmos/cosmos-sdk/runtime"
15
18
  sdk "github.com/cosmos/cosmos-sdk/types"
16
19
 
20
+ "cosmossdk.io/log"
17
21
  agorictypes "github.com/Agoric/agoric-sdk/golang/cosmos/types"
18
- dbm "github.com/cometbft/cometbft-db"
19
- "github.com/cometbft/cometbft/libs/log"
20
22
  tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
23
+ dbm "github.com/cosmos/cosmos-db"
21
24
  )
22
25
 
23
26
  var (
@@ -32,22 +35,23 @@ type testKit struct {
32
35
  keeper Keeper
33
36
  handler vstorageHandler
34
37
  ctx sdk.Context
35
- cctx context.Context
36
38
  }
37
39
 
38
40
  func makeTestKit() testKit {
39
- keeper := NewKeeper(storeKey)
41
+ kvStoreService := runtime.NewKVStoreService(storeKey)
42
+
43
+ keeper := NewKeeper(storeKey.Name(), kvStoreService)
40
44
  db := dbm.NewMemDB()
41
- ms := store.NewCommitMultiStore(db)
45
+ logger := log.NewNopLogger()
46
+ ms := store.NewCommitMultiStore(db, logger, storemetrics.NewNoOpMetrics())
42
47
  ms.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db)
43
48
  err := ms.LoadLatestVersion()
44
49
  if err != nil {
45
50
  panic(err)
46
51
  }
47
52
  ctx := sdk.NewContext(ms, tmproto.Header{}, false, log.NewNopLogger())
48
- cctx := sdk.WrapSDKContext(ctx)
49
53
  handler := vstorageHandler{keeper}
50
- return testKit{keeper, handler, ctx, cctx}
54
+ return testKit{keeper, handler, ctx}
51
55
  }
52
56
 
53
57
  func callReceive(
@@ -68,7 +72,7 @@ func callReceive(
68
72
 
69
73
  func TestGetAndHas(t *testing.T) {
70
74
  kit := makeTestKit()
71
- keeper, handler, ctx, cctx := kit.keeper, kit.handler, kit.ctx, kit.cctx
75
+ keeper, handler, ctx := kit.keeper, kit.handler, kit.ctx
72
76
 
73
77
  keeper.SetStorage(ctx, agorictypes.NewKVEntry("foo", "bar"))
74
78
  keeper.SetStorage(ctx, agorictypes.NewKVEntry("empty", ""))
@@ -92,8 +96,8 @@ func TestGetAndHas(t *testing.T) {
92
96
  {label: "extra args", args: []interface{}{"foo", "bar"}, errContains: ptr(`extra`)},
93
97
  }
94
98
  for _, desc := range cases {
95
- got, err := callReceive(handler, cctx, "get", desc.args)
96
- has, hasErr := callReceive(handler, cctx, "has", desc.args)
99
+ got, err := callReceive(handler, ctx, "get", desc.args)
100
+ has, hasErr := callReceive(handler, ctx, "has", desc.args)
97
101
 
98
102
  // Verify get/has error agreement.
99
103
  if (err == nil) != (hasErr == nil) {
@@ -125,7 +129,7 @@ func TestGetAndHas(t *testing.T) {
125
129
 
126
130
  func doTestSet(t *testing.T, method string, expectNotify bool) {
127
131
  kit := makeTestKit()
128
- keeper, handler, ctx, cctx := kit.keeper, kit.handler, kit.ctx, kit.cctx
132
+ keeper, handler, ctx := kit.keeper, kit.handler, kit.ctx
129
133
 
130
134
  type testCase struct {
131
135
  label string
@@ -183,7 +187,7 @@ func doTestSet(t *testing.T, method string, expectNotify bool) {
183
187
  stateChangeEvent("qux", "A"),
184
188
  }
185
189
  for _, desc := range cases {
186
- got, err := callReceive(handler, cctx, method, desc.args)
190
+ got, err := callReceive(handler, ctx, method, desc.args)
187
191
 
188
192
  if desc.errContains == nil {
189
193
  if err != nil {
@@ -208,7 +212,7 @@ func doTestSet(t *testing.T, method string, expectNotify bool) {
208
212
  }
209
213
  wantBackBytes, _ := json.Marshal(value)
210
214
  wantBack := string(wantBackBytes)
211
- gotBack, err := callReceive(handler, cctx, "get", []interface{}{path})
215
+ gotBack, err := callReceive(handler, ctx, "get", []interface{}{path})
212
216
  if err != nil {
213
217
  t.Errorf("%s %s read back %q: got unexpected error %v", method, desc.label, path, err)
214
218
  } else if gotBack != wantBack {
@@ -226,7 +230,9 @@ func doTestSet(t *testing.T, method string, expectNotify bool) {
226
230
  if got := ctx.EventManager().Events(); !reflect.DeepEqual(got, sdk.Events{}) {
227
231
  t.Errorf("%s got unexpected events before flush %#v", method, got)
228
232
  }
229
- keeper.FlushChangeEvents(ctx)
233
+ if err := keeper.FlushChangeEvents(ctx); err != nil {
234
+ t.Errorf("%s got unexpected flush error %v", method, err)
235
+ }
230
236
  if !expectNotify {
231
237
  if got := ctx.EventManager().Events(); !reflect.DeepEqual(got, sdk.Events{}) {
232
238
  t.Errorf("%s got unexpected events after flush %#v", method, got)
@@ -257,7 +263,7 @@ func TestSetWithoutNotify(t *testing.T) {
257
263
 
258
264
  func TestEntries(t *testing.T) {
259
265
  kit := makeTestKit()
260
- keeper, handler, ctx, cctx := kit.keeper, kit.handler, kit.ctx, kit.cctx
266
+ keeper, handler, ctx := kit.keeper, kit.handler, kit.ctx
261
267
 
262
268
  keeper.SetStorage(ctx, agorictypes.NewKVEntry("key1", "value1"))
263
269
  keeper.SetStorage(ctx, agorictypes.NewKVEntry("key1.child1.grandchild1", "value1grandchild"))
@@ -286,7 +292,7 @@ func TestEntries(t *testing.T) {
286
292
  {path: "nosuchkey", want: `[]`},
287
293
  }
288
294
  for _, desc := range cases {
289
- got, err := callReceive(handler, cctx, "entries", []interface{}{desc.path})
295
+ got, err := callReceive(handler, ctx, "entries", []interface{}{desc.path})
290
296
  if got != desc.want {
291
297
  t.Errorf("%s: got %q; want %q", desc.path, got, desc.want)
292
298
  }
@@ -4,7 +4,6 @@ import (
4
4
  "fmt"
5
5
 
6
6
  "github.com/Agoric/agoric-sdk/golang/cosmos/x/vtransfer/types"
7
- abci "github.com/cometbft/cometbft/abci/types"
8
7
  sdk "github.com/cosmos/cosmos-sdk/types"
9
8
  )
10
9
 
@@ -23,9 +22,8 @@ func DefaultGenesisState() *types.GenesisState {
23
22
  return &types.GenesisState{}
24
23
  }
25
24
 
26
- func InitGenesis(ctx sdk.Context, keeper Keeper, data *types.GenesisState) []abci.ValidatorUpdate {
25
+ func InitGenesis(ctx sdk.Context, keeper Keeper, data *types.GenesisState) {
27
26
  keeper.SetWatchedAddresses(ctx, data.GetWatchedAddresses())
28
- return []abci.ValidatorUpdate{}
29
27
  }
30
28
 
31
29
  func ExportGenesis(ctx sdk.Context, k Keeper) *types.GenesisState {
@@ -3,15 +3,16 @@ package vtransfer
3
3
  import (
4
4
  "fmt"
5
5
 
6
+ sdkioerrors "cosmossdk.io/errors"
6
7
  "github.com/Agoric/agoric-sdk/golang/cosmos/x/vtransfer/keeper"
8
+ "github.com/cosmos/cosmos-sdk/baseapp"
7
9
  sdk "github.com/cosmos/cosmos-sdk/types"
8
10
 
9
- sdkioerrors "cosmossdk.io/errors"
10
11
  sdktypeserrors "github.com/cosmos/cosmos-sdk/types/errors"
11
12
  )
12
13
 
13
14
  // NewHandler returns a handler for "vtransfer" type messages.
14
- func NewHandler(keeper keeper.Keeper) sdk.Handler {
15
+ func NewHandler(keeper keeper.Keeper) baseapp.MsgServiceHandler {
15
16
  return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
16
17
  switch msg := msg.(type) {
17
18
  default:
@@ -3,11 +3,11 @@ package vtransfer
3
3
  import (
4
4
  "github.com/Agoric/agoric-sdk/golang/cosmos/x/vtransfer/keeper"
5
5
  sdk "github.com/cosmos/cosmos-sdk/types"
6
- capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
7
- clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
8
- channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
9
- porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types"
10
- "github.com/cosmos/ibc-go/v7/modules/core/exported"
6
+ capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"
7
+ clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
8
+ channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
9
+ porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types"
10
+ "github.com/cosmos/ibc-go/v8/modules/core/exported"
11
11
  )
12
12
 
13
13
  // IBCMiddleware (https://ibc.cosmos.network/main/ibc/apps/ibcmodule) forwards
@@ -10,12 +10,12 @@ import (
10
10
  "testing"
11
11
  "text/template"
12
12
 
13
+ "cosmossdk.io/log"
14
+ "cosmossdk.io/store"
13
15
  app "github.com/Agoric/agoric-sdk/golang/cosmos/app"
14
16
  "github.com/Agoric/agoric-sdk/golang/cosmos/vm"
15
- dbm "github.com/cometbft/cometbft-db"
16
- "github.com/cometbft/cometbft/libs/log"
17
+ dbm "github.com/cosmos/cosmos-db"
17
18
  "github.com/cosmos/cosmos-sdk/codec"
18
- "github.com/cosmos/cosmos-sdk/store"
19
19
  "github.com/cosmos/cosmos-sdk/testutil/sims"
20
20
  "github.com/cosmos/cosmos-sdk/testutil/testdata"
21
21
  "github.com/iancoleman/orderedmap"
@@ -26,16 +26,18 @@ import (
26
26
  swingsettypes "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/types"
27
27
  vibctypes "github.com/Agoric/agoric-sdk/golang/cosmos/x/vibc/types"
28
28
 
29
+ sdkmath "cosmossdk.io/math"
30
+ abci "github.com/cometbft/cometbft/abci/types"
29
31
  tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
30
32
  "github.com/cosmos/cosmos-sdk/baseapp"
31
33
  sdk "github.com/cosmos/cosmos-sdk/types"
32
34
  authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
33
35
  banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
34
- packetforwardtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/types"
35
- ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
36
- channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
37
- ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
38
- ibctesting "github.com/cosmos/ibc-go/v7/testing"
36
+ packetforwardtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8/packetforward/types"
37
+ ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
38
+ channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
39
+ ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
40
+ ibctesting "github.com/cosmos/ibc-go/v8/testing"
39
41
  )
40
42
 
41
43
  const (
@@ -106,7 +108,7 @@ func (s *IntegrationTestSuite) nextChannelOffset(instance int) int {
106
108
  return offset
107
109
  }
108
110
 
109
- func SetupAgoricTestingApp(instance int) TestingAppMaker {
111
+ func SetupAgoricTestingApp(t *testing.T, instance int) TestingAppMaker {
110
112
  return func() (ibctesting.TestingApp, map[string]json.RawMessage) {
111
113
  db := dbm.NewMemDB()
112
114
  mockController := func(ctx context.Context, needReply bool, jsonRequest string) (jsonReply string, err error) {
@@ -122,9 +124,9 @@ func SetupAgoricTestingApp(instance int) TestingAppMaker {
122
124
  jsonReply = `true`
123
125
  return jsonReply, nil
124
126
  }
125
- appd := app.NewAgoricApp(mockController, vm.NewAgdServer(), log.TestingLogger(), db, nil,
127
+ appd := app.NewAgoricApp(mockController, vm.NewAgdServer(), log.NewTestLogger(t), db, nil,
126
128
  true, sims.EmptyAppOptions{}, interBlockCacheOpt())
127
- genesisState := app.NewDefaultGenesisState()
129
+ genesisState := app.NewDefaultGenesisState(appd.AppCodec(), appd.BasicModuleManager)
128
130
 
129
131
  t := template.Must(template.New("").Parse(`
130
132
  {
@@ -146,7 +148,7 @@ func SetupAgoricTestingApp(instance int) TestingAppMaker {
146
148
  "connections": [],
147
149
  "next_connection_sequence": "{{.nextConnectionSequence}}",
148
150
  "params": {
149
- "max_expected_time_per_block": "30000000000"
151
+ "max_expected_time_per_block": "30000000000"
150
152
  }
151
153
  },
152
154
  "channel_genesis": {
@@ -155,6 +157,15 @@ func SetupAgoricTestingApp(instance int) TestingAppMaker {
155
157
  "channels": [],
156
158
  "commitments": [],
157
159
  "next_channel_sequence": "{{.nextChannelSequence}}",
160
+ "params": {
161
+ "upgrade_timeout": {
162
+ "height": {
163
+ "revision_number": "0",
164
+ "revision_height": "0"
165
+ },
166
+ "timestamp": "600000000000"
167
+ }
168
+ },
158
169
  "receipts": [],
159
170
  "recv_sequences": [],
160
171
  "send_sequences": []
@@ -184,14 +195,14 @@ func (s *IntegrationTestSuite) SetupTest() {
184
195
 
185
196
  chains := make(map[string]*ibctesting.TestChain)
186
197
  for i := 0; i < 3; i++ {
187
- ibctesting.DefaultTestingAppInit = SetupAgoricTestingApp(i)
198
+ ibctesting.DefaultTestingAppInit = SetupAgoricTestingApp(s.T(), i)
188
199
 
189
200
  chainID := ibctesting.GetChainID(i)
190
201
  chain := ibctesting.NewTestChain(s.T(), s.coordinator, chainID)
191
202
 
192
203
  balance := banktypes.Balance{
193
204
  Address: chain.SenderAccount.GetAddress().String(),
194
- Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000000000000))),
205
+ Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100000000000000))),
195
206
  }
196
207
 
197
208
  // create application and override files in the IBC test chain
@@ -353,7 +364,7 @@ func (s *IntegrationTestSuite) TransferFromEndpoint(
353
364
  src *ibctesting.Endpoint,
354
365
  data ibctransfertypes.FungibleTokenPacketData,
355
366
  ) error {
356
- tokenAmt, ok := sdk.NewIntFromString(data.Amount)
367
+ tokenAmt, ok := sdkmath.NewIntFromString(data.Amount)
357
368
  s.Require().True(ok)
358
369
 
359
370
  timeoutHeight := src.Counterparty.Chain.GetTimeoutHeight()
@@ -416,11 +427,11 @@ func (s *IntegrationTestSuite) overrideSendPacketData(cdc codec.Codec, data []by
416
427
 
417
428
  func (s *IntegrationTestSuite) mintToAddress(chain *ibctesting.TestChain, addr sdk.AccAddress, denom, amount string) {
418
429
  app := s.GetApp(chain)
419
- tokenAmt, ok := sdk.NewIntFromString(amount)
430
+ tokenAmt, ok := sdkmath.NewIntFromString(amount)
420
431
  s.Require().True(ok)
421
432
  intAmt, err := strconv.ParseInt(amount, 10, 64)
422
433
  s.Require().NoError(err)
423
- coins := sdk.NewCoins(sdk.NewCoin(denom, tokenAmt.Mul(sdk.NewInt(intAmt))))
434
+ coins := sdk.NewCoins(sdk.NewCoin(denom, tokenAmt.Mul(sdkmath.NewInt(intAmt))))
424
435
  err = app.BankKeeper.MintCoins(chain.GetContext(), ibctransfertypes.ModuleName, coins)
425
436
  s.Require().NoError(err)
426
437
  err = app.BankKeeper.SendCoinsFromModuleToAccount(chain.GetContext(), ibctransfertypes.ModuleName, addr, coins)
@@ -577,13 +588,13 @@ func (s *IntegrationTestSuite) TestHops() {
577
588
  err = s.TransferFromEndpoint(sendContext, paths[0].EndpointA, transferData)
578
589
  s.Require().NoError(err)
579
590
 
580
- sendPacket, err := ParsePacketFromEvents(sendContext.EventManager().Events())
591
+ sendPacket, err := ParsePacketFromEvents(sendContext.EventManager().ABCIEvents())
581
592
  s.Require().NoError(err)
582
593
 
583
594
  s.coordinator.CommitBlock(s.chainA)
584
595
 
585
596
  // Relay the packet through the intermediaries to the final destination.
586
- var packetRes *sdk.Result
597
+ var packetRes *abci.ExecTxResult
587
598
  var writeAcknowledgementHeight, writeAcknowledgementTime int64
588
599
  for pathIdx := 0; pathIdx < hops; pathIdx += 1 {
589
600
  nextPath := paths[pathIdx]
@@ -611,7 +622,8 @@ func (s *IntegrationTestSuite) TestHops() {
611
622
  }
612
623
 
613
624
  // The PFM should have received the packet and advertised a send toward the last path.
614
- sendPacket, err = ParsePacketFromEvents(packetRes.GetEvents())
625
+
626
+ sendPacket, err = ParsePacketFromEvents(packetRes.Events)
615
627
  s.Require().NoError(err)
616
628
  }
617
629
 
@@ -621,10 +633,10 @@ func (s *IntegrationTestSuite) TestHops() {
621
633
  expectedAck := channeltypes.NewResultAcknowledgement([]byte{1})
622
634
 
623
635
  {
624
- var events sdk.Events
636
+ var events []abci.Event
625
637
  var ackData []byte
626
638
  if packetRes != nil {
627
- events = packetRes.GetEvents()
639
+ events = packetRes.Events
628
640
  ackData, err = ParseAckFromEvents(events)
629
641
  }
630
642
  if tc.receiverIsTarget {
@@ -636,7 +648,7 @@ func (s *IntegrationTestSuite) TestHops() {
636
648
  err = s.GetApp(s.chainB).VtransferKeeper.ReceiveWriteAcknowledgement(vmAckContext, sendPacket, expectedAck)
637
649
  s.Require().NoError(err)
638
650
 
639
- events = vmAckContext.EventManager().Events()
651
+ events = vmAckContext.EventManager().ABCIEvents()
640
652
  ackData, err = ParseAckFromEvents(events)
641
653
  }
642
654
 
@@ -685,10 +697,10 @@ func (s *IntegrationTestSuite) TestHops() {
685
697
  ackRes, err := acknowledgePacketWithResult(priorPath.EndpointA, ackedPacket, ack.Acknowledgement())
686
698
  s.Require().NoError(err)
687
699
 
688
- ackedPacket, err = ParsePacketFromFilteredEvents(ackRes.GetEvents(), channeltypes.EventTypeWriteAck)
700
+ ackedPacket, err = ParsePacketFromFilteredEvents(ackRes.Events, channeltypes.EventTypeWriteAck)
689
701
  s.Require().NoError(err)
690
702
 
691
- ackData, err := ParseAckFromEvents(ackRes.GetEvents())
703
+ ackData, err := ParseAckFromEvents(ackRes.Events)
692
704
  s.Require().NoError(err)
693
705
  ack = vibctypes.NewRawAcknowledgement(ackData)
694
706
 
@@ -712,13 +724,15 @@ func (s *IntegrationTestSuite) TestHops() {
712
724
  // Verify the resulting events.
713
725
  gotEvents := 0
714
726
  expectedEvents := 2
715
- for _, event := range ackRes.GetEvents() {
727
+ for _, event := range ackRes.Events {
716
728
  if event.Type == ibctransfertypes.EventTypePacket {
717
729
  gotEvents += 1
718
- if gotEvents == 2 && len(event.Attributes) == 1 {
730
+ if gotEvents == 2 && len(event.Attributes) == 2 {
719
731
  // We get a trailing event with a single "success" attribute.
720
732
  s.Require().Equal(ibctransfertypes.AttributeKeyAckSuccess, string(event.Attributes[0].Key))
721
733
  s.Require().Equal("\x01", string(event.Attributes[0].Value))
734
+ s.Require().Equal("msg_index", string(event.Attributes[1].Key))
735
+ s.Require().Equal("0", string(event.Attributes[1].Value))
722
736
  continue
723
737
  }
724
738
  expectedAttrs := 6
@@ -793,7 +807,7 @@ func (s *IntegrationTestSuite) TestHops() {
793
807
  res, err := s.GetApp(s.chainB).BankKeeper.AllBalances(s.chainB.GetContext(), req)
794
808
  s.Require().NoError(err)
795
809
 
796
- amt, ok := sdk.NewIntFromString(transferData.Amount)
810
+ amt, ok := sdkmath.NewIntFromString(transferData.Amount)
797
811
  s.Require().True(ok)
798
812
 
799
813
  // Decode the denom trace to get the denom hash.
@@ -805,7 +819,7 @@ func (s *IntegrationTestSuite) TestHops() {
805
819
  receivedDenom := `ibc/` + hashRes.Hash
806
820
 
807
821
  coins := sdk.NewCoins(sdk.NewCoin(receivedDenom, amt))
808
- s.Require().True(coins.IsEqual(res.Balances))
822
+ s.Require().True(coins.Equal(res.Balances))
809
823
  })
810
824
  }
811
825
  }