@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.
Files changed (90) hide show
  1. package/MAINTAINERS.md +3 -0
  2. package/Makefile +38 -34
  3. package/ante/ante.go +1 -4
  4. package/ante/inbound_test.go +2 -2
  5. package/app/app.go +198 -137
  6. package/app/upgrade.go +248 -0
  7. package/cmd/agd/agvm.go +3 -3
  8. package/cmd/agd/find_binary.go +2 -2
  9. package/cmd/agd/main.go +9 -10
  10. package/cmd/libdaemon/main.go +13 -13
  11. package/daemon/cmd/root.go +235 -92
  12. package/daemon/cmd/root_test.go +189 -1
  13. package/daemon/main.go +3 -2
  14. package/git-revision.txt +1 -1
  15. package/go.mod +14 -11
  16. package/go.sum +20 -19
  17. package/index.cjs +1 -1
  18. package/package.json +4 -3
  19. package/proto/agoric/swingset/genesis.proto +4 -0
  20. package/proto/agoric/swingset/swingset.proto +26 -1
  21. package/proto/agoric/vbank/vbank.proto +7 -0
  22. package/proto/agoric/vtransfer/genesis.proto +18 -0
  23. package/scripts/protocgen.sh +7 -8
  24. package/types/kv_entry_helpers.go +42 -0
  25. package/upgradegaia.sh +8 -8
  26. package/util/util.go +21 -0
  27. package/vm/action.go +1 -1
  28. package/vm/client.go +15 -13
  29. package/vm/client_test.go +34 -36
  30. package/vm/controller.go +3 -38
  31. package/vm/core_proposals.go +22 -2
  32. package/vm/proto_json.go +38 -0
  33. package/vm/proto_json_test.go +103 -0
  34. package/vm/server.go +106 -5
  35. package/x/swingset/alias.go +2 -0
  36. package/x/swingset/config.go +234 -0
  37. package/x/swingset/genesis.go +178 -40
  38. package/x/swingset/keeper/extension_snapshotter.go +2 -2
  39. package/x/swingset/keeper/keeper.go +24 -27
  40. package/x/swingset/keeper/swing_store_exports_handler.go +14 -3
  41. package/x/swingset/keeper/test_utils.go +16 -0
  42. package/x/swingset/module.go +24 -9
  43. package/x/swingset/testing/queue.go +17 -0
  44. package/x/swingset/types/default-params.go +31 -5
  45. package/x/swingset/types/expected_keepers.go +2 -2
  46. package/x/swingset/types/genesis.pb.go +78 -25
  47. package/x/swingset/types/msgs.go +53 -12
  48. package/x/swingset/types/params.go +53 -43
  49. package/x/swingset/types/params_test.go +75 -9
  50. package/x/swingset/types/swingset.pb.go +387 -57
  51. package/x/vbank/README.md +6 -1
  52. package/x/vbank/genesis.go +0 -2
  53. package/x/vbank/keeper/keeper.go +4 -9
  54. package/x/vbank/keeper/migrations.go +30 -0
  55. package/x/vbank/module.go +8 -7
  56. package/x/vbank/types/key.go +3 -3
  57. package/x/vbank/types/msgs.go +0 -12
  58. package/x/vbank/types/params.go +43 -2
  59. package/x/vbank/types/vbank.pb.go +105 -36
  60. package/x/vbank/vbank.go +8 -13
  61. package/x/vbank/vbank_test.go +14 -9
  62. package/x/vibc/alias.go +1 -1
  63. package/x/vibc/module.go +2 -7
  64. package/x/vibc/types/ibc_module.go +9 -3
  65. package/x/vibc/types/receiver.go +17 -7
  66. package/x/vlocalchain/handler.go +2 -1
  67. package/x/vlocalchain/keeper/keeper.go +24 -8
  68. package/x/vlocalchain/keeper/keeper_test.go +65 -1
  69. package/x/vlocalchain/types/expected_keepers.go +12 -0
  70. package/x/vlocalchain/vlocalchain.go +27 -22
  71. package/x/vlocalchain/vlocalchain_test.go +163 -8
  72. package/x/vstorage/keeper/grpc_query.go +0 -1
  73. package/x/vstorage/keeper/keeper.go +9 -17
  74. package/x/vstorage/module.go +0 -5
  75. package/x/vstorage/testing/queue.go +28 -0
  76. package/x/vtransfer/alias.go +13 -0
  77. package/x/vtransfer/genesis.go +39 -0
  78. package/x/vtransfer/genesis_test.go +12 -0
  79. package/x/vtransfer/handler.go +20 -0
  80. package/x/vtransfer/ibc_middleware.go +186 -0
  81. package/x/vtransfer/ibc_middleware_test.go +449 -0
  82. package/x/vtransfer/keeper/keeper.go +282 -0
  83. package/x/vtransfer/module.go +124 -0
  84. package/x/vtransfer/types/baseaddr.go +156 -0
  85. package/x/vtransfer/types/baseaddr_test.go +167 -0
  86. package/x/vtransfer/types/expected_keepers.go +38 -0
  87. package/x/vtransfer/types/genesis.pb.go +328 -0
  88. package/x/vtransfer/types/key.go +9 -0
  89. package/x/vtransfer/types/msgs.go +9 -0
  90. package/ante/fee.go +0 -97
