@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.
- package/Makefile +6 -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 +256 -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 +40 -90
- 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 +130 -109
- package/go.sum +228 -469
- package/package.json +2 -2
- package/proto/agoric/swingset/msgs.proto +72 -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/scripts/mockgen.sh +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 +349 -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 -27
- 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 +28 -23
- package/x/swingset/keeper/keeper_test.go +10 -7
- package/x/swingset/keeper/msg_server.go +52 -5
- package/x/swingset/keeper/msg_server_test.go +121 -0
- package/x/swingset/keeper/proposal.go +4 -0
- package/x/swingset/keeper/querier.go +1 -1
- 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/keeper/test_utils.go +2 -2
- package/x/swingset/module.go +20 -22
- package/x/swingset/testing/queue.go +5 -2
- package/x/swingset/testutil/mocks.go +379 -0
- package/x/swingset/types/codec.go +10 -5
- package/x/swingset/types/default-params.go +13 -12
- package/x/swingset/types/expected_keepers.go +29 -4
- package/x/swingset/types/msgs.go +51 -36
- package/x/swingset/types/msgs.pb.go +561 -51
- package/x/swingset/types/params_test.go +21 -20
- package/x/swingset/types/swingset.pb.go +67 -61
- package/x/vbank/genesis.go +13 -9
- 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 +10 -5
- 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 +29 -11
- 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/grpc_query.go +1 -1
- package/x/vstorage/keeper/keeper.go +72 -50
- package/x/vstorage/keeper/keeper_test.go +74 -54
- package/x/vstorage/keeper/querier.go +1 -1
- package/x/vstorage/module.go +27 -13
- package/x/vstorage/testing/queue.go +5 -3
- package/x/vstorage/vstorage.go +10 -9
- package/x/vstorage/vstorage_test.go +24 -18
- 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
package/x/vstorage/module.go
CHANGED
|
@@ -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
|
|
25
|
-
_ module.
|
|
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
|
|
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
|
|
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)
|
|
117
|
+
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) {
|
|
111
118
|
var genesisState types.GenesisState
|
|
112
|
-
cdc.
|
|
113
|
-
|
|
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(
|
|
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(
|
|
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(
|
|
33
|
+
unlimitedCtx := ctx.WithGasMeter(storetypes.NewInfiniteGasMeter())
|
|
32
34
|
vstorageKeeper.RemoveEntriesWithPrefix(unlimitedCtx, queuePath)
|
|
33
35
|
return nil
|
|
34
36
|
}
|
package/x/vstorage/vstorage.go
CHANGED
|
@@ -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
|
|
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
|
|
180
|
+
if children == nil {
|
|
180
181
|
return "[]", nil
|
|
181
182
|
}
|
|
182
|
-
bytes, err := json.Marshal(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
|
|
196
|
-
for i, child := range 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
|
|
218
|
-
for i, child := range 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
|
|
235
|
+
if children == nil {
|
|
235
236
|
return "0", nil
|
|
236
237
|
}
|
|
237
|
-
return fmt.Sprint(len(children
|
|
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
|
-
"
|
|
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 {
|
|
@@ -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
|
|
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,
|
|
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
|
}
|
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
|
}
|