@typeberry/convert 0.5.3 → 0.5.4-61ca416
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/README.md +0 -1
- package/index.js +230 -241
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -4362,7 +4362,6 @@ const env = typeof process === "undefined" ? {} : process.env;
|
|
|
4362
4362
|
|
|
4363
4363
|
var GpVersion;
|
|
4364
4364
|
(function (GpVersion) {
|
|
4365
|
-
GpVersion["V0_7_0"] = "0.7.0";
|
|
4366
4365
|
GpVersion["V0_7_1"] = "0.7.1";
|
|
4367
4366
|
GpVersion["V0_7_2"] = "0.7.2";
|
|
4368
4367
|
})(GpVersion || (GpVersion = {}));
|
|
@@ -4371,7 +4370,7 @@ var TestSuite;
|
|
|
4371
4370
|
TestSuite["W3F_DAVXY"] = "w3f-davxy";
|
|
4372
4371
|
})(TestSuite || (TestSuite = {}));
|
|
4373
4372
|
// NOTE: Also acts as a supported versions
|
|
4374
|
-
const ALL_VERSIONS_IN_ORDER = [GpVersion.
|
|
4373
|
+
const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_7_1, GpVersion.V0_7_2];
|
|
4375
4374
|
const DEFAULT_SUITE = TestSuite.W3F_DAVXY;
|
|
4376
4375
|
const DEFAULT_VERSION = GpVersion.V0_7_2;
|
|
4377
4376
|
let CURRENT_VERSION = parseCurrentVersion(env.GP_VERSION) ?? DEFAULT_VERSION;
|
|
@@ -4956,7 +4955,7 @@ function isResult(x) {
|
|
|
4956
4955
|
var minimist = __nccwpck_require__(595);
|
|
4957
4956
|
var minimist_default = /*#__PURE__*/__nccwpck_require__.n(minimist);
|
|
4958
4957
|
;// CONCATENATED MODULE: ./bin/convert/package.json
|
|
4959
|
-
const package_namespaceObject = {"rE":"0.5.
|
|
4958
|
+
const package_namespaceObject = {"rE":"0.5.4"};
|
|
4960
4959
|
;// CONCATENATED MODULE: ./packages/core/bytes/bitvec.ts
|
|
4961
4960
|
|
|
4962
4961
|
/**
|
|
@@ -5346,7 +5345,7 @@ const bytesBlobComparator = (a, b) => a.compare(b);
|
|
|
5346
5345
|
const asTypedNumber = (v) => v;
|
|
5347
5346
|
const MAX_VALUE_U8 = 0xff;
|
|
5348
5347
|
const MAX_VALUE_U16 = 0xffff;
|
|
5349
|
-
const
|
|
5348
|
+
const numbers_MAX_VALUE_U32 = 0xffff_ffff;
|
|
5350
5349
|
const MAX_VALUE_U64 = 0xffffffffffffffffn;
|
|
5351
5350
|
/** Attempt to cast an input number into U8. */
|
|
5352
5351
|
const tryAsU8 = (v) => {
|
|
@@ -5368,7 +5367,7 @@ const numbers_tryAsU32 = (v) => {
|
|
|
5368
5367
|
return asTypedNumber(v);
|
|
5369
5368
|
};
|
|
5370
5369
|
/** Check if given number is a valid U32 number. */
|
|
5371
|
-
const isU32 = (v) => (v &
|
|
5370
|
+
const isU32 = (v) => (v & numbers_MAX_VALUE_U32) >>> 0 === v;
|
|
5372
5371
|
/** Attempt to cast an input number into U64. */
|
|
5373
5372
|
const numbers_tryAsU64 = (x) => {
|
|
5374
5373
|
const v = BigInt(x);
|
|
@@ -5850,7 +5849,7 @@ class Skipper {
|
|
|
5850
5849
|
*
|
|
5851
5850
|
* Descriptors can be composed to form more complex typings.
|
|
5852
5851
|
*/
|
|
5853
|
-
class
|
|
5852
|
+
class descriptor_Descriptor {
|
|
5854
5853
|
name;
|
|
5855
5854
|
sizeHint;
|
|
5856
5855
|
encode;
|
|
@@ -5860,11 +5859,11 @@ class Descriptor {
|
|
|
5860
5859
|
View;
|
|
5861
5860
|
/** New descriptor with specialized `View`. */
|
|
5862
5861
|
static withView(name, sizeHint, encode, decode, skip, view) {
|
|
5863
|
-
return new
|
|
5862
|
+
return new descriptor_Descriptor(name, sizeHint, encode, decode, skip, view);
|
|
5864
5863
|
}
|
|
5865
5864
|
/** Create a new descriptor without a specialized `View`. */
|
|
5866
5865
|
static new(name, sizeHint, encode, decode, skip) {
|
|
5867
|
-
return new
|
|
5866
|
+
return new descriptor_Descriptor(name, sizeHint, encode, decode, skip, null);
|
|
5868
5867
|
}
|
|
5869
5868
|
constructor(
|
|
5870
5869
|
/** Descriptive name of the coded data. */
|
|
@@ -5901,7 +5900,7 @@ class Descriptor {
|
|
|
5901
5900
|
}
|
|
5902
5901
|
/** Return a new descriptor that converts data into some other type. */
|
|
5903
5902
|
convert(input, output) {
|
|
5904
|
-
return new
|
|
5903
|
+
return new descriptor_Descriptor(this.name, this.sizeHint, (e, elem) => this.encode(e, input(elem)), (d) => output(this.decode(d)), this.skip, this.View);
|
|
5905
5904
|
}
|
|
5906
5905
|
/** Safely cast the descriptor value to a opaque type. */
|
|
5907
5906
|
asOpaque() {
|
|
@@ -6600,53 +6599,53 @@ const bytes = (() => {
|
|
|
6600
6599
|
return (len) => {
|
|
6601
6600
|
let ret = cache.get(len);
|
|
6602
6601
|
if (ret === undefined) {
|
|
6603
|
-
ret =
|
|
6602
|
+
ret = descriptor_Descriptor.new(`Bytes<${len}>`, exactHint(len), (e, v) => e.bytes(v), (d) => d.bytes(len), (s) => s.bytes(len));
|
|
6604
6603
|
cache.set(len, ret);
|
|
6605
6604
|
}
|
|
6606
6605
|
return ret;
|
|
6607
6606
|
};
|
|
6608
6607
|
})();
|
|
6609
6608
|
/** Zero-size `void` value. */
|
|
6610
|
-
const nothing =
|
|
6609
|
+
const nothing = descriptor_Descriptor.new("void", { bytes: 0, isExact: true }, (_e, _v) => { }, (_d) => { }, (_s) => { });
|
|
6611
6610
|
/** Variable-length U32. */
|
|
6612
|
-
const varU32 =
|
|
6611
|
+
const varU32 = descriptor_Descriptor.new("var_u32", { bytes: 4, isExact: false }, (e, v) => e.varU32(v), (d) => d.varU32(), (d) => d.varU32());
|
|
6613
6612
|
/** Variable-length U64. */
|
|
6614
|
-
const varU64 =
|
|
6613
|
+
const varU64 = descriptor_Descriptor.new("var_u64", { bytes: 8, isExact: false }, (e, v) => e.varU64(v), (d) => d.varU64(), (d) => d.varU64());
|
|
6615
6614
|
/** Unsigned 64-bit number. */
|
|
6616
|
-
const u64 =
|
|
6615
|
+
const u64 = descriptor_Descriptor.withView("u64", exactHint(8), (e, v) => e.i64(v), (d) => d.u64(), (d) => d.u64(), bytes(8));
|
|
6617
6616
|
/** Unsigned 32-bit number. */
|
|
6618
|
-
const u32 =
|
|
6617
|
+
const u32 = descriptor_Descriptor.withView("u32", exactHint(4), (e, v) => e.i32(v), (d) => d.u32(), (d) => d.u32(), bytes(4));
|
|
6619
6618
|
/** Unsigned 24-bit number. */
|
|
6620
|
-
const u24 =
|
|
6619
|
+
const u24 = descriptor_Descriptor.withView("u24", exactHint(3), (e, v) => e.i24(v), (d) => d.u24(), (d) => d.u24(), bytes(3));
|
|
6621
6620
|
/** Unsigned 16-bit number. */
|
|
6622
|
-
const u16 =
|
|
6621
|
+
const u16 = descriptor_Descriptor.withView("u16", exactHint(2), (e, v) => e.i16(v), (d) => d.u16(), (d) => d.u16(), bytes(2));
|
|
6623
6622
|
/** Unsigned 8-bit number. */
|
|
6624
|
-
const u8 =
|
|
6623
|
+
const u8 = descriptor_Descriptor.new("u8", exactHint(1), (e, v) => e.i8(v), (d) => d.u8(), (d) => d.u8());
|
|
6625
6624
|
/** Signed 64-bit number. */
|
|
6626
|
-
const i64 =
|
|
6625
|
+
const i64 = descriptor_Descriptor.withView("i64", exactHint(8), (e, v) => e.i64(v), (d) => d.i64(), (s) => s.u64(), bytes(8));
|
|
6627
6626
|
/** Signed 32-bit number. */
|
|
6628
|
-
const i32 =
|
|
6627
|
+
const i32 = descriptor_Descriptor.withView("i32", exactHint(4), (e, v) => e.i32(v), (d) => d.i32(), (s) => s.u32(), bytes(4));
|
|
6629
6628
|
/** Signed 24-bit number. */
|
|
6630
|
-
const i24 =
|
|
6629
|
+
const i24 = descriptor_Descriptor.withView("i24", exactHint(3), (e, v) => e.i24(v), (d) => d.i24(), (s) => s.u24(), bytes(3));
|
|
6631
6630
|
/** Signed 16-bit number. */
|
|
6632
|
-
const i16 =
|
|
6631
|
+
const i16 = descriptor_Descriptor.withView("i16", exactHint(2), (e, v) => e.i16(v), (d) => d.i16(), (s) => s.u16(), bytes(2));
|
|
6633
6632
|
/** Signed 8-bit number. */
|
|
6634
|
-
const i8 =
|
|
6633
|
+
const i8 = descriptor_Descriptor.new("i8", exactHint(1), (e, v) => e.i8(v), (d) => d.i8(), (s) => s.u8());
|
|
6635
6634
|
/** 1-byte boolean value. */
|
|
6636
|
-
const bool =
|
|
6635
|
+
const bool = descriptor_Descriptor.new("bool", exactHint(1), (e, v) => e.bool(v), (d) => d.bool(), (s) => s.bool());
|
|
6637
6636
|
/** Variable-length bytes blob. */
|
|
6638
|
-
const blob =
|
|
6637
|
+
const blob = descriptor_Descriptor.new("BytesBlob", { bytes: TYPICAL_SEQUENCE_LENGTH, isExact: false }, (e, v) => e.bytesBlob(v), (d) => d.bytesBlob(), (s) => s.bytesBlob());
|
|
6639
6638
|
/** String encoded as variable-length bytes blob. */
|
|
6640
|
-
const string =
|
|
6639
|
+
const string = descriptor_Descriptor.withView("string", { bytes: TYPICAL_SEQUENCE_LENGTH, isExact: false }, (e, v) => e.bytesBlob(bytes_BytesBlob.blobFrom(new TextEncoder().encode(v))), (d) => new TextDecoder("utf8", { fatal: true }).decode(d.bytesBlob().raw), (s) => s.bytesBlob(), blob);
|
|
6641
6640
|
/** Variable-length bit vector. */
|
|
6642
|
-
const bitVecVarLen =
|
|
6641
|
+
const bitVecVarLen = descriptor_Descriptor.new("BitVec[?]", { bytes: TYPICAL_SEQUENCE_LENGTH >>> 3, isExact: false }, (e, v) => e.bitVecVarLen(v), (d) => d.bitVecVarLen(), (s) => s.bitVecVarLen());
|
|
6643
6642
|
/** Fixed-length bit vector. */
|
|
6644
|
-
const bitVecFixLen = (bitLen) =>
|
|
6643
|
+
const bitVecFixLen = (bitLen) => descriptor_Descriptor.new(`BitVec[${bitLen}]`, exactHint(bitLen >>> 3), (e, v) => e.bitVecFixLen(v), (d) => d.bitVecFixLen(bitLen), (s) => s.bitVecFixLen(bitLen));
|
|
6645
6644
|
/** Optionality wrapper for given type. */
|
|
6646
6645
|
const optional = (type) => {
|
|
6647
|
-
const self =
|
|
6646
|
+
const self = descriptor_Descriptor.new(`Optional<${type.name}>`, addSizeHints({ bytes: 1, isExact: false }, type.sizeHint), (e, v) => e.optional(type, v), (d) => d.optional(type), (s) => s.optional(type));
|
|
6648
6647
|
if (hasUniqueView(type)) {
|
|
6649
|
-
return
|
|
6648
|
+
return descriptor_Descriptor.withView(self.name, self.sizeHint, self.encode, self.decode, self.skip, optional(type.View));
|
|
6650
6649
|
}
|
|
6651
6650
|
return self;
|
|
6652
6651
|
};
|
|
@@ -6657,7 +6656,7 @@ const sequenceVarLen = (type, options = {
|
|
|
6657
6656
|
}) => {
|
|
6658
6657
|
const name = `Sequence<${type.name}>[?]`;
|
|
6659
6658
|
const typicalLength = options.typicalLength ?? TYPICAL_SEQUENCE_LENGTH;
|
|
6660
|
-
return
|
|
6659
|
+
return descriptor_Descriptor.withView(name, { bytes: typicalLength * type.sizeHint.bytes, isExact: false }, (e, v) => {
|
|
6661
6660
|
validateLength(options, v.length, name);
|
|
6662
6661
|
e.sequenceVarLen(type, v);
|
|
6663
6662
|
}, (d) => {
|
|
@@ -6671,10 +6670,10 @@ const sequenceVarLen = (type, options = {
|
|
|
6671
6670
|
}, sequenceViewVarLen(type, options));
|
|
6672
6671
|
};
|
|
6673
6672
|
/** Fixed-length sequence of given type. */
|
|
6674
|
-
const sequenceFixLen = (type, len) =>
|
|
6673
|
+
const sequenceFixLen = (type, len) => descriptor_Descriptor.withView(`Sequence<${type.name}>[${len}]`, { bytes: len * type.sizeHint.bytes, isExact: type.sizeHint.isExact }, (e, v) => e.sequenceFixLen(type, v), (d) => d.sequenceFixLen(type, len), (s) => s.sequenceFixLen(type, len), sequenceViewFixLen(type, { fixedLength: len }));
|
|
6675
6674
|
/** Small dictionary codec. */
|
|
6676
6675
|
const dictionary = (key, value, { sortKeys, fixedLength, }) => {
|
|
6677
|
-
const self =
|
|
6676
|
+
const self = descriptor_Descriptor.new(`Dictionary<${key.name}, ${value.name}>[${fixedLength ?? "?"}]`, {
|
|
6678
6677
|
bytes: fixedLength !== undefined
|
|
6679
6678
|
? fixedLength * addSizeHints(key.sizeHint, value.sizeHint).bytes
|
|
6680
6679
|
: TYPICAL_DICTIONARY_LENGTH * (addSizeHints(key.sizeHint, value.sizeHint).bytes ?? 0),
|
|
@@ -6713,13 +6712,13 @@ const dictionary = (key, value, { sortKeys, fixedLength, }) => {
|
|
|
6713
6712
|
s.sequenceFixLen(value, len);
|
|
6714
6713
|
});
|
|
6715
6714
|
if (hasUniqueView(value)) {
|
|
6716
|
-
return
|
|
6715
|
+
return descriptor_Descriptor.withView(self.name, self.sizeHint, self.encode, self.decode, self.skip, dictionary(key, value.View, { sortKeys, fixedLength }));
|
|
6717
6716
|
}
|
|
6718
6717
|
return self;
|
|
6719
6718
|
};
|
|
6720
6719
|
/** Encoding of pair of two values. */
|
|
6721
6720
|
const pair = (a, b) => {
|
|
6722
|
-
const self =
|
|
6721
|
+
const self = descriptor_Descriptor.new(`Pair<${a.name}, ${b.name}>`, addSizeHints(a.sizeHint, b.sizeHint), (e, elem) => {
|
|
6723
6722
|
a.encode(e, elem[0]);
|
|
6724
6723
|
b.encode(e, elem[1]);
|
|
6725
6724
|
}, (d) => {
|
|
@@ -6731,12 +6730,12 @@ const pair = (a, b) => {
|
|
|
6731
6730
|
b.skip(s);
|
|
6732
6731
|
});
|
|
6733
6732
|
if (hasUniqueView(a) && hasUniqueView(b)) {
|
|
6734
|
-
return
|
|
6733
|
+
return descriptor_Descriptor.withView(self.name, self.sizeHint, self.encode, self.decode, self.skip, pair(a.View, b.View));
|
|
6735
6734
|
}
|
|
6736
6735
|
return self;
|
|
6737
6736
|
};
|
|
6738
6737
|
/** Custom encoding / decoding logic. */
|
|
6739
|
-
const custom = ({ name, sizeHint = { bytes: 0, isExact: false }, }, encode, decode, skip) =>
|
|
6738
|
+
const custom = ({ name, sizeHint = { bytes: 0, isExact: false }, }, encode, decode, skip) => descriptor_Descriptor.new(name, sizeHint, encode, decode, skip);
|
|
6740
6739
|
/** Tagged union type encoding. */
|
|
6741
6740
|
const union = (name, variants) => {
|
|
6742
6741
|
const keys = Object.keys(variants).map(Number);
|
|
@@ -6777,12 +6776,12 @@ const union = (name, variants) => {
|
|
|
6777
6776
|
const codec = variants[kind];
|
|
6778
6777
|
codec.skip(s);
|
|
6779
6778
|
};
|
|
6780
|
-
return
|
|
6779
|
+
return descriptor_Descriptor.new(name, sizeHint, encode, decode, skip);
|
|
6781
6780
|
};
|
|
6782
6781
|
/** Choose a descriptor depending on the encoding/decoding context. */
|
|
6783
6782
|
const descriptors_select = ({ name, sizeHint, }, chooser) => {
|
|
6784
6783
|
const Self = chooser(null);
|
|
6785
|
-
return
|
|
6784
|
+
return descriptor_Descriptor.withView(name, sizeHint, (e, x) => chooser(e.getContext()).encode(e, x), (d) => chooser(d.getContext()).decode(d), (s) => chooser(s.decoder.getContext()).skip(s), hasUniqueView(Self)
|
|
6786
6785
|
? descriptors_select({
|
|
6787
6786
|
name: Self.View.name,
|
|
6788
6787
|
sizeHint: Self.View.sizeHint,
|
|
@@ -6825,7 +6824,7 @@ const Class = (Class, descriptors) => {
|
|
|
6825
6824
|
};
|
|
6826
6825
|
const view = objectView(Class, descriptors, sizeHint, skipper);
|
|
6827
6826
|
// and create the descriptor for the entire class.
|
|
6828
|
-
return
|
|
6827
|
+
return descriptor_Descriptor.withView(Class.name, sizeHint, (e, t) => {
|
|
6829
6828
|
forEachDescriptor(descriptors, (key, descriptor) => {
|
|
6830
6829
|
const value = t[key];
|
|
6831
6830
|
descriptor.encode(e, value);
|
|
@@ -6878,7 +6877,7 @@ function objectView(Class, descriptors, sizeHint, skipper) {
|
|
|
6878
6877
|
});
|
|
6879
6878
|
}
|
|
6880
6879
|
});
|
|
6881
|
-
return
|
|
6880
|
+
return descriptor_Descriptor.new(`View<${Class.name}>`, sizeHint, (e, t) => {
|
|
6882
6881
|
const encoded = t.encoded();
|
|
6883
6882
|
e.bytes(bytes_Bytes.fromBlob(encoded.raw, encoded.length));
|
|
6884
6883
|
}, (d) => {
|
|
@@ -6897,7 +6896,7 @@ function sequenceViewVarLen(type, options) {
|
|
|
6897
6896
|
validateLength(options, length, name);
|
|
6898
6897
|
return s.sequenceFixLen(type, length);
|
|
6899
6898
|
};
|
|
6900
|
-
return
|
|
6899
|
+
return descriptor_Descriptor.new(name, sizeHint, (e, t) => {
|
|
6901
6900
|
validateLength(options, t.length, name);
|
|
6902
6901
|
const encoded = t.encoded();
|
|
6903
6902
|
e.bytes(bytes_Bytes.fromBlob(encoded.raw, encoded.length));
|
|
@@ -6913,7 +6912,7 @@ function sequenceViewFixLen(type, { fixedLength }) {
|
|
|
6913
6912
|
const skipper = (s) => s.sequenceFixLen(type, fixedLength);
|
|
6914
6913
|
const view = type.name !== type.View.name ? `, ${type.View.name}` : "";
|
|
6915
6914
|
const name = `SeqView<${type.name}${view}>[${fixedLength}]`;
|
|
6916
|
-
return
|
|
6915
|
+
return descriptor_Descriptor.new(name, sizeHint, (e, t) => {
|
|
6917
6916
|
const encoded = t.encoded();
|
|
6918
6917
|
e.bytes(bytes_Bytes.fromBlob(encoded.raw, encoded.length));
|
|
6919
6918
|
}, (d) => {
|
|
@@ -7743,6 +7742,7 @@ const ZERO_HASH = bytes_Bytes.zero(hash_HASH_SIZE);
|
|
|
7743
7742
|
class WithHash extends WithDebug {
|
|
7744
7743
|
hash;
|
|
7745
7744
|
data;
|
|
7745
|
+
// TODO [ToDr] use static method and make constructor private
|
|
7746
7746
|
constructor(hash, data) {
|
|
7747
7747
|
super();
|
|
7748
7748
|
this.hash = hash;
|
|
@@ -9176,7 +9176,7 @@ const codecFixedSizeArray = (val, len) => {
|
|
|
9176
9176
|
};
|
|
9177
9177
|
/** Codec for a hash-dictionary. */
|
|
9178
9178
|
const codecHashDictionary = (value, extractKey, { typicalLength = codec_codec.TYPICAL_DICTIONARY_LENGTH, compare = (a, b) => extractKey(a).compare(extractKey(b)), } = {}) => {
|
|
9179
|
-
return
|
|
9179
|
+
return descriptor_Descriptor.new(`HashDictionary<${value.name}>[?]`, {
|
|
9180
9180
|
bytes: typicalLength * value.sizeHint.bytes,
|
|
9181
9181
|
isExact: false,
|
|
9182
9182
|
}, (e, v) => {
|
|
@@ -9751,14 +9751,18 @@ class work_item_WorkItem extends WithDebug {
|
|
|
9751
9751
|
|
|
9752
9752
|
|
|
9753
9753
|
|
|
9754
|
-
/**
|
|
9754
|
+
/** Convert the value to `WorkItemsCount` bounds. */
|
|
9755
9755
|
function tryAsWorkItemsCount(len) {
|
|
9756
9756
|
debug_check `
|
|
9757
|
-
${len
|
|
9757
|
+
${isWorkItemsCount(len)}
|
|
9758
9758
|
WorkItemsCount: Expected '${MIN_NUMBER_OF_WORK_ITEMS} <= count <= ${work_package_MAX_NUMBER_OF_WORK_ITEMS}' got ${len}
|
|
9759
9759
|
`;
|
|
9760
9760
|
return tryAsU8(len);
|
|
9761
9761
|
}
|
|
9762
|
+
/** Verify the value is within the `WorkItemsCount` bounds. */
|
|
9763
|
+
function isWorkItemsCount(len) {
|
|
9764
|
+
return len >= MIN_NUMBER_OF_WORK_ITEMS && len <= work_package_MAX_NUMBER_OF_WORK_ITEMS;
|
|
9765
|
+
}
|
|
9762
9766
|
/** Minimal number of work items in the work package or results in work report. */
|
|
9763
9767
|
const MIN_NUMBER_OF_WORK_ITEMS = 1;
|
|
9764
9768
|
/** `I`: Maximal number of work items in the work package or results in work report. */
|
|
@@ -9859,6 +9863,12 @@ class WorkExecResult extends WithDebug {
|
|
|
9859
9863
|
}
|
|
9860
9864
|
return { kind: x.kind };
|
|
9861
9865
|
}, (x) => new WorkExecResult(x.kind, x.kind === WorkExecResultKind.ok ? x.okBlob : null));
|
|
9866
|
+
static ok(blob) {
|
|
9867
|
+
return new WorkExecResult(WorkExecResultKind.ok, blob);
|
|
9868
|
+
}
|
|
9869
|
+
static error(kind) {
|
|
9870
|
+
return new WorkExecResult(kind, null);
|
|
9871
|
+
}
|
|
9862
9872
|
constructor(
|
|
9863
9873
|
/** The execution result tag. */
|
|
9864
9874
|
kind,
|
|
@@ -10800,6 +10810,9 @@ var json;
|
|
|
10800
10810
|
if (typeof inJson !== "object" || inJson === null) {
|
|
10801
10811
|
throw new Error("Expected map for parsing");
|
|
10802
10812
|
}
|
|
10813
|
+
if (Array.isArray(inJson)) {
|
|
10814
|
+
throw new Error("Expected map, got array");
|
|
10815
|
+
}
|
|
10803
10816
|
const result = new Map();
|
|
10804
10817
|
for (const [key, value] of Object.entries(inJson)) {
|
|
10805
10818
|
result.set(parse_parseFromJson(key, K, `${context}.key`), parse_parseFromJson(value, V, `${context}.value`));
|
|
@@ -10949,22 +10962,22 @@ const workExecResultFromJson = json.object({
|
|
|
10949
10962
|
}, (val) => {
|
|
10950
10963
|
const { ok, out_of_gas, panic, bad_code, code_oversize, output_oversize } = val;
|
|
10951
10964
|
if (ok !== undefined) {
|
|
10952
|
-
return
|
|
10965
|
+
return WorkExecResult.ok(ok);
|
|
10953
10966
|
}
|
|
10954
10967
|
if (out_of_gas === null) {
|
|
10955
|
-
return
|
|
10968
|
+
return WorkExecResult.error(WorkExecResultKind.outOfGas);
|
|
10956
10969
|
}
|
|
10957
10970
|
if (panic === null) {
|
|
10958
|
-
return
|
|
10971
|
+
return WorkExecResult.error(WorkExecResultKind.panic);
|
|
10959
10972
|
}
|
|
10960
10973
|
if (bad_code === null) {
|
|
10961
|
-
return
|
|
10974
|
+
return WorkExecResult.error(WorkExecResultKind.badCode);
|
|
10962
10975
|
}
|
|
10963
10976
|
if (code_oversize === null) {
|
|
10964
|
-
return
|
|
10977
|
+
return WorkExecResult.error(WorkExecResultKind.codeOversize);
|
|
10965
10978
|
}
|
|
10966
10979
|
if (output_oversize === null) {
|
|
10967
|
-
return
|
|
10980
|
+
return WorkExecResult.error(WorkExecResultKind.digestTooBig);
|
|
10968
10981
|
}
|
|
10969
10982
|
throw new Error("Invalid WorkExecResult");
|
|
10970
10983
|
});
|
|
@@ -11162,6 +11175,13 @@ const blockFromJson = (spec) => json.object({
|
|
|
11162
11175
|
header: headerFromJson,
|
|
11163
11176
|
extrinsic: getExtrinsicFromJson(spec),
|
|
11164
11177
|
}, ({ header, extrinsic }) => Block.create({ header, extrinsic }));
|
|
11178
|
+
const blockViewFromJson = (spec) => {
|
|
11179
|
+
const parseBlock = blockFromJson(spec);
|
|
11180
|
+
return json.fromAny((p) => {
|
|
11181
|
+
const block = parse_parseFromJson(p, parseBlock);
|
|
11182
|
+
return reencodeAsView(Block.Codec, block, spec);
|
|
11183
|
+
});
|
|
11184
|
+
};
|
|
11165
11185
|
|
|
11166
11186
|
;// CONCATENATED MODULE: ./packages/jam/block-json/index.ts
|
|
11167
11187
|
|
|
@@ -11656,13 +11676,13 @@ const getStateCodec = codec_codec.bytes(hash_HASH_SIZE).asOpaque();
|
|
|
11656
11676
|
/** StateRoot ::= StateRootHash */
|
|
11657
11677
|
const stateRootCodec = codec_codec.bytes(hash_HASH_SIZE).asOpaque();
|
|
11658
11678
|
/** Error ::= UTF8String */
|
|
11659
|
-
class
|
|
11679
|
+
class types_ErrorMessage extends WithDebug {
|
|
11660
11680
|
message;
|
|
11661
|
-
static Codec = codec_codec.Class(
|
|
11681
|
+
static Codec = codec_codec.Class(types_ErrorMessage, {
|
|
11662
11682
|
message: codec_codec.string,
|
|
11663
11683
|
});
|
|
11664
11684
|
static create({ message }) {
|
|
11665
|
-
return new
|
|
11685
|
+
return new types_ErrorMessage(message);
|
|
11666
11686
|
}
|
|
11667
11687
|
constructor(message) {
|
|
11668
11688
|
super();
|
|
@@ -11716,7 +11736,7 @@ const types_messageCodec = codec_codec.custom({
|
|
|
11716
11736
|
stateCodec.encode(e, msg.value);
|
|
11717
11737
|
break;
|
|
11718
11738
|
case types_MessageType.Error:
|
|
11719
|
-
|
|
11739
|
+
types_ErrorMessage.Codec.encode(e, msg.value);
|
|
11720
11740
|
break;
|
|
11721
11741
|
default:
|
|
11722
11742
|
throw new Error(`Unknown message type: ${msg}`);
|
|
@@ -11737,7 +11757,7 @@ const types_messageCodec = codec_codec.custom({
|
|
|
11737
11757
|
case types_MessageType.State:
|
|
11738
11758
|
return { type: types_MessageType.State, value: stateCodec.decode(d) };
|
|
11739
11759
|
case types_MessageType.Error:
|
|
11740
|
-
return { type: types_MessageType.Error, value:
|
|
11760
|
+
return { type: types_MessageType.Error, value: types_ErrorMessage.Codec.decode(d) };
|
|
11741
11761
|
default:
|
|
11742
11762
|
throw new Error(`Unknown message type: ${type}`);
|
|
11743
11763
|
}
|
|
@@ -11763,7 +11783,7 @@ const types_messageCodec = codec_codec.custom({
|
|
|
11763
11783
|
stateCodec.View.skip(s);
|
|
11764
11784
|
break;
|
|
11765
11785
|
case types_MessageType.Error:
|
|
11766
|
-
|
|
11786
|
+
types_ErrorMessage.Codec.View.skip(s);
|
|
11767
11787
|
break;
|
|
11768
11788
|
default:
|
|
11769
11789
|
throw new Error(`Unknown message type: ${type}`);
|
|
@@ -11826,35 +11846,59 @@ class FuzzTarget {
|
|
|
11826
11846
|
break;
|
|
11827
11847
|
}
|
|
11828
11848
|
case MessageType.Initialize: {
|
|
11829
|
-
|
|
11830
|
-
|
|
11831
|
-
type: MessageType.StateRoot,
|
|
11832
|
-
value: stateRoot,
|
|
11833
|
-
};
|
|
11834
|
-
break;
|
|
11835
|
-
}
|
|
11836
|
-
case MessageType.ImportBlock: {
|
|
11837
|
-
const result = await this.msgHandler.importBlock(message.value);
|
|
11838
|
-
if (result.isOk) {
|
|
11849
|
+
try {
|
|
11850
|
+
const stateRoot = await this.msgHandler.initialize(message.value);
|
|
11839
11851
|
response = {
|
|
11840
11852
|
type: MessageType.StateRoot,
|
|
11841
|
-
value:
|
|
11853
|
+
value: stateRoot,
|
|
11842
11854
|
};
|
|
11843
11855
|
}
|
|
11844
|
-
|
|
11856
|
+
catch (e) {
|
|
11857
|
+
response = {
|
|
11858
|
+
type: MessageType.Error,
|
|
11859
|
+
value: ErrorMessage.create({ message: `initialize error: ${e}` }),
|
|
11860
|
+
};
|
|
11861
|
+
}
|
|
11862
|
+
break;
|
|
11863
|
+
}
|
|
11864
|
+
case MessageType.ImportBlock: {
|
|
11865
|
+
try {
|
|
11866
|
+
const result = await this.msgHandler.importBlock(message.value);
|
|
11867
|
+
if (result.isOk) {
|
|
11868
|
+
response = {
|
|
11869
|
+
type: MessageType.StateRoot,
|
|
11870
|
+
value: result.ok,
|
|
11871
|
+
};
|
|
11872
|
+
}
|
|
11873
|
+
else {
|
|
11874
|
+
response = {
|
|
11875
|
+
type: MessageType.Error,
|
|
11876
|
+
value: result.error,
|
|
11877
|
+
};
|
|
11878
|
+
}
|
|
11879
|
+
}
|
|
11880
|
+
catch (e) {
|
|
11845
11881
|
response = {
|
|
11846
11882
|
type: MessageType.Error,
|
|
11847
|
-
value:
|
|
11883
|
+
value: ErrorMessage.create({ message: `importBlock error: ${e}` }),
|
|
11848
11884
|
};
|
|
11849
11885
|
}
|
|
11850
11886
|
break;
|
|
11851
11887
|
}
|
|
11852
11888
|
case MessageType.GetState: {
|
|
11853
|
-
|
|
11854
|
-
|
|
11855
|
-
|
|
11856
|
-
|
|
11857
|
-
|
|
11889
|
+
try {
|
|
11890
|
+
const state = await this.msgHandler.getSerializedState(message.value);
|
|
11891
|
+
response = {
|
|
11892
|
+
type: MessageType.State,
|
|
11893
|
+
value: state,
|
|
11894
|
+
};
|
|
11895
|
+
}
|
|
11896
|
+
catch (e) {
|
|
11897
|
+
response = {
|
|
11898
|
+
type: MessageType.Error,
|
|
11899
|
+
value: ErrorMessage.create({ message: `getState error: ${e}` }),
|
|
11900
|
+
};
|
|
11901
|
+
}
|
|
11858
11902
|
break;
|
|
11859
11903
|
}
|
|
11860
11904
|
case MessageType.StateRoot: {
|
|
@@ -12314,13 +12358,6 @@ function hashComparator(a, b) {
|
|
|
12314
12358
|
return a.compare(b);
|
|
12315
12359
|
}
|
|
12316
12360
|
|
|
12317
|
-
;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/ops/math-consts.ts
|
|
12318
|
-
const math_consts_MAX_VALUE = 4294967295;
|
|
12319
|
-
const math_consts_MAX_VALUE_U64 = (/* unused pure expression or super */ null && (2n ** 63n));
|
|
12320
|
-
const math_consts_MIN_VALUE = (/* unused pure expression or super */ null && (-(2 ** 31)));
|
|
12321
|
-
const math_consts_MAX_SHIFT_U32 = 32;
|
|
12322
|
-
const math_consts_MAX_SHIFT_U64 = 64n;
|
|
12323
|
-
|
|
12324
12361
|
;// CONCATENATED MODULE: ./packages/jam/state/recent-blocks.ts
|
|
12325
12362
|
|
|
12326
12363
|
|
|
@@ -12575,7 +12612,7 @@ const zeroSizeHint = {
|
|
|
12575
12612
|
/** 0-byte read, return given default value */
|
|
12576
12613
|
const ignoreValueWithDefault = (defaultValue) => Descriptor.new("ignoreValue", zeroSizeHint, (_e, _v) => { }, (_d) => defaultValue, (_s) => { });
|
|
12577
12614
|
/** Encode and decode object with leading version number. */
|
|
12578
|
-
const codecWithVersion = (val) =>
|
|
12615
|
+
const codecWithVersion = (val) => descriptor_Descriptor.new("withVersion", {
|
|
12579
12616
|
bytes: val.sizeHint.bytes + 8,
|
|
12580
12617
|
isExact: false,
|
|
12581
12618
|
}, (e, v) => {
|
|
@@ -12738,8 +12775,6 @@ class LookupHistoryItem {
|
|
|
12738
12775
|
|
|
12739
12776
|
|
|
12740
12777
|
|
|
12741
|
-
|
|
12742
|
-
|
|
12743
12778
|
/**
|
|
12744
12779
|
* Activity Record of a single validator.
|
|
12745
12780
|
*
|
|
@@ -12870,42 +12905,20 @@ class ServiceStatistics {
|
|
|
12870
12905
|
extrinsicCount;
|
|
12871
12906
|
accumulateCount;
|
|
12872
12907
|
accumulateGasUsed;
|
|
12873
|
-
|
|
12874
|
-
|
|
12875
|
-
|
|
12876
|
-
|
|
12877
|
-
|
|
12878
|
-
|
|
12879
|
-
|
|
12880
|
-
|
|
12881
|
-
|
|
12882
|
-
|
|
12883
|
-
|
|
12884
|
-
exports: codecVarU16,
|
|
12885
|
-
accumulateCount: codec_codec.varU32,
|
|
12886
|
-
accumulateGasUsed: codecVarGas,
|
|
12887
|
-
onTransfersCount: codec_codec.varU32,
|
|
12888
|
-
onTransfersGasUsed: codecVarGas,
|
|
12889
|
-
}),
|
|
12890
|
-
versions: {
|
|
12891
|
-
[GpVersion.V0_7_1]: codec_codec.Class(ServiceStatistics, {
|
|
12892
|
-
providedCount: codecVarU16,
|
|
12893
|
-
providedSize: codec_codec.varU32,
|
|
12894
|
-
refinementCount: codec_codec.varU32,
|
|
12895
|
-
refinementGasUsed: codecVarGas,
|
|
12896
|
-
imports: codecVarU16,
|
|
12897
|
-
extrinsicCount: codecVarU16,
|
|
12898
|
-
extrinsicSize: codec_codec.varU32,
|
|
12899
|
-
exports: codecVarU16,
|
|
12900
|
-
accumulateCount: codec_codec.varU32,
|
|
12901
|
-
accumulateGasUsed: codecVarGas,
|
|
12902
|
-
onTransfersCount: ignoreValueWithDefault(numbers_tryAsU32(0)),
|
|
12903
|
-
onTransfersGasUsed: ignoreValueWithDefault(tryAsServiceGas(0)),
|
|
12904
|
-
}),
|
|
12905
|
-
},
|
|
12908
|
+
static Codec = codec_codec.Class(ServiceStatistics, {
|
|
12909
|
+
providedCount: codecVarU16,
|
|
12910
|
+
providedSize: codec_codec.varU32,
|
|
12911
|
+
refinementCount: codec_codec.varU32,
|
|
12912
|
+
refinementGasUsed: codecVarGas,
|
|
12913
|
+
imports: codecVarU16,
|
|
12914
|
+
extrinsicCount: codecVarU16,
|
|
12915
|
+
extrinsicSize: codec_codec.varU32,
|
|
12916
|
+
exports: codecVarU16,
|
|
12917
|
+
accumulateCount: codec_codec.varU32,
|
|
12918
|
+
accumulateGasUsed: codecVarGas,
|
|
12906
12919
|
});
|
|
12907
12920
|
static create(v) {
|
|
12908
|
-
return new ServiceStatistics(v.providedCount, v.providedSize, v.refinementCount, v.refinementGasUsed, v.imports, v.exports, v.extrinsicSize, v.extrinsicCount, v.accumulateCount, v.accumulateGasUsed
|
|
12921
|
+
return new ServiceStatistics(v.providedCount, v.providedSize, v.refinementCount, v.refinementGasUsed, v.imports, v.exports, v.extrinsicSize, v.extrinsicCount, v.accumulateCount, v.accumulateGasUsed);
|
|
12909
12922
|
}
|
|
12910
12923
|
constructor(
|
|
12911
12924
|
/** `p.0` */
|
|
@@ -12927,11 +12940,7 @@ class ServiceStatistics {
|
|
|
12927
12940
|
/** `a.0` */
|
|
12928
12941
|
accumulateCount,
|
|
12929
12942
|
/** `a.1` */
|
|
12930
|
-
accumulateGasUsed
|
|
12931
|
-
/** `t.0` @deprecated since 0.7.1 */
|
|
12932
|
-
onTransfersCount,
|
|
12933
|
-
/** `t.1` @deprecated since 0.7.1 */
|
|
12934
|
-
onTransfersGasUsed) {
|
|
12943
|
+
accumulateGasUsed) {
|
|
12935
12944
|
this.providedCount = providedCount;
|
|
12936
12945
|
this.providedSize = providedSize;
|
|
12937
12946
|
this.refinementCount = refinementCount;
|
|
@@ -12942,14 +12951,12 @@ class ServiceStatistics {
|
|
|
12942
12951
|
this.extrinsicCount = extrinsicCount;
|
|
12943
12952
|
this.accumulateCount = accumulateCount;
|
|
12944
12953
|
this.accumulateGasUsed = accumulateGasUsed;
|
|
12945
|
-
this.onTransfersCount = onTransfersCount;
|
|
12946
|
-
this.onTransfersGasUsed = onTransfersGasUsed;
|
|
12947
12954
|
}
|
|
12948
12955
|
static empty() {
|
|
12949
12956
|
const zero = numbers_tryAsU32(0);
|
|
12950
12957
|
const zero16 = numbers_tryAsU16(0);
|
|
12951
12958
|
const zeroGas = tryAsServiceGas(0);
|
|
12952
|
-
return new ServiceStatistics(zero16, zero, zero, zeroGas, zero16, zero16, zero, zero16, zero, zeroGas
|
|
12959
|
+
return new ServiceStatistics(zero16, zero, zero, zeroGas, zero16, zero16, zero, zero16, zero, zeroGas);
|
|
12953
12960
|
}
|
|
12954
12961
|
}
|
|
12955
12962
|
/** `pi`: Statistics of each validator, cores statistics and services statistics. */
|
|
@@ -13048,9 +13055,6 @@ class InMemoryStateView {
|
|
|
13048
13055
|
;// CONCATENATED MODULE: ./packages/jam/state/privileged-services.ts
|
|
13049
13056
|
|
|
13050
13057
|
|
|
13051
|
-
|
|
13052
|
-
|
|
13053
|
-
|
|
13054
13058
|
/**
|
|
13055
13059
|
* https://graypaper.fluffylabs.dev/#/ab2cdbd/114402114402?v=0.7.2
|
|
13056
13060
|
*/
|
|
@@ -13065,9 +13069,7 @@ class PrivilegedServices {
|
|
|
13065
13069
|
manager: codec_codec.u32.asOpaque(),
|
|
13066
13070
|
assigners: codecPerCore(codec_codec.u32.asOpaque()),
|
|
13067
13071
|
delegator: codec_codec.u32.asOpaque(),
|
|
13068
|
-
registrar:
|
|
13069
|
-
? codec_codec.u32.asOpaque()
|
|
13070
|
-
: ignoreValueWithDefault(tryAsServiceId(2 ** 32 - 1)),
|
|
13072
|
+
registrar: codec_codec.u32.asOpaque(),
|
|
13071
13073
|
autoAccumulateServices: codec_codec.dictionary(codec_codec.u32.asOpaque(), codec_codec.u64.asOpaque(), {
|
|
13072
13074
|
sortKeys: (a, b) => a - b,
|
|
13073
13075
|
}),
|
|
@@ -13300,7 +13302,6 @@ class UpdateStorage {
|
|
|
13300
13302
|
|
|
13301
13303
|
|
|
13302
13304
|
|
|
13303
|
-
|
|
13304
13305
|
|
|
13305
13306
|
|
|
13306
13307
|
var UpdateError;
|
|
@@ -13733,7 +13734,7 @@ class InMemoryState extends WithDebug {
|
|
|
13733
13734
|
manager: tryAsServiceId(0),
|
|
13734
13735
|
assigners: tryAsPerCore(new Array(spec.coresCount).fill(tryAsServiceId(0)), spec),
|
|
13735
13736
|
delegator: tryAsServiceId(0),
|
|
13736
|
-
registrar: tryAsServiceId(
|
|
13737
|
+
registrar: tryAsServiceId(numbers_MAX_VALUE_U32),
|
|
13737
13738
|
autoAccumulateServices: new Map(),
|
|
13738
13739
|
}),
|
|
13739
13740
|
accumulationOutputLog: SortedArray.fromArray(accumulationOutputComparator, []),
|
|
@@ -13783,7 +13784,7 @@ const serviceDataCodec = codec_codec.dictionary(codec_codec.u32.asOpaque(), serv
|
|
|
13783
13784
|
|
|
13784
13785
|
class JsonServiceInfo {
|
|
13785
13786
|
static fromJson = json.object({
|
|
13786
|
-
|
|
13787
|
+
version: "number",
|
|
13787
13788
|
code_hash: fromJson.bytes32(),
|
|
13788
13789
|
balance: json.fromNumber((x) => numbers_tryAsU64(x)),
|
|
13789
13790
|
min_item_gas: json.fromNumber((x) => tryAsServiceGas(x)),
|
|
@@ -13836,33 +13837,61 @@ class JsonStorageItem {
|
|
|
13836
13837
|
key;
|
|
13837
13838
|
value;
|
|
13838
13839
|
}
|
|
13839
|
-
const
|
|
13840
|
+
const preimageStatusFromJson = json.object({
|
|
13840
13841
|
key: {
|
|
13841
13842
|
hash: fromJson.bytes32(),
|
|
13842
13843
|
length: "number",
|
|
13843
13844
|
},
|
|
13844
13845
|
value: json.array("number"),
|
|
13845
|
-
}, ({ key, value }) => new LookupHistoryItem(key.hash, key.length, value));
|
|
13846
|
-
|
|
13846
|
+
}, ({ key, value }) => new LookupHistoryItem(key.hash, numbers_tryAsU32(key.length), value));
|
|
13847
|
+
class JsonService {
|
|
13848
|
+
static fromJson = json.object({
|
|
13849
|
+
id: "number",
|
|
13850
|
+
data: {
|
|
13851
|
+
service: JsonServiceInfo.fromJson,
|
|
13852
|
+
storage: json.optional(json.array(JsonStorageItem.fromJson)),
|
|
13853
|
+
preimage_blobs: json.optional(json.array(JsonPreimageItem.fromJson)),
|
|
13854
|
+
preimage_requests: json.optional(json.array(preimageStatusFromJson)),
|
|
13855
|
+
},
|
|
13856
|
+
}, ({ id, data }) => {
|
|
13857
|
+
const preimages = HashDictionary.fromEntries((data.preimage_blobs ?? []).map((x) => [x.hash, x]));
|
|
13858
|
+
const lookupHistory = HashDictionary.new();
|
|
13859
|
+
for (const item of data.preimage_requests ?? []) {
|
|
13860
|
+
const data = lookupHistory.get(item.hash) ?? [];
|
|
13861
|
+
data.push(item);
|
|
13862
|
+
lookupHistory.set(item.hash, data);
|
|
13863
|
+
}
|
|
13864
|
+
const storage = new Map();
|
|
13865
|
+
const entries = (data.storage ?? []).map(({ key, value }) => {
|
|
13866
|
+
const opaqueKey = opaque_asOpaqueType(key);
|
|
13867
|
+
return [opaqueKey, StorageItem.create({ key: opaqueKey, value })];
|
|
13868
|
+
});
|
|
13869
|
+
for (const [key, item] of entries) {
|
|
13870
|
+
storage.set(key.toString(), item);
|
|
13871
|
+
}
|
|
13872
|
+
return new InMemoryService(id, {
|
|
13873
|
+
info: data.service,
|
|
13874
|
+
preimages,
|
|
13875
|
+
storage,
|
|
13876
|
+
lookupHistory,
|
|
13877
|
+
});
|
|
13878
|
+
});
|
|
13879
|
+
id;
|
|
13880
|
+
data;
|
|
13881
|
+
}
|
|
13882
|
+
const preimageStatusFromJson072 = json.object({
|
|
13847
13883
|
hash: fromJson.bytes32(),
|
|
13848
13884
|
status: json.array("number"),
|
|
13849
13885
|
}, ({ hash, status }) => new LookupHistoryItem(hash, numbers_tryAsU32(0), status));
|
|
13850
|
-
class
|
|
13886
|
+
class JsonServicePre072 {
|
|
13851
13887
|
static fromJson = json.object({
|
|
13852
13888
|
id: "number",
|
|
13853
|
-
data:
|
|
13854
|
-
|
|
13855
|
-
|
|
13856
|
-
|
|
13857
|
-
|
|
13858
|
-
|
|
13859
|
-
}
|
|
13860
|
-
: {
|
|
13861
|
-
service: JsonServiceInfo.fromJson,
|
|
13862
|
-
preimages: json.optional(json.array(JsonPreimageItem.fromJson)),
|
|
13863
|
-
storage: json.optional(json.array(JsonStorageItem.fromJson)),
|
|
13864
|
-
lookup_meta: json.optional(json.array(lookupMetaFromJson)),
|
|
13865
|
-
},
|
|
13889
|
+
data: {
|
|
13890
|
+
service: JsonServiceInfo.fromJson,
|
|
13891
|
+
storage: json.optional(json.array(JsonStorageItem.fromJson)),
|
|
13892
|
+
preimages_blob: json.optional(json.array(JsonPreimageItem.fromJson)),
|
|
13893
|
+
preimages_status: json.optional(json.array(preimageStatusFromJson072)),
|
|
13894
|
+
},
|
|
13866
13895
|
}, ({ id, data }) => {
|
|
13867
13896
|
const preimages = HashDictionary.fromEntries((data.preimages ?? data.preimages_blob ?? []).map((x) => [x.hash, x]));
|
|
13868
13897
|
const lookupHistory = HashDictionary.new();
|
|
@@ -14021,8 +14050,6 @@ class TicketsOrKeys {
|
|
|
14021
14050
|
|
|
14022
14051
|
|
|
14023
14052
|
|
|
14024
|
-
|
|
14025
|
-
|
|
14026
14053
|
class JsonValidatorStatistics {
|
|
14027
14054
|
static fromJson = json.object({
|
|
14028
14055
|
blocks: "number",
|
|
@@ -14091,13 +14118,7 @@ class JsonServiceStatistics {
|
|
|
14091
14118
|
extrinsic_count: "number",
|
|
14092
14119
|
accumulate_count: "number",
|
|
14093
14120
|
accumulate_gas_used: json.fromBigInt(tryAsServiceGas),
|
|
14094
|
-
|
|
14095
|
-
? {}
|
|
14096
|
-
: {
|
|
14097
|
-
on_transfers_count: "number",
|
|
14098
|
-
on_transfers_gas_used: json.fromBigInt(tryAsServiceGas),
|
|
14099
|
-
}),
|
|
14100
|
-
}, ({ provided_count, provided_size, refinement_count, refinement_gas_used, imports, exports, extrinsic_size, extrinsic_count, accumulate_count, accumulate_gas_used, on_transfers_count, on_transfers_gas_used, }) => {
|
|
14121
|
+
}, ({ provided_count, provided_size, refinement_count, refinement_gas_used, imports, exports, extrinsic_size, extrinsic_count, accumulate_count, accumulate_gas_used, }) => {
|
|
14101
14122
|
return ServiceStatistics.create({
|
|
14102
14123
|
providedCount: provided_count,
|
|
14103
14124
|
providedSize: provided_size,
|
|
@@ -14109,8 +14130,6 @@ class JsonServiceStatistics {
|
|
|
14109
14130
|
extrinsicCount: extrinsic_count,
|
|
14110
14131
|
accumulateCount: accumulate_count,
|
|
14111
14132
|
accumulateGasUsed: accumulate_gas_used,
|
|
14112
|
-
onTransfersCount: on_transfers_count ?? numbers_tryAsU32(0),
|
|
14113
|
-
onTransfersGasUsed: on_transfers_gas_used ?? tryAsServiceGas(0),
|
|
14114
14133
|
});
|
|
14115
14134
|
});
|
|
14116
14135
|
provided_count;
|
|
@@ -14123,8 +14142,6 @@ class JsonServiceStatistics {
|
|
|
14123
14142
|
extrinsic_count;
|
|
14124
14143
|
accumulate_count;
|
|
14125
14144
|
accumulate_gas_used;
|
|
14126
|
-
on_transfers_count;
|
|
14127
|
-
on_transfers_gas_used;
|
|
14128
14145
|
}
|
|
14129
14146
|
const serviceStatisticsEntryFromJson = {
|
|
14130
14147
|
id: "number",
|
|
@@ -14183,7 +14200,6 @@ const validatorDataFromJson = json.object({
|
|
|
14183
14200
|
|
|
14184
14201
|
|
|
14185
14202
|
|
|
14186
|
-
|
|
14187
14203
|
const fullStateDumpFromJson = (spec) => json.object({
|
|
14188
14204
|
alpha: json.array(json.array(fromJson.bytes32())),
|
|
14189
14205
|
varphi: json.array(json.array(fromJson.bytes32())),
|
|
@@ -14205,18 +14221,15 @@ const fullStateDumpFromJson = (spec) => json.object({
|
|
|
14205
14221
|
chi_m: "number",
|
|
14206
14222
|
chi_a: json.array("number"),
|
|
14207
14223
|
chi_v: "number",
|
|
14208
|
-
chi_r:
|
|
14224
|
+
chi_r: "number",
|
|
14209
14225
|
chi_g: json.nullable(json.map("number", json.fromNumber((v) => tryAsServiceGas(v)))),
|
|
14210
14226
|
},
|
|
14211
14227
|
pi: JsonStatisticsData.fromJson,
|
|
14212
14228
|
omega: json.array(json.array(notYetAccumulatedFromJson)),
|
|
14213
14229
|
xi: json.array(json.array(fromJson.bytes32())),
|
|
14214
14230
|
theta: json.nullable(json.array(accumulationOutput)),
|
|
14215
|
-
accounts: json.array(
|
|
14231
|
+
accounts: json.array(JsonServicePre072.fromJson),
|
|
14216
14232
|
}, ({ alpha, varphi, beta, gamma, psi, eta, iota, kappa, lambda, rho, tau, chi, pi, omega, xi, theta, accounts, }) => {
|
|
14217
|
-
if (Compatibility.isGreaterOrEqual(GpVersion.V0_7_1) && chi.chi_r === undefined) {
|
|
14218
|
-
throw new Error("Registrar is required in Privileges GP ^0.7.1");
|
|
14219
|
-
}
|
|
14220
14233
|
return InMemoryState.new(spec, {
|
|
14221
14234
|
authPools: tryAsPerCore(alpha.map((perCore) => {
|
|
14222
14235
|
if (perCore.length > MAX_AUTH_POOL_SIZE) {
|
|
@@ -14246,7 +14259,7 @@ const fullStateDumpFromJson = (spec) => json.object({
|
|
|
14246
14259
|
manager: chi.chi_m,
|
|
14247
14260
|
assigners: chi.chi_a,
|
|
14248
14261
|
delegator: chi.chi_v,
|
|
14249
|
-
registrar: chi.chi_r
|
|
14262
|
+
registrar: chi.chi_r,
|
|
14250
14263
|
autoAccumulateServices: chi.chi_g ?? new Map(),
|
|
14251
14264
|
}),
|
|
14252
14265
|
statistics: JsonStatisticsData.toStatisticsData(spec, pi),
|
|
@@ -14422,7 +14435,6 @@ function legacyServiceNested(serviceId, hash) {
|
|
|
14422
14435
|
|
|
14423
14436
|
|
|
14424
14437
|
|
|
14425
|
-
|
|
14426
14438
|
/** Serialization for particular state entries. */
|
|
14427
14439
|
var serialize_serialize;
|
|
14428
14440
|
(function (serialize) {
|
|
@@ -14530,24 +14542,22 @@ var serialize_serialize;
|
|
|
14530
14542
|
Codec: codec_codec.sequenceVarLen(AccumulationOutput.Codec).convert((i) => i.array, (o) => SortedArray.fromSortedArray(accumulationOutputComparator, o)),
|
|
14531
14543
|
extract: (s) => s.accumulationOutputLog,
|
|
14532
14544
|
};
|
|
14533
|
-
/** C(255, s): https://graypaper.fluffylabs.dev/#/
|
|
14545
|
+
/** C(255, s): https://graypaper.fluffylabs.dev/#/ab2cdbd/3b7d033b7d03?v=0.7.2 */
|
|
14534
14546
|
serialize.serviceData = (serviceId) => ({
|
|
14535
14547
|
key: stateKeys.serviceInfo(serviceId),
|
|
14536
|
-
Codec:
|
|
14537
|
-
? codecWithVersion(ServiceAccountInfo.Codec)
|
|
14538
|
-
: ServiceAccountInfo.Codec,
|
|
14548
|
+
Codec: codecWithVersion(ServiceAccountInfo.Codec),
|
|
14539
14549
|
});
|
|
14540
|
-
/** https://graypaper.fluffylabs.dev/#/
|
|
14550
|
+
/** https://graypaper.fluffylabs.dev/#/ab2cdbd/3bac033bac03?v=0.7.2 */
|
|
14541
14551
|
serialize.serviceStorage = (blake2b, serviceId, key) => ({
|
|
14542
14552
|
key: stateKeys.serviceStorage(blake2b, serviceId, key),
|
|
14543
14553
|
Codec: dumpCodec,
|
|
14544
14554
|
});
|
|
14545
|
-
/** https://graypaper.fluffylabs.dev/#/
|
|
14555
|
+
/** https://graypaper.fluffylabs.dev/#/ab2cdbd/3bc9033bc903?v=0.7.2 */
|
|
14546
14556
|
serialize.servicePreimages = (blake2b, serviceId, hash) => ({
|
|
14547
14557
|
key: stateKeys.servicePreimage(blake2b, serviceId, hash),
|
|
14548
14558
|
Codec: dumpCodec,
|
|
14549
14559
|
});
|
|
14550
|
-
/** https://graypaper.fluffylabs.dev/#/
|
|
14560
|
+
/** https://graypaper.fluffylabs.dev/#/ab2cdbd/3bea033b0904?v=0.7.2 */
|
|
14551
14561
|
serialize.serviceLookupHistory = (blake2b, serviceId, hash, len) => ({
|
|
14552
14562
|
key: stateKeys.serviceLookupHistory(blake2b, serviceId, hash, len),
|
|
14553
14563
|
Codec: codec_codec.readonlyArray(codec_codec.sequenceVarLen(codec_codec.u32)),
|
|
@@ -14560,7 +14570,7 @@ var serialize_serialize;
|
|
|
14560
14570
|
* determine the boundary of the bytes, so it can only be used
|
|
14561
14571
|
* as the last element of the codec and can't be used in sequences!
|
|
14562
14572
|
*/
|
|
14563
|
-
const dumpCodec =
|
|
14573
|
+
const dumpCodec = descriptor_Descriptor.new("Dump", { bytes: 64, isExact: false }, (e, v) => e.bytes(bytes_Bytes.fromBlob(v.raw, v.raw.length)), (d) => bytes_BytesBlob.blobFrom(d.bytes(d.source.length - d.bytesRead()).raw), (s) => s.bytes(s.decoder.source.length - s.decoder.bytesRead()));
|
|
14564
14574
|
|
|
14565
14575
|
;// CONCATENATED MODULE: ./packages/jam/state-merkleization/serialized-state-view.ts
|
|
14566
14576
|
|
|
@@ -15888,7 +15898,7 @@ const codecMap = (value, extractKey, { typicalLength = codec_codec.TYPICAL_DICTI
|
|
|
15888
15898
|
}
|
|
15889
15899
|
return Ordering.Equal;
|
|
15890
15900
|
}, } = {}) => {
|
|
15891
|
-
return
|
|
15901
|
+
return descriptor_Descriptor.new(`Map<${value.name}>[?]`, {
|
|
15892
15902
|
bytes: typicalLength * value.sizeHint.bytes,
|
|
15893
15903
|
isExact: false,
|
|
15894
15904
|
}, (e, v) => {
|
|
@@ -16065,11 +16075,11 @@ class StateTransition {
|
|
|
16065
16075
|
static fromJson = {
|
|
16066
16076
|
pre_state: TestState.fromJson,
|
|
16067
16077
|
post_state: TestState.fromJson,
|
|
16068
|
-
block:
|
|
16078
|
+
block: blockViewFromJson(chain_spec_tinyChainSpec),
|
|
16069
16079
|
};
|
|
16070
16080
|
static Codec = codec_codec.object({
|
|
16071
16081
|
pre_state: TestState.Codec,
|
|
16072
|
-
block: Block.Codec,
|
|
16082
|
+
block: Block.Codec.View,
|
|
16073
16083
|
post_state: TestState.Codec,
|
|
16074
16084
|
});
|
|
16075
16085
|
pre_state;
|
|
@@ -16147,41 +16157,21 @@ async function runWorkItemTest(test, { path }) {
|
|
|
16147
16157
|
|
|
16148
16158
|
|
|
16149
16159
|
|
|
16150
|
-
|
|
16151
|
-
|
|
16152
|
-
|
|
16153
|
-
|
|
16154
|
-
|
|
16155
|
-
|
|
16156
|
-
|
|
16157
|
-
|
|
16158
|
-
|
|
16159
|
-
|
|
16160
|
-
|
|
16161
|
-
|
|
16162
|
-
|
|
16163
|
-
|
|
16164
|
-
|
|
16165
|
-
authCodeHost: auth_code_host,
|
|
16166
|
-
authCodeHash: auth_code_hash,
|
|
16167
|
-
parametrization: authorizer_config,
|
|
16168
|
-
context,
|
|
16169
|
-
items: FixedSizeArray.new(items, tryAsWorkItemsCount(items.length)),
|
|
16170
|
-
}))
|
|
16171
|
-
: json.object({
|
|
16172
|
-
authorization: json.fromString(bytes_BytesBlob.parseBlob),
|
|
16173
|
-
auth_code_host: "number",
|
|
16174
|
-
authorizer: authorizerFromJson,
|
|
16175
|
-
context: refineContextFromJson,
|
|
16176
|
-
items: json.array(workItemFromJson),
|
|
16177
|
-
}, ({ authorization, auth_code_host, authorizer, context, items }) => work_package_WorkPackage.create({
|
|
16178
|
-
authorization,
|
|
16179
|
-
authCodeHost: auth_code_host,
|
|
16180
|
-
authCodeHash: authorizer.code_hash,
|
|
16181
|
-
parametrization: authorizer.params,
|
|
16182
|
-
context,
|
|
16183
|
-
items: FixedSizeArray.new(items, tryAsWorkItemsCount(items.length)),
|
|
16184
|
-
}));
|
|
16160
|
+
const workPackageFromJson = json.object({
|
|
16161
|
+
authorization: json.fromString(bytes_BytesBlob.parseBlob),
|
|
16162
|
+
auth_code_host: "number",
|
|
16163
|
+
auth_code_hash: fromJson.bytes32(),
|
|
16164
|
+
authorizer_config: json.fromString(bytes_BytesBlob.parseBlob),
|
|
16165
|
+
context: refineContextFromJson,
|
|
16166
|
+
items: json.array(workItemFromJson),
|
|
16167
|
+
}, ({ authorization, auth_code_host, auth_code_hash, authorizer_config, context, items }) => work_package_WorkPackage.create({
|
|
16168
|
+
authorization,
|
|
16169
|
+
authCodeHost: auth_code_host,
|
|
16170
|
+
authCodeHash: auth_code_hash,
|
|
16171
|
+
parametrization: authorizer_config,
|
|
16172
|
+
context,
|
|
16173
|
+
items: FixedSizeArray.new(items, tryAsWorkItemsCount(items.length)),
|
|
16174
|
+
}));
|
|
16185
16175
|
async function runWorkPackageTest(test, { path: file }) {
|
|
16186
16176
|
runCodecTest(WorkPackage.Codec, test, file);
|
|
16187
16177
|
}
|
|
@@ -17893,22 +17883,22 @@ class memory_builder_MemoryBuilder {
|
|
|
17893
17883
|
* Overflowing addition for two-complement representation of 32-bit signed numbers.
|
|
17894
17884
|
*/
|
|
17895
17885
|
function math_utils_addWithOverflowU32(a, b) {
|
|
17896
|
-
if (a >
|
|
17886
|
+
if (a > MAX_VALUE_U32 - b) {
|
|
17897
17887
|
/**
|
|
17898
|
-
*
|
|
17899
|
-
*
|
|
17900
|
-
* =
|
|
17901
|
-
* =
|
|
17902
|
-
* = a + b -
|
|
17888
|
+
* MAX_VALUE_U32 is equal to 2 ** 32 - 1
|
|
17889
|
+
* MAX_VALUE_U32 - ( (MAX_VALUE_U32 - a) + (MAX_VALUE_U32 - b) ) - 1
|
|
17890
|
+
* = MAX_VALUE_U32 - (2MAX_VALUE_U32 - a - b) -1
|
|
17891
|
+
* = MAX_VALUE_U32 - 2MAX_VALUE_U32 + a + b - 1
|
|
17892
|
+
* = a + b - MAX_VALUE_U32 - 1
|
|
17903
17893
|
* = a + b - 2 ** 32
|
|
17904
|
-
* but we know that
|
|
17894
|
+
* but we know that 2MAX_VALUE_U32 > a + b > MAX_VALUE_U32 so in this case:
|
|
17905
17895
|
* a + b - 2 ** 32 <=> (a + b) % 2 ** 32
|
|
17906
|
-
* = (a + b) % (
|
|
17896
|
+
* = (a + b) % (MAX_VALUE_U32 + 1)
|
|
17907
17897
|
*/
|
|
17908
|
-
const spaceToMaxA =
|
|
17909
|
-
const spaceToMaxB =
|
|
17898
|
+
const spaceToMaxA = MAX_VALUE_U32 - a;
|
|
17899
|
+
const spaceToMaxB = MAX_VALUE_U32 - b;
|
|
17910
17900
|
const overflowSum = spaceToMaxA + spaceToMaxB;
|
|
17911
|
-
return
|
|
17901
|
+
return MAX_VALUE_U32 - overflowSum - 1;
|
|
17912
17902
|
}
|
|
17913
17903
|
return a + b;
|
|
17914
17904
|
}
|
|
@@ -17923,7 +17913,7 @@ function math_utils_addWithOverflowU64(a, b) {
|
|
|
17923
17913
|
*/
|
|
17924
17914
|
function math_utils_subU32(a, b) {
|
|
17925
17915
|
if (b > a) {
|
|
17926
|
-
return
|
|
17916
|
+
return MAX_VALUE_U32 - b + a + 1;
|
|
17927
17917
|
}
|
|
17928
17918
|
return a - b;
|
|
17929
17919
|
}
|
|
@@ -18509,7 +18499,7 @@ class math_ops_MathOps {
|
|
|
18509
18499
|
if (this.regs.getLowerU32(secondIndex) === 0) {
|
|
18510
18500
|
this.regs.setU64(resultIndex, 2n ** 64n - 1n);
|
|
18511
18501
|
}
|
|
18512
|
-
else if (this.regs.getLowerI32(secondIndex) === -1 && this.regs.getLowerI32(firstIndex) ===
|
|
18502
|
+
else if (this.regs.getLowerI32(secondIndex) === -1 && this.regs.getLowerI32(firstIndex) === MIN_VALUE_I32) {
|
|
18513
18503
|
this.regs.setU64(resultIndex, signExtend32To64(this.regs.getLowerU32(firstIndex)));
|
|
18514
18504
|
}
|
|
18515
18505
|
else {
|
|
@@ -18547,7 +18537,7 @@ class math_ops_MathOps {
|
|
|
18547
18537
|
if (this.regs.getLowerU32(secondIndex) === 0) {
|
|
18548
18538
|
this.regs.setU64(resultIndex, BigInt(this.regs.getLowerI32(firstIndex)));
|
|
18549
18539
|
}
|
|
18550
|
-
else if (this.regs.getLowerI32(secondIndex) === -1 && this.regs.getLowerI32(firstIndex) ===
|
|
18540
|
+
else if (this.regs.getLowerI32(secondIndex) === -1 && this.regs.getLowerI32(firstIndex) === MIN_VALUE_I32) {
|
|
18551
18541
|
this.regs.setU64(resultIndex, 0n);
|
|
18552
18542
|
}
|
|
18553
18543
|
else {
|
|
@@ -20273,7 +20263,7 @@ const SUPPORTED_TYPES = [
|
|
|
20273
20263
|
if (option === "as-block") {
|
|
20274
20264
|
return looseType({
|
|
20275
20265
|
encode: Block.Codec,
|
|
20276
|
-
value: test.block,
|
|
20266
|
+
value: test.block.materialize(),
|
|
20277
20267
|
});
|
|
20278
20268
|
}
|
|
20279
20269
|
if (option === "as-fuzz-message") {
|
|
@@ -20281,11 +20271,9 @@ const SUPPORTED_TYPES = [
|
|
|
20281
20271
|
console.warn("⚠️ Warning: 'as-fuzz-message' is deprecated and will be removed in version 0.6.0. Use 'as-block-fuzz-message' instead.");
|
|
20282
20272
|
}
|
|
20283
20273
|
if (option === "as-block-fuzz-message" || option === "as-fuzz-message") {
|
|
20284
|
-
const encoded = encoder_Encoder.encodeObject(Block.Codec, test.block, spec);
|
|
20285
|
-
const blockView = decoder_Decoder.decodeObject(Block.Codec.View, encoded, spec);
|
|
20286
20274
|
const msg = {
|
|
20287
20275
|
type: types_MessageType.ImportBlock,
|
|
20288
|
-
value:
|
|
20276
|
+
value: test.block,
|
|
20289
20277
|
};
|
|
20290
20278
|
return looseType({
|
|
20291
20279
|
value: msg,
|
|
@@ -20293,13 +20281,14 @@ const SUPPORTED_TYPES = [
|
|
|
20293
20281
|
});
|
|
20294
20282
|
}
|
|
20295
20283
|
if (option === "as-state-fuzz-message") {
|
|
20284
|
+
const blockHeader = test.block.header.materialize();
|
|
20296
20285
|
const init = Initialize.create({
|
|
20297
20286
|
header: header_Header.empty(),
|
|
20298
20287
|
keyvals: test.pre_state.keyvals,
|
|
20299
20288
|
ancestry: [
|
|
20300
20289
|
AncestryItem.create({
|
|
20301
|
-
headerHash:
|
|
20302
|
-
slot: common_tryAsTimeSlot(Math.max(0,
|
|
20290
|
+
headerHash: blockHeader.parentHeaderHash,
|
|
20291
|
+
slot: common_tryAsTimeSlot(Math.max(0, blockHeader.timeSlotIndex - 1)),
|
|
20303
20292
|
}),
|
|
20304
20293
|
],
|
|
20305
20294
|
});
|