@agoric/cosmos 0.35.0-upgrade-14-dev-c8f9e7b.0 → 0.35.0-upgrade-16a-dev-fb592e4.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.
Files changed (133) hide show
  1. package/CHANGELOG.md +121 -77
  2. package/MAINTAINERS.md +3 -0
  3. package/Makefile +36 -26
  4. package/ante/ante.go +7 -9
  5. package/ante/inbound_test.go +3 -2
  6. package/ante/vm_admission.go +2 -1
  7. package/app/app.go +212 -140
  8. package/app/upgrade.go +76 -0
  9. package/cmd/agd/agvm.go +42 -0
  10. package/cmd/agd/main.go +130 -11
  11. package/cmd/libdaemon/main.go +64 -53
  12. package/cmd/libdaemon/main_test.go +2 -1
  13. package/daemon/cmd/root.go +171 -74
  14. package/daemon/cmd/root_test.go +189 -1
  15. package/daemon/main.go +4 -2
  16. package/e2e_test/Makefile +29 -0
  17. package/e2e_test/README.md +100 -0
  18. package/e2e_test/go.mod +217 -0
  19. package/e2e_test/go.sum +1323 -0
  20. package/e2e_test/ibc_conformance_test.go +56 -0
  21. package/e2e_test/pfm_test.go +613 -0
  22. package/e2e_test/util.go +271 -0
  23. package/git-revision.txt +1 -1
  24. package/go.mod +22 -11
  25. package/go.sum +17 -13
  26. package/package.json +9 -5
  27. package/proto/agoric/swingset/genesis.proto +4 -0
  28. package/proto/agoric/swingset/swingset.proto +1 -1
  29. package/proto/agoric/vlocalchain/.clang-format +7 -0
  30. package/proto/agoric/vlocalchain/vlocalchain.proto +31 -0
  31. package/proto/agoric/vtransfer/genesis.proto +18 -0
  32. package/scripts/protocgen.sh +7 -8
  33. package/types/kv_entry_helpers.go +42 -0
  34. package/upgradegaia.sh +8 -8
  35. package/vm/action.go +5 -4
  36. package/vm/action_test.go +31 -11
  37. package/vm/client.go +113 -0
  38. package/vm/client_test.go +182 -0
  39. package/vm/controller.go +17 -40
  40. package/vm/core_proposals.go +22 -2
  41. package/vm/jsonrpcconn/jsonrpcconn.go +160 -0
  42. package/vm/jsonrpcconn/jsonrpcconn_test.go +126 -0
  43. package/vm/proto_json.go +38 -0
  44. package/vm/proto_json_test.go +103 -0
  45. package/vm/server.go +124 -0
  46. package/x/swingset/abci.go +10 -10
  47. package/x/swingset/alias.go +2 -0
  48. package/x/swingset/client/cli/tx.go +4 -0
  49. package/x/swingset/genesis.go +84 -24
  50. package/x/swingset/handler.go +2 -1
  51. package/x/swingset/keeper/extension_snapshotter.go +2 -2
  52. package/x/swingset/keeper/keeper.go +13 -25
  53. package/x/swingset/keeper/msg_server.go +18 -18
  54. package/x/swingset/keeper/proposal.go +3 -3
  55. package/x/swingset/keeper/querier.go +12 -11
  56. package/x/swingset/keeper/swing_store_exports_handler.go +21 -6
  57. package/x/swingset/keeper/test_utils.go +16 -0
  58. package/x/swingset/module.go +7 -7
  59. package/x/swingset/proposal_handler.go +2 -1
  60. package/x/swingset/testing/queue.go +17 -0
  61. package/x/swingset/types/default-params.go +1 -1
  62. package/x/swingset/types/expected_keepers.go +3 -2
  63. package/x/swingset/types/genesis.pb.go +78 -25
  64. package/x/swingset/types/msgs.go +44 -24
  65. package/x/swingset/types/params.go +2 -1
  66. package/x/swingset/types/proposal.go +5 -4
  67. package/x/swingset/types/swingset.pb.go +1 -1
  68. package/x/vbank/genesis.go +0 -2
  69. package/x/vbank/handler.go +2 -1
  70. package/x/vbank/keeper/querier.go +4 -3
  71. package/x/vbank/module.go +0 -5
  72. package/x/vbank/types/msgs.go +0 -12
  73. package/x/vbank/vbank.go +9 -9
  74. package/x/vbank/vbank_test.go +2 -2
  75. package/x/vibc/alias.go +3 -0
  76. package/x/vibc/handler.go +16 -9
  77. package/x/vibc/keeper/keeper.go +102 -65
  78. package/x/vibc/keeper/triggers.go +101 -0
  79. package/x/vibc/module.go +5 -8
  80. package/x/vibc/types/expected_keepers.go +13 -0
  81. package/x/vibc/types/ibc_module.go +336 -0
  82. package/x/vibc/types/receiver.go +170 -0
  83. package/x/vlocalchain/alias.go +19 -0
  84. package/x/vlocalchain/handler.go +21 -0
  85. package/x/vlocalchain/keeper/keeper.go +279 -0
  86. package/x/vlocalchain/keeper/keeper_test.go +97 -0
  87. package/x/vlocalchain/types/codec.go +34 -0
  88. package/x/vlocalchain/types/key.go +27 -0
  89. package/x/vlocalchain/types/msgs.go +16 -0
  90. package/x/vlocalchain/types/vlocalchain.pb.go +1072 -0
  91. package/x/vlocalchain/vlocalchain.go +114 -0
  92. package/x/vlocalchain/vlocalchain_test.go +434 -0
  93. package/x/vstorage/handler.go +2 -1
  94. package/x/vstorage/keeper/grpc_query.go +0 -1
  95. package/x/vstorage/keeper/keeper.go +13 -20
  96. package/x/vstorage/keeper/querier.go +6 -5
  97. package/x/vstorage/keeper/querier_test.go +4 -3
  98. package/x/vstorage/module.go +0 -5
  99. package/x/vstorage/testing/queue.go +27 -0
  100. package/x/vtransfer/alias.go +13 -0
  101. package/x/vtransfer/genesis.go +39 -0
  102. package/x/vtransfer/genesis_test.go +12 -0
  103. package/x/vtransfer/handler.go +20 -0
  104. package/x/vtransfer/ibc_middleware.go +186 -0
  105. package/x/vtransfer/ibc_middleware_test.go +448 -0
  106. package/x/vtransfer/keeper/keeper.go +281 -0
  107. package/x/vtransfer/module.go +124 -0
  108. package/x/vtransfer/types/expected_keepers.go +38 -0
  109. package/x/vtransfer/types/genesis.pb.go +327 -0
  110. package/x/vtransfer/types/key.go +9 -0
  111. package/x/vtransfer/types/msgs.go +9 -0
  112. package/ante/fee.go +0 -96
  113. package/proto/agoric/lien/genesis.proto +0 -25
  114. package/proto/agoric/lien/lien.proto +0 -25
  115. package/x/lien/alias.go +0 -17
  116. package/x/lien/genesis.go +0 -58
  117. package/x/lien/genesis_test.go +0 -101
  118. package/x/lien/keeper/account.go +0 -290
  119. package/x/lien/keeper/keeper.go +0 -255
  120. package/x/lien/keeper/keeper_test.go +0 -623
  121. package/x/lien/lien.go +0 -205
  122. package/x/lien/lien_test.go +0 -533
  123. package/x/lien/module.go +0 -115
  124. package/x/lien/spec/01_concepts.md +0 -146
  125. package/x/lien/spec/02_messages.md +0 -96
  126. package/x/lien/types/accountkeeper.go +0 -81
  127. package/x/lien/types/accountstate.go +0 -27
  128. package/x/lien/types/expected_keepers.go +0 -18
  129. package/x/lien/types/genesis.pb.go +0 -567
  130. package/x/lien/types/key.go +0 -25
  131. package/x/lien/types/lien.pb.go +0 -403
  132. package/x/vibc/ibc.go +0 -394
  133. /package/{src/index.cjs → index.cjs} +0 -0