@@ -5,7 +5,6 @@ import (
5
5
  "encoding/json"
6
6
  "fmt"
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(ctx 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
  }
@@ -85,10 +80,18 @@ type AppModule struct {
85
80
  setBootstrapNeeded func()
86
81
  ensureControllerInited func(sdk.Context)
87
82
  swingStoreExportDir string
83
+ swingStoreExportMode string
88
84
  }
89
85
 
90
86
  // NewAppModule creates a new AppModule Object
91
- func NewAppModule(k Keeper, swingStoreExportsHandler *SwingStoreExportsHandler, setBootstrapNeeded func(), ensureControllerInited func(sdk.Context), swingStoreExportDir string) AppModule {
87
+ func NewAppModule(
88
+ k Keeper,
89
+ swingStoreExportsHandler *SwingStoreExportsHandler,
90
+ setBootstrapNeeded func(),
91
+ ensureControllerInited func(sdk.Context),
92
+ swingStoreExportDir string,
93
+ swingStoreExportMode string,
94
+ ) AppModule {
92
95
  am := AppModule{
93
96
  AppModuleBasic: AppModuleBasic{},
94
97
  keeper: k,
@@ -96,6 +99,7 @@ func NewAppModule(k Keeper, swingStoreExportsHandler *SwingStoreExportsHandler,
96
99
  setBootstrapNeeded: setBootstrapNeeded,
97
100
  ensureControllerInited: ensureControllerInited,
98
101
  swingStoreExportDir: swingStoreExportDir,
102
+ swingStoreExportMode: swingStoreExportMode,
99
103
  }
100
104
  return am
101
105
  }
@@ -104,6 +108,11 @@ func (AppModule) Name() string {
104
108
  return ModuleName
105
109
  }
106
110
 
111
+ // For testing purposes
112
+ func (am *AppModule) SetSwingStoreExportDir(dir string) {
113
+ am.swingStoreExportDir = dir
114
+ }
115
+
107
116
  func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {}
108
117
 
109
118
  func (am AppModule) Route() sdk.Route {
@@ -154,9 +163,9 @@ func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.V
154
163
  return []abci.ValidatorUpdate{}
155
164
  }
156
165
 
157
- func (am AppModule) checkSwingStoreExportSetup() {
166
+ func (am *AppModule) checkSwingStoreExportSetup() {
158
167
  if am.swingStoreExportDir == "" {
159
- panic(fmt.Errorf("SwingStore export dir not set"))
168
+ am.swingStoreExportDir = "/tmp/swingset_export"
160
169
  }
161
170
  }
162
171
 
@@ -173,6 +182,12 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.
173
182
 
174
183
  func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
175
184
  am.checkSwingStoreExportSetup()
176
- gs := ExportGenesis(ctx, am.keeper, am.swingStoreExportsHandler, am.swingStoreExportDir)
185
+ gs := ExportGenesis(
186
+ ctx,
187
+ am.keeper,
188
+ am.swingStoreExportsHandler,
189
+ am.swingStoreExportDir,
190
+ am.swingStoreExportMode,
191
+ )
177
192
  return cdc.MustMarshalJSON(gs)
178
193
  }
@@ -0,0 +1,17 @@
1
+ package testing
2
+
3
+ import (
4
+ "testing"
5
+
6
+ "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/keeper"
7
+ vstoragetesting "github.com/Agoric/agoric-sdk/golang/cosmos/x/vstorage/testing"
8
+ sdk "github.com/cosmos/cosmos-sdk/types"
9
+ )
10
+
11
+ // GetActionQueueRecords returns the records in the action queue.
12
+ // This is a testing utility function.
13
+ func GetActionQueueRecords(t *testing.T, ctx sdk.Context, swingsetKeeper keeper.Keeper) ([]string, error) {
14
+ vstorageKeeper := keeper.GetVstorageKeeper(t, swingsetKeeper)
15
+ actionQueueName := keeper.StoragePathActionQueue
16
+ return vstoragetesting.GetQueueItems(ctx, vstorageKeeper, actionQueueName)
17
+ }
@@ -22,13 +22,23 @@ const (
22
22
  BeansPerXsnapComputron = "xsnapComputron"
23
23
  BeansPerSmartWalletProvision = "smartWalletProvision"
24
24
 
25
+ // PowerFlags.
26
+ PowerFlagSmartWallet = "SMART_WALLET"
27
+
25
28
  // QueueSize keys.
26
- // Keep up-to-date with updateQueueAllowed() in packanges/cosmic-swingset/src/launch-chain.js
29
+ // Keep up-to-date with updateQueueAllowed() in packages/cosmic-swingset/src/launch-chain.js
27
30
  QueueInbound = "inbound"
28
31
  QueueInboundMempool = "inbound_mempool"
29
32
 
30
- // PowerFlags.
31
- PowerFlagSmartWallet = "SMART_WALLET"
33
+ // Vat cleanup budget keys.
34
+ // Keep up-to-date with CleanupBudget in packages/cosmic-swingset/src/launch-chain.js
35
+ VatCleanupDefault = "default"
36
+ VatCleanupExports = "exports"
37
+ VatCleanupImports = "imports"
38
+ VatCleanupPromises = "promises"
39
+ VatCleanupKv = "kv"
40
+ VatCleanupSnapshots = "snapshots"
41
+ VatCleanupTranscripts = "transcripts"
32
42
  )
33
43
 
34
44
  var (
@@ -62,10 +72,26 @@ var (
62
72
  }
63
73
 
64
74
  DefaultInboundQueueMax = int32(1_000)
65
-
66
- DefaultQueueMax = []QueueSize{
75
+ DefaultQueueMax = []QueueSize{
67
76
  NewQueueSize(QueueInbound, DefaultInboundQueueMax),
68
77
  }
78
+
79
+ DefaultVatCleanupDefault = sdk.NewUint(5)
80
+ // DefaultVatCleanupExports = DefaultVatCleanupDefault
81
+ // DefaultVatCleanupImports = DefaultVatCleanupDefault
82
+ // DefaultVatCleanupPromises = DefaultVatCleanupDefault
83
+ DefaultVatCleanupKv = sdk.NewUint(50)
84
+ // DefaultVatCleanupSnapshots = DefaultVatCleanupDefault
85
+ // DefaultVatCleanupTranscripts = DefaultVatCleanupDefault
86
+ DefaultVatCleanupBudget = []UintMapEntry{
87
+ UintMapEntry{VatCleanupDefault, DefaultVatCleanupDefault},
88
+ // UintMapEntry{VatCleanupExports, DefaultVatCleanupExports},
89
+ // UintMapEntry{VatCleanupImports, DefaultVatCleanupImports},
90
+ // UintMapEntry{VatCleanupPromises, DefaultVatCleanupPromises},
91
+ UintMapEntry{VatCleanupKv, DefaultVatCleanupKv},
92
+ // UintMapEntry{VatCleanupSnapshots, DefaultVatCleanupSnapshots},
93
+ // UintMapEntry{VatCleanupTranscripts, DefaultVatCleanupTranscripts},
94
+ }
69
95
  )
70
96
 
71
97
  // move DefaultBeansPerUnit to a function to allow for boot overriding of the Default params
@@ -23,8 +23,8 @@ type AccountKeeper interface {
23
23
 
24
24
  type SwingSetKeeper interface {
25
25
  GetBeansPerUnit(ctx sdk.Context) map[string]sdkmath.Uint
26
- ChargeBeans(ctx sdk.Context, addr sdk.AccAddress, beans sdkmath.Uint) error
26
+ ChargeBeans(ctx sdk.Context, beansPerUnit map[string]sdkmath.Uint, addr sdk.AccAddress, beans sdkmath.Uint) error
27
27
  IsHighPriorityAddress(ctx sdk.Context, addr sdk.AccAddress) (bool, error)
28
28
  GetSmartWalletState(ctx sdk.Context, addr sdk.AccAddress) SmartWalletState
29
- ChargeForSmartWallet(ctx sdk.Context, addr sdk.AccAddress) error
29
+ ChargeForSmartWallet(ctx sdk.Context, beansPerUnit map[string]sdkmath.Uint, addr sdk.AccAddress) error
30
30
  }
@@ -25,9 +25,10 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
25
25
 
26
26
  // The initial or exported state.
27
27
  type GenesisState struct {
28
- Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"`
29
- State State `protobuf:"bytes,3,opt,name=state,proto3" json:"state"`
30
- SwingStoreExportData []*SwingStoreExportDataEntry `protobuf:"bytes,4,rep,name=swing_store_export_data,json=swingStoreExportData,proto3" json:"swingStoreExportData"`
28
+ Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"`
29
+ State State `protobuf:"bytes,3,opt,name=state,proto3" json:"state"`
30
+ SwingStoreExportData []*SwingStoreExportDataEntry `protobuf:"bytes,4,rep,name=swing_store_export_data,json=swingStoreExportData,proto3" json:"swingStoreExportData"`
31
+ SwingStoreExportDataHash string `protobuf:"bytes,5,opt,name=swing_store_export_data_hash,json=swingStoreExportDataHash,proto3" json:"swingStoreExportDataHash"`
31
32
  }
32
33
 
33
34
  func (m *GenesisState) Reset() { *m = GenesisState{} }
@@ -84,6 +85,13 @@ func (m *GenesisState) GetSwingStoreExportData() []*SwingStoreExportDataEntry {
84
85
  return nil
85
86
  }
86
87
 
88
+ func (m *GenesisState) GetSwingStoreExportDataHash() string {
89
+ if m != nil {
90
+ return m.SwingStoreExportDataHash
91
+ }
92
+ return ""
93
+ }
94
+
87
95
  // A SwingStore "export data" entry.
88
96
  type SwingStoreExportDataEntry struct {
89
97
  Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
@@ -145,28 +153,30 @@ func init() {
145
153
  func init() { proto.RegisterFile("agoric/swingset/genesis.proto", fileDescriptor_49b057311de9d296) }
146
154
 
147
155
  var fileDescriptor_49b057311de9d296 = []byte{
148
- // 334 bytes of a gzipped FileDescriptorProto
149
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x91, 0xcf, 0x4b, 0x02, 0x41,
150
- 0x1c, 0xc5, 0x77, 0xf2, 0x07, 0x38, 0x06, 0xc5, 0x22, 0xb9, 0x09, 0x8d, 0xe2, 0x49, 0x82, 0x76,
151
- 0xc0, 0xe8, 0x52, 0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, 0x66, 0xa4, 0xd5, 0xa4, 0xe1, 0x7d, 0xcf, 0xcb, 0x05, 0xd8, 0x81, 0x83, 0x9d, 0x7f,
163
- 0x2f, 0xd3, 0x5f, 0xef, 0x65, 0xa7, 0x7a, 0x83, 0x8f, 0xff, 0xad, 0x74, 0x0f, 0x71, 0xaa, 0xcf,
164
- 0x27, 0x1e, 0xaa, 0xa0, 0x5a, 0x2e, 0x48, 0xa4, 0x5b, 0xc0, 0x99, 0x67, 0x36, 0x18, 0x71, 0xf3,
165
- 0x36, 0xb9, 0xc0, 0x7e, 0x34, 0x1e, 0xa6, 0x0b, 0x82, 0x66, 0x0b, 0x82, 0x3e, 0x17, 0x04, 0xbd,
166
- 0x2d, 0x89, 0x33, 0x5b, 0x12, 0xe7, 0x63, 0x49, 0x9c, 0xc7, 0x2b, 0x11, 0xea, 0xa7, 0x51, 0xc7,
167
- 0xef, 0xca, 0x21, 0xbd, 0xb6, 0x43, 0xd8, 0x1b, 0x9d, 0x41, 0xaf, 0x4f, 0x85, 0x1c, 0xb0, 0x48,
168
- 0xd0, 0xae, 0x84, 0xa1, 0x04, 0x3a, 0xfe, 0xdb, 0x48, 0x4f, 0x62, 0x0e, 0x9d, 0xac, 0x59, 0xe8,
169
- 0xfc, 0x37, 0x00, 0x00, 0xff, 0xff, 0x94, 0xe9, 0x22, 0x36, 0x09, 0x02, 0x00, 0x00,
156
+ // 363 bytes of a gzipped FileDescriptorProto
157
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0xcd, 0x4a, 0xc3, 0x40,
158
+ 0x14, 0x85, 0x93, 0xfe, 0x41, 0xa7, 0x82, 0x12, 0x8a, 0x8d, 0xa5, 0x26, 0xa5, 0xab, 0x22, 0x98,
159
+ 0x40, 0xc5, 0x8d, 0xae, 0x8c, 0x16, 0x5d, 0x4a, 0x8a, 0x1b, 0x11, 0xc2, 0xb4, 0x1d, 0x26, 0xa1,
160
+ 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 0xf3, 0xad, 0xf6, 0x82, 0x2a, 0x7b, 0x86, 0x7b, 0x3e, 0x06, 0x5f, 0xcf, 0x56, 0xd5, 0x7a, 0xde,
172
+ 0xa9, 0x2c, 0x67, 0xa6, 0xbe, 0x2b, 0xff, 0x80, 0xc1, 0x77, 0xf7, 0x92, 0xab, 0xcc, 0xef, 0xa7,
173
+ 0xa9, 0xd4, 0x6e, 0xd1, 0xc9, 0xde, 0x0f, 0xd6, 0x8e, 0x50, 0xba, 0x47, 0xc6, 0xba, 0x9a, 0xcc,
174
+ 0x71, 0x13, 0xa9, 0x15, 0x51, 0xf6, 0x15, 0xf7, 0x87, 0x44, 0x6c, 0x3e, 0xef, 0xca, 0x07, 0xe7,
175
+ 0x69, 0x32, 0x37, 0xd4, 0xe9, 0xdc, 0x50, 0x7f, 0xe6, 0x86, 0xfa, 0xb1, 0x30, 0x94, 0xe9, 0xc2,
176
+ 0x50, 0xbe, 0x16, 0x86, 0xf2, 0x7c, 0x4d, 0x03, 0xee, 0x0f, 0xdb, 0x56, 0x87, 0x0d, 0xec, 0x1b,
177
+ 0x79, 0x66, 0xb9, 0xaf, 0x73, 0xe8, 0xf6, 0x6c, 0xca, 0xfa, 0x38, 0xa4, 0x76, 0x87, 0xc1, 0x80,
178
+ 0x81, 0x3d, 0xfa, 0xff, 0x03, 0xf8, 0x38, 0x22, 0xd0, 0xce, 0x89, 0xfb, 0x5f, 0xfc, 0x05, 0x00,
179
+ 0x00, 0xff, 0xff, 0x1b, 0x95, 0x41, 0xea, 0x67, 0x02, 0x00, 0x00,
170
180
  }
171
181
 
172
182
  func (m *GenesisState) Marshal() (dAtA []byte, err error) {
@@ -189,6 +199,13 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
189
199
  _ = i
190
200
  var l int
191
201
  _ = l
202
+ if len(m.SwingStoreExportDataHash) > 0 {
203
+ i -= len(m.SwingStoreExportDataHash)
204
+ copy(dAtA[i:], m.SwingStoreExportDataHash)
205
+ i = encodeVarintGenesis(dAtA, i, uint64(len(m.SwingStoreExportDataHash)))
206
+ i--
207
+ dAtA[i] = 0x2a
208
+ }
192
209
  if len(m.SwingStoreExportData) > 0 {
193
210
  for iNdEx := len(m.SwingStoreExportData) - 1; iNdEx >= 0; iNdEx-- {
194
211
  {
@@ -290,6 +307,10 @@ func (m *GenesisState) Size() (n int) {
290
307
  n += 1 + l + sovGenesis(uint64(l))
291
308
  }
292
309
  }
310
+ l = len(m.SwingStoreExportDataHash)
311
+ if l > 0 {
312
+ n += 1 + l + sovGenesis(uint64(l))
313
+ }
293
314
  return n
294
315
  }
295
316
 
@@ -445,6 +466,38 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error {
445
466
  return err
446
467
  }
447
468
  iNdEx = postIndex
469
+ case 5:
470
+ if wireType != 2 {
471
+ return fmt.Errorf("proto: wrong wireType = %d for field SwingStoreExportDataHash", wireType)
472
+ }
473
+ var stringLen uint64
474
+ for shift := uint(0); ; shift += 7 {
475
+ if shift >= 64 {
476
+ return ErrIntOverflowGenesis
477
+ }
478
+ if iNdEx >= l {
479
+ return io.ErrUnexpectedEOF
480
+ }
481
+ b := dAtA[iNdEx]
482
+ iNdEx++
483
+ stringLen |= uint64(b&0x7F) << shift
484
+ if b < 0x80 {
485
+ break
486
+ }
487
+ }
488
+ intStringLen := int(stringLen)
489
+ if intStringLen < 0 {
490
+ return ErrInvalidLengthGenesis
491
+ }
492
+ postIndex := iNdEx + intStringLen
493
+ if postIndex < 0 {
494
+ return ErrInvalidLengthGenesis
495
+ }
496
+ if postIndex > l {
497
+ return io.ErrUnexpectedEOF
498
+ }
499
+ m.SwingStoreExportDataHash = string(dAtA[iNdEx:postIndex])
500
+ iNdEx = postIndex
448
501
  default:
449
502
  iNdEx = preIndex
450
503
  skippy, err := skipGenesis(dAtA[iNdEx:])
@@ -8,9 +8,12 @@ import (
8
8
  "strings"
9
9
 
10
10
  sdkioerrors "cosmossdk.io/errors"
11
- "github.com/Agoric/agoric-sdk/golang/cosmos/vm"
11
+ sdkmath "cosmossdk.io/math"
12
+
12
13
  sdk "github.com/cosmos/cosmos-sdk/types"
13
14
  sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
15
+
16
+ "github.com/Agoric/agoric-sdk/golang/cosmos/vm"
14
17
  )
15
18
 
16
19
  const RouterKey = ModuleName // this was defined in your key.go file
@@ -29,6 +32,25 @@ var (
29
32
  _ vm.ControllerAdmissionMsg = &MsgWalletSpendAction{}
30
33
  )
31
34
 
35
+ // Contextual information about the message source of an action on an inbound queue.
36
+ // This context should be unique per inboundQueueRecord.
37
+ type ActionContext struct {
38
+ // The block height in which the corresponding action was enqueued
39
+ BlockHeight int64 `json:"blockHeight"`
40
+ // The hash of the cosmos transaction that included the message
41
+ // If the action didn't result from a transaction message, a substitute value
42
+ // may be used. For example the VBANK_BALANCE_UPDATE actions use `x/vbank`.
43
+ TxHash string `json:"txHash"`
44
+ // The index of the message within the transaction. If the action didn't
45
+ // result from a cosmos transaction, a number should be chosen to make the
46
+ // actionContext unique. (for example a counter per block and source module).
47
+ MsgIdx int `json:"msgIdx"`
48
+ }
49
+ type InboundQueueRecord struct {
50
+ Action vm.Jsonable `json:"action"`
51
+ Context ActionContext `json:"context"`
52
+ }
53
+
32
54
  const (
33
55
  // bundleUncompressedSizeLimit is the (exclusive) limit on uncompressed bundle size.
34
56
  // We must ensure there is an exclusive int64 limit in order to detect an underflow.
@@ -37,16 +59,26 @@ const (
37
59
 
38
60
  // Charge an account address for the beans associated with given messages and storage.
39
61
  // See list of bean charges in default-params.go
40
- func chargeAdmission(ctx sdk.Context, keeper SwingSetKeeper, addr sdk.AccAddress, msgs []string, storageLen uint64) error {
41
- beansPerUnit := keeper.GetBeansPerUnit(ctx)
62
+ func chargeAdmission(
63
+ ctx sdk.Context,
64
+ keeper SwingSetKeeper,
65
+ beansPerUnit map[string]sdkmath.Uint,
66
+ addr sdk.AccAddress,
67
+ msgs []string,
68
+ storageLen uint64,
69
+ ) error {
70
+ // A flat charge for each transaction.
42
71
  beans := beansPerUnit[BeansPerInboundTx]
72
+ // A charge for each message in the transaction.
43
73
  beans = beans.Add(beansPerUnit[BeansPerMessage].MulUint64((uint64(len(msgs)))))
74
+ // A charge for the total byte length of all messages.
44
75
  for _, msg := range msgs {
45
76
  beans = beans.Add(beansPerUnit[BeansPerMessageByte].MulUint64(uint64(len(msg))))
46
77
  }
78
+ // A charge for persistent storage.
47
79
  beans = beans.Add(beansPerUnit[BeansPerStorageByte].MulUint64(storageLen))
48
80
 
49
- return keeper.ChargeBeans(ctx, addr, beans)
81
+ return keeper.ChargeBeans(ctx, beansPerUnit, addr, beans)
50
82
  }
51
83
 
52
84
  // checkSmartWalletProvisioned verifies if a smart wallet message (MsgWalletAction
@@ -55,7 +87,12 @@ func chargeAdmission(ctx sdk.Context, keeper SwingSetKeeper, addr sdk.AccAddress
55
87
  // provisioning fee is charged successfully.
56
88
  // All messages for non-provisioned smart wallets allowed here will result in
57
89
  // an auto-provision action generated by the msg server.
58
- func checkSmartWalletProvisioned(ctx sdk.Context, keeper SwingSetKeeper, addr sdk.AccAddress) error {
90
+ func checkSmartWalletProvisioned(
91
+ ctx sdk.Context,
92
+ keeper SwingSetKeeper,
93
+ beansPerUnit map[string]sdkmath.Uint,
94
+ addr sdk.AccAddress,
95
+ ) error {
59
96
  walletState := keeper.GetSmartWalletState(ctx, addr)
60
97
 
61
98
  switch walletState {
@@ -72,7 +109,7 @@ func checkSmartWalletProvisioned(ctx sdk.Context, keeper SwingSetKeeper, addr sd
72
109
  // This is a separate charge from the smart wallet action which triggered the check
73
110
  // TODO: Currently this call does not mark the smart wallet provisioning as
74
111
  // pending, resulting in multiple provisioning charges for the owner.
75
- return keeper.ChargeForSmartWallet(ctx, addr)
112
+ return keeper.ChargeForSmartWallet(ctx, beansPerUnit, addr)
76
113
  }
77
114
  }
78
115
 
@@ -99,7 +136,8 @@ func (msg MsgDeliverInbound) CheckAdmissibility(ctx sdk.Context, data interface{
99
136
  }
100
137
  */
101
138
 
102
- return chargeAdmission(ctx, keeper, msg.Submitter, msg.Messages, 0)
139
+ beansPerUnit := keeper.GetBeansPerUnit(ctx)
140
+ return chargeAdmission(ctx, keeper, beansPerUnit, msg.Submitter, msg.Messages, 0)
103
141
  }
104
142
 
105
143
  // GetInboundMsgCount implements InboundMsgCarrier.
@@ -165,12 +203,13 @@ func (msg MsgWalletAction) CheckAdmissibility(ctx sdk.Context, data interface{})
165
203
  return sdkioerrors.Wrapf(sdkerrors.ErrInvalidRequest, "data must be a SwingSetKeeper, not a %T", data)
166
204
  }
167
205
 
168
- err := checkSmartWalletProvisioned(ctx, keeper, msg.Owner)
206
+ beansPerUnit := keeper.GetBeansPerUnit(ctx)
207
+ err := checkSmartWalletProvisioned(ctx, keeper, beansPerUnit, msg.Owner)
169
208
  if err != nil {
170
209
  return err
171
210
  }
172
211
 
173
- return chargeAdmission(ctx, keeper, msg.Owner, []string{msg.Action}, 0)
212
+ return chargeAdmission(ctx, keeper, beansPerUnit, msg.Owner, []string{msg.Action}, 0)
174
213
  }
175
214
 
176
215
  // GetInboundMsgCount implements InboundMsgCarrier.
@@ -237,12 +276,13 @@ func (msg MsgWalletSpendAction) CheckAdmissibility(ctx sdk.Context, data interfa
237
276
  return sdkioerrors.Wrapf(sdkerrors.ErrInvalidRequest, "data must be a SwingSetKeeper, not a %T", data)
238
277
  }
239
278
 
240
- err := checkSmartWalletProvisioned(ctx, keeper, msg.Owner)
279
+ beansPerUnit := keeper.GetBeansPerUnit(ctx)
280
+ err := checkSmartWalletProvisioned(ctx, keeper, beansPerUnit, msg.Owner)
241
281
  if err != nil {
242
282
  return err
243
283
  }
244
284
 
245
- return chargeAdmission(ctx, keeper, msg.Owner, []string{msg.SpendAction}, 0)
285
+ return chargeAdmission(ctx, keeper, beansPerUnit, msg.Owner, []string{msg.SpendAction}, 0)
246
286
  }
247
287
 
248
288
  // GetInboundMsgCount implements InboundMsgCarrier.
@@ -354,7 +394,8 @@ func (msg MsgInstallBundle) CheckAdmissibility(ctx sdk.Context, data interface{}
354
394
  if !ok {
355
395
  return sdkioerrors.Wrapf(sdkerrors.ErrInvalidRequest, "data must be a SwingSetKeeper, not a %T", data)
356
396
  }
357
- return chargeAdmission(ctx, keeper, msg.Submitter, []string{msg.Bundle}, msg.ExpectedUncompressedSize())
397
+ beansPerUnit := keeper.GetBeansPerUnit(ctx)
398
+ return chargeAdmission(ctx, keeper, beansPerUnit, msg.Submitter, []string{msg.Bundle}, msg.ExpectedUncompressedSize())
358
399
  }
359
400
 
360
401
  // GetInboundMsgCount implements InboundMsgCarrier.
@@ -17,6 +17,7 @@ var (
17
17
  ParamStoreKeyFeeUnitPrice = []byte("fee_unit_price")
18
18
  ParamStoreKeyPowerFlagFees = []byte("power_flag_fees")
19
19
  ParamStoreKeyQueueMax = []byte("queue_max")
20
+ ParamStoreKeyVatCleanupBudget = []byte("vat_cleanup_budget")
20
21
  )
21
22
 
22
23
  func NewStringBeans(key string, beans sdkmath.Uint) StringBeans {
@@ -53,6 +54,7 @@ func DefaultParams() Params {
53
54
  FeeUnitPrice: DefaultFeeUnitPrice,
54
55
  PowerFlagFees: DefaultPowerFlagFees,
55
56
  QueueMax: DefaultQueueMax,
57
+ VatCleanupBudget: DefaultVatCleanupBudget,
56
58
  }
57
59
  }
58
60
 
@@ -69,6 +71,7 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
69
71
  paramtypes.NewParamSetPair(ParamStoreKeyBootstrapVatConfig, &p.BootstrapVatConfig, validateBootstrapVatConfig),
70
72
  paramtypes.NewParamSetPair(ParamStoreKeyPowerFlagFees, &p.PowerFlagFees, validatePowerFlagFees),
71
73
  paramtypes.NewParamSetPair(ParamStoreKeyQueueMax, &p.QueueMax, validateQueueMax),
74
+ paramtypes.NewParamSetPair(ParamStoreKeyVatCleanupBudget, &p.VatCleanupBudget, validateVatCleanupBudget),
72
75
  }
73
76
  }
74
77
 
@@ -89,6 +92,9 @@ func (p Params) ValidateBasic() error {
89
92
  if err := validateQueueMax(p.QueueMax); err != nil {
90
93
  return err
91
94
  }
95
+ if err := validateVatCleanupBudget(p.VatCleanupBudget); err != nil {
96
+ return err
97
+ }
92
98
 
93
99
  return nil
94
100
  }
@@ -165,20 +171,42 @@ func validateQueueMax(i interface{}) error {
165
171
  return nil
166
172
  }
167
173
 
174
+ func validateVatCleanupBudget(i interface{}) error {
175
+ entries, ok := i.([]UintMapEntry)
176
+ if !ok {
177
+ return fmt.Errorf("invalid parameter type: %T", i)
178
+ }
179
+ hasDefault := false
180
+ for _, entry := range entries {
181
+ if entry.Key == VatCleanupDefault {
182
+ hasDefault = true
183
+ break
184
+ }
185
+ }
186
+ if len(entries) > 0 && !hasDefault {
187
+ return fmt.Errorf("`default` must be present in a non-empty vat cleanup budget")
188
+ }
189
+ return nil
190
+ }
191
+
168
192
  // UpdateParams appends any missing params, configuring them to their defaults,
169
193
  // then returning the updated params or an error. Existing params are not
170
194
  // modified, regardless of their value, and they are not removed if they no
171
195
  // longer appear in the defaults.
172
196
  func UpdateParams(params Params) (Params, error) {
173
- newBpu, err := appendMissingDefaultBeansPerUnit(params.BeansPerUnit, DefaultBeansPerUnit())
197
+ newBpu, err := appendMissingDefaults(params.BeansPerUnit, DefaultBeansPerUnit())
174
198
  if err != nil {
175
199
  return params, err
176
200
  }
177
- newPff, err := appendMissingDefaultPowerFlagFees(params.PowerFlagFees, DefaultPowerFlagFees)
201
+ newPff, err := appendMissingDefaults(params.PowerFlagFees, DefaultPowerFlagFees)
178
202
  if err != nil {
179
203
  return params, err
180
204
  }
181
- newQm, err := appendMissingDefaultQueueSize(params.QueueMax, DefaultQueueMax)
205
+ newQm, err := appendMissingDefaults(params.QueueMax, DefaultQueueMax)
206
+ if err != nil {
207
+ return params, err
208
+ }
209
+ newVcb, err := appendMissingDefaults(params.VatCleanupBudget, DefaultVatCleanupBudget)
182
210
  if err != nil {
183
211
  return params, err
184
212
  }
@@ -186,55 +214,37 @@ func UpdateParams(params Params) (Params, error) {
186
214
  params.BeansPerUnit = newBpu
187
215
  params.PowerFlagFees = newPff
188
216
  params.QueueMax = newQm
217
+ params.VatCleanupBudget = newVcb
189
218
  return params, nil
190
219
  }
191
220
 
192
- // appendMissingDefaultBeansPerUnit appends the default beans per unit entries
193
- // not in the list of bean costs already, returning the possibly-updated list,
194
- // or an error.
195
- func appendMissingDefaultBeansPerUnit(bpu []StringBeans, defaultBpu []StringBeans) ([]StringBeans, error) {
196
- existingBpu := make(map[string]struct{}, len(bpu))
197
- for _, ob := range bpu {
198
- existingBpu[ob.Key] = struct{}{}
199
- }
200
-
201
- for _, b := range defaultBpu {
202
- if _, exists := existingBpu[b.Key]; !exists {
203
- bpu = append(bpu, b)
221
+ // appendMissingDefaults appends to an input list any missing entries with their
222
+ // respective default values and returns the result.
223
+ func appendMissingDefaults[Entry StringBeans | PowerFlagFee | QueueSize | UintMapEntry](entries []Entry, defaults []Entry) ([]Entry, error) {
224
+ getKey := func(entry any) string {
225
+ switch e := entry.(type) {
226
+ case StringBeans:
227
+ return e.Key
228
+ case PowerFlagFee:
229
+ return e.PowerFlag
230
+ case QueueSize:
231
+ return e.Key
232
+ case UintMapEntry:
233
+ return e.Key
204
234
  }
235
+ panic("unreachable")
205
236
  }
206
- return bpu, nil
207
- }
208
237
 
209
- // appendMissingDefaultPowerFlagFees appends the default power flag fee entries
210
- // not in the list of power flags already, returning the possibly-updated list,
211
- // or an error.
212
- func appendMissingDefaultPowerFlagFees(pff []PowerFlagFee, defaultPff []PowerFlagFee) ([]PowerFlagFee, error) {
213
- existingPff := make(map[string]struct{}, len(pff))
214
- for _, of := range pff {
215
- existingPff[of.PowerFlag] = struct{}{}
238
+ existingKeys := make(map[string]bool, len(entries))
239
+ for _, entry := range entries {
240
+ existingKeys[getKey(entry)] = true
216
241
  }
217
242
 
218
- for _, f := range defaultPff {
219
- if _, exists := existingPff[f.PowerFlag]; !exists {
220
- pff = append(pff, f)
243
+ for _, defaultEntry := range defaults {
244
+ if exists := existingKeys[getKey(defaultEntry)]; !exists {
245
+ entries = append(entries, defaultEntry)
221
246
  }
222
247
  }
223
- return pff, nil
224
- }
225
-
226
- // appendMissingDefaultQueueSize appends the default queue size entries not in
227
- // the list of sizes already, returning the possibly-updated list, or an error.
228
- func appendMissingDefaultQueueSize(qs []QueueSize, defaultQs []QueueSize) ([]QueueSize, error) {
229
- existingQs := make(map[string]struct{}, len(qs))
230
- for _, os := range qs {
231
- existingQs[os.Key] = struct{}{}
232
- }
233
248
 
234
- for _, s := range defaultQs {
235
- if _, exists := existingQs[s.Key]; !exists {
236
- qs = append(qs, s)
237
- }
238
- }
239
- return qs, nil
249
+ return entries, nil
240
250
  }