@agoric/cosmos 0.34.2-dev-a29afed.0.a29afed → 0.34.2-dev-cb1866d.0.cb1866d
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/git-revision.txt +1 -1
- package/package.json +2 -2
- package/proto/agoric/swingset/msgs.proto +75 -6
- package/proto/agoric/swingset/query.proto +26 -0
- package/proto/agoric/swingset/swingset.proto +95 -0
- package/x/swingset/abci.go +5 -0
- package/x/swingset/keeper/chunked_artifact_id_test.go +168 -0
- package/x/swingset/keeper/grpc_query.go +24 -0
- package/x/swingset/keeper/keeper.go +210 -2
- package/x/swingset/keeper/msg_server.go +204 -1
- package/x/swingset/keeper/msg_server_test.go +297 -1
- package/x/swingset/types/default-params.go +9 -0
- package/x/swingset/types/list_tools.go +103 -0
- package/x/swingset/types/msgs.go +131 -21
- package/x/swingset/types/msgs.pb.go +876 -198
- package/x/swingset/types/msgs_test.go +11 -21
- package/x/swingset/types/params.go +63 -13
- package/x/swingset/types/params_test.go +56 -26
- package/x/swingset/types/query.pb.go +526 -32
- package/x/swingset/types/query.pb.gw.go +101 -0
- package/x/swingset/types/swingset.pb.go +1288 -123
|
@@ -2,7 +2,6 @@ package types
|
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
4
|
"bytes"
|
|
5
|
-
"math"
|
|
6
5
|
"testing"
|
|
7
6
|
|
|
8
7
|
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
|
|
@@ -120,6 +119,16 @@ func TestInstallBundle_ValidateBasic(t *testing.T) {
|
|
|
120
119
|
UncompressedSize: 4,
|
|
121
120
|
},
|
|
122
121
|
},
|
|
122
|
+
{
|
|
123
|
+
name: "compressed with empty chunked artifact",
|
|
124
|
+
msg: &MsgInstallBundle{
|
|
125
|
+
Submitter: addr,
|
|
126
|
+
CompressedBundle: []byte{1, 2, 3},
|
|
127
|
+
UncompressedSize: 4,
|
|
128
|
+
ChunkedArtifact: &ChunkedArtifact{},
|
|
129
|
+
},
|
|
130
|
+
shouldErr: true,
|
|
131
|
+
},
|
|
123
132
|
{
|
|
124
133
|
name: "both",
|
|
125
134
|
msg: &MsgInstallBundle{
|
|
@@ -151,28 +160,9 @@ func TestInstallBundle_ValidateBasic(t *testing.T) {
|
|
|
151
160
|
msg: &MsgInstallBundle{
|
|
152
161
|
Submitter: addr,
|
|
153
162
|
CompressedBundle: []byte{1, 2, 3},
|
|
154
|
-
UncompressedSize:
|
|
163
|
+
UncompressedSize: int64(DefaultBundleUncompressedSizeLimitBytes - 1),
|
|
155
164
|
},
|
|
156
165
|
},
|
|
157
|
-
|
|
158
|
-
{
|
|
159
|
-
name: "limit",
|
|
160
|
-
msg: &MsgInstallBundle{
|
|
161
|
-
Submitter: addr,
|
|
162
|
-
CompressedBundle: []byte{1, 2, 3},
|
|
163
|
-
UncompressedSize: bundleUncompressedSizeLimit,
|
|
164
|
-
},
|
|
165
|
-
shouldErr: true,
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
name: "max",
|
|
169
|
-
msg: &MsgInstallBundle{
|
|
170
|
-
Submitter: addr,
|
|
171
|
-
CompressedBundle: []byte{1, 2, 3},
|
|
172
|
-
UncompressedSize: math.MaxInt64,
|
|
173
|
-
},
|
|
174
|
-
shouldErr: true,
|
|
175
|
-
},
|
|
176
166
|
} {
|
|
177
167
|
t.Run(tt.name, func(t *testing.T) {
|
|
178
168
|
err := tt.msg.ValidateBasic()
|
|
@@ -12,12 +12,14 @@ import (
|
|
|
12
12
|
|
|
13
13
|
// Parameter keys
|
|
14
14
|
var (
|
|
15
|
-
ParamStoreKeyBeansPerUnit
|
|
16
|
-
ParamStoreKeyBootstrapVatConfig
|
|
17
|
-
ParamStoreKeyFeeUnitPrice
|
|
18
|
-
ParamStoreKeyPowerFlagFees
|
|
19
|
-
ParamStoreKeyQueueMax
|
|
20
|
-
ParamStoreKeyVatCleanupBudget
|
|
15
|
+
ParamStoreKeyBeansPerUnit = []byte("beans_per_unit")
|
|
16
|
+
ParamStoreKeyBootstrapVatConfig = []byte("bootstrap_vat_config")
|
|
17
|
+
ParamStoreKeyFeeUnitPrice = []byte("fee_unit_price")
|
|
18
|
+
ParamStoreKeyPowerFlagFees = []byte("power_flag_fees")
|
|
19
|
+
ParamStoreKeyQueueMax = []byte("queue_max")
|
|
20
|
+
ParamStoreKeyVatCleanupBudget = []byte("vat_cleanup_budget")
|
|
21
|
+
ParamStoreKeyBundleUncompressedSizeLimitBytes = []byte("bundle_uncompressed_size_limit_bytes")
|
|
22
|
+
ParamStoreKeyChunkSizeLimitBytes = []byte("chunk_size_limit_bytes")
|
|
21
23
|
)
|
|
22
24
|
|
|
23
25
|
func NewStringBeans(key string, beans sdkmath.Uint) StringBeans {
|
|
@@ -49,12 +51,14 @@ func ParamKeyTable() paramtypes.KeyTable {
|
|
|
49
51
|
// DefaultParams returns default swingset parameters
|
|
50
52
|
func DefaultParams() Params {
|
|
51
53
|
return Params{
|
|
52
|
-
BeansPerUnit:
|
|
53
|
-
BootstrapVatConfig:
|
|
54
|
-
FeeUnitPrice:
|
|
55
|
-
PowerFlagFees:
|
|
56
|
-
QueueMax:
|
|
57
|
-
VatCleanupBudget:
|
|
54
|
+
BeansPerUnit: DefaultBeansPerUnit(),
|
|
55
|
+
BootstrapVatConfig: DefaultBootstrapVatConfig,
|
|
56
|
+
FeeUnitPrice: DefaultFeeUnitPrice,
|
|
57
|
+
PowerFlagFees: DefaultPowerFlagFees,
|
|
58
|
+
QueueMax: DefaultQueueMax,
|
|
59
|
+
VatCleanupBudget: DefaultVatCleanupBudget,
|
|
60
|
+
BundleUncompressedSizeLimitBytes: DefaultBundleUncompressedSizeLimitBytes,
|
|
61
|
+
ChunkSizeLimitBytes: DefaultChunkSizeLimitBytes,
|
|
58
62
|
}
|
|
59
63
|
}
|
|
60
64
|
|
|
@@ -72,6 +76,8 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
|
|
|
72
76
|
paramtypes.NewParamSetPair(ParamStoreKeyPowerFlagFees, &p.PowerFlagFees, validatePowerFlagFees),
|
|
73
77
|
paramtypes.NewParamSetPair(ParamStoreKeyQueueMax, &p.QueueMax, validateQueueMax),
|
|
74
78
|
paramtypes.NewParamSetPair(ParamStoreKeyVatCleanupBudget, &p.VatCleanupBudget, validateVatCleanupBudget),
|
|
79
|
+
paramtypes.NewParamSetPair(ParamStoreKeyBundleUncompressedSizeLimitBytes, &p.BundleUncompressedSizeLimitBytes, validateBundleUncompressedSizeLimitBytes),
|
|
80
|
+
paramtypes.NewParamSetPair(ParamStoreKeyChunkSizeLimitBytes, &p.ChunkSizeLimitBytes, validateChunkSizeLimitBytes),
|
|
75
81
|
}
|
|
76
82
|
}
|
|
77
83
|
|
|
@@ -95,6 +101,12 @@ func (p Params) ValidateBasic() error {
|
|
|
95
101
|
if err := validateVatCleanupBudget(p.VatCleanupBudget); err != nil {
|
|
96
102
|
return err
|
|
97
103
|
}
|
|
104
|
+
if err := validateBundleUncompressedSizeLimitBytes(p.BundleUncompressedSizeLimitBytes); err != nil {
|
|
105
|
+
return err
|
|
106
|
+
}
|
|
107
|
+
if err := validateChunkSizeLimitBytes(p.ChunkSizeLimitBytes); err != nil {
|
|
108
|
+
return err
|
|
109
|
+
}
|
|
98
110
|
|
|
99
111
|
return nil
|
|
100
112
|
}
|
|
@@ -189,10 +201,33 @@ func validateVatCleanupBudget(i interface{}) error {
|
|
|
189
201
|
return nil
|
|
190
202
|
}
|
|
191
203
|
|
|
204
|
+
func validateBundleUncompressedSizeLimitBytes(i interface{}) error {
|
|
205
|
+
if value, ok := i.(int64); !ok {
|
|
206
|
+
return fmt.Errorf("bundle_uncompressed_size_limit_bytes must be int64, got %#v", i)
|
|
207
|
+
} else if value <= 0 {
|
|
208
|
+
return fmt.Errorf("bundle_uncompressed_size_limit_bytes must be positive (>0), got %d", value)
|
|
209
|
+
}
|
|
210
|
+
return nil
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
func validateChunkSizeLimitBytes(i interface{}) error {
|
|
214
|
+
if value, ok := i.(int64); !ok {
|
|
215
|
+
return fmt.Errorf("chunk_size_limit_bytes must be int64, got %#v", i)
|
|
216
|
+
} else if value <= 0 {
|
|
217
|
+
return fmt.Errorf("chunk_size_limit_bytes must be positive (>0), got %d", value)
|
|
218
|
+
}
|
|
219
|
+
return nil
|
|
220
|
+
}
|
|
221
|
+
|
|
192
222
|
// UpdateParams appends any missing params, configuring them to their defaults,
|
|
193
|
-
// then returning the updated params or an error.
|
|
223
|
+
// then returning the updated params or an error.
|
|
224
|
+
// Existing params are not
|
|
194
225
|
// modified, regardless of their value, and they are not removed if they no
|
|
195
226
|
// longer appear in the defaults.
|
|
227
|
+
// UpdateParams appends missing entries and fills defaults. Note that
|
|
228
|
+
// InstallationDeadlineBlocks and InstallationDeadlineSeconds treat 0 as
|
|
229
|
+
// "unset" and will be replaced with DefaultInstallationDeadlineBlocks and
|
|
230
|
+
// DefaultInstallationDeadlineSeconds, respectively.
|
|
196
231
|
func UpdateParams(params Params) (Params, error) {
|
|
197
232
|
newBpu, err := appendMissingDefaults(params.BeansPerUnit, DefaultBeansPerUnit())
|
|
198
233
|
if err != nil {
|
|
@@ -215,6 +250,21 @@ func UpdateParams(params Params) (Params, error) {
|
|
|
215
250
|
params.PowerFlagFees = newPff
|
|
216
251
|
params.QueueMax = newQm
|
|
217
252
|
params.VatCleanupBudget = newVcb
|
|
253
|
+
|
|
254
|
+
// 0 is treated as unset for these fields.
|
|
255
|
+
if params.InstallationDeadlineBlocks == 0 {
|
|
256
|
+
params.InstallationDeadlineBlocks = DefaultInstallationDeadlineBlocks
|
|
257
|
+
}
|
|
258
|
+
if params.InstallationDeadlineSeconds == 0 {
|
|
259
|
+
params.InstallationDeadlineSeconds = DefaultInstallationDeadlineSeconds
|
|
260
|
+
}
|
|
261
|
+
if params.BundleUncompressedSizeLimitBytes == 0 {
|
|
262
|
+
params.BundleUncompressedSizeLimitBytes = DefaultBundleUncompressedSizeLimitBytes
|
|
263
|
+
}
|
|
264
|
+
if params.ChunkSizeLimitBytes == 0 {
|
|
265
|
+
params.ChunkSizeLimitBytes = DefaultChunkSizeLimitBytes
|
|
266
|
+
}
|
|
267
|
+
|
|
218
268
|
return params, nil
|
|
219
269
|
}
|
|
220
270
|
|
|
@@ -101,12 +101,16 @@ func TestUpdateParamsFromEmpty(t *testing.T) {
|
|
|
101
101
|
VatCleanupBudget: nil,
|
|
102
102
|
}
|
|
103
103
|
want := Params{
|
|
104
|
-
BeansPerUnit:
|
|
105
|
-
BootstrapVatConfig:
|
|
106
|
-
FeeUnitPrice:
|
|
107
|
-
PowerFlagFees:
|
|
108
|
-
QueueMax:
|
|
109
|
-
VatCleanupBudget:
|
|
104
|
+
BeansPerUnit: DefaultBeansPerUnit(),
|
|
105
|
+
BootstrapVatConfig: "",
|
|
106
|
+
FeeUnitPrice: sdk.NewCoins(sdk.NewInt64Coin("denom", 789)),
|
|
107
|
+
PowerFlagFees: DefaultPowerFlagFees,
|
|
108
|
+
QueueMax: DefaultQueueMax,
|
|
109
|
+
VatCleanupBudget: DefaultVatCleanupBudget,
|
|
110
|
+
InstallationDeadlineBlocks: DefaultInstallationDeadlineBlocks,
|
|
111
|
+
InstallationDeadlineSeconds: DefaultInstallationDeadlineSeconds,
|
|
112
|
+
BundleUncompressedSizeLimitBytes: DefaultBundleUncompressedSizeLimitBytes,
|
|
113
|
+
ChunkSizeLimitBytes: DefaultChunkSizeLimitBytes,
|
|
110
114
|
}
|
|
111
115
|
got, err := UpdateParams(in)
|
|
112
116
|
if err != nil {
|
|
@@ -124,20 +128,26 @@ func TestUpdateParamsFromExisting(t *testing.T) {
|
|
|
124
128
|
customQueueSize := NewQueueSize("qux", int32(3))
|
|
125
129
|
customVatCleanup := UintMapEntry{"corge", sdkmath.NewUint(4)}
|
|
126
130
|
in := Params{
|
|
127
|
-
BeansPerUnit:
|
|
128
|
-
BootstrapVatConfig:
|
|
129
|
-
FeeUnitPrice:
|
|
130
|
-
PowerFlagFees:
|
|
131
|
-
QueueMax:
|
|
132
|
-
VatCleanupBudget:
|
|
131
|
+
BeansPerUnit: append([]StringBeans{customBeansPerUnit}, defaultBeansPerUnit[2:4]...),
|
|
132
|
+
BootstrapVatConfig: "",
|
|
133
|
+
FeeUnitPrice: sdk.NewCoins(sdk.NewInt64Coin("denom", 789)),
|
|
134
|
+
PowerFlagFees: []PowerFlagFee{customPowerFlagFee},
|
|
135
|
+
QueueMax: []QueueSize{NewQueueSize(QueueInbound, int32(10)), customQueueSize},
|
|
136
|
+
VatCleanupBudget: []UintMapEntry{customVatCleanup, UintMapEntry{VatCleanupDefault, sdkmath.NewUint(10)}},
|
|
137
|
+
InstallationDeadlineBlocks: 300,
|
|
138
|
+
InstallationDeadlineSeconds: -1,
|
|
133
139
|
}
|
|
134
140
|
want := Params{
|
|
135
|
-
BeansPerUnit:
|
|
136
|
-
BootstrapVatConfig:
|
|
137
|
-
FeeUnitPrice:
|
|
138
|
-
PowerFlagFees:
|
|
139
|
-
QueueMax:
|
|
140
|
-
VatCleanupBudget:
|
|
141
|
+
BeansPerUnit: append(append(in.BeansPerUnit, defaultBeansPerUnit[0:2]...), defaultBeansPerUnit[4:]...),
|
|
142
|
+
BootstrapVatConfig: in.BootstrapVatConfig,
|
|
143
|
+
FeeUnitPrice: in.FeeUnitPrice,
|
|
144
|
+
PowerFlagFees: append(in.PowerFlagFees, DefaultPowerFlagFees...),
|
|
145
|
+
QueueMax: in.QueueMax,
|
|
146
|
+
VatCleanupBudget: append(in.VatCleanupBudget, DefaultVatCleanupBudget[1:]...),
|
|
147
|
+
InstallationDeadlineBlocks: in.InstallationDeadlineBlocks,
|
|
148
|
+
InstallationDeadlineSeconds: in.InstallationDeadlineSeconds,
|
|
149
|
+
BundleUncompressedSizeLimitBytes: DefaultBundleUncompressedSizeLimitBytes,
|
|
150
|
+
ChunkSizeLimitBytes: DefaultChunkSizeLimitBytes,
|
|
141
151
|
}
|
|
142
152
|
got, err := UpdateParams(in)
|
|
143
153
|
if err != nil {
|
|
@@ -148,15 +158,35 @@ func TestUpdateParamsFromExisting(t *testing.T) {
|
|
|
148
158
|
}
|
|
149
159
|
}
|
|
150
160
|
|
|
151
|
-
func
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
161
|
+
func TestUpdateParamsTreatsZeroDeadlinesAsUnset(t *testing.T) {
|
|
162
|
+
in := DefaultParams()
|
|
163
|
+
in.InstallationDeadlineBlocks = 0
|
|
164
|
+
in.InstallationDeadlineSeconds = 0
|
|
165
|
+
|
|
166
|
+
got, err := UpdateParams(in)
|
|
167
|
+
if err != nil {
|
|
168
|
+
t.Fatalf("UpdateParam error %v", err)
|
|
169
|
+
}
|
|
170
|
+
if got.InstallationDeadlineBlocks != DefaultInstallationDeadlineBlocks {
|
|
171
|
+
t.Fatalf(
|
|
172
|
+
"expected InstallationDeadlineBlocks to default when set to 0: got %d, want %d",
|
|
173
|
+
got.InstallationDeadlineBlocks,
|
|
174
|
+
DefaultInstallationDeadlineBlocks,
|
|
175
|
+
)
|
|
176
|
+
}
|
|
177
|
+
if got.InstallationDeadlineSeconds != DefaultInstallationDeadlineSeconds {
|
|
178
|
+
t.Fatalf(
|
|
179
|
+
"expected InstallationDeadlineSeconds to default when set to 0: got %d, want %d",
|
|
180
|
+
got.InstallationDeadlineSeconds,
|
|
181
|
+
DefaultInstallationDeadlineSeconds,
|
|
182
|
+
)
|
|
159
183
|
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
func TestValidateParams(t *testing.T) {
|
|
187
|
+
params := DefaultParams()
|
|
188
|
+
params.BootstrapVatConfig = "foo"
|
|
189
|
+
params.FeeUnitPrice = sdk.NewCoins(sdk.NewInt64Coin("denom", 789))
|
|
160
190
|
err := params.ValidateBasic()
|
|
161
191
|
if err != nil {
|
|
162
192
|
t.Errorf("unexpected ValidateBasic() error with default params: %v", err)
|