@agoric/cosmos 0.34.2-orchestration-dev-096c4e8.0 → 0.34.2-other-dev-3eb1a1d.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/MAINTAINERS.md +3 -0
- package/Makefile +38 -34
- package/ante/ante.go +1 -4
- package/ante/inbound_test.go +2 -2
- package/app/app.go +198 -137
- package/app/upgrade.go +248 -0
- package/cmd/agd/agvm.go +3 -3
- package/cmd/agd/find_binary.go +2 -2
- package/cmd/agd/main.go +9 -10
- package/cmd/libdaemon/main.go +13 -13
- package/daemon/cmd/root.go +235 -92
- package/daemon/cmd/root_test.go +189 -1
- package/daemon/main.go +3 -2
- package/git-revision.txt +1 -1
- package/go.mod +14 -11
- package/go.sum +20 -19
- package/index.cjs +1 -1
- package/package.json +4 -3
- package/proto/agoric/swingset/genesis.proto +4 -0
- package/proto/agoric/swingset/swingset.proto +26 -1
- package/proto/agoric/vbank/vbank.proto +7 -0
- package/proto/agoric/vtransfer/genesis.proto +18 -0
- package/scripts/protocgen.sh +7 -8
- package/types/kv_entry_helpers.go +42 -0
- package/upgradegaia.sh +8 -8
- package/util/util.go +21 -0
- package/vm/action.go +1 -1
- package/vm/client.go +15 -13
- package/vm/client_test.go +34 -36
- package/vm/controller.go +3 -38
- package/vm/core_proposals.go +22 -2
- package/vm/proto_json.go +38 -0
- package/vm/proto_json_test.go +103 -0
- package/vm/server.go +106 -5
- package/x/swingset/alias.go +2 -0
- package/x/swingset/config.go +234 -0
- package/x/swingset/genesis.go +178 -40
- package/x/swingset/keeper/extension_snapshotter.go +2 -2
- package/x/swingset/keeper/keeper.go +24 -27
- package/x/swingset/keeper/swing_store_exports_handler.go +14 -3
- package/x/swingset/keeper/test_utils.go +16 -0
- package/x/swingset/module.go +24 -9
- package/x/swingset/testing/queue.go +17 -0
- package/x/swingset/types/default-params.go +31 -5
- package/x/swingset/types/expected_keepers.go +2 -2
- package/x/swingset/types/genesis.pb.go +78 -25
- package/x/swingset/types/msgs.go +53 -12
- package/x/swingset/types/params.go +53 -43
- package/x/swingset/types/params_test.go +75 -9
- package/x/swingset/types/swingset.pb.go +387 -57
- package/x/vbank/README.md +6 -1
- package/x/vbank/genesis.go +0 -2
- package/x/vbank/keeper/keeper.go +4 -9
- package/x/vbank/keeper/migrations.go +30 -0
- package/x/vbank/module.go +8 -7
- package/x/vbank/types/key.go +3 -3
- package/x/vbank/types/msgs.go +0 -12
- package/x/vbank/types/params.go +43 -2
- package/x/vbank/types/vbank.pb.go +105 -36
- package/x/vbank/vbank.go +8 -13
- package/x/vbank/vbank_test.go +14 -9
- package/x/vibc/alias.go +1 -1
- package/x/vibc/module.go +2 -7
- package/x/vibc/types/ibc_module.go +9 -3
- package/x/vibc/types/receiver.go +17 -7
- package/x/vlocalchain/handler.go +2 -1
- package/x/vlocalchain/keeper/keeper.go +24 -8
- package/x/vlocalchain/keeper/keeper_test.go +65 -1
- package/x/vlocalchain/types/expected_keepers.go +12 -0
- package/x/vlocalchain/vlocalchain.go +27 -22
- package/x/vlocalchain/vlocalchain_test.go +163 -8
- package/x/vstorage/keeper/grpc_query.go +0 -1
- package/x/vstorage/keeper/keeper.go +9 -17
- package/x/vstorage/module.go +0 -5
- package/x/vstorage/testing/queue.go +28 -0
- package/x/vtransfer/alias.go +13 -0
- package/x/vtransfer/genesis.go +39 -0
- package/x/vtransfer/genesis_test.go +12 -0
- package/x/vtransfer/handler.go +20 -0
- package/x/vtransfer/ibc_middleware.go +186 -0
- package/x/vtransfer/ibc_middleware_test.go +449 -0
- package/x/vtransfer/keeper/keeper.go +282 -0
- package/x/vtransfer/module.go +124 -0
- package/x/vtransfer/types/baseaddr.go +156 -0
- package/x/vtransfer/types/baseaddr_test.go +167 -0
- package/x/vtransfer/types/expected_keepers.go +38 -0
- package/x/vtransfer/types/genesis.pb.go +328 -0
- package/x/vtransfer/types/key.go +9 -0
- package/x/vtransfer/types/msgs.go +9 -0
- package/ante/fee.go +0 -97
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
package keeper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vbank/types"
|
|
5
|
+
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
// Migrator handles in-place store migrations.
|
|
9
|
+
type Migrator struct {
|
|
10
|
+
keeper Keeper
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// NewMigrator creates a new Migrator based on the keeper.
|
|
14
|
+
func NewMigrator(keeper Keeper) Migrator {
|
|
15
|
+
return Migrator{keeper: keeper}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Migrate1to2 migrates from version 1 to 2.
|
|
19
|
+
func (m Migrator) Migrate1to2(ctx sdk.Context) error {
|
|
20
|
+
params := m.keeper.GetParams(ctx)
|
|
21
|
+
if params.AllowedMonitoringAccounts != nil {
|
|
22
|
+
return nil
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
defaultParams := types.DefaultParams()
|
|
26
|
+
params.AllowedMonitoringAccounts = defaultParams.AllowedMonitoringAccounts
|
|
27
|
+
m.keeper.SetParams(ctx, params)
|
|
28
|
+
|
|
29
|
+
return nil
|
|
30
|
+
}
|
package/x/vbank/module.go
CHANGED
|
@@ -5,7 +5,6 @@ import (
|
|
|
5
5
|
"encoding/json"
|
|
6
6
|
stdlog "log"
|
|
7
7
|
|
|
8
|
-
"github.com/gorilla/mux"
|
|
9
8
|
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
|
10
9
|
"github.com/spf13/cobra"
|
|
11
10
|
|
|
@@ -60,10 +59,6 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod
|
|
|
60
59
|
return ValidateGenesis(&data)
|
|
61
60
|
}
|
|
62
61
|
|
|
63
|
-
// Register rest routes
|
|
64
|
-
func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {
|
|
65
|
-
}
|
|
66
|
-
|
|
67
62
|
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
|
|
68
63
|
_ = types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx))
|
|
69
64
|
}
|
|
@@ -96,7 +91,7 @@ func (AppModule) Name() string {
|
|
|
96
91
|
return ModuleName
|
|
97
92
|
}
|
|
98
93
|
|
|
99
|
-
func (AppModule) ConsensusVersion() uint64 { return
|
|
94
|
+
func (AppModule) ConsensusVersion() uint64 { return 2 }
|
|
100
95
|
|
|
101
96
|
// BeginBlock implements the AppModule interface
|
|
102
97
|
func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {
|
|
@@ -162,7 +157,7 @@ NextEvent:
|
|
|
162
157
|
addressToUpdate = make(map[string]sdk.Coins, len(addressToUpdate))
|
|
163
158
|
for addr, denoms := range unfilteredAddresses {
|
|
164
159
|
accAddr, err := sdk.AccAddressFromBech32(addr)
|
|
165
|
-
if err == nil && am.keeper.
|
|
160
|
+
if err == nil && am.keeper.IsAllowedMonitoringAccount(ctx, accAddr) {
|
|
166
161
|
// Pass through the module account.
|
|
167
162
|
addressToUpdate[addr] = denoms
|
|
168
163
|
}
|
|
@@ -209,6 +204,12 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
|
|
|
209
204
|
tx := &types.UnimplementedMsgServer{}
|
|
210
205
|
types.RegisterMsgServer(cfg.MsgServer(), tx)
|
|
211
206
|
types.RegisterQueryServer(cfg.QueryServer(), am.keeper)
|
|
207
|
+
|
|
208
|
+
m := keeper.NewMigrator(am.keeper)
|
|
209
|
+
err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2)
|
|
210
|
+
if err != nil {
|
|
211
|
+
panic(err)
|
|
212
|
+
}
|
|
212
213
|
}
|
|
213
214
|
|
|
214
215
|
// InitGenesis performs genesis initialization for the ibc-transfer module. It returns
|
package/x/vbank/types/key.go
CHANGED
|
@@ -7,7 +7,7 @@ const (
|
|
|
7
7
|
// StoreKey to be used when creating the KVStore
|
|
8
8
|
StoreKey = ModuleName
|
|
9
9
|
|
|
10
|
-
ReservePoolName
|
|
11
|
-
GiveawayPoolName
|
|
12
|
-
ProvisionPoolName
|
|
10
|
+
ReservePoolName = "vbank/reserve"
|
|
11
|
+
GiveawayPoolName = "vbank/giveaway"
|
|
12
|
+
ProvisionPoolName = "vbank/provision"
|
|
13
13
|
)
|
package/x/vbank/types/msgs.go
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
1
|
package types
|
|
2
2
|
|
|
3
3
|
const RouterKey = ModuleName // this was defined in your key.go file
|
|
4
|
-
|
|
5
|
-
type VbankSingleBalanceUpdate struct {
|
|
6
|
-
Address string `json:"address"`
|
|
7
|
-
Denom string `json:"denom"`
|
|
8
|
-
Amount string `json:"amount"`
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
type VbankBalanceUpdate struct {
|
|
12
|
-
Nonce uint64 `json:"nonce"`
|
|
13
|
-
Type string `json:"type"`
|
|
14
|
-
Updated []VbankSingleBalanceUpdate `json:"updated"`
|
|
15
|
-
}
|
package/x/vbank/types/params.go
CHANGED
|
@@ -6,14 +6,18 @@ import (
|
|
|
6
6
|
yaml "gopkg.in/yaml.v2"
|
|
7
7
|
|
|
8
8
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
9
|
+
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
|
9
10
|
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
|
10
11
|
)
|
|
11
12
|
|
|
13
|
+
const AllowAllMonitoringAccountsPattern = "*"
|
|
14
|
+
|
|
12
15
|
// Parameter keys
|
|
13
16
|
var (
|
|
14
17
|
ParamStoreKeyRewardEpochDurationBlocks = []byte("reward_epoch_duration_blocks")
|
|
15
18
|
ParamStoreKeyRewardSmoothingBlocks = []byte("reward_smoothing_blocks")
|
|
16
19
|
ParamStoreKeyPerEpochRewardFraction = []byte("per_epoch_reward_fraction")
|
|
20
|
+
ParamStoreKeyAllowedMonitoringAccounts = []byte("allowed_monitoring_accounts")
|
|
17
21
|
)
|
|
18
22
|
|
|
19
23
|
// ParamKeyTable returns the parameter key table.
|
|
@@ -21,12 +25,14 @@ func ParamKeyTable() paramtypes.KeyTable {
|
|
|
21
25
|
return paramtypes.NewKeyTable().RegisterParamSet(&Params{})
|
|
22
26
|
}
|
|
23
27
|
|
|
24
|
-
// DefaultParams returns default
|
|
28
|
+
// DefaultParams returns default parameters
|
|
25
29
|
func DefaultParams() Params {
|
|
30
|
+
provisionAddress := authtypes.NewModuleAddress(ProvisionPoolName)
|
|
26
31
|
return Params{
|
|
27
32
|
RewardEpochDurationBlocks: 0,
|
|
28
33
|
RewardSmoothingBlocks: 1,
|
|
29
34
|
PerEpochRewardFraction: sdk.OneDec(),
|
|
35
|
+
AllowedMonitoringAccounts: []string{provisionAddress.String()},
|
|
30
36
|
}
|
|
31
37
|
}
|
|
32
38
|
|
|
@@ -67,12 +73,27 @@ func (p Params) RewardRate(pool sdk.Coins, blocks int64) sdk.Coins {
|
|
|
67
73
|
return sdk.NewCoins(coins...)
|
|
68
74
|
}
|
|
69
75
|
|
|
76
|
+
// IsAllowedMonitoringAccount checks to see if a given address is allowed to monitor its balance.
|
|
77
|
+
func (p Params) IsAllowedMonitoringAccount(addr string) bool {
|
|
78
|
+
for _, pat := range p.AllowedMonitoringAccounts {
|
|
79
|
+
switch pat {
|
|
80
|
+
case AllowAllMonitoringAccountsPattern, addr:
|
|
81
|
+
// Got an AllowAll pattern or an exact match.
|
|
82
|
+
return true
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// No match found.
|
|
87
|
+
return false
|
|
88
|
+
}
|
|
89
|
+
|
|
70
90
|
// ParamSetPairs returns the parameter set pairs.
|
|
71
91
|
func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
|
|
72
92
|
return paramtypes.ParamSetPairs{
|
|
73
93
|
paramtypes.NewParamSetPair(ParamStoreKeyRewardEpochDurationBlocks, &p.RewardEpochDurationBlocks, validateRewardEpochDurationBlocks),
|
|
74
94
|
paramtypes.NewParamSetPair(ParamStoreKeyRewardSmoothingBlocks, &p.RewardSmoothingBlocks, validateRewardSmoothingBlocks),
|
|
75
95
|
paramtypes.NewParamSetPair(ParamStoreKeyPerEpochRewardFraction, &p.PerEpochRewardFraction, validatePerEpochRewardFraction),
|
|
96
|
+
paramtypes.NewParamSetPair(ParamStoreKeyAllowedMonitoringAccounts, &p.AllowedMonitoringAccounts, validateAllowedMonitoringAccounts),
|
|
76
97
|
}
|
|
77
98
|
}
|
|
78
99
|
|
|
@@ -84,7 +105,12 @@ func (p Params) ValidateBasic() error {
|
|
|
84
105
|
if err := validatePerEpochRewardFraction(p.PerEpochRewardFraction); err != nil {
|
|
85
106
|
return err
|
|
86
107
|
}
|
|
87
|
-
|
|
108
|
+
if err := validateRewardSmoothingBlocks(p.RewardSmoothingBlocks); err != nil {
|
|
109
|
+
return err
|
|
110
|
+
}
|
|
111
|
+
if err := validateAllowedMonitoringAccounts(p.AllowedMonitoringAccounts); err != nil {
|
|
112
|
+
return err
|
|
113
|
+
}
|
|
88
114
|
return nil
|
|
89
115
|
}
|
|
90
116
|
|
|
@@ -130,3 +156,18 @@ func validatePerEpochRewardFraction(i interface{}) error {
|
|
|
130
156
|
|
|
131
157
|
return nil
|
|
132
158
|
}
|
|
159
|
+
|
|
160
|
+
func validateAllowedMonitoringAccounts(i interface{}) error {
|
|
161
|
+
v, ok := i.([]string)
|
|
162
|
+
if !ok {
|
|
163
|
+
return fmt.Errorf("invalid parameter type: %T", i)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
for a, acc := range v {
|
|
167
|
+
if acc == "" {
|
|
168
|
+
return fmt.Errorf("allowed monitoring accounts element[%d] cannot be empty", a)
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return nil
|
|
173
|
+
}
|
|
@@ -39,6 +39,10 @@ type Params struct {
|
|
|
39
39
|
// an epoch's rewards. If zero, use the same value as
|
|
40
40
|
// reward_epoch_duration_blocks.
|
|
41
41
|
RewardSmoothingBlocks int64 `protobuf:"varint,3,opt,name=reward_smoothing_blocks,json=rewardSmoothingBlocks,proto3" json:"reward_smoothing_blocks,omitempty" yaml:"reward_smoothing_blocks"`
|
|
42
|
+
// allowed_monitoring_accounts is an array of account addresses that can be
|
|
43
|
+
// monitored for sends and receives. An element of `"*"` will permit any
|
|
44
|
+
// address.
|
|
45
|
+
AllowedMonitoringAccounts []string `protobuf:"bytes,4,rep,name=allowed_monitoring_accounts,json=allowedMonitoringAccounts,proto3" json:"allowed_monitoring_accounts,omitempty" yaml:"allowed_monitoring_accounts"`
|
|
42
46
|
}
|
|
43
47
|
|
|
44
48
|
func (m *Params) Reset() { *m = Params{} }
|
|
@@ -87,6 +91,13 @@ func (m *Params) GetRewardSmoothingBlocks() int64 {
|
|
|
87
91
|
return 0
|
|
88
92
|
}
|
|
89
93
|
|
|
94
|
+
func (m *Params) GetAllowedMonitoringAccounts() []string {
|
|
95
|
+
if m != nil {
|
|
96
|
+
return m.AllowedMonitoringAccounts
|
|
97
|
+
}
|
|
98
|
+
return nil
|
|
99
|
+
}
|
|
100
|
+
|
|
90
101
|
// The current state of the module.
|
|
91
102
|
type State struct {
|
|
92
103
|
// rewardPool is the current balance of rewards in the module account.
|
|
@@ -170,42 +181,45 @@ func init() {
|
|
|
170
181
|
func init() { proto.RegisterFile("agoric/vbank/vbank.proto", fileDescriptor_5e89b3b9e5e671b4) }
|
|
171
182
|
|
|
172
183
|
var fileDescriptor_5e89b3b9e5e671b4 = []byte{
|
|
173
|
-
//
|
|
174
|
-
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94,
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
0x20,
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
0x72,
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
0x62,
|
|
207
|
-
|
|
208
|
-
|
|
184
|
+
// 597 bytes of a gzipped FileDescriptorProto
|
|
185
|
+
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0x3f, 0x6f, 0xd3, 0x4e,
|
|
186
|
+
0x18, 0xc7, 0xe3, 0x26, 0xbf, 0xea, 0xd7, 0x6b, 0x19, 0x30, 0x05, 0x9c, 0x16, 0xd9, 0xd1, 0x21,
|
|
187
|
+
0x4a, 0x18, 0xb0, 0x55, 0x58, 0x50, 0x25, 0x86, 0x9a, 0xd2, 0x0d, 0x54, 0xb9, 0x03, 0x52, 0x97,
|
|
188
|
+
0xe8, 0x7c, 0xb9, 0x3a, 0x56, 0x6d, 0x3f, 0xe1, 0xee, 0xd2, 0xd2, 0x95, 0x57, 0x80, 0x98, 0x60,
|
|
189
|
+
0xeb, 0xcc, 0x2b, 0xe9, 0xd8, 0x05, 0x09, 0x21, 0x61, 0x50, 0xbb, 0x30, 0xe7, 0x15, 0xa0, 0xfb,
|
|
190
|
+
0x53, 0xda, 0x20, 0x14, 0x60, 0x49, 0xe2, 0x7c, 0xbe, 0xcf, 0x93, 0xef, 0xf3, 0x27, 0x0f, 0xf2,
|
|
191
|
+
0x48, 0x06, 0x3c, 0xa7, 0xd1, 0x7e, 0x4a, 0xaa, 0x3d, 0xf3, 0x1a, 0x0e, 0x39, 0x48, 0x70, 0x17,
|
|
192
|
+
0x0c, 0x09, 0xf5, 0x77, 0x4b, 0x8b, 0x19, 0x64, 0xa0, 0x41, 0xa4, 0x3e, 0x19, 0xcd, 0x92, 0x4f,
|
|
193
|
+
0x41, 0x94, 0x20, 0xa2, 0x94, 0x08, 0x16, 0xed, 0xaf, 0xa6, 0x4c, 0x92, 0xd5, 0x88, 0x42, 0x5e,
|
|
194
|
+
0x19, 0x8e, 0x3f, 0x36, 0xd1, 0xec, 0x16, 0xe1, 0xa4, 0x14, 0xee, 0x00, 0xdd, 0xe2, 0xec, 0x80,
|
|
195
|
+
0xf0, 0x7e, 0x8f, 0x0d, 0x81, 0x0e, 0x7a, 0xfd, 0x11, 0x27, 0x32, 0x87, 0xaa, 0x97, 0x16, 0x40,
|
|
196
|
+
0xf7, 0x84, 0xe7, 0x74, 0x9c, 0x6e, 0x33, 0xbe, 0x3b, 0xae, 0x83, 0xdb, 0x87, 0xa4, 0x2c, 0xd6,
|
|
197
|
+
0xf0, 0x34, 0x35, 0x4e, 0xda, 0x06, 0x3f, 0x55, 0x74, 0xc3, 0xc2, 0x58, 0x33, 0xf7, 0xad, 0x83,
|
|
198
|
+
0xda, 0x43, 0xc6, 0x6d, 0xa4, 0x4d, 0xb3, 0xcb, 0x09, 0x55, 0x1a, 0x6f, 0xa6, 0xe3, 0x74, 0xe7,
|
|
199
|
+
0xe2, 0x17, 0xc7, 0x75, 0xd0, 0xf8, 0x5c, 0x07, 0x2b, 0x59, 0x2e, 0x07, 0xa3, 0x34, 0xa4, 0x50,
|
|
200
|
+
0x46, 0xb6, 0x16, 0xf3, 0x76, 0x5f, 0xf4, 0xf7, 0x22, 0x79, 0x38, 0x64, 0x22, 0xdc, 0x60, 0x74,
|
|
201
|
+
0x5c, 0x07, 0x77, 0x8c, 0xab, 0x7e, 0x2e, 0x28, 0x67, 0x92, 0xfd, 0x3e, 0x3b, 0x4e, 0x6e, 0x0c,
|
|
202
|
+
0x19, 0xd7, 0xa6, 0x12, 0x4d, 0x36, 0x2d, 0x70, 0x77, 0xd0, 0x4d, 0xab, 0x15, 0x25, 0x80, 0x1c,
|
|
203
|
+
0xe4, 0x55, 0x76, 0x5e, 0x79, 0x53, 0x57, 0x8e, 0xc7, 0x75, 0xe0, 0x4f, 0x54, 0xfe, 0xab, 0x10,
|
|
204
|
+
0x27, 0xd7, 0x0d, 0xd9, 0x3e, 0x07, 0xb6, 0xe0, 0x5d, 0xb4, 0x4c, 0x8a, 0x02, 0x0e, 0x58, 0xbf,
|
|
205
|
+
0x57, 0x42, 0x95, 0x4b, 0xe0, 0x2a, 0x88, 0x50, 0x0a, 0xa3, 0x4a, 0x0a, 0xaf, 0xd5, 0x69, 0x76,
|
|
206
|
+
0xe7, 0xe2, 0x95, 0x71, 0x1d, 0x60, 0x93, 0x7f, 0x8a, 0x18, 0x27, 0x6d, 0x4b, 0x9f, 0xfd, 0x84,
|
|
207
|
+
0xeb, 0x96, 0xad, 0xfd, 0xff, 0xee, 0x28, 0x68, 0x7c, 0x3f, 0x0a, 0x1c, 0xfc, 0xa5, 0x89, 0xfe,
|
|
208
|
+
0xdb, 0x96, 0x44, 0x32, 0xf7, 0xb5, 0x83, 0xe6, 0xad, 0xdf, 0x21, 0x40, 0xe1, 0x39, 0x9d, 0x66,
|
|
209
|
+
0x77, 0xfe, 0x41, 0x3b, 0x34, 0x5d, 0x0c, 0xd5, 0x62, 0x84, 0x76, 0x31, 0xc2, 0x27, 0x90, 0x57,
|
|
210
|
+
0xf1, 0xa6, 0xea, 0xfc, 0xb8, 0x0e, 0xdc, 0x89, 0x5a, 0x55, 0x2c, 0xfe, 0xf0, 0x35, 0xe8, 0xfe,
|
|
211
|
+
0xc5, 0x3c, 0x54, 0x1a, 0x91, 0x20, 0x13, 0xb9, 0x05, 0x50, 0xb8, 0xef, 0x1d, 0x74, 0xcd, 0x26,
|
|
212
|
+
0xd2, 0xad, 0xea, 0x91, 0x52, 0x39, 0xf6, 0x66, 0xfe, 0x64, 0xe6, 0xb9, 0x35, 0xb3, 0x34, 0x61,
|
|
213
|
+
0xe6, 0x72, 0x8e, 0x7f, 0x33, 0x75, 0xd5, 0x64, 0xd0, 0x73, 0x59, 0xd7, 0xf1, 0xee, 0x63, 0x74,
|
|
214
|
+
0xa5, 0x20, 0x42, 0xf6, 0x04, 0x7b, 0x39, 0x62, 0x15, 0x65, 0x7a, 0xdc, 0xad, 0xd8, 0x1b, 0xd7,
|
|
215
|
+
0xc1, 0xa2, 0xf9, 0xd5, 0x09, 0x8c, 0x93, 0x05, 0xf5, 0xbc, 0x6d, 0x1f, 0xdd, 0x0a, 0xf9, 0x9a,
|
|
216
|
+
0x5b, 0x6b, 0xfd, 0x5c, 0x48, 0x9e, 0xa7, 0xa3, 0x8b, 0xff, 0x82, 0xd7, 0xd2, 0xeb, 0x73, 0xef,
|
|
217
|
+
0x62, 0x45, 0xa7, 0xeb, 0x71, 0xb2, 0xac, 0x04, 0x66, 0x3d, 0x37, 0x2e, 0x61, 0x6d, 0x7a, 0xad,
|
|
218
|
+
0xa5, 0xe6, 0x1b, 0x27, 0xc7, 0xa7, 0xbe, 0x73, 0x72, 0xea, 0x3b, 0xdf, 0x4e, 0x7d, 0xe7, 0xcd,
|
|
219
|
+
0x99, 0xdf, 0x38, 0x39, 0xf3, 0x1b, 0x9f, 0xce, 0xfc, 0xc6, 0xce, 0xa3, 0x4b, 0xbd, 0x58, 0x37,
|
|
220
|
+
0xa7, 0xc3, 0xdc, 0x09, 0xdd, 0x8b, 0x0c, 0x0a, 0x52, 0x65, 0xe7, 0x4d, 0x7a, 0x65, 0xaf, 0x8a,
|
|
221
|
+
0xee, 0x50, 0x3a, 0xab, 0x4f, 0xc2, 0xc3, 0x1f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x60, 0x18, 0x80,
|
|
222
|
+
0x8f, 0x72, 0x04, 0x00, 0x00,
|
|
209
223
|
}
|
|
210
224
|
|
|
211
225
|
func (this *Params) Equal(that interface{}) bool {
|
|
@@ -236,6 +250,14 @@ func (this *Params) Equal(that interface{}) bool {
|
|
|
236
250
|
if this.RewardSmoothingBlocks != that1.RewardSmoothingBlocks {
|
|
237
251
|
return false
|
|
238
252
|
}
|
|
253
|
+
if len(this.AllowedMonitoringAccounts) != len(that1.AllowedMonitoringAccounts) {
|
|
254
|
+
return false
|
|
255
|
+
}
|
|
256
|
+
for i := range this.AllowedMonitoringAccounts {
|
|
257
|
+
if this.AllowedMonitoringAccounts[i] != that1.AllowedMonitoringAccounts[i] {
|
|
258
|
+
return false
|
|
259
|
+
}
|
|
260
|
+
}
|
|
239
261
|
return true
|
|
240
262
|
}
|
|
241
263
|
func (this *State) Equal(that interface{}) bool {
|
|
@@ -301,6 +323,15 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|
|
301
323
|
_ = i
|
|
302
324
|
var l int
|
|
303
325
|
_ = l
|
|
326
|
+
if len(m.AllowedMonitoringAccounts) > 0 {
|
|
327
|
+
for iNdEx := len(m.AllowedMonitoringAccounts) - 1; iNdEx >= 0; iNdEx-- {
|
|
328
|
+
i -= len(m.AllowedMonitoringAccounts[iNdEx])
|
|
329
|
+
copy(dAtA[i:], m.AllowedMonitoringAccounts[iNdEx])
|
|
330
|
+
i = encodeVarintVbank(dAtA, i, uint64(len(m.AllowedMonitoringAccounts[iNdEx])))
|
|
331
|
+
i--
|
|
332
|
+
dAtA[i] = 0x22
|
|
333
|
+
}
|
|
334
|
+
}
|
|
304
335
|
if m.RewardSmoothingBlocks != 0 {
|
|
305
336
|
i = encodeVarintVbank(dAtA, i, uint64(m.RewardSmoothingBlocks))
|
|
306
337
|
i--
|
|
@@ -410,6 +441,12 @@ func (m *Params) Size() (n int) {
|
|
|
410
441
|
if m.RewardSmoothingBlocks != 0 {
|
|
411
442
|
n += 1 + sovVbank(uint64(m.RewardSmoothingBlocks))
|
|
412
443
|
}
|
|
444
|
+
if len(m.AllowedMonitoringAccounts) > 0 {
|
|
445
|
+
for _, s := range m.AllowedMonitoringAccounts {
|
|
446
|
+
l = len(s)
|
|
447
|
+
n += 1 + l + sovVbank(uint64(l))
|
|
448
|
+
}
|
|
449
|
+
}
|
|
413
450
|
return n
|
|
414
451
|
}
|
|
415
452
|
|
|
@@ -547,6 +584,38 @@ func (m *Params) Unmarshal(dAtA []byte) error {
|
|
|
547
584
|
break
|
|
548
585
|
}
|
|
549
586
|
}
|
|
587
|
+
case 4:
|
|
588
|
+
if wireType != 2 {
|
|
589
|
+
return fmt.Errorf("proto: wrong wireType = %d for field AllowedMonitoringAccounts", wireType)
|
|
590
|
+
}
|
|
591
|
+
var stringLen uint64
|
|
592
|
+
for shift := uint(0); ; shift += 7 {
|
|
593
|
+
if shift >= 64 {
|
|
594
|
+
return ErrIntOverflowVbank
|
|
595
|
+
}
|
|
596
|
+
if iNdEx >= l {
|
|
597
|
+
return io.ErrUnexpectedEOF
|
|
598
|
+
}
|
|
599
|
+
b := dAtA[iNdEx]
|
|
600
|
+
iNdEx++
|
|
601
|
+
stringLen |= uint64(b&0x7F) << shift
|
|
602
|
+
if b < 0x80 {
|
|
603
|
+
break
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
intStringLen := int(stringLen)
|
|
607
|
+
if intStringLen < 0 {
|
|
608
|
+
return ErrInvalidLengthVbank
|
|
609
|
+
}
|
|
610
|
+
postIndex := iNdEx + intStringLen
|
|
611
|
+
if postIndex < 0 {
|
|
612
|
+
return ErrInvalidLengthVbank
|
|
613
|
+
}
|
|
614
|
+
if postIndex > l {
|
|
615
|
+
return io.ErrUnexpectedEOF
|
|
616
|
+
}
|
|
617
|
+
m.AllowedMonitoringAccounts = append(m.AllowedMonitoringAccounts, string(dAtA[iNdEx:postIndex]))
|
|
618
|
+
iNdEx = postIndex
|
|
550
619
|
default:
|
|
551
620
|
iNdEx = preIndex
|
|
552
621
|
skippy, err := skipVbank(dAtA[iNdEx:])
|
package/x/vbank/vbank.go
CHANGED
|
@@ -34,14 +34,14 @@ func NewPortHandler(am AppModule, keeper Keeper) portHandler {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
type
|
|
37
|
+
type VbankSingleBalanceUpdate struct {
|
|
38
38
|
Address string `json:"address"`
|
|
39
39
|
Denom string `json:"denom"`
|
|
40
40
|
Amount string `json:"amount"`
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
// Make vbankManyBalanceUpdates sortable
|
|
44
|
-
type vbankManyBalanceUpdates []
|
|
44
|
+
type vbankManyBalanceUpdates []VbankSingleBalanceUpdate
|
|
45
45
|
|
|
46
46
|
var _ sort.Interface = vbankManyBalanceUpdates{}
|
|
47
47
|
|
|
@@ -67,7 +67,7 @@ func (vbu vbankManyBalanceUpdates) Swap(i int, j int) {
|
|
|
67
67
|
vbu[i], vbu[j] = vbu[j], vbu[i]
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
type
|
|
70
|
+
type VbankBalanceUpdate struct {
|
|
71
71
|
*vm.ActionHeader `actionType:"VBANK_BALANCE_UPDATE"`
|
|
72
72
|
Nonce uint64 `json:"nonce"`
|
|
73
73
|
Updated vbankManyBalanceUpdates `json:"updated"`
|
|
@@ -83,9 +83,9 @@ func getBalanceUpdate(ctx sdk.Context, keeper Keeper, addressToUpdate map[string
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
nonce := keeper.GetNextSequence(ctx)
|
|
86
|
-
event :=
|
|
86
|
+
event := VbankBalanceUpdate{
|
|
87
87
|
Nonce: nonce,
|
|
88
|
-
Updated: make([]
|
|
88
|
+
Updated: make([]VbankSingleBalanceUpdate, 0, nentries),
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
// Note that Golang randomises the order of iteration, so we have to sort
|
|
@@ -99,7 +99,7 @@ func getBalanceUpdate(ctx sdk.Context, keeper Keeper, addressToUpdate map[string
|
|
|
99
99
|
for _, coin := range coins {
|
|
100
100
|
// generate an update even when the current balance is zero
|
|
101
101
|
balance := keeper.GetBalance(ctx, account, coin.Denom)
|
|
102
|
-
update :=
|
|
102
|
+
update := VbankSingleBalanceUpdate{
|
|
103
103
|
Address: address,
|
|
104
104
|
Denom: coin.Denom,
|
|
105
105
|
Amount: balance.Amount.String(),
|
|
@@ -144,11 +144,9 @@ func (ch portHandler) Receive(cctx context.Context, str string) (ret string, err
|
|
|
144
144
|
}
|
|
145
145
|
coin := keeper.GetBalance(ctx, addr, msg.Denom)
|
|
146
146
|
packet := coin.Amount.String()
|
|
147
|
+
bytes, err := json.Marshal(&packet)
|
|
147
148
|
if err == nil {
|
|
148
|
-
|
|
149
|
-
if err == nil {
|
|
150
|
-
ret = string(bytes)
|
|
151
|
-
}
|
|
149
|
+
ret = string(bytes)
|
|
152
150
|
}
|
|
153
151
|
|
|
154
152
|
case "VBANK_GRAB":
|
|
@@ -216,9 +214,6 @@ func (ch portHandler) Receive(cctx context.Context, str string) (ret string, err
|
|
|
216
214
|
if err := keeper.StoreRewardCoins(ctx, coins); err != nil {
|
|
217
215
|
return "", fmt.Errorf("cannot store reward %s coins: %s", coins.Sort().String(), err)
|
|
218
216
|
}
|
|
219
|
-
if err != nil {
|
|
220
|
-
return "", err
|
|
221
|
-
}
|
|
222
217
|
state := keeper.GetState(ctx)
|
|
223
218
|
state.RewardPool = state.RewardPool.Add(coins...)
|
|
224
219
|
keeper.SetState(ctx, state)
|
package/x/vbank/vbank_test.go
CHANGED
|
@@ -71,7 +71,7 @@ func newBalances(opts ...balancesOption) balances {
|
|
|
71
71
|
return bal
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
func validateBalanceUpdate(vbu
|
|
74
|
+
func validateBalanceUpdate(vbu VbankBalanceUpdate) error {
|
|
75
75
|
if vbu.Type != "VBANK_BALANCE_UPDATE" {
|
|
76
76
|
return fmt.Errorf("bad balance update type: %s", vbu.Type)
|
|
77
77
|
}
|
|
@@ -89,7 +89,7 @@ func decodeBalances(encoded []byte) (balances, uint64, error) {
|
|
|
89
89
|
if encoded == nil {
|
|
90
90
|
return nil, 0, nil
|
|
91
91
|
}
|
|
92
|
-
balanceUpdate :=
|
|
92
|
+
balanceUpdate := VbankBalanceUpdate{}
|
|
93
93
|
err := json.Unmarshal(encoded, &balanceUpdate)
|
|
94
94
|
if err != nil {
|
|
95
95
|
return nil, 0, err
|
|
@@ -439,6 +439,7 @@ func Test_Receive_GiveToRewardDistributor(t *testing.T) {
|
|
|
439
439
|
params := types.DefaultParams()
|
|
440
440
|
params.RewardEpochDurationBlocks = 0
|
|
441
441
|
params.RewardSmoothingBlocks = tt.duration
|
|
442
|
+
params.AllowedMonitoringAccounts = []string{"*"}
|
|
442
443
|
|
|
443
444
|
keeper.SetParams(ctx, params)
|
|
444
445
|
keeper.SetState(ctx, types.State{RewardPool: tt.rewardPool})
|
|
@@ -524,7 +525,7 @@ func Test_EndBlock_Events(t *testing.T) {
|
|
|
524
525
|
}
|
|
525
526
|
keeper, ctx := makeTestKit(acct, bank)
|
|
526
527
|
// Turn off rewards.
|
|
527
|
-
keeper.SetParams(ctx, types.Params{PerEpochRewardFraction: sdk.ZeroDec()})
|
|
528
|
+
keeper.SetParams(ctx, types.Params{PerEpochRewardFraction: sdk.ZeroDec(), AllowedMonitoringAccounts: []string{"*"}})
|
|
528
529
|
msgsSent := []string{}
|
|
529
530
|
keeper.PushAction = func(ctx sdk.Context, action vm.Action) error {
|
|
530
531
|
bz, err := json.Marshal(action)
|
|
@@ -804,15 +805,19 @@ func Test_Module_Account(t *testing.T) {
|
|
|
804
805
|
}
|
|
805
806
|
|
|
806
807
|
modAddr := sdk.MustAccAddressFromBech32(moduleBech32)
|
|
807
|
-
if
|
|
808
|
-
t.Errorf("got
|
|
808
|
+
if keeper.IsAllowedMonitoringAccount(ctx, modAddr) {
|
|
809
|
+
t.Errorf("got IsAllowedMonitoringAccount modAddr = true, want false")
|
|
810
|
+
}
|
|
811
|
+
provisionPool := authtypes.NewModuleAddress("vbank/provision")
|
|
812
|
+
if !keeper.IsAllowedMonitoringAccount(ctx, provisionPool) {
|
|
813
|
+
t.Errorf("got IsAllowedMonitoringAccount provisionPool = false, want true")
|
|
809
814
|
}
|
|
810
815
|
notModAddr := sdk.MustAccAddressFromBech32(addr1)
|
|
811
|
-
if keeper.
|
|
812
|
-
t.Errorf("got
|
|
816
|
+
if keeper.IsAllowedMonitoringAccount(ctx, notModAddr) {
|
|
817
|
+
t.Errorf("got IsAllowedMonitoringAccount notModAddr = true, want false")
|
|
813
818
|
}
|
|
814
819
|
missingAddr := sdk.MustAccAddressFromBech32(addr2)
|
|
815
|
-
if keeper.
|
|
816
|
-
t.Errorf("got
|
|
820
|
+
if keeper.IsAllowedMonitoringAccount(ctx, missingAddr) {
|
|
821
|
+
t.Errorf("got IsAllowedMonitoringAccount missingAddr = false, want true")
|
|
817
822
|
}
|
|
818
823
|
}
|
package/x/vibc/alias.go
CHANGED
package/x/vibc/module.go
CHANGED
|
@@ -3,7 +3,6 @@ package vibc
|
|
|
3
3
|
import (
|
|
4
4
|
"encoding/json"
|
|
5
5
|
|
|
6
|
-
"github.com/gorilla/mux"
|
|
7
6
|
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
|
8
7
|
"github.com/spf13/cobra"
|
|
9
8
|
|
|
@@ -51,10 +50,6 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod
|
|
|
51
50
|
return nil
|
|
52
51
|
}
|
|
53
52
|
|
|
54
|
-
// Register rest routes
|
|
55
|
-
func (AppModuleBasic) RegisterRESTRoutes(ctx client.Context, rtr *mux.Router) {
|
|
56
|
-
}
|
|
57
|
-
|
|
58
53
|
func (AppModuleBasic) RegisterGRPCGatewayRoutes(_ client.Context, _ *runtime.ServeMux) {
|
|
59
54
|
}
|
|
60
55
|
|
|
@@ -70,7 +65,7 @@ func (AppModuleBasic) GetQueryCmd() *cobra.Command {
|
|
|
70
65
|
|
|
71
66
|
type AppModule struct {
|
|
72
67
|
AppModuleBasic
|
|
73
|
-
keeper
|
|
68
|
+
keeper Keeper
|
|
74
69
|
bankKeeper types.BankKeeper
|
|
75
70
|
}
|
|
76
71
|
|
|
@@ -79,7 +74,7 @@ func NewAppModule(k Keeper, bankKeeper types.BankKeeper) AppModule {
|
|
|
79
74
|
am := AppModule{
|
|
80
75
|
AppModuleBasic: AppModuleBasic{},
|
|
81
76
|
keeper: k,
|
|
82
|
-
bankKeeper:
|
|
77
|
+
bankKeeper: bankKeeper,
|
|
83
78
|
}
|
|
84
79
|
return am
|
|
85
80
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
package types
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
|
+
fmt "fmt"
|
|
5
|
+
|
|
4
6
|
sdkioerrors "cosmossdk.io/errors"
|
|
5
7
|
"github.com/Agoric/agoric-sdk/golang/cosmos/vm"
|
|
6
8
|
capability "github.com/cosmos/cosmos-sdk/x/capability/types"
|
|
7
9
|
channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types"
|
|
8
10
|
porttypes "github.com/cosmos/ibc-go/v6/modules/core/05-port/types"
|
|
9
11
|
host "github.com/cosmos/ibc-go/v6/modules/core/24-host"
|
|
10
|
-
ibckeeper "github.com/cosmos/ibc-go/v6/modules/core/keeper"
|
|
11
12
|
|
|
12
13
|
"github.com/cosmos/ibc-go/v6/modules/core/exported"
|
|
13
14
|
|
|
@@ -19,7 +20,9 @@ const (
|
|
|
19
20
|
// asynchronous versions. If it does, then the VM must supply an empty
|
|
20
21
|
// version string to indicate that the VM explicitly (possibly async)
|
|
21
22
|
// performs the Write* method.
|
|
22
|
-
|
|
23
|
+
// This flag is created in anticipation of ibc-go implementing async versions,
|
|
24
|
+
// see https://github.com/Agoric/agoric-sdk/issues/9358 for more details.
|
|
25
|
+
AsyncVersions = false
|
|
23
26
|
)
|
|
24
27
|
|
|
25
28
|
var (
|
|
@@ -220,7 +223,10 @@ func (im IBCModule) OnChanCloseInit(
|
|
|
220
223
|
}
|
|
221
224
|
|
|
222
225
|
err := im.impl.PushAction(ctx, event)
|
|
223
|
-
|
|
226
|
+
if err != nil {
|
|
227
|
+
return err
|
|
228
|
+
}
|
|
229
|
+
return fmt.Errorf("OnChanCloseInit can only be sent by the VM")
|
|
224
230
|
}
|
|
225
231
|
|
|
226
232
|
type ChannelCloseConfirmEvent struct {
|