@agoric/cosmos 0.35.0-u21.0 → 0.35.0-u22.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.
- package/CHANGELOG.md +11 -187
- package/Makefile +2 -2
- package/ante/ante.go +2 -2
- package/ante/inbound.go +1 -2
- package/ante/inbound_test.go +3 -1
- package/ante/vm_admission.go +1 -2
- package/app/app.go +255 -174
- package/app/encoding.go +6 -3
- package/app/export.go +50 -21
- package/app/genesis.go +7 -5
- package/app/params/encoding.go +1 -1
- package/app/params/proto.go +6 -4
- package/app/sim_test.go +11 -13
- package/app/txconfig/tx_config.go +169 -0
- package/app/upgrade.go +52 -97
- package/app/upgrade_test.go +1 -1
- package/cmd/agd/agvm.go +1 -1
- package/cmd/agd/main.go +1 -1
- package/cmd/libdaemon/main.go +2 -2
- package/daemon/cmd/root.go +99 -30
- package/daemon/cmd/root_test.go +12 -27
- package/daemon/main.go +2 -9
- package/git-revision.txt +1 -1
- package/go.mod +129 -109
- package/go.sum +228 -469
- package/package.json +2 -2
- package/proto/agoric/swingset/msgs.proto +46 -9
- package/proto/agoric/swingset/swingset.proto +7 -2
- package/proto/agoric/vbank/vbank.proto +1 -1
- package/proto/agoric/vibc/msgs.proto +4 -0
- package/tests/e2e/vbank/vbank_test.go +172 -0
- package/tests/integrations/types/aminojson_test.go +214 -0
- package/tests/integrations/vbank/vbank_test.go +348 -0
- package/third_party/proto/amino/amino.proto +6 -1
- package/third_party/proto/cosmos/base/v1beta1/coin.proto +18 -5
- package/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto +4 -8
- package/third_party/proto/ibc/core/channel/v1/channel.proto +42 -17
- package/third_party/proto/ibc/core/client/v1/client.proto +48 -40
- package/types/address_hooks.go +2 -2
- package/types/address_hooks_test.go +3 -3
- package/types/ibc_packet.go +3 -3
- package/types/ibc_packet_test.go +3 -3
- package/types/kv_entry_helpers.go +3 -3
- package/types/kv_entry_helpers_test.go +2 -2
- package/types/legacy_address_encoder.go +58 -0
- package/vm/proto_json_test.go +1 -1
- package/vm/server.go +2 -1
- package/x/swingset/abci.go +2 -2
- package/x/swingset/client/cli/tx.go +16 -14
- package/x/swingset/config.go +1 -1
- package/x/swingset/genesis.go +2 -1
- package/x/swingset/handler.go +2 -1
- package/x/swingset/keeper/extension_snapshotter.go +14 -5
- package/x/swingset/keeper/extension_snapshotter_test.go +1 -1
- package/x/swingset/keeper/keeper.go +21 -17
- package/x/swingset/keeper/keeper_test.go +10 -7
- package/x/swingset/keeper/msg_server.go +26 -5
- package/x/swingset/keeper/swing_store_exports_handler.go +1 -1
- package/x/swingset/keeper/swing_store_exports_handler_test.go +1 -1
- package/x/swingset/module.go +20 -22
- package/x/swingset/types/codec.go +10 -5
- package/x/swingset/types/default-params.go +13 -12
- package/x/swingset/types/expected_keepers.go +5 -4
- package/x/swingset/types/msgs.go +50 -36
- package/x/swingset/types/msgs.pb.go +60 -51
- package/x/swingset/types/params_test.go +21 -20
- package/x/swingset/types/swingset.pb.go +67 -61
- package/x/vbank/genesis.go +12 -8
- package/x/vbank/handler.go +2 -1
- package/x/vbank/keeper/grpc_query.go +4 -1
- package/x/vbank/keeper/keeper.go +108 -23
- package/x/vbank/keeper/querier.go +4 -1
- package/x/vbank/keeper/rewards.go +6 -2
- package/x/vbank/module.go +47 -75
- package/x/vbank/types/expected_keepers.go +15 -10
- package/x/vbank/types/key.go +3 -0
- package/x/vbank/types/params.go +4 -3
- package/x/vbank/types/vbank.pb.go +41 -40
- package/x/vbank/vbank.go +25 -10
- package/x/vbank/vbank_test.go +213 -154
- package/x/vibc/handler.go +2 -1
- package/x/vibc/keeper/keeper.go +10 -10
- package/x/vibc/keeper/migrations.go +1 -1
- package/x/vibc/keeper/triggers.go +1 -1
- package/x/vibc/module.go +5 -22
- package/x/vibc/types/codec.go +2 -1
- package/x/vibc/types/expected_keepers.go +7 -5
- package/x/vibc/types/ibc_module.go +5 -5
- package/x/vibc/types/msgs.go +30 -7
- package/x/vibc/types/msgs.pb.go +29 -25
- package/x/vibc/types/receiver.go +2 -2
- package/x/vlocalchain/handler.go +2 -1
- package/x/vlocalchain/keeper/keeper.go +17 -5
- package/x/vlocalchain/keeper/keeper_test.go +3 -2
- package/x/vlocalchain/types/expected_keepers.go +7 -4
- package/x/vlocalchain/vlocalchain_test.go +38 -26
- package/x/vstorage/genesis.go +10 -10
- package/x/vstorage/handler.go +2 -1
- package/x/vstorage/keeper/keeper.go +68 -46
- package/x/vstorage/keeper/keeper_test.go +35 -19
- package/x/vstorage/module.go +27 -13
- package/x/vstorage/testing/queue.go +5 -3
- package/x/vstorage/vstorage.go +2 -1
- package/x/vstorage/vstorage_test.go +21 -17
- package/x/vtransfer/genesis.go +1 -3
- package/x/vtransfer/handler.go +3 -2
- package/x/vtransfer/ibc_middleware.go +5 -5
- package/x/vtransfer/ibc_middleware_test.go +43 -29
- package/x/vtransfer/keeper/keeper.go +35 -33
- package/x/vtransfer/module.go +8 -11
- package/x/vtransfer/types/expected_keepers.go +3 -3
- package/x/vtransfer/utils_test.go +26 -11
- package/daemon/cmd/testnet.go +0 -539
|
@@ -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
|
-
"
|
|
14
|
-
storetypes "
|
|
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
|
-
|
|
41
|
+
kvStoreService := runtime.NewKVStoreService(storeKey)
|
|
42
|
+
|
|
43
|
+
keeper := NewKeeper(storeKey.Name(), kvStoreService)
|
|
40
44
|
db := dbm.NewMemDB()
|
|
41
|
-
|
|
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
|
|
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
|
|
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,
|
|
96
|
-
has, hasErr := callReceive(handler,
|
|
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
|
|
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,
|
|
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,
|
|
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 {
|
|
@@ -257,7 +261,7 @@ func TestSetWithoutNotify(t *testing.T) {
|
|
|
257
261
|
|
|
258
262
|
func TestEntries(t *testing.T) {
|
|
259
263
|
kit := makeTestKit()
|
|
260
|
-
keeper, handler, ctx
|
|
264
|
+
keeper, handler, ctx := kit.keeper, kit.handler, kit.ctx
|
|
261
265
|
|
|
262
266
|
keeper.SetStorage(ctx, agorictypes.NewKVEntry("key1", "value1"))
|
|
263
267
|
keeper.SetStorage(ctx, agorictypes.NewKVEntry("key1.child1.grandchild1", "value1grandchild"))
|
|
@@ -286,7 +290,7 @@ func TestEntries(t *testing.T) {
|
|
|
286
290
|
{path: "nosuchkey", want: `[]`},
|
|
287
291
|
}
|
|
288
292
|
for _, desc := range cases {
|
|
289
|
-
got, err := callReceive(handler,
|
|
293
|
+
got, err := callReceive(handler, ctx, "entries", []interface{}{desc.path})
|
|
290
294
|
if got != desc.want {
|
|
291
295
|
t.Errorf("%s: got %q; want %q", desc.path, got, desc.want)
|
|
292
296
|
}
|
package/x/vtransfer/genesis.go
CHANGED
|
@@ -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)
|
|
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 {
|
package/x/vtransfer/handler.go
CHANGED
|
@@ -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)
|
|
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/
|
|
7
|
-
clienttypes "github.com/cosmos/ibc-go/
|
|
8
|
-
channeltypes "github.com/cosmos/ibc-go/
|
|
9
|
-
porttypes "github.com/cosmos/ibc-go/
|
|
10
|
-
"github.com/cosmos/ibc-go/
|
|
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/
|
|
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/
|
|
35
|
-
ibctransfertypes "github.com/cosmos/ibc-go/
|
|
36
|
-
channeltypes "github.com/cosmos/ibc-go/
|
|
37
|
-
ibcexported "github.com/cosmos/ibc-go/
|
|
38
|
-
ibctesting "github.com/cosmos/ibc-go/
|
|
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.
|
|
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
|
-
|
|
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,
|
|
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 :=
|
|
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 :=
|
|
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(
|
|
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().
|
|
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 *
|
|
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
|
-
|
|
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
|
|
636
|
+
var events []abci.Event
|
|
625
637
|
var ackData []byte
|
|
626
638
|
if packetRes != nil {
|
|
627
|
-
events = packetRes.
|
|
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().
|
|
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.
|
|
700
|
+
ackedPacket, err = ParsePacketFromFilteredEvents(ackRes.Events, channeltypes.EventTypeWriteAck)
|
|
689
701
|
s.Require().NoError(err)
|
|
690
702
|
|
|
691
|
-
ackData, err := ParseAckFromEvents(ackRes.
|
|
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.
|
|
727
|
+
for _, event := range ackRes.Events {
|
|
716
728
|
if event.Type == ibctransfertypes.EventTypePacket {
|
|
717
729
|
gotEvents += 1
|
|
718
|
-
if gotEvents == 2 && len(event.Attributes) ==
|
|
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 :=
|
|
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.
|
|
822
|
+
s.Require().True(coins.Equal(res.Balances))
|
|
809
823
|
})
|
|
810
824
|
}
|
|
811
825
|
}
|
|
@@ -6,27 +6,28 @@ import (
|
|
|
6
6
|
"encoding/json"
|
|
7
7
|
"fmt"
|
|
8
8
|
|
|
9
|
+
corestore "cosmossdk.io/core/store"
|
|
10
|
+
sdkioerrors "cosmossdk.io/errors"
|
|
11
|
+
"cosmossdk.io/store/prefix"
|
|
12
|
+
storetypes "cosmossdk.io/store/types"
|
|
9
13
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
10
|
-
"github.com/cosmos/cosmos-sdk/
|
|
11
|
-
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
|
14
|
+
"github.com/cosmos/cosmos-sdk/runtime"
|
|
12
15
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
13
|
-
|
|
14
|
-
sdkioerrors "cosmossdk.io/errors"
|
|
15
16
|
sdktypeserrors "github.com/cosmos/cosmos-sdk/types/errors"
|
|
16
17
|
|
|
17
|
-
capabilitykeeper "github.com/cosmos/
|
|
18
|
-
capabilitytypes "github.com/cosmos/
|
|
18
|
+
capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper"
|
|
19
|
+
capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"
|
|
19
20
|
|
|
20
21
|
agtypes "github.com/Agoric/agoric-sdk/golang/cosmos/types"
|
|
21
22
|
"github.com/Agoric/agoric-sdk/golang/cosmos/vm"
|
|
22
23
|
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vibc"
|
|
23
24
|
vibctypes "github.com/Agoric/agoric-sdk/golang/cosmos/x/vibc/types"
|
|
24
25
|
|
|
25
|
-
clienttypes "github.com/cosmos/ibc-go/
|
|
26
|
-
channeltypes "github.com/cosmos/ibc-go/
|
|
27
|
-
porttypes "github.com/cosmos/ibc-go/
|
|
28
|
-
host "github.com/cosmos/ibc-go/
|
|
29
|
-
ibcexported "github.com/cosmos/ibc-go/
|
|
26
|
+
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
|
|
27
|
+
channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
|
|
28
|
+
porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types"
|
|
29
|
+
host "github.com/cosmos/ibc-go/v8/modules/core/24-host"
|
|
30
|
+
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
|
|
30
31
|
)
|
|
31
32
|
|
|
32
33
|
var _ porttypes.ICS4Wrapper = (*Keeper)(nil)
|
|
@@ -56,8 +57,8 @@ type Keeper struct {
|
|
|
56
57
|
|
|
57
58
|
vibcKeeper vibc.Keeper
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
cdc
|
|
60
|
+
storeService corestore.KVStoreService
|
|
61
|
+
cdc codec.Codec
|
|
61
62
|
|
|
62
63
|
vibcModule porttypes.IBCModule
|
|
63
64
|
|
|
@@ -137,7 +138,7 @@ func NewICS4Wrapper(k Keeper, down porttypes.ICS4Wrapper) *ics4Wrapper {
|
|
|
137
138
|
// NewKeeper creates a new vtransfer Keeper instance
|
|
138
139
|
func NewKeeper(
|
|
139
140
|
cdc codec.Codec,
|
|
140
|
-
|
|
141
|
+
storeService corestore.KVStoreService,
|
|
141
142
|
prototypeVibcKeeper vibc.Keeper,
|
|
142
143
|
scopedTransferKeeper capabilitykeeper.ScopedKeeper,
|
|
143
144
|
pushAction vm.ActionPusher,
|
|
@@ -150,10 +151,10 @@ func NewKeeper(
|
|
|
150
151
|
k := Keeper{
|
|
151
152
|
ReceiverImpl: vibcKeeper,
|
|
152
153
|
|
|
153
|
-
vibcKeeper:
|
|
154
|
-
|
|
155
|
-
vibcModule:
|
|
156
|
-
cdc:
|
|
154
|
+
vibcKeeper: vibcKeeper,
|
|
155
|
+
storeService: storeService,
|
|
156
|
+
vibcModule: vibc.NewIBCModule(vibcKeeper),
|
|
157
|
+
cdc: cdc,
|
|
157
158
|
|
|
158
159
|
debug: &KeeperDebugOptions{
|
|
159
160
|
OverridePacket: nil,
|
|
@@ -208,7 +209,9 @@ func sequencePath(sequence uint64) string {
|
|
|
208
209
|
func (k Keeper) PacketStore(ctx sdk.Context, ourOrigin agtypes.PacketOrigin, ourPort string, ourChannel string, sequence uint64) (storetypes.KVStore, []byte) {
|
|
209
210
|
key := fmt.Sprintf("%s/%s/%s", ourOrigin, channelPath(ourPort, ourChannel), sequencePath(sequence))
|
|
210
211
|
packetKey := []byte(key)
|
|
211
|
-
|
|
212
|
+
kvstore := k.storeService.OpenKVStore(ctx)
|
|
213
|
+
store := runtime.KVStoreAdapter(kvstore)
|
|
214
|
+
return prefix.NewStore(store, []byte(packetDataStoreKeyPrefix)), packetKey
|
|
212
215
|
}
|
|
213
216
|
|
|
214
217
|
func (k Keeper) PacketStoreFromOrigin(ctx sdk.Context, ourOrigin agtypes.PacketOrigin, packet ibcexported.PacketI) (storetypes.KVStore, []byte) {
|
|
@@ -371,19 +374,20 @@ func (k Keeper) InterceptWriteAcknowledgement(ctx sdk.Context, chanCap *capabili
|
|
|
371
374
|
|
|
372
375
|
// targetIsWatched checks if a target address has been watched by the VM.
|
|
373
376
|
func (k Keeper) targetIsWatched(ctx sdk.Context, target string) bool {
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
)
|
|
377
|
+
kvstore := k.storeService.OpenKVStore(ctx)
|
|
378
|
+
store := runtime.KVStoreAdapter(kvstore)
|
|
379
|
+
prefixStore := prefix.NewStore(store, []byte(watchedAddressStoreKeyPrefix))
|
|
378
380
|
return prefixStore.Has([]byte(target))
|
|
379
381
|
}
|
|
380
382
|
|
|
381
383
|
// GetWatchedAdresses returns the watched addresses from the keeper as a slice
|
|
382
384
|
// of account addresses.
|
|
383
385
|
func (k Keeper) GetWatchedAddresses(ctx sdk.Context) ([]sdk.AccAddress, error) {
|
|
386
|
+
kvstore := k.storeService.OpenKVStore(ctx)
|
|
387
|
+
store := runtime.KVStoreAdapter(kvstore)
|
|
384
388
|
addresses := make([]sdk.AccAddress, 0)
|
|
385
|
-
prefixStore := prefix.NewStore(
|
|
386
|
-
iterator :=
|
|
389
|
+
prefixStore := prefix.NewStore(store, []byte(watchedAddressStoreKeyPrefix))
|
|
390
|
+
iterator := storetypes.KVStorePrefixIterator(prefixStore, []byte{})
|
|
387
391
|
defer iterator.Close()
|
|
388
392
|
for ; iterator.Valid(); iterator.Next() {
|
|
389
393
|
addr, err := sdk.AccAddressFromBech32(string(iterator.Key()))
|
|
@@ -398,10 +402,9 @@ func (k Keeper) GetWatchedAddresses(ctx sdk.Context) ([]sdk.AccAddress, error) {
|
|
|
398
402
|
// SetWatchedAddresses sets the watched addresses in the keeper from a slice of
|
|
399
403
|
// SDK account addresses.
|
|
400
404
|
func (k Keeper) SetWatchedAddresses(ctx sdk.Context, addresses []sdk.AccAddress) {
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
)
|
|
405
|
+
kvstore := k.storeService.OpenKVStore(ctx)
|
|
406
|
+
store := runtime.KVStoreAdapter(kvstore)
|
|
407
|
+
prefixStore := prefix.NewStore(store, []byte(watchedAddressStoreKeyPrefix))
|
|
405
408
|
for _, addr := range addresses {
|
|
406
409
|
prefixStore.Set([]byte(addr.String()), []byte(watchedAddressSentinel))
|
|
407
410
|
}
|
|
@@ -420,10 +423,9 @@ func (k Keeper) Receive(cctx context.Context, jsonRequest string) (jsonReply str
|
|
|
420
423
|
return "", err
|
|
421
424
|
}
|
|
422
425
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
)
|
|
426
|
+
kvstore := k.storeService.OpenKVStore(ctx)
|
|
427
|
+
store := runtime.KVStoreAdapter(kvstore)
|
|
428
|
+
prefixStore := prefix.NewStore(store, []byte(watchedAddressStoreKeyPrefix))
|
|
427
429
|
switch msg.Type {
|
|
428
430
|
case "BRIDGE_TARGET_REGISTER":
|
|
429
431
|
prefixStore.Set([]byte(msg.Target), []byte(watchedAddressSentinel))
|
package/x/vtransfer/module.go
CHANGED
|
@@ -12,7 +12,6 @@ import (
|
|
|
12
12
|
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
|
|
13
13
|
"github.com/cosmos/cosmos-sdk/types/module"
|
|
14
14
|
|
|
15
|
-
abci "github.com/cometbft/cometbft/abci/types"
|
|
16
15
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
17
16
|
)
|
|
18
17
|
|
|
@@ -20,12 +19,18 @@ import (
|
|
|
20
19
|
var (
|
|
21
20
|
_ module.AppModule = AppModule{}
|
|
22
21
|
_ module.AppModuleBasic = AppModuleBasic{}
|
|
22
|
+
_ module.HasGenesis = AppModule{}
|
|
23
23
|
)
|
|
24
24
|
|
|
25
25
|
// app module Basics object
|
|
26
26
|
type AppModuleBasic struct {
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
// IsAppModule implements the appmodule.AppModule interface.
|
|
30
|
+
func (am AppModule) IsAppModule() {}
|
|
31
|
+
|
|
32
|
+
// IsOnePerModuleType is a marker function just indicates that this is a one-per-module type.
|
|
33
|
+
func (am AppModule) IsOnePerModuleType() {}
|
|
29
34
|
func (AppModuleBasic) Name() string {
|
|
30
35
|
return ModuleName
|
|
31
36
|
}
|
|
@@ -91,18 +96,10 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
|
|
|
91
96
|
|
|
92
97
|
func (AppModule) ConsensusVersion() uint64 { return 1 }
|
|
93
98
|
|
|
94
|
-
func (am AppModule)
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate {
|
|
98
|
-
// Prevent Cosmos SDK internal errors.
|
|
99
|
-
return []abci.ValidatorUpdate{}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate {
|
|
99
|
+
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) {
|
|
103
100
|
var genesisState types.GenesisState
|
|
104
101
|
cdc.MustUnmarshalJSON(data, &genesisState)
|
|
105
|
-
|
|
102
|
+
InitGenesis(ctx, am.keeper, &genesisState)
|
|
106
103
|
}
|
|
107
104
|
|
|
108
105
|
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
|
|
@@ -2,9 +2,9 @@ package types
|
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
4
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
5
|
-
capability "github.com/cosmos/
|
|
6
|
-
channel "github.com/cosmos/ibc-go/
|
|
7
|
-
ibcexported "github.com/cosmos/ibc-go/
|
|
5
|
+
capability "github.com/cosmos/ibc-go/modules/capability/types"
|
|
6
|
+
channel "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
|
|
7
|
+
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
|
|
8
8
|
)
|
|
9
9
|
|
|
10
10
|
// ChannelKeeper defines the expected IBC channel keeper
|