@agoric/cosmos 0.35.0-u19.2 → 0.35.0-u21.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/.clang-format +116 -0
- package/CHANGELOG.md +18 -18
- package/Makefile +38 -67
- package/ante/ante.go +2 -2
- package/ante/inbound_test.go +1 -1
- package/app/app.go +173 -142
- package/app/export.go +6 -6
- package/app/genesis.go +4 -0
- package/app/sim_test.go +299 -50
- package/app/upgrade.go +142 -96
- package/app/upgrade_test.go +63 -0
- package/cmd/agd/agvm.go +1 -1
- package/cmd/agd/main.go +1 -1
- package/cmd/libdaemon/main.go +34 -1
- package/daemon/cmd/root.go +26 -35
- package/daemon/cmd/root_test.go +5 -4
- package/daemon/cmd/testnet.go +221 -95
- package/daemon/main.go +1 -0
- package/git-revision.txt +1 -1
- package/go.mod +93 -58
- package/go.sum +148 -95
- package/package.json +6 -3
- package/proto/agoric/swingset/genesis.proto +7 -11
- package/proto/agoric/swingset/msgs.proto +56 -75
- package/proto/agoric/swingset/query.proto +7 -10
- package/proto/agoric/swingset/swingset.proto +79 -108
- package/proto/agoric/vbank/genesis.proto +5 -5
- package/proto/agoric/vbank/msgs.proto +1 -2
- package/proto/agoric/vbank/vbank.proto +42 -52
- package/proto/agoric/vibc/msgs.proto +8 -11
- package/proto/agoric/vstorage/genesis.proto +6 -9
- package/proto/agoric/vstorage/query.proto +19 -48
- package/proto/agoric/vstorage/vstorage.proto +4 -10
- package/proto/agoric/vtransfer/genesis.proto +7 -7
- package/proto/buf.gen.gogo.yaml +8 -0
- package/proto/buf.gen.pulsar.yaml +17 -0
- package/proto/buf.gen.swagger.yaml +5 -0
- package/proto/buf.yaml +10 -0
- package/scripts/protocgen.sh +14 -21
- package/third_party/proto/amino/amino.proto +79 -0
- package/third_party/proto/cosmos/base/v1beta1/coin.proto +7 -2
- package/third_party/proto/cosmos/ics23/v1/proofs.proto +243 -0
- package/third_party/proto/cosmos/msg/v1/msg.proto +30 -0
- package/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto +17 -5
- package/third_party/proto/cosmos_proto/cosmos.proto +16 -1
- package/third_party/proto/gogoproto/gogo.proto +2 -2
- package/third_party/proto/google/protobuf/any.proto +6 -3
- package/third_party/proto/ibc/core/channel/v1/channel.proto +1 -1
- package/third_party/proto/ibc/core/client/v1/client.proto +4 -2
- package/types/address_hooks.go +5 -12
- package/types/address_hooks_test.go +34 -34
- package/types/codec.go +23 -0
- package/types/ibc_packet.go +64 -0
- package/types/ibc_packet_test.go +117 -0
- package/vm/client.go +32 -7
- package/vm/proto_json.go +2 -2
- package/x/swingset/abci.go +1 -1
- package/x/swingset/alias.go +0 -1
- package/x/swingset/config.go +1 -1
- package/x/swingset/keeper/extension_snapshotter.go +1 -1
- package/x/swingset/keeper/extension_snapshotter_test.go +1 -1
- package/x/swingset/keeper/keeper.go +1 -1
- package/x/swingset/keeper/keeper_test.go +1 -1
- package/x/swingset/keeper/querier.go +1 -30
- 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 +1 -14
- package/x/swingset/types/default-params.go +24 -16
- package/x/swingset/types/genesis.pb.go +2 -2
- package/x/swingset/types/msgs.pb.go +4 -3
- package/x/swingset/types/msgs_test.go +1 -1
- package/x/swingset/types/query.pb.go +4 -3
- package/x/swingset/types/swingset.pb.go +2 -2
- package/x/vbank/genesis.go +1 -1
- package/x/vbank/keeper/querier.go +1 -21
- package/x/vbank/module.go +1 -16
- package/x/vbank/types/genesis.pb.go +2 -2
- package/x/vbank/types/msgs.pb.go +3 -2
- package/x/vbank/types/query.pb.go +4 -3
- package/x/vbank/types/vbank.pb.go +2 -2
- package/x/vbank/vbank_test.go +95 -16
- package/x/vibc/keeper/keeper.go +8 -5
- package/x/vibc/keeper/migrations.go +36 -0
- package/x/vibc/keeper/triggers.go +6 -32
- package/x/vibc/module.go +9 -17
- package/x/vibc/types/expected_keepers.go +6 -10
- package/x/vibc/types/ibc_module.go +30 -20
- package/x/vibc/types/msgs.go +1 -1
- package/x/vibc/types/msgs.pb.go +5 -4
- package/x/vibc/types/receiver.go +17 -17
- package/x/vlocalchain/keeper/keeper.go +3 -3
- package/x/vlocalchain/types/vlocalchain.pb.go +1 -1
- package/x/vlocalchain/vlocalchain_test.go +6 -6
- package/x/vstorage/README.md +0 -8
- package/x/vstorage/alias.go +0 -1
- package/x/vstorage/client/cli/query.go +1 -1
- package/x/vstorage/genesis.go +1 -1
- package/x/vstorage/keeper/keeper.go +40 -5
- package/x/vstorage/keeper/keeper_test.go +24 -24
- package/x/vstorage/keeper/querier.go +1 -32
- package/x/vstorage/keeper/querier_test.go +41 -6
- package/x/vstorage/module.go +1 -14
- package/x/vstorage/types/genesis.pb.go +2 -2
- package/x/vstorage/types/path_keys.go +7 -8
- package/x/vstorage/types/query.pb.go +8 -5
- package/x/vstorage/types/vstorage.pb.go +2 -2
- package/x/vstorage/vstorage_test.go +3 -3
- package/x/vtransfer/genesis.go +1 -1
- package/x/vtransfer/handler.go +4 -2
- package/x/vtransfer/ibc_middleware.go +4 -4
- package/x/vtransfer/ibc_middleware_test.go +14 -16
- package/x/vtransfer/keeper/keeper.go +38 -48
- package/x/vtransfer/module.go +1 -14
- package/x/vtransfer/types/expected_keepers.go +2 -18
- package/x/vtransfer/types/genesis.pb.go +2 -2
- package/x/vtransfer/utils_test.go +15 -15
- package/daemon/cmd/genaccounts.go +0 -195
- package/e2e_test/Makefile +0 -29
- package/e2e_test/README.md +0 -100
- package/e2e_test/go.mod +0 -239
- package/e2e_test/go.sum +0 -1323
- package/e2e_test/ibc_conformance_test.go +0 -56
- package/e2e_test/pfm_test.go +0 -613
- package/e2e_test/util.go +0 -271
|
@@ -1,34 +1,14 @@
|
|
|
1
1
|
package keeper
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
|
-
abci "github.com/
|
|
4
|
+
abci "github.com/cometbft/cometbft/abci/types"
|
|
5
5
|
|
|
6
6
|
sdkioerrors "cosmossdk.io/errors"
|
|
7
|
-
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vbank/types"
|
|
8
7
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
9
8
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
10
9
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
|
11
10
|
)
|
|
12
11
|
|
|
13
|
-
func NewQuerier(k Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier {
|
|
14
|
-
return func(ctx sdk.Context, path []string, req abci.RequestQuery) ([]byte, error) {
|
|
15
|
-
var queryType string
|
|
16
|
-
if len(path) > 0 {
|
|
17
|
-
queryType = path[0]
|
|
18
|
-
}
|
|
19
|
-
switch queryType {
|
|
20
|
-
case types.QueryParams:
|
|
21
|
-
return queryParams(ctx, path[1:], req, k, legacyQuerierCdc)
|
|
22
|
-
|
|
23
|
-
case types.QueryState:
|
|
24
|
-
return queryState(ctx, path[1:], req, k, legacyQuerierCdc)
|
|
25
|
-
|
|
26
|
-
default:
|
|
27
|
-
return nil, sdkioerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown vbank query path")
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
12
|
func queryParams(ctx sdk.Context, _ []string, _ abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) {
|
|
33
13
|
params := k.GetParams(ctx)
|
|
34
14
|
|
package/x/vbank/module.go
CHANGED
|
@@ -17,9 +17,9 @@ import (
|
|
|
17
17
|
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
|
|
18
18
|
"github.com/cosmos/cosmos-sdk/types/module"
|
|
19
19
|
|
|
20
|
+
abci "github.com/cometbft/cometbft/abci/types"
|
|
20
21
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
21
22
|
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
|
22
|
-
abci "github.com/tendermint/tendermint/abci/types"
|
|
23
23
|
)
|
|
24
24
|
|
|
25
25
|
// type check to ensure the interface is properly implemented
|
|
@@ -184,21 +184,6 @@ func (AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {
|
|
|
184
184
|
// TODO
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
// Route implements the AppModule interface
|
|
188
|
-
func (am AppModule) Route() sdk.Route {
|
|
189
|
-
return sdk.NewRoute(RouterKey, NewHandler(am.keeper))
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// QuerierRoute implements the AppModule interface
|
|
193
|
-
func (AppModule) QuerierRoute() string {
|
|
194
|
-
return ModuleName
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// LegacyQuerierHandler implements the AppModule interface
|
|
198
|
-
func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier {
|
|
199
|
-
return keeper.NewQuerier(am.keeper, legacyQuerierCdc)
|
|
200
|
-
}
|
|
201
|
-
|
|
202
187
|
// RegisterServices registers module services.
|
|
203
188
|
func (am AppModule) RegisterServices(cfg module.Configurator) {
|
|
204
189
|
tx := &types.UnimplementedMsgServer{}
|
package/x/vbank/types/msgs.pb.go
CHANGED
|
@@ -6,8 +6,8 @@ package types
|
|
|
6
6
|
import (
|
|
7
7
|
context "context"
|
|
8
8
|
fmt "fmt"
|
|
9
|
-
grpc1 "github.com/
|
|
10
|
-
proto "github.com/
|
|
9
|
+
grpc1 "github.com/cosmos/gogoproto/grpc"
|
|
10
|
+
proto "github.com/cosmos/gogoproto/proto"
|
|
11
11
|
grpc "google.golang.org/grpc"
|
|
12
12
|
math "math"
|
|
13
13
|
)
|
|
@@ -72,6 +72,7 @@ func RegisterMsgServer(s grpc1.Server, srv MsgServer) {
|
|
|
72
72
|
s.RegisterService(&_Msg_serviceDesc, srv)
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
var Msg_serviceDesc = _Msg_serviceDesc
|
|
75
76
|
var _Msg_serviceDesc = grpc.ServiceDesc{
|
|
76
77
|
ServiceName: "agoric.vbank.Msg",
|
|
77
78
|
HandlerType: (*MsgServer)(nil),
|
|
@@ -6,9 +6,9 @@ package types
|
|
|
6
6
|
import (
|
|
7
7
|
context "context"
|
|
8
8
|
fmt "fmt"
|
|
9
|
-
_ "github.com/
|
|
10
|
-
grpc1 "github.com/
|
|
11
|
-
proto "github.com/
|
|
9
|
+
_ "github.com/cosmos/gogoproto/gogoproto"
|
|
10
|
+
grpc1 "github.com/cosmos/gogoproto/grpc"
|
|
11
|
+
proto "github.com/cosmos/gogoproto/proto"
|
|
12
12
|
_ "google.golang.org/genproto/googleapis/api/annotations"
|
|
13
13
|
grpc "google.golang.org/grpc"
|
|
14
14
|
codes "google.golang.org/grpc/codes"
|
|
@@ -333,6 +333,7 @@ func _Query_State_Handler(srv interface{}, ctx context.Context, dec func(interfa
|
|
|
333
333
|
return interceptor(ctx, in, info, handler)
|
|
334
334
|
}
|
|
335
335
|
|
|
336
|
+
var Query_serviceDesc = _Query_serviceDesc
|
|
336
337
|
var _Query_serviceDesc = grpc.ServiceDesc{
|
|
337
338
|
ServiceName: "agoric.vbank.Query",
|
|
338
339
|
HandlerType: (*QueryServer)(nil),
|
|
@@ -7,8 +7,8 @@ import (
|
|
|
7
7
|
fmt "fmt"
|
|
8
8
|
github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
|
|
9
9
|
types "github.com/cosmos/cosmos-sdk/types"
|
|
10
|
-
_ "github.com/
|
|
11
|
-
proto "github.com/
|
|
10
|
+
_ "github.com/cosmos/gogoproto/gogoproto"
|
|
11
|
+
proto "github.com/cosmos/gogoproto/proto"
|
|
12
12
|
io "io"
|
|
13
13
|
math "math"
|
|
14
14
|
math_bits "math/bits"
|
package/x/vbank/vbank_test.go
CHANGED
|
@@ -10,17 +10,18 @@ import (
|
|
|
10
10
|
"github.com/Agoric/agoric-sdk/golang/cosmos/app/params"
|
|
11
11
|
"github.com/Agoric/agoric-sdk/golang/cosmos/vm"
|
|
12
12
|
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vbank/types"
|
|
13
|
+
dbm "github.com/cometbft/cometbft-db"
|
|
14
|
+
abci "github.com/cometbft/cometbft/abci/types"
|
|
15
|
+
"github.com/cometbft/cometbft/crypto/secp256k1"
|
|
16
|
+
"github.com/cometbft/cometbft/libs/log"
|
|
17
|
+
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
|
13
18
|
"github.com/cosmos/cosmos-sdk/store"
|
|
14
19
|
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
|
15
20
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
21
|
+
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
|
16
22
|
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
|
17
23
|
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
|
|
18
24
|
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
|
19
|
-
abci "github.com/tendermint/tendermint/abci/types"
|
|
20
|
-
"github.com/tendermint/tendermint/crypto/secp256k1"
|
|
21
|
-
"github.com/tendermint/tendermint/libs/log"
|
|
22
|
-
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
|
23
|
-
dbm "github.com/tendermint/tm-db"
|
|
24
25
|
)
|
|
25
26
|
|
|
26
27
|
var (
|
|
@@ -233,6 +234,24 @@ func (b *mockBank) MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins)
|
|
|
233
234
|
|
|
234
235
|
func (b *mockBank) SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error {
|
|
235
236
|
b.record(fmt.Sprintf("SendCoinsFromAccountToModule %s %s %s", senderAddr, recipientModule, amt))
|
|
237
|
+
|
|
238
|
+
// for each coin in the request, check spendable vs. requested
|
|
239
|
+
for _, coin := range amt {
|
|
240
|
+
// mimic GetBalance logic
|
|
241
|
+
have := b.balances[senderAddr.String()].AmountOf(coin.Denom)
|
|
242
|
+
spendable := sdk.NewCoin(coin.Denom, have)
|
|
243
|
+
|
|
244
|
+
if spendable.IsLT(coin) {
|
|
245
|
+
// wrap exactly like the real x/bank keeper
|
|
246
|
+
// https://github.com/agoric-labs/cosmos-sdk/blob/8b2b975304291c51991278734daa2ff5e57fcb83/x/bank/keeper/send.go#L252-L256
|
|
247
|
+
return sdkerrors.Wrapf(
|
|
248
|
+
sdkerrors.ErrInsufficientFunds,
|
|
249
|
+
"spendable balance %s is smaller than %s",
|
|
250
|
+
spendable, coin,
|
|
251
|
+
)
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
236
255
|
return nil
|
|
237
256
|
}
|
|
238
257
|
|
|
@@ -541,32 +560,32 @@ func Test_EndBlock_Events(t *testing.T) {
|
|
|
541
560
|
{
|
|
542
561
|
Type: "coin_received",
|
|
543
562
|
Attributes: []abci.EventAttribute{
|
|
544
|
-
{Key:
|
|
545
|
-
{Key:
|
|
563
|
+
{Key: "receiver", Value: addr1},
|
|
564
|
+
{Key: "amount", Value: "500ubld,600urun,700ushmoo"},
|
|
546
565
|
},
|
|
547
566
|
},
|
|
548
567
|
{
|
|
549
568
|
Type: "coin_spent",
|
|
550
569
|
Attributes: []abci.EventAttribute{
|
|
551
|
-
{Key:
|
|
552
|
-
{Key:
|
|
553
|
-
{Key:
|
|
570
|
+
{Key: "spender", Value: addr2},
|
|
571
|
+
{Key: "amount", Value: "500ubld,600urun,700ushmoo"},
|
|
572
|
+
{Key: "other", Value: addr3},
|
|
554
573
|
},
|
|
555
574
|
},
|
|
556
575
|
{
|
|
557
576
|
Type: "something_else",
|
|
558
577
|
Attributes: []abci.EventAttribute{
|
|
559
|
-
{Key:
|
|
560
|
-
{Key:
|
|
561
|
-
{Key:
|
|
578
|
+
{Key: "receiver", Value: addr4},
|
|
579
|
+
{Key: "spender", Value: addr4},
|
|
580
|
+
{Key: "amount", Value: "500ubld,600urun,700ushmoo"},
|
|
562
581
|
},
|
|
563
582
|
},
|
|
564
583
|
{
|
|
565
584
|
Type: "non_modaccount",
|
|
566
585
|
Attributes: []abci.EventAttribute{
|
|
567
|
-
{Key:
|
|
568
|
-
{Key:
|
|
569
|
-
{Key:
|
|
586
|
+
{Key: "receiver", Value: addr3},
|
|
587
|
+
{Key: "spender", Value: addr4},
|
|
588
|
+
{Key: "amount", Value: "100ubld"},
|
|
570
589
|
},
|
|
571
590
|
},
|
|
572
591
|
}
|
|
@@ -821,3 +840,63 @@ func Test_Module_Account(t *testing.T) {
|
|
|
821
840
|
t.Errorf("got IsAllowedMonitoringAccount missingAddr = false, want true")
|
|
822
841
|
}
|
|
823
842
|
}
|
|
843
|
+
|
|
844
|
+
|
|
845
|
+
|
|
846
|
+
func Test_Receive_Grab_InsufficientFunds(t *testing.T) {
|
|
847
|
+
tests := []struct {
|
|
848
|
+
name string
|
|
849
|
+
initialBalance sdk.Coin
|
|
850
|
+
}{
|
|
851
|
+
{
|
|
852
|
+
name: "only 100 available",
|
|
853
|
+
initialBalance: sdk.NewInt64Coin("ufoo", 100),
|
|
854
|
+
},
|
|
855
|
+
{
|
|
856
|
+
name: "zero available",
|
|
857
|
+
initialBalance: sdk.NewInt64Coin("ufoo", 0),
|
|
858
|
+
},
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
for _, tc := range tests {
|
|
862
|
+
t.Run(tc.name, func(t *testing.T) {
|
|
863
|
+
// set up mockBank with the desired starting balance
|
|
864
|
+
bank := &mockBank{balances: map[string]sdk.Coins{
|
|
865
|
+
addr1: sdk.NewCoins(tc.initialBalance),
|
|
866
|
+
}}
|
|
867
|
+
|
|
868
|
+
// wire into keeper
|
|
869
|
+
keeper, ctx := makeTestKit(nil, bank)
|
|
870
|
+
handler := NewPortHandler(AppModule{}, keeper)
|
|
871
|
+
ctl := sdk.WrapSDKContext(ctx)
|
|
872
|
+
|
|
873
|
+
// attempt to grab 500ufoo
|
|
874
|
+
grabAmt := sdk.NewCoins(sdk.NewInt64Coin("ufoo", 500))
|
|
875
|
+
_, err := handler.Receive(ctl, fmt.Sprintf(`{
|
|
876
|
+
"type":"VBANK_GRAB",
|
|
877
|
+
"sender":"%s",
|
|
878
|
+
"amount":"500",
|
|
879
|
+
"denom":"ufoo"
|
|
880
|
+
}`, addr1))
|
|
881
|
+
if err == nil {
|
|
882
|
+
t.Fatal("expected insufficient-funds error, got nil")
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
expected := fmt.Sprintf(
|
|
886
|
+
"cannot grab %s coins: spendable balance %s is smaller than %s: %s",
|
|
887
|
+
grabAmt.Sort().String(),
|
|
888
|
+
tc.initialBalance.String(),
|
|
889
|
+
grabAmt.Sort().String(),
|
|
890
|
+
sdkerrors.ErrInsufficientFunds.Error(),
|
|
891
|
+
)
|
|
892
|
+
|
|
893
|
+
t.Logf("actual error: %q", err.Error())
|
|
894
|
+
|
|
895
|
+
got := err.Error()
|
|
896
|
+
if got != expected {
|
|
897
|
+
t.Errorf("wrong error message:\n expected: %q\n got: %q",
|
|
898
|
+
expected, got)
|
|
899
|
+
}
|
|
900
|
+
})
|
|
901
|
+
}
|
|
902
|
+
}
|
package/x/vibc/keeper/keeper.go
CHANGED
|
@@ -9,11 +9,11 @@ import (
|
|
|
9
9
|
|
|
10
10
|
sdkioerrors "cosmossdk.io/errors"
|
|
11
11
|
capability "github.com/cosmos/cosmos-sdk/x/capability/types"
|
|
12
|
-
clienttypes "github.com/cosmos/ibc-go/
|
|
13
|
-
channeltypes "github.com/cosmos/ibc-go/
|
|
14
|
-
porttypes "github.com/cosmos/ibc-go/
|
|
15
|
-
host "github.com/cosmos/ibc-go/
|
|
16
|
-
ibcexported "github.com/cosmos/ibc-go/
|
|
12
|
+
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
|
|
13
|
+
channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
|
|
14
|
+
porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types"
|
|
15
|
+
host "github.com/cosmos/ibc-go/v7/modules/core/24-host"
|
|
16
|
+
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
|
|
17
17
|
|
|
18
18
|
"github.com/Agoric/agoric-sdk/golang/cosmos/vm"
|
|
19
19
|
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vibc/types"
|
|
@@ -31,6 +31,7 @@ type Keeper struct {
|
|
|
31
31
|
|
|
32
32
|
channelKeeper types.ChannelKeeper
|
|
33
33
|
portKeeper types.PortKeeper
|
|
34
|
+
clientKeeper types.ClientKeeper
|
|
34
35
|
|
|
35
36
|
// Filled out by `WithScope`
|
|
36
37
|
scopedKeeper types.ScopedKeeper
|
|
@@ -43,12 +44,14 @@ func NewKeeper(
|
|
|
43
44
|
cdc codec.Codec,
|
|
44
45
|
channelKeeper types.ChannelKeeper,
|
|
45
46
|
portKeeper types.PortKeeper,
|
|
47
|
+
clientKeeper types.ClientKeeper,
|
|
46
48
|
) Keeper {
|
|
47
49
|
|
|
48
50
|
return Keeper{
|
|
49
51
|
cdc: cdc,
|
|
50
52
|
channelKeeper: channelKeeper,
|
|
51
53
|
portKeeper: portKeeper,
|
|
54
|
+
clientKeeper: clientKeeper,
|
|
52
55
|
}
|
|
53
56
|
}
|
|
54
57
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
package keeper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
5
|
+
|
|
6
|
+
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
// Migrator handles in-place store migrations.
|
|
10
|
+
type Migrator struct {
|
|
11
|
+
keeper Keeper
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// NewMigrator returns a new migrator based on the keeper.
|
|
15
|
+
func NewMigrator(keeper Keeper) Migrator {
|
|
16
|
+
return Migrator{keeper: keeper}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Migrate1to2 migrates from version 1 to 2.
|
|
20
|
+
func (m Migrator) Migrate1to2(ctx sdk.Context) error {
|
|
21
|
+
return m.AddLocalhostParams(ctx)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// explicitly update the IBC 02-client params, adding the localhost client type
|
|
25
|
+
func (m Migrator) AddLocalhostParams(ctx sdk.Context) error {
|
|
26
|
+
params := m.keeper.clientKeeper.GetParams(ctx)
|
|
27
|
+
for _, client := range params.AllowedClients {
|
|
28
|
+
if client == ibcexported.Localhost {
|
|
29
|
+
// Already added, return.
|
|
30
|
+
return nil
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
params.AllowedClients = append(params.AllowedClients, ibcexported.Localhost)
|
|
34
|
+
m.keeper.clientKeeper.SetParams(ctx, params)
|
|
35
|
+
return nil
|
|
36
|
+
}
|
|
@@ -3,47 +3,21 @@ package keeper
|
|
|
3
3
|
import (
|
|
4
4
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types"
|
|
8
|
-
ibcexported "github.com/cosmos/ibc-go/v6/modules/core/exported"
|
|
6
|
+
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
|
|
9
7
|
|
|
10
|
-
"github.com/Agoric/agoric-sdk/golang/cosmos/
|
|
8
|
+
agtypes "github.com/Agoric/agoric-sdk/golang/cosmos/types"
|
|
11
9
|
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vibc/types"
|
|
12
10
|
)
|
|
13
11
|
|
|
14
|
-
func reifyPacket(packet ibcexported.PacketI) channeltypes.Packet {
|
|
15
|
-
|
|
16
|
-
timeoutHeight := clienttypes.MustParseHeight(packet.GetTimeoutHeight().String())
|
|
17
|
-
return channeltypes.Packet{
|
|
18
|
-
Sequence: packet.GetSequence(),
|
|
19
|
-
SourcePort: packet.GetSourcePort(),
|
|
20
|
-
SourceChannel: packet.GetSourceChannel(),
|
|
21
|
-
DestinationPort: packet.GetDestPort(),
|
|
22
|
-
DestinationChannel: packet.GetDestChannel(),
|
|
23
|
-
Data: packet.GetData(),
|
|
24
|
-
TimeoutHeight: timeoutHeight,
|
|
25
|
-
TimeoutTimestamp: packet.GetTimeoutTimestamp(),
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
type WriteAcknowledgementEvent struct {
|
|
30
|
-
*vm.ActionHeader `actionType:"IBC_EVENT"`
|
|
31
|
-
Event string `json:"event" default:"writeAcknowledgement"`
|
|
32
|
-
Target string `json:"target"`
|
|
33
|
-
Packet channeltypes.Packet `json:"packet"`
|
|
34
|
-
Acknowledgement []byte `json:"acknowledgement"`
|
|
35
|
-
Relayer sdk.AccAddress `json:"relayer"`
|
|
36
|
-
}
|
|
37
|
-
|
|
38
12
|
func (k Keeper) TriggerWriteAcknowledgement(
|
|
39
13
|
ctx sdk.Context,
|
|
40
14
|
target string,
|
|
41
15
|
packet ibcexported.PacketI,
|
|
42
16
|
acknowledgement ibcexported.Acknowledgement,
|
|
43
17
|
) error {
|
|
44
|
-
event := WriteAcknowledgementEvent{
|
|
18
|
+
event := types.WriteAcknowledgementEvent{
|
|
45
19
|
Target: target,
|
|
46
|
-
Packet:
|
|
20
|
+
Packet: agtypes.CopyToIBCPacket(packet),
|
|
47
21
|
Acknowledgement: acknowledgement.Acknowledgement(),
|
|
48
22
|
}
|
|
49
23
|
|
|
@@ -64,7 +38,7 @@ func (k Keeper) TriggerOnAcknowledgementPacket(
|
|
|
64
38
|
) error {
|
|
65
39
|
event := types.AcknowledgementPacketEvent{
|
|
66
40
|
Target: target,
|
|
67
|
-
Packet:
|
|
41
|
+
Packet: agtypes.CopyToIBCPacket(packet),
|
|
68
42
|
Acknowledgement: acknowledgement,
|
|
69
43
|
Relayer: relayer,
|
|
70
44
|
}
|
|
@@ -85,7 +59,7 @@ func (k Keeper) TriggerOnTimeoutPacket(
|
|
|
85
59
|
) error {
|
|
86
60
|
event := types.TimeoutPacketEvent{
|
|
87
61
|
Target: target,
|
|
88
|
-
Packet:
|
|
62
|
+
Packet: agtypes.CopyToIBCPacket(packet),
|
|
89
63
|
Relayer: relayer,
|
|
90
64
|
}
|
|
91
65
|
|
package/x/vibc/module.go
CHANGED
|
@@ -6,6 +6,7 @@ import (
|
|
|
6
6
|
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
|
7
7
|
"github.com/spf13/cobra"
|
|
8
8
|
|
|
9
|
+
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vibc/keeper"
|
|
9
10
|
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vibc/types"
|
|
10
11
|
|
|
11
12
|
"github.com/cosmos/cosmos-sdk/client"
|
|
@@ -13,8 +14,8 @@ import (
|
|
|
13
14
|
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
|
|
14
15
|
"github.com/cosmos/cosmos-sdk/types/module"
|
|
15
16
|
|
|
17
|
+
abci "github.com/cometbft/cometbft/abci/types"
|
|
16
18
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
17
|
-
abci "github.com/tendermint/tendermint/abci/types"
|
|
18
19
|
)
|
|
19
20
|
|
|
20
21
|
// type check to ensure the interface is properly implemented
|
|
@@ -83,7 +84,7 @@ func (AppModule) Name() string {
|
|
|
83
84
|
return ModuleName
|
|
84
85
|
}
|
|
85
86
|
|
|
86
|
-
func (AppModule) ConsensusVersion() uint64 { return
|
|
87
|
+
func (AppModule) ConsensusVersion() uint64 { return 2 }
|
|
87
88
|
|
|
88
89
|
// BeginBlock implements the AppModule interface
|
|
89
90
|
func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {
|
|
@@ -99,25 +100,16 @@ func (AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {
|
|
|
99
100
|
// TODO
|
|
100
101
|
}
|
|
101
102
|
|
|
102
|
-
// Route implements the AppModule interface
|
|
103
|
-
func (am AppModule) Route() sdk.Route {
|
|
104
|
-
return sdk.NewRoute(RouterKey, NewHandler(am.keeper, am.bankKeeper))
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// QuerierRoute implements the AppModule interface
|
|
108
|
-
func (AppModule) QuerierRoute() string {
|
|
109
|
-
return ModuleName
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// LegacyQuerierHandler implements the AppModule interface
|
|
113
|
-
func (am AppModule) LegacyQuerierHandler(*codec.LegacyAmino) sdk.Querier {
|
|
114
|
-
return nil
|
|
115
|
-
}
|
|
116
|
-
|
|
117
103
|
// RegisterServices registers module services.
|
|
118
104
|
func (am AppModule) RegisterServices(cfg module.Configurator) {
|
|
119
105
|
tx := &types.UnimplementedMsgServer{}
|
|
120
106
|
types.RegisterMsgServer(cfg.MsgServer(), tx)
|
|
107
|
+
|
|
108
|
+
m := keeper.NewMigrator(am.keeper)
|
|
109
|
+
err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2)
|
|
110
|
+
if err != nil {
|
|
111
|
+
panic(err)
|
|
112
|
+
}
|
|
121
113
|
}
|
|
122
114
|
|
|
123
115
|
// InitGenesis performs genesis initialization for the ibc-transfer module. It returns
|
|
@@ -3,10 +3,9 @@ package types
|
|
|
3
3
|
import (
|
|
4
4
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
5
5
|
capability "github.com/cosmos/cosmos-sdk/x/capability/types"
|
|
6
|
-
clienttypes "github.com/cosmos/ibc-go/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
ibcexported "github.com/cosmos/ibc-go/v6/modules/core/exported"
|
|
6
|
+
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
|
|
7
|
+
channel "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
|
|
8
|
+
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
|
|
10
9
|
)
|
|
11
10
|
|
|
12
11
|
type BankKeeper interface {
|
|
@@ -33,18 +32,15 @@ type ChannelKeeper interface {
|
|
|
33
32
|
connectionHops []string, counterparty channel.Counterparty, version string)
|
|
34
33
|
WriteOpenTryChannel(ctx sdk.Context, portID, channelID string, order channel.Order,
|
|
35
34
|
connectionHops []string, counterparty channel.Counterparty, version string)
|
|
35
|
+
WriteOpenAckChannel(ctx sdk.Context, portID, channelID, counterpartyVersion, counterpartyChannelID string)
|
|
36
36
|
ChanCloseInit(ctx sdk.Context, portID, channelID string, chanCap *capability.Capability) error
|
|
37
37
|
TimeoutExecuted(ctx sdk.Context, channelCap *capability.Capability, packet ibcexported.PacketI) error
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
// ClientKeeper defines the expected IBC client keeper
|
|
41
41
|
type ClientKeeper interface {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
// ConnectionKeeper defines the expected IBC connection keeper
|
|
46
|
-
type ConnectionKeeper interface {
|
|
47
|
-
GetConnection(ctx sdk.Context, connectionID string) (connection connection.ConnectionEnd, found bool)
|
|
42
|
+
GetParams(ctx sdk.Context) clienttypes.Params
|
|
43
|
+
SetParams(ctx sdk.Context, params clienttypes.Params)
|
|
48
44
|
}
|
|
49
45
|
|
|
50
46
|
// PortKeeper defines the expected IBC port keeper
|
|
@@ -4,13 +4,14 @@ import (
|
|
|
4
4
|
fmt "fmt"
|
|
5
5
|
|
|
6
6
|
sdkioerrors "cosmossdk.io/errors"
|
|
7
|
+
agtypes "github.com/Agoric/agoric-sdk/golang/cosmos/types"
|
|
7
8
|
"github.com/Agoric/agoric-sdk/golang/cosmos/vm"
|
|
8
9
|
capability "github.com/cosmos/cosmos-sdk/x/capability/types"
|
|
9
|
-
channeltypes "github.com/cosmos/ibc-go/
|
|
10
|
-
porttypes "github.com/cosmos/ibc-go/
|
|
11
|
-
host "github.com/cosmos/ibc-go/
|
|
10
|
+
channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
|
|
11
|
+
porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types"
|
|
12
|
+
host "github.com/cosmos/ibc-go/v7/modules/core/24-host"
|
|
12
13
|
|
|
13
|
-
"github.com/cosmos/ibc-go/
|
|
14
|
+
"github.com/cosmos/ibc-go/v7/modules/core/exported"
|
|
14
15
|
|
|
15
16
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
16
17
|
)
|
|
@@ -45,6 +46,15 @@ func NewIBCModule(impl IBCModuleImpl) IBCModule {
|
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
|
|
49
|
+
type WriteAcknowledgementEvent struct {
|
|
50
|
+
*vm.ActionHeader `actionType:"IBC_EVENT"`
|
|
51
|
+
Event string `json:"event" default:"writeAcknowledgement"`
|
|
52
|
+
Target string `json:"target"`
|
|
53
|
+
Packet agtypes.IBCPacket `json:"packet"`
|
|
54
|
+
Acknowledgement []byte `json:"acknowledgement"`
|
|
55
|
+
Relayer sdk.AccAddress `json:"relayer"`
|
|
56
|
+
}
|
|
57
|
+
|
|
48
58
|
type ChannelOpenInitEvent struct {
|
|
49
59
|
*vm.ActionHeader `actionType:"IBC_EVENT"`
|
|
50
60
|
Event string `json:"event" default:"channelOpenInit"`
|
|
@@ -253,10 +263,10 @@ func (im IBCModule) OnChanCloseConfirm(
|
|
|
253
263
|
|
|
254
264
|
type ReceivePacketEvent struct {
|
|
255
265
|
*vm.ActionHeader `actionType:"IBC_EVENT"`
|
|
256
|
-
Event string
|
|
257
|
-
Target string
|
|
258
|
-
Packet
|
|
259
|
-
Relayer sdk.AccAddress
|
|
266
|
+
Event string `json:"event" default:"receivePacket"`
|
|
267
|
+
Target string `json:"target,omitempty"`
|
|
268
|
+
Packet agtypes.IBCPacket `json:"packet"`
|
|
269
|
+
Relayer sdk.AccAddress `json:"relayer"`
|
|
260
270
|
}
|
|
261
271
|
|
|
262
272
|
func (im IBCModule) OnRecvPacket(
|
|
@@ -273,7 +283,7 @@ func (im IBCModule) OnRecvPacket(
|
|
|
273
283
|
// the same packets.
|
|
274
284
|
|
|
275
285
|
event := ReceivePacketEvent{
|
|
276
|
-
Packet: packet,
|
|
286
|
+
Packet: agtypes.CopyToIBCPacket(packet),
|
|
277
287
|
Relayer: relayer,
|
|
278
288
|
}
|
|
279
289
|
|
|
@@ -287,11 +297,11 @@ func (im IBCModule) OnRecvPacket(
|
|
|
287
297
|
|
|
288
298
|
type AcknowledgementPacketEvent struct {
|
|
289
299
|
*vm.ActionHeader `actionType:"IBC_EVENT"`
|
|
290
|
-
Event string
|
|
291
|
-
Target string
|
|
292
|
-
Packet
|
|
293
|
-
Acknowledgement []byte
|
|
294
|
-
Relayer sdk.AccAddress
|
|
300
|
+
Event string `json:"event" default:"acknowledgementPacket"`
|
|
301
|
+
Target string `json:"target,omitempty"`
|
|
302
|
+
Packet agtypes.IBCPacket `json:"packet"`
|
|
303
|
+
Acknowledgement []byte `json:"acknowledgement"`
|
|
304
|
+
Relayer sdk.AccAddress `json:"relayer"`
|
|
295
305
|
}
|
|
296
306
|
|
|
297
307
|
func (im IBCModule) OnAcknowledgementPacket(
|
|
@@ -301,7 +311,7 @@ func (im IBCModule) OnAcknowledgementPacket(
|
|
|
301
311
|
relayer sdk.AccAddress,
|
|
302
312
|
) error {
|
|
303
313
|
event := AcknowledgementPacketEvent{
|
|
304
|
-
Packet: packet,
|
|
314
|
+
Packet: agtypes.CopyToIBCPacket(packet),
|
|
305
315
|
Acknowledgement: acknowledgement,
|
|
306
316
|
Relayer: relayer,
|
|
307
317
|
}
|
|
@@ -316,10 +326,10 @@ func (im IBCModule) OnAcknowledgementPacket(
|
|
|
316
326
|
|
|
317
327
|
type TimeoutPacketEvent struct {
|
|
318
328
|
*vm.ActionHeader `actionType:"IBC_EVENT"`
|
|
319
|
-
Event string
|
|
320
|
-
Target string
|
|
321
|
-
Packet
|
|
322
|
-
Relayer sdk.AccAddress
|
|
329
|
+
Event string `json:"event" default:"timeoutPacket"`
|
|
330
|
+
Target string `json:"target,omitempty"`
|
|
331
|
+
Packet agtypes.IBCPacket `json:"packet"`
|
|
332
|
+
Relayer sdk.AccAddress `json:"relayer"`
|
|
323
333
|
}
|
|
324
334
|
|
|
325
335
|
func (im IBCModule) OnTimeoutPacket(
|
|
@@ -328,7 +338,7 @@ func (im IBCModule) OnTimeoutPacket(
|
|
|
328
338
|
relayer sdk.AccAddress,
|
|
329
339
|
) error {
|
|
330
340
|
event := TimeoutPacketEvent{
|
|
331
|
-
Packet: packet,
|
|
341
|
+
Packet: agtypes.CopyToIBCPacket(packet),
|
|
332
342
|
Relayer: relayer,
|
|
333
343
|
}
|
|
334
344
|
|
package/x/vibc/types/msgs.go
CHANGED
|
@@ -4,7 +4,7 @@ import (
|
|
|
4
4
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
5
5
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
|
6
6
|
|
|
7
|
-
chanTypes "github.com/cosmos/ibc-go/
|
|
7
|
+
chanTypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
|
|
8
8
|
)
|
|
9
9
|
|
|
10
10
|
const RouterKey = ModuleName // this was defined in your key.go file
|