@agoric/cosmos 0.34.2-dev-28c592b.0.28c592b → 0.34.2-dev-91a9ad7.0.91a9ad7
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
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
91a9ad7
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/cosmos",
|
|
3
|
-
"version": "0.34.2-dev-
|
|
3
|
+
"version": "0.34.2-dev-91a9ad7.0.91a9ad7",
|
|
4
4
|
"description": "Connect JS to the Cosmos blockchain SDK",
|
|
5
5
|
"parsers": {
|
|
6
6
|
"js": "mjs"
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"typeCoverage": {
|
|
42
42
|
"atLeast": 0
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "91a9ad7ba5458194cd2e3f952738997cbcc55a38"
|
|
45
45
|
}
|
|
@@ -70,12 +70,18 @@ func (k Querier) ChunkedArtifactStatus(c context.Context, req *types.QueryChunke
|
|
|
70
70
|
|
|
71
71
|
msg := k.GetPendingBundleInstall(ctx, req.ChunkedArtifactId)
|
|
72
72
|
if msg == nil {
|
|
73
|
-
return nil, status.
|
|
73
|
+
return nil, status.Errorf(codes.NotFound,
|
|
74
|
+
"no pending chunked artifact with id %d; it may have expired or been finalized",
|
|
75
|
+
req.ChunkedArtifactId,
|
|
76
|
+
)
|
|
74
77
|
}
|
|
75
78
|
|
|
76
79
|
can := k.GetChunkedArtifactNode(ctx, req.ChunkedArtifactId)
|
|
77
80
|
if can == nil {
|
|
78
|
-
return nil, status.
|
|
81
|
+
return nil, status.Errorf(codes.NotFound,
|
|
82
|
+
"pending chunked artifact %d exists but its tracking node is missing (possible state inconsistency)",
|
|
83
|
+
req.ChunkedArtifactId,
|
|
84
|
+
)
|
|
79
85
|
}
|
|
80
86
|
|
|
81
87
|
return &types.QueryChunkedArtifactStatusResponse{
|
|
@@ -20,6 +20,8 @@ var (
|
|
|
20
20
|
ParamStoreKeyVatCleanupBudget = []byte("vat_cleanup_budget")
|
|
21
21
|
ParamStoreKeyBundleUncompressedSizeLimitBytes = []byte("bundle_uncompressed_size_limit_bytes")
|
|
22
22
|
ParamStoreKeyChunkSizeLimitBytes = []byte("chunk_size_limit_bytes")
|
|
23
|
+
ParamStoreKeyInstallationDeadlineSeconds = []byte("installation_deadline_seconds")
|
|
24
|
+
ParamStoreKeyInstallationDeadlineBlocks = []byte("installation_deadline_blocks")
|
|
23
25
|
)
|
|
24
26
|
|
|
25
27
|
func NewStringBeans(key string, beans sdkmath.Uint) StringBeans {
|
|
@@ -59,6 +61,8 @@ func DefaultParams() Params {
|
|
|
59
61
|
VatCleanupBudget: DefaultVatCleanupBudget,
|
|
60
62
|
BundleUncompressedSizeLimitBytes: DefaultBundleUncompressedSizeLimitBytes,
|
|
61
63
|
ChunkSizeLimitBytes: DefaultChunkSizeLimitBytes,
|
|
64
|
+
InstallationDeadlineSeconds: DefaultInstallationDeadlineSeconds, // 86400 (24h)
|
|
65
|
+
InstallationDeadlineBlocks: DefaultInstallationDeadlineBlocks, // -1 (unlimited)
|
|
62
66
|
}
|
|
63
67
|
}
|
|
64
68
|
|
|
@@ -78,6 +82,8 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
|
|
|
78
82
|
paramtypes.NewParamSetPair(ParamStoreKeyVatCleanupBudget, &p.VatCleanupBudget, validateVatCleanupBudget),
|
|
79
83
|
paramtypes.NewParamSetPair(ParamStoreKeyBundleUncompressedSizeLimitBytes, &p.BundleUncompressedSizeLimitBytes, validateBundleUncompressedSizeLimitBytes),
|
|
80
84
|
paramtypes.NewParamSetPair(ParamStoreKeyChunkSizeLimitBytes, &p.ChunkSizeLimitBytes, validateChunkSizeLimitBytes),
|
|
85
|
+
paramtypes.NewParamSetPair(ParamStoreKeyInstallationDeadlineSeconds, &p.InstallationDeadlineSeconds, validateInstallationDeadlineSeconds),
|
|
86
|
+
paramtypes.NewParamSetPair(ParamStoreKeyInstallationDeadlineBlocks, &p.InstallationDeadlineBlocks, validateInstallationDeadlineBlocks),
|
|
81
87
|
}
|
|
82
88
|
}
|
|
83
89
|
|
|
@@ -101,6 +107,12 @@ func (p Params) ValidateBasic() error {
|
|
|
101
107
|
if err := validateVatCleanupBudget(p.VatCleanupBudget); err != nil {
|
|
102
108
|
return err
|
|
103
109
|
}
|
|
110
|
+
if err := validateInstallationDeadlineBlocks(p.InstallationDeadlineBlocks); err != nil {
|
|
111
|
+
return err
|
|
112
|
+
}
|
|
113
|
+
if err := validateInstallationDeadlineSeconds(p.InstallationDeadlineSeconds); err != nil {
|
|
114
|
+
return err
|
|
115
|
+
}
|
|
104
116
|
if err := validateBundleUncompressedSizeLimitBytes(p.BundleUncompressedSizeLimitBytes); err != nil {
|
|
105
117
|
return err
|
|
106
118
|
}
|
|
@@ -219,6 +231,34 @@ func validateChunkSizeLimitBytes(i interface{}) error {
|
|
|
219
231
|
return nil
|
|
220
232
|
}
|
|
221
233
|
|
|
234
|
+
func validateInstallationDeadlineSeconds(i interface{}) error {
|
|
235
|
+
value, ok := i.(int64)
|
|
236
|
+
if !ok {
|
|
237
|
+
return fmt.Errorf("installation_deadline_seconds must be int64, got %#v", i)
|
|
238
|
+
}
|
|
239
|
+
if value < -1 {
|
|
240
|
+
return fmt.Errorf(
|
|
241
|
+
"installation_deadline_seconds must be -1 (unlimited), 0 (expire immediately), or positive, got %d",
|
|
242
|
+
value,
|
|
243
|
+
)
|
|
244
|
+
}
|
|
245
|
+
return nil
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
func validateInstallationDeadlineBlocks(i interface{}) error {
|
|
249
|
+
value, ok := i.(int64)
|
|
250
|
+
if !ok {
|
|
251
|
+
return fmt.Errorf("installation_deadline_blocks must be int64, got %#v", i)
|
|
252
|
+
}
|
|
253
|
+
if value < -1 {
|
|
254
|
+
return fmt.Errorf(
|
|
255
|
+
"installation_deadline_blocks must be -1 (unlimited), 0 (expire immediately), or positive, got %d",
|
|
256
|
+
value,
|
|
257
|
+
)
|
|
258
|
+
}
|
|
259
|
+
return nil
|
|
260
|
+
}
|
|
261
|
+
|
|
222
262
|
// UpdateParams appends any missing params, configuring them to their defaults,
|
|
223
263
|
// then returning the updated params or an error.
|
|
224
264
|
// Existing params are not
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
package types
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
|
+
"strings"
|
|
4
5
|
"reflect"
|
|
5
6
|
"testing"
|
|
6
7
|
|
|
@@ -211,3 +212,64 @@ func TestValidateParams(t *testing.T) {
|
|
|
211
212
|
t.Errorf("unexpected ValidateBasic() error with empty VatCleanupBudget: %v", params.VatCleanupBudget)
|
|
212
213
|
}
|
|
213
214
|
}
|
|
215
|
+
|
|
216
|
+
func TestValidateInstallationDeadlineBounds(t *testing.T) {
|
|
217
|
+
const minInt64 int64 = -1 << 63
|
|
218
|
+
|
|
219
|
+
for _, tc := range []struct {
|
|
220
|
+
name string
|
|
221
|
+
seconds int64
|
|
222
|
+
blocks int64
|
|
223
|
+
wantErrSubstr string
|
|
224
|
+
}{
|
|
225
|
+
{name: "both unlimited", seconds: -1, blocks: -1},
|
|
226
|
+
{name: "both immediate", seconds: 0, blocks: 0},
|
|
227
|
+
{name: "both positive", seconds: 1, blocks: 1},
|
|
228
|
+
{
|
|
229
|
+
name: "seconds below minimum",
|
|
230
|
+
seconds: -2,
|
|
231
|
+
blocks: -1,
|
|
232
|
+
wantErrSubstr: "installation_deadline_seconds must be -1 (unlimited), 0 (expire immediately), or positive, got -2",
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
name: "blocks below minimum",
|
|
236
|
+
seconds: -1,
|
|
237
|
+
blocks: -2,
|
|
238
|
+
wantErrSubstr: "installation_deadline_blocks must be -1 (unlimited), 0 (expire immediately), or positive, got -2",
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
name: "seconds at int64 minimum",
|
|
242
|
+
seconds: minInt64,
|
|
243
|
+
blocks: -1,
|
|
244
|
+
wantErrSubstr: "installation_deadline_seconds must be -1 (unlimited), 0 (expire immediately), or positive, got -9223372036854775808",
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
name: "blocks at int64 minimum",
|
|
248
|
+
seconds: -1,
|
|
249
|
+
blocks: minInt64,
|
|
250
|
+
wantErrSubstr: "installation_deadline_blocks must be -1 (unlimited), 0 (expire immediately), or positive, got -9223372036854775808",
|
|
251
|
+
},
|
|
252
|
+
} {
|
|
253
|
+
t.Run(tc.name, func(t *testing.T) {
|
|
254
|
+
params := DefaultParams()
|
|
255
|
+
params.BootstrapVatConfig = "foo"
|
|
256
|
+
params.FeeUnitPrice = sdk.NewCoins(sdk.NewInt64Coin("denom", 789))
|
|
257
|
+
params.InstallationDeadlineSeconds = tc.seconds
|
|
258
|
+
params.InstallationDeadlineBlocks = tc.blocks
|
|
259
|
+
|
|
260
|
+
err := params.ValidateBasic()
|
|
261
|
+
if tc.wantErrSubstr == "" {
|
|
262
|
+
if err != nil {
|
|
263
|
+
t.Fatalf("unexpected ValidateBasic() error: %v", err)
|
|
264
|
+
}
|
|
265
|
+
return
|
|
266
|
+
}
|
|
267
|
+
if err == nil {
|
|
268
|
+
t.Fatal("expected ValidateBasic() error, got nil")
|
|
269
|
+
}
|
|
270
|
+
if !strings.Contains(err.Error(), tc.wantErrSubstr) {
|
|
271
|
+
t.Fatalf("expected error containing %q, got %q", tc.wantErrSubstr, err)
|
|
272
|
+
}
|
|
273
|
+
})
|
|
274
|
+
}
|
|
275
|
+
}
|