@@ -1,146 +0,0 @@
1
- <!--
2
- order: 1
3
- -->
4
-
5
- # Concepts
6
-
7
- ## Notes on Terminology
8
-
9
- * "Bonded", "delegated", and "staked" are all synonyms.
10
- * "Unlocking" is a time-delayed process by which tokens become available for
11
- withdrawal. "Vesting" is a time-delayed process where tokens change
12
- ownership, and is subject to "clawback" which stops the process. The
13
- cosmos-sdk implements several kinds of "vesting account" which implement
14
- unlocking, and only one - clawback accounts - which implement vesting.
15
-
16
- ## Account Balances
17
-
18
- The existing dynamic of account balances work in two dimensions: bonding
19
- and locking.
20
-
21
- ### The Bonding Dimension
22
-
23
- In the bonding dimension, the balance of the staking token owned by an account
24
- is partitioned into three categories:
25
-
26
- * "Bonded": tokens that are currently staked with a validator.
27
- * "Unbonding": tokens that are held in escrow after being bonded and subject
28
- to slashing if validator misbehavior is discovered after the fact.
29
- * "Unbonded": tokens that are not bonded and unencumbered by any slashing
30
- liability. These are the only tokens that are shown in the account balance
31
- in the `x/bank` module.
32
-
33
- ### The Locking Dimension
34
-
35
- In the locking dimension, the balance of tokens owned by an account is
36
- partitioned into two categories:
37
-
38
- * "Locked" (aka "vesting" or "unvested"): tokens which may not yet be
39
- transfered out of the account.
40
- * "Unlocked" (aka "vested"): tokens which may be freely transferred
41
- out of the account.
42
-
43
- The sum of these two categories must be equal to the sum of the three
44
- categories in the bonding dimension.
45
-
46
- ### The Vesting (Clawback) Dimension
47
-
48
- The vesting dimension is similar to the locking dimension in that
49
- unvested tokens are encumbered and many not be transferred out of the
50
- account, but further, unvested tokens are subject to clawback.
51
- Be careful to distinguish the legacy use of "vesting" to mean locking
52
- and the clawback-aware notion of vesting.
53
-
54
- * "Unvested" (aka "vesting): tokens which may not yet be transferred
55
- out of the account, and are subject to clawback.
56
- * "Vested": tokens which may be freely transferred and are not
57
- subject to clawback.
58
-
59
- ### No Cartesian Product
60
-
61
- Surprisingly, tokens are *not* tracked by the cartesian product of the
62
- dimensions, i.e. the system does not track whether the tokens staked to
63
- a particular validator are locked or unlocked. Instead, when trying to
64
- transfer tokens out of an account, it checks separately whether enough
65
- unbonded tokens are available, and whether enough unlocked tokens are
66
- available, and deducts the transferred amount from both of those
67
- categories.
68
-
69
- Slashed tokens are taken out of the locked category until it is depleted,
70
- and then from the unlocked category.
71
-
72
- ## Introducing Liens
73
-
74
- Liens are an encumbrance on tokens that prevent them from being transferred
75
- out of the account, much like locking (and liens are implemented by reusing
76
- the locking/vesting mechanisms). Liens live in the vesting dimension,
77
- as tokens may be orthogonally locked, but must be vested in order to
78
- be liened. The categories in the vesting dimension are now:
79
-
80
- * "Unvested": tokens which may not be transferred and are subject to clawback.
81
- * "Liened": vested tokens encumbered by a lien which may not be transferred.
82
- * "Free": the remainder of tokens in an account which are neither
83
- encumbered nor subject to clawback.
84
-
85
- Liens are imposed and lifted by the higher Agoric swingset layer.
86
- We intend liens to be placed on bonded, vested tokens only. However,
87
- we cannot force tokens to remain bonded, as they may be involuntarily
88
- unbonded when a validator retires. The best we can do is that when
89
- the higher layers wish to increase the total liened amount, the new
90
- total must be less than the bonded tokens and less than the unlocked
91
- tokens. Liens can be lifted at any time.
92
-
93
- The liened amount is *not* reduced by slashing, and if slashing reduces
94
- the account balance below the liened amount, the account effectively has
95
- negative equity. We'll model this by allowing the Unliened amount to
96
- be negative.
97
-
98
- ## Representing Account State
99
-
100
- Putting all three dimensions together, the account state is:
101
-
102
- * Bonding Dimension:
103
- * Bonded
104
- * Unbonding
105
- * Unbonded
106
- * Locking Dimension:
107
- * Locked
108
- * Unlocked
109
- * Lien Dimension:
110
- * Unvested
111
- * Liened
112
- * Unliened (may be negative)
113
-
114
- with the constraint that the sum of categories in each dimension must be
115
- the same. We can represent this without the constraints with the following
116
- primary quantities:
117
-
118
- * Total: total amount in the account
119
- * Bonded
120
- * Unbonding
121
- * Locked
122
- * Liened
123
- * Unvested
124
-
125
- which gives rise to the derived quantities:
126
-
127
- * Unbonded = Total - (Bonded + Unbonding)
128
- * Unlocked = Total - Locked
129
- * Free = Total - Unvested - Liened (may be negative)
130
-
131
- ## Implementing Lien Encumbrance
132
-
133
- Liened tokens may not be transferred out of an account. Rather than
134
- modifying the `x/bank` module to implement a new type of containment,
135
- we leverage the existing mechanism to prevent locked tokens from being
136
- transferred.
137
-
138
- To do this, we create a new type of vesting \[*sic*\] account which wraps
139
- an existing account where the liened tokens are considered locked. If
140
- the existing account is already a vesting account, the wrapper locks the
141
- maximum of the liened and locked amounts.
142
-
143
- To effect this wrapping of accounts, a different wrapper is placed around
144
- an `AccountKeeper` which intercepts `GetAccount()` and `SetAccount()` calls
145
- which read and write the account from the store. This way no change is
146
- needed in the persisted representation of accounts.
@@ -1,96 +0,0 @@
1
- <!--
2
- order: 2
3
- -->
4
-
5
- # Messages
6
-
7
- This documents the messages sent across the bridge to the Javascript swingset.
8
-
9
- ## From Javascript to Golang
10
-
11
- ### LIEN_CHANGE_LIENED
12
-
13
- Request: JSON object with the fields
14
-
15
- * type: "LIEN_CHANGE_LIENED"
16
- * address: string, bech32-encoded
17
- * denom: string
18
- * delta: string encoding integer of change to liened amount
19
-
20
- Response: JSON string encoding nonnegative integer holding the current lien amount.
21
-
22
- The following rules are used:
23
-
24
- * The total liened amount can always be decreased.
25
- * When increasing the total liened amount, the new total liened plus unvested
26
- must be less than or equal to the bonded amount.
27
- * Can be used to change from zero balance or to zero balance.
28
-
29
- ### LIEN_GET_ACCOUNT_STATE
30
-
31
- Request: JSON object with the fields
32
-
33
- * type: "LIEN_GET_ACCOUNT_STATE"
34
- * address: string, bech32-encoded
35
- * denom: string
36
-
37
- Response: JSON object with the fields
38
-
39
- * currentTime: string timestamp
40
- * total: string encoding nonnegativeinteger
41
- * bonded: string encoding nonnegative integer
42
- * unbonding: string encoding nonnegative integer
43
- * locked: string encoding nonnegative integer
44
- * liened: string encoding nonnegative integer
45
-
46
- See [Concepts](01_concepts.md) for the meaning of the amounts.
47
-
48
- ### LIEN_GET_STAKING
49
-
50
- Request: JSON object with the fields
51
-
52
- * type: "LIEN_GET_STAKING"
53
- * validators: array of strings of bech32-encoded operator addresses
54
- * delegators: array of strings of bech32-encoded account addresses
55
-
56
- Response: JSON object with the fields
57
-
58
- * epoch_tag: string encoding the staking epoch.
59
- If it is the same in two different responses, the results can be
60
- safely aggregated.
61
- * denom: string giving the name of the staking token
62
- * validator_values: array of the same length as the request `validators`,
63
- where each entry is a string encoding nonnegative integer
64
- giving the tokens delegated to the corresponding validator, or `null`
65
- if that validator address is malformed.
66
- * delegator_states: array of the same length as the request `delegators`,
67
- holding `null` if the address is malformed, otherwise an object containing:
68
- * val_idx: array of nonnegative integers referring to the index of
69
- a validator in the request. If the same validator address is
70
- given multiple times in the request, the index of the last one is used.
71
- * values: array of strings of the same size as `val_idx` encoding
72
- nonnegative integers for the amount this delegator has delegated
73
- to the referenced validator.
74
- * other: string encoding nonnegative integer of the total amount
75
- this delegator has delegated to validators not mentioned in the request.
76
-
77
- This call obtains a partial snapshot of staking data in a compact
78
- representation. It is intended for use in tallying votes of delegated tokens,
79
- with proxying of votes based on delegation. It has nothing to do with liens
80
- per se, but the lien module has the necessary connectivity to implement it.
81
- This call may be moved to another module in the future if appropriate.
82
-
83
- ## From Golang to Javascript
84
-
85
- None.
86
-
87
- ## Design Notes
88
-
89
- The LIEN_SET_TOTAL operation checks the Golang-side state and might reject
90
- the operation. It has the power to do so to avoid a race between checking
91
- the account state and updating the liened amount, vs other cosmos-sdk
92
- operations which might change the account state. The cosmos-side lien amount
93
- is the source of truth for the lien.
94
-
95
- The LIEN_GET_STAKING call is categorized as a lien operation onlyb because
96
- of the similarity to LIEN_GET_ACCOUNT_STATE.
@@ -1,81 +0,0 @@
1
- package types
2
-
3
- import (
4
- sdk "github.com/cosmos/cosmos-sdk/types"
5
- authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
6
- authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
7
- )
8
-
9
- // AccountWrapper wraps/unwraps accounts.
10
- // The Wrap and Unwrap functions map accounts to accounts.
11
- type AccountWrapper struct {
12
- Wrap func(sdk.Context, authtypes.AccountI) authtypes.AccountI
13
- Unwrap func(sdk.Context, authtypes.AccountI) authtypes.AccountI
14
- }
15
-
16
- // identWrap is an identity mapping of accounts.
17
- func identWrap(_ sdk.Context, a authtypes.AccountI) authtypes.AccountI {
18
- return a
19
- }
20
-
21
- // DefaultAccountWrapper is an AccountWrapper that does nothing.
22
- var DefaultAccountWrapper = AccountWrapper{
23
- Wrap: identWrap,
24
- Unwrap: identWrap,
25
- }
26
-
27
- // WrappedAccountKeeper wraps an account AccountKeeper transform accounts
28
- // when reading or writing accounts from/to storage.
29
- // Applies the Wrap function when reading accounts from the store and applies
30
- // the Unwrap function when writing them to the store.
31
- //
32
- // Note that we do not wrap the Accounts() method since the returned accounts
33
- // are serialized and sent in the GRPC response and we don't need to modify
34
- // their behavior.
35
- type WrappedAccountKeeper struct {
36
- authkeeper.AccountKeeper
37
- AccountWrapper
38
- }
39
-
40
- var _ authkeeper.AccountKeeper = (*WrappedAccountKeeper)(nil)
41
-
42
- // NewWrappedAccountKeeper returns a WrappedAccountKeeper with the default (identity) wrapper.
43
- func NewWrappedAccountKeeper(ak authkeeper.AccountKeeper) *WrappedAccountKeeper {
44
- return &WrappedAccountKeeper{
45
- AccountKeeper: ak,
46
- AccountWrapper: DefaultAccountWrapper,
47
- }
48
- }
49
-
50
- // GetAccount implements AccountKeeper.GetAccount().
51
- // It calls the embedded AccountKeeper then Wraps the account.
52
- func (wak *WrappedAccountKeeper) GetAccount(ctx sdk.Context, address sdk.AccAddress) authtypes.AccountI {
53
- acc := wak.AccountKeeper.GetAccount(ctx, address)
54
- if acc == nil {
55
- return nil
56
- }
57
- return wak.Wrap(ctx, acc)
58
- }
59
-
60
- // IterateAccounts implements AccountKeeper.IterateAccounts().
61
- // It calls the embedded AccountKeeper but Wraps the retrieved accounts.
62
- func (wak *WrappedAccountKeeper) IterateAccounts(ctx sdk.Context, cb func(account authtypes.AccountI) (stop bool)) {
63
- wak.AccountKeeper.IterateAccounts(ctx, func(acc authtypes.AccountI) (stop bool) {
64
- return cb(wak.Wrap(ctx, acc))
65
- })
66
- }
67
-
68
- // SetAccount implements AccountKeeper.SetAccount().
69
- // It Unwraps the account then calls the embedded AccountKeeper.
70
- func (wak *WrappedAccountKeeper) SetAccount(ctx sdk.Context, acc authtypes.AccountI) {
71
- unwrappedAcc := wak.Unwrap(ctx, acc)
72
- wak.AccountKeeper.SetAccount(ctx, unwrappedAcc)
73
- }
74
-
75
- // SetWrapper updates the AccountWrapper.
76
- // We need to modify the wrapper after it's created for the planned use,
77
- // since there is a circular dependency in the creation of the WrappedAccountKeeper
78
- // and the lien.Keeper.
79
- func (wak *WrappedAccountKeeper) SetWrapper(aw AccountWrapper) {
80
- wak.AccountWrapper = aw
81
- }
@@ -1,27 +0,0 @@
1
- package types
2
-
3
- import (
4
- sdk "github.com/cosmos/cosmos-sdk/types"
5
- )
6
-
7
- // AccountState represents the abstract state of an account.
8
- // See ../spec/01_concepts.md for details.
9
- type AccountState struct {
10
- Total sdk.Coins `json:"total"`
11
- Bonded sdk.Coins `json:"bonded"`
12
- Unbonding sdk.Coins `json:"unbonding"`
13
- Locked sdk.Coins `json:"locked"`
14
- Liened sdk.Coins `json:"liened"`
15
- Unvested sdk.Coins `json:"unvested"`
16
- }
17
-
18
- // IsEqual returns whether two AccountStates are equal.
19
- // (Coins don't play nicely with equality (==) or reflect.DeepEqual().)
20
- func (s AccountState) IsEqual(other AccountState) bool {
21
- return s.Total.IsEqual(other.Total) &&
22
- s.Bonded.IsEqual(other.Bonded) &&
23
- s.Unbonding.IsEqual(other.Unbonding) &&
24
- s.Locked.IsEqual(other.Locked) &&
25
- s.Liened.IsEqual(other.Liened) &&
26
- s.Unvested.IsEqual(other.Unvested)
27
- }
@@ -1,18 +0,0 @@
1
- package types
2
-
3
- import (
4
- sdk "github.com/cosmos/cosmos-sdk/types"
5
- stakingTypes "github.com/cosmos/cosmos-sdk/x/staking/types"
6
- )
7
-
8
- type BankKeeper interface {
9
- GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins
10
- GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin
11
- }
12
-
13
- type StakingKeeper interface {
14
- BondDenom(ctx sdk.Context) string
15
- GetDelegatorDelegations(ctx sdk.Context, delegator sdk.AccAddress, maxRetrieve uint16) []stakingTypes.Delegation
16
- GetUnbondingDelegations(ctx sdk.Context, delegator sdk.AccAddress, maxRetrieve uint16) []stakingTypes.UnbondingDelegation
17
- GetValidator(ctx sdk.Context, addr sdk.ValAddress) (stakingTypes.Validator, bool)
18
- }