@agoric/cosmos 0.35.0-u20.0 → 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 +14 -2
- 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 +125 -24
- 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 +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 +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/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 +1 -1
- package/x/vibc/module.go +9 -17
- package/x/vibc/types/expected_keepers.go +5 -10
- package/x/vibc/types/ibc_module.go +4 -4
- package/x/vibc/types/msgs.go +1 -1
- package/x/vibc/types/msgs.pb.go +5 -4
- package/x/vibc/types/receiver.go +2 -2
- 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/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 +6 -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/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/ibc_middleware.go +4 -4
- package/x/vtransfer/ibc_middleware_test.go +10 -11
- package/x/vtransfer/keeper/keeper.go +5 -5
- 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
|
@@ -2,9 +2,8 @@ package keeper
|
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
4
|
"fmt"
|
|
5
|
-
"strings"
|
|
6
5
|
|
|
7
|
-
abci "github.com/
|
|
6
|
+
abci "github.com/cometbft/cometbft/abci/types"
|
|
8
7
|
|
|
9
8
|
sdkioerrors "cosmossdk.io/errors"
|
|
10
9
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
@@ -22,34 +21,6 @@ const (
|
|
|
22
21
|
LegacyQueryKeys = "keys"
|
|
23
22
|
)
|
|
24
23
|
|
|
25
|
-
// NewQuerier is the module level router for state queries
|
|
26
|
-
func NewQuerier(keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier {
|
|
27
|
-
return func(ctx sdk.Context, path []string, req abci.RequestQuery) (res []byte, err error) {
|
|
28
|
-
var queryType string
|
|
29
|
-
if len(path) > 0 {
|
|
30
|
-
queryType = path[0]
|
|
31
|
-
}
|
|
32
|
-
switch queryType {
|
|
33
|
-
case QueryEgress:
|
|
34
|
-
if len(path) < 2 || path[1] == "" {
|
|
35
|
-
return nil, sdkioerrors.Wrap(sdkerrors.ErrInvalidRequest, "missing egress address")
|
|
36
|
-
}
|
|
37
|
-
return queryEgress(ctx, path[1], req, keeper, legacyQuerierCdc)
|
|
38
|
-
case QueryMailbox:
|
|
39
|
-
if len(path) < 2 || path[1] == "" {
|
|
40
|
-
return nil, sdkioerrors.Wrap(sdkerrors.ErrInvalidRequest, "missing mailbox peer")
|
|
41
|
-
}
|
|
42
|
-
return queryMailbox(ctx, path[1], req, keeper, legacyQuerierCdc)
|
|
43
|
-
case LegacyQueryStorage:
|
|
44
|
-
return legacyQueryStorage(ctx, strings.Join(path[1:], "/"), req, keeper, legacyQuerierCdc)
|
|
45
|
-
case LegacyQueryKeys:
|
|
46
|
-
return legacyQueryKeys(ctx, strings.Join(path[1:], "/"), req, keeper, legacyQuerierCdc)
|
|
47
|
-
default:
|
|
48
|
-
return nil, sdkioerrors.Wrap(sdkerrors.ErrUnknownRequest, "unknown swingset query path")
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
24
|
// nolint: unparam
|
|
54
25
|
func queryEgress(ctx sdk.Context, bech32 string, req abci.RequestQuery, keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) {
|
|
55
26
|
acc, err := sdk.AccAddressFromBech32(bech32)
|
|
@@ -13,7 +13,7 @@ import (
|
|
|
13
13
|
agoric "github.com/Agoric/agoric-sdk/golang/cosmos/types"
|
|
14
14
|
"github.com/Agoric/agoric-sdk/golang/cosmos/vm"
|
|
15
15
|
"github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/types"
|
|
16
|
-
"github.com/
|
|
16
|
+
"github.com/cometbft/cometbft/libs/log"
|
|
17
17
|
)
|
|
18
18
|
|
|
19
19
|
// This module abstracts the generation and handling of swing-store exports,
|
package/x/swingset/module.go
CHANGED
|
@@ -16,8 +16,8 @@ import (
|
|
|
16
16
|
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
|
|
17
17
|
"github.com/cosmos/cosmos-sdk/types/module"
|
|
18
18
|
|
|
19
|
+
abci "github.com/cometbft/cometbft/abci/types"
|
|
19
20
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
20
|
-
abci "github.com/tendermint/tendermint/abci/types"
|
|
21
21
|
)
|
|
22
22
|
|
|
23
23
|
// type check to ensure the interface is properly implemented
|
|
@@ -115,19 +115,6 @@ func (am *AppModule) SetSwingStoreExportDir(dir string) {
|
|
|
115
115
|
|
|
116
116
|
func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {}
|
|
117
117
|
|
|
118
|
-
func (am AppModule) Route() sdk.Route {
|
|
119
|
-
return sdk.NewRoute(types.RouterKey, NewHandler(am.keeper))
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
func (am AppModule) QuerierRoute() string {
|
|
123
|
-
return ModuleName
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// LegacyQuerierHandler returns the sdk.Querier for deployment module
|
|
127
|
-
func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier {
|
|
128
|
-
return keeper.NewQuerier(am.keeper, legacyQuerierCdc)
|
|
129
|
-
}
|
|
130
|
-
|
|
131
118
|
func (am AppModule) RegisterServices(cfg module.Configurator) {
|
|
132
119
|
types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper))
|
|
133
120
|
querier := keeper.Querier{Keeper: am.keeper}
|
|
@@ -11,15 +11,16 @@ import (
|
|
|
11
11
|
// experience if they don't.
|
|
12
12
|
|
|
13
13
|
const (
|
|
14
|
+
BeansPerBlockComputeLimit = "blockComputeLimit"
|
|
15
|
+
BeansPerVatCreation = "vatCreation"
|
|
16
|
+
BeansPerXsnapComputron = "xsnapComputron"
|
|
17
|
+
|
|
14
18
|
BeansPerFeeUnit = "feeUnit"
|
|
15
19
|
BeansPerInboundTx = "inboundTx"
|
|
16
|
-
BeansPerBlockComputeLimit = "blockComputeLimit"
|
|
17
20
|
BeansPerMessage = "message"
|
|
18
21
|
BeansPerMessageByte = "messageByte"
|
|
19
22
|
BeansPerMinFeeDebit = "minFeeDebit"
|
|
20
23
|
BeansPerStorageByte = "storageByte"
|
|
21
|
-
BeansPerVatCreation = "vatCreation"
|
|
22
|
-
BeansPerXsnapComputron = "xsnapComputron"
|
|
23
24
|
BeansPerSmartWalletProvision = "smartWalletProvision"
|
|
24
25
|
|
|
25
26
|
// PowerFlags.
|
|
@@ -52,18 +53,24 @@ var (
|
|
|
52
53
|
// observed: 0.385 sec
|
|
53
54
|
DefaultBeansPerVatCreation = sdk.NewUint(300000).Mul(DefaultBeansPerXsnapComputron)
|
|
54
55
|
|
|
55
|
-
// Fees are
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
// Fees are represented as integer "beans", where each bean is a uniform
|
|
57
|
+
// fraction of this `fee_unit_price` as controlled by the below
|
|
58
|
+
// `beans_per_unit` "feeUnit".
|
|
58
59
|
// TODO: create the cost model we want, and update these to be more principled.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
60
|
+
DefaultFeeUnitPrice = sdk.NewCoins(sdk.NewInt64Coin("ubld", 1_000_000)) // 1 BLD
|
|
61
|
+
|
|
62
|
+
// The count of "beans" into which `fee_unit_price` is divided.
|
|
63
|
+
// Larger numbers make for smaller beans, and we expect values to be rather
|
|
64
|
+
// large for representing fees precisely in beans that each approximate
|
|
65
|
+
// a "picoUSD"--one trillionth of a USD.
|
|
66
|
+
DefaultBeansPerFeeUnit = sdk.NewUint(1_000_000_000_000) // 1e12 (assumes $1 per BLD)
|
|
67
|
+
|
|
68
|
+
DefaultBeansPerInboundTx = DefaultBeansPerFeeUnit.Quo(sdk.NewUint(100)) // 10e09, ~$0.01
|
|
69
|
+
DefaultBeansPerMessage = DefaultBeansPerFeeUnit.Quo(sdk.NewUint(1_000)) // 1e09, ~$0.001
|
|
70
|
+
DefaultBeansPerMessageByte = DefaultBeansPerFeeUnit.Quo(sdk.NewUint(50_000)) // 20e06, ~$0.00002
|
|
71
|
+
DefaultBeansPerMinFeeDebit = DefaultBeansPerFeeUnit.Quo(sdk.NewUint(5)) // 200e09, ~$0.2
|
|
72
|
+
DefaultBeansPerStorageByte = DefaultBeansPerFeeUnit.Quo(sdk.NewUint(500)) // 2e09, ~$0.002
|
|
73
|
+
DefaultBeansPerSmartWalletProvision = DefaultBeansPerFeeUnit // 1e12, ~$1
|
|
67
74
|
|
|
68
75
|
DefaultBootstrapVatConfig = "@agoric/vm-config/decentral-core-config.json"
|
|
69
76
|
|
|
@@ -97,15 +104,16 @@ var (
|
|
|
97
104
|
// move DefaultBeansPerUnit to a function to allow for boot overriding of the Default params
|
|
98
105
|
func DefaultBeansPerUnit() []StringBeans {
|
|
99
106
|
return []StringBeans{
|
|
107
|
+
NewStringBeans(BeansPerXsnapComputron, DefaultBeansPerXsnapComputron),
|
|
100
108
|
NewStringBeans(BeansPerBlockComputeLimit, DefaultBeansPerBlockComputeLimit),
|
|
109
|
+
NewStringBeans(BeansPerVatCreation, DefaultBeansPerVatCreation),
|
|
110
|
+
|
|
101
111
|
NewStringBeans(BeansPerFeeUnit, DefaultBeansPerFeeUnit),
|
|
102
112
|
NewStringBeans(BeansPerInboundTx, DefaultBeansPerInboundTx),
|
|
103
113
|
NewStringBeans(BeansPerMessage, DefaultBeansPerMessage),
|
|
104
114
|
NewStringBeans(BeansPerMessageByte, DefaultBeansPerMessageByte),
|
|
105
115
|
NewStringBeans(BeansPerMinFeeDebit, DefaultBeansPerMinFeeDebit),
|
|
106
116
|
NewStringBeans(BeansPerStorageByte, DefaultBeansPerStorageByte),
|
|
107
|
-
NewStringBeans(BeansPerVatCreation, DefaultBeansPerVatCreation),
|
|
108
|
-
NewStringBeans(BeansPerXsnapComputron, DefaultBeansPerXsnapComputron),
|
|
109
117
|
NewStringBeans(BeansPerSmartWalletProvision, DefaultBeansPerSmartWalletProvision),
|
|
110
118
|
}
|
|
111
119
|
}
|
|
@@ -7,9 +7,9 @@ import (
|
|
|
7
7
|
context "context"
|
|
8
8
|
fmt "fmt"
|
|
9
9
|
github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
|
|
10
|
-
_ "github.com/
|
|
11
|
-
grpc1 "github.com/
|
|
12
|
-
proto "github.com/
|
|
10
|
+
_ "github.com/cosmos/gogoproto/gogoproto"
|
|
11
|
+
grpc1 "github.com/cosmos/gogoproto/grpc"
|
|
12
|
+
proto "github.com/cosmos/gogoproto/proto"
|
|
13
13
|
grpc "google.golang.org/grpc"
|
|
14
14
|
codes "google.golang.org/grpc/codes"
|
|
15
15
|
status "google.golang.org/grpc/status"
|
|
@@ -811,6 +811,7 @@ func _Msg_Provision_Handler(srv interface{}, ctx context.Context, dec func(inter
|
|
|
811
811
|
return interceptor(ctx, in, info, handler)
|
|
812
812
|
}
|
|
813
813
|
|
|
814
|
+
var Msg_serviceDesc = _Msg_serviceDesc
|
|
814
815
|
var _Msg_serviceDesc = grpc.ServiceDesc{
|
|
815
816
|
ServiceName: "agoric.swingset.Msg",
|
|
816
817
|
HandlerType: (*MsgServer)(nil),
|
|
@@ -7,9 +7,9 @@ import (
|
|
|
7
7
|
context "context"
|
|
8
8
|
fmt "fmt"
|
|
9
9
|
github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
|
|
10
|
-
_ "github.com/
|
|
11
|
-
grpc1 "github.com/
|
|
12
|
-
proto "github.com/
|
|
10
|
+
_ "github.com/cosmos/gogoproto/gogoproto"
|
|
11
|
+
grpc1 "github.com/cosmos/gogoproto/grpc"
|
|
12
|
+
proto "github.com/cosmos/gogoproto/proto"
|
|
13
13
|
_ "google.golang.org/genproto/googleapis/api/annotations"
|
|
14
14
|
grpc "google.golang.org/grpc"
|
|
15
15
|
codes "google.golang.org/grpc/codes"
|
|
@@ -476,6 +476,7 @@ func _Query_Mailbox_Handler(srv interface{}, ctx context.Context, dec func(inter
|
|
|
476
476
|
return interceptor(ctx, in, info, handler)
|
|
477
477
|
}
|
|
478
478
|
|
|
479
|
+
var Query_serviceDesc = _Query_serviceDesc
|
|
479
480
|
var _Query_serviceDesc = grpc.ServiceDesc{
|
|
480
481
|
ServiceName: "agoric.swingset.Query",
|
|
481
482
|
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/genesis.go
CHANGED
|
@@ -4,8 +4,8 @@ import (
|
|
|
4
4
|
"fmt"
|
|
5
5
|
|
|
6
6
|
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vbank/types"
|
|
7
|
+
abci "github.com/cometbft/cometbft/abci/types"
|
|
7
8
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
8
|
-
abci "github.com/tendermint/tendermint/abci/types"
|
|
9
9
|
)
|
|
10
10
|
|
|
11
11
|
func NewGenesisState() *types.GenesisState {
|
|
@@ -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
|
+
}
|