@agoric/cosmos 0.35.0-u15.0 → 0.35.0-u16.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 (131) hide show
  1. package/CHANGELOG.md +121 -149
  2. package/MAINTAINERS.md +3 -0
  3. package/Makefile +36 -26
  4. package/ante/ante.go +6 -5
  5. package/ante/inbound_test.go +3 -2
  6. package/ante/vm_admission.go +2 -1
  7. package/app/app.go +206 -147
  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 +164 -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 +12 -7
  25. package/go.sum +13 -9
  26. package/package.json +8 -4
  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 +16 -5
  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/proto/agoric/lien/genesis.proto +0 -25
  113. package/proto/agoric/lien/lien.proto +0 -25
  114. package/x/lien/alias.go +0 -17
  115. package/x/lien/genesis.go +0 -58
  116. package/x/lien/genesis_test.go +0 -101
  117. package/x/lien/keeper/account.go +0 -290
  118. package/x/lien/keeper/keeper.go +0 -255
  119. package/x/lien/keeper/keeper_test.go +0 -623
  120. package/x/lien/lien.go +0 -205
  121. package/x/lien/lien_test.go +0 -533
  122. package/x/lien/module.go +0 -115
  123. package/x/lien/spec/01_concepts.md +0 -146
  124. package/x/lien/spec/02_messages.md +0 -96
  125. package/x/lien/types/accountkeeper.go +0 -81
  126. package/x/lien/types/accountstate.go +0 -27
  127. package/x/lien/types/expected_keepers.go +0 -18
  128. package/x/lien/types/genesis.pb.go +0 -567
  129. package/x/lien/types/key.go +0 -25
  130. package/x/lien/types/lien.pb.go +0 -403
  131. package/x/vibc/ibc.go +0 -394
package/x/lien/lien.go DELETED
@@ -1,205 +0,0 @@
1
- // Package lien is a cosmos-sdk module that implements liens.
2
- // Liens are an encumbrance that prevents the transfer of tokens
3
- // out of an account, much like the unvested tokens in a vesting
4
- // account. See spec/ for full details.
5
- package lien
6
-
7
- import (
8
- "context"
9
- "encoding/json"
10
- "fmt"
11
- "math"
12
-
13
- "github.com/Agoric/agoric-sdk/golang/cosmos/vm"
14
-
15
- sdk "github.com/cosmos/cosmos-sdk/types"
16
- )
17
-
18
- // portHandler implements a vm.PortHandler.
19
- type portHandler struct {
20
- keeper Keeper
21
- }
22
-
23
- // portMessage is a struct that any lien bridge message can unmarshal into.
24
- type portMessage struct {
25
- Type string `json:"type"`
26
- Address string `json:"address"`
27
- Denom string `json:"denom"`
28
- Delta sdk.Int `json:"delta"`
29
- Validators []string `json:"validators"`
30
- Delegators []string `json:"delegators"`
31
- }
32
-
33
- // msgAccountState marshals into the AccountState message for the lien bridge.
34
- type msgAccountState struct {
35
- CurrentTime int64 `json:"currentTime"`
36
- Total sdk.Int `json:"total"`
37
- Bonded sdk.Int `json:"bonded"`
38
- Unbonding sdk.Int `json:"unbonding"`
39
- Locked sdk.Int `json:"locked"`
40
- Liened sdk.Int `json:"liened"`
41
- // TODO: send unvested amount
42
- }
43
-
44
- type delegatorState struct {
45
- ValidatorIdx []int `json:"val_idx"`
46
- Values []sdk.Int `json:"values"`
47
- Other sdk.Int `json:"other"`
48
- }
49
-
50
- type msgStaking struct {
51
- EpochTag string `json:"epoch_tag"`
52
- Denom string `json:"denom"`
53
- // the following fields are arrays of pointer types so we can use JSON null
54
- // for out-of-band values
55
- ValidatorValues []*sdk.Int `json:"validator_values"`
56
- DelegatorStates []*delegatorState `json:"delegator_states"`
57
- }
58
-
59
- // NewPortHandler returns a port handler for the Keeper.
60
- func NewPortHandler(k Keeper) vm.PortHandler {
61
- return portHandler{keeper: k}
62
- }
63
-
64
- const (
65
- LIEN_GET_ACCOUNT_STATE = "LIEN_GET_ACCOUNT_STATE"
66
- LIEN_GET_STAKING = "LIEN_GET_STAKING"
67
- LIEN_CHANGE_LIENED = "LIEN_CHANGE_LIENED"
68
- )
69
-
70
- // Receive implements the vm.PortHandler method.
71
- // Receives and processes a bridge message, returning the
72
- // JSON-encoded response or error.
73
- // See spec/02_messages.md for the messages and responses.
74
- func (ch portHandler) Receive(cctx context.Context, str string) (string, error) {
75
- ctx := sdk.UnwrapSDKContext(cctx)
76
- var msg portMessage
77
- err := json.Unmarshal([]byte(str), &msg)
78
- if err != nil {
79
- return "", err
80
- }
81
- switch msg.Type {
82
- case LIEN_GET_ACCOUNT_STATE:
83
- return ch.handleGetAccountState(ctx, msg)
84
-
85
- case LIEN_GET_STAKING:
86
- return ch.handleGetStaking(ctx, msg)
87
-
88
- case LIEN_CHANGE_LIENED:
89
- return ch.handleChangeLiened(ctx, msg)
90
- }
91
- return "", fmt.Errorf("unrecognized type %s", msg.Type)
92
- }
93
-
94
- func (ch portHandler) handleGetStaking(ctx sdk.Context, msg portMessage) (string, error) {
95
- reply := msgStaking{
96
- EpochTag: fmt.Sprint(ctx.BlockHeight()),
97
- Denom: ch.keeper.BondDenom(ctx),
98
- ValidatorValues: make([]*sdk.Int, len(msg.Validators)),
99
- DelegatorStates: make([]*delegatorState, len(msg.Delegators)),
100
- }
101
- validatorIndex := map[string]int{} // map of validators addresses to indexes
102
- for i, v := range msg.Validators {
103
- validatorIndex[v] = i
104
- valAddr, err := sdk.ValAddressFromBech32(v)
105
- if err != nil {
106
- reply.ValidatorValues[i] = nil
107
- continue
108
- }
109
- value := sdk.NewInt(0)
110
- validator, found := ch.keeper.GetValidator(ctx, valAddr)
111
- if found {
112
- value = validator.Tokens
113
- }
114
- reply.ValidatorValues[i] = &value
115
- }
116
- for i, d := range msg.Delegators {
117
- addr, err := sdk.AccAddressFromBech32(d)
118
- if err != nil {
119
- reply.DelegatorStates[i] = nil
120
- continue
121
- }
122
- delegations := ch.keeper.GetDelegatorDelegations(ctx, addr, math.MaxUint16)
123
- // Note that the delegations were returned in a specific order - no nodeterminism
124
- state := delegatorState{
125
- ValidatorIdx: make([]int, 0, len(delegations)),
126
- Values: make([]sdk.Int, 0, len(delegations)),
127
- Other: sdk.NewInt(0),
128
- }
129
- for _, d := range delegations {
130
- valAddr, err := sdk.ValAddressFromBech32(d.ValidatorAddress)
131
- if err != nil {
132
- panic(err)
133
- }
134
- validator, found := ch.keeper.GetValidator(ctx, valAddr)
135
- if !found {
136
- panic("validator not found")
137
- }
138
- shares := d.GetShares()
139
- tokens := validator.TokensFromShares(shares).RoundInt()
140
- valIndex, found := validatorIndex[valAddr.String()]
141
- if found {
142
- state.ValidatorIdx = append(state.ValidatorIdx, valIndex)
143
- state.Values = append(state.Values, tokens)
144
- } else {
145
- state.Other = state.Other.Add(tokens)
146
- }
147
- }
148
- reply.DelegatorStates[i] = &state
149
- }
150
- bz, err := json.Marshal(&reply)
151
- if err != nil {
152
- return "", fmt.Errorf("cannot marshal %v: %s", reply, err)
153
- }
154
- return string(bz), nil
155
- }
156
-
157
- // handleGetAccountState processes a LIEN_GET_ACCOUNT_STATE message.
158
- // See spec/02_messages.md for the messages and responses.
159
- func (ch portHandler) handleGetAccountState(ctx sdk.Context, msg portMessage) (string, error) {
160
- addr, err := sdk.AccAddressFromBech32(msg.Address)
161
- if err != nil {
162
- return "", fmt.Errorf("cannot convert %s to address: %s", msg.Address, err)
163
- }
164
- denom := msg.Denom
165
- if err = sdk.ValidateDenom(denom); err != nil {
166
- return "", fmt.Errorf("invalid denom %s: %s", denom, err)
167
- }
168
- state := ch.keeper.GetAccountState(ctx, addr)
169
- reply := msgAccountState{
170
- CurrentTime: ctx.BlockTime().Unix(),
171
- Total: state.Total.AmountOf(denom),
172
- Bonded: state.Bonded.AmountOf(denom),
173
- Unbonding: state.Unbonding.AmountOf(denom),
174
- Locked: state.Locked.AmountOf(denom),
175
- Liened: state.Liened.AmountOf(denom),
176
- }
177
- bz, err := json.Marshal(&reply)
178
- if err != nil {
179
- return "", fmt.Errorf("cannot marshal %v: %s", reply, err)
180
- }
181
- return string(bz), nil
182
- }
183
-
184
- // handleChangeLiened processes a LIEN_CHANGE_LIENED message.
185
- // See spec/02_messages.md for the messages and responses.
186
- func (ch portHandler) handleChangeLiened(ctx sdk.Context, msg portMessage) (string, error) {
187
- addr, err := sdk.AccAddressFromBech32(msg.Address)
188
- if err != nil {
189
- return "", fmt.Errorf("cannot convert %s to address: %s", msg.Address, err)
190
- }
191
- denom := msg.Denom
192
- if err = sdk.ValidateDenom(denom); err != nil {
193
- return "", fmt.Errorf("invalid denom %s: %s", denom, err)
194
- }
195
-
196
- newAmt, err := ch.keeper.ChangeLien(ctx, addr, denom, msg.Delta)
197
- if err != nil {
198
- return "", err
199
- }
200
- bz, err := json.Marshal(&newAmt)
201
- if err != nil {
202
- return "", fmt.Errorf("cannot marshal %v: %s", newAmt, err)
203
- }
204
- return string(bz), nil
205
- }