@typeberry/convert 0.5.3 → 0.5.4-ab9c0e1
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 +227 -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,
|
|
@@ -10949,22 +10959,22 @@ const workExecResultFromJson = json.object({
|
|
|
10949
10959
|
}, (val) => {
|
|
10950
10960
|
const { ok, out_of_gas, panic, bad_code, code_oversize, output_oversize } = val;
|
|
10951
10961
|
if (ok !== undefined) {
|
|
10952
|
-
return
|
|
10962
|
+
return WorkExecResult.ok(ok);
|
|
10953
10963
|
}
|
|
10954
10964
|
if (out_of_gas === null) {
|
|
10955
|
-
return
|
|
10965
|
+
return WorkExecResult.error(WorkExecResultKind.outOfGas);
|
|
10956
10966
|
}
|
|
10957
10967
|
if (panic === null) {
|
|
10958
|
-
return
|
|
10968
|
+
return WorkExecResult.error(WorkExecResultKind.panic);
|
|
10959
10969
|
}
|
|
10960
10970
|
if (bad_code === null) {
|
|
10961
|
-
return
|
|
10971
|
+
return WorkExecResult.error(WorkExecResultKind.badCode);
|
|
10962
10972
|
}
|
|
10963
10973
|
if (code_oversize === null) {
|
|
10964
|
-
return
|
|
10974
|
+
return WorkExecResult.error(WorkExecResultKind.codeOversize);
|
|
10965
10975
|
}
|
|
10966
10976
|
if (output_oversize === null) {
|
|
10967
|
-
return
|
|
10977
|
+
return WorkExecResult.error(WorkExecResultKind.digestTooBig);
|
|
10968
10978
|
}
|
|
10969
10979
|
throw new Error("Invalid WorkExecResult");
|
|
10970
10980
|
});
|
|
@@ -11162,6 +11172,13 @@ const blockFromJson = (spec) => json.object({
|
|
|
11162
11172
|
header: headerFromJson,
|
|
11163
11173
|
extrinsic: getExtrinsicFromJson(spec),
|
|
11164
11174
|
}, ({ header, extrinsic }) => Block.create({ header, extrinsic }));
|
|
11175
|
+
const blockViewFromJson = (spec) => {
|
|
11176
|
+
const parseBlock = blockFromJson(spec);
|
|
11177
|
+
return json.fromAny((p) => {
|
|
11178
|
+
const block = parse_parseFromJson(p, parseBlock);
|
|
11179
|
+
return reencodeAsView(Block.Codec, block, spec);
|
|
11180
|
+
});
|
|
11181
|
+
};
|
|
11165
11182
|
|
|
11166
11183
|
;// CONCATENATED MODULE: ./packages/jam/block-json/index.ts
|
|
11167
11184
|
|
|
@@ -11656,13 +11673,13 @@ const getStateCodec = codec_codec.bytes(hash_HASH_SIZE).asOpaque();
|
|
|
11656
11673
|
/** StateRoot ::= StateRootHash */
|
|
11657
11674
|
const stateRootCodec = codec_codec.bytes(hash_HASH_SIZE).asOpaque();
|
|
11658
11675
|
/** Error ::= UTF8String */
|
|
11659
|
-
class
|
|
11676
|
+
class types_ErrorMessage extends WithDebug {
|
|
11660
11677
|
message;
|
|
11661
|
-
static Codec = codec_codec.Class(
|
|
11678
|
+
static Codec = codec_codec.Class(types_ErrorMessage, {
|
|
11662
11679
|
message: codec_codec.string,
|
|
11663
11680
|
});
|
|
11664
11681
|
static create({ message }) {
|
|
11665
|
-
return new
|
|
11682
|
+
return new types_ErrorMessage(message);
|
|
11666
11683
|
}
|
|
11667
11684
|
constructor(message) {
|
|
11668
11685
|
super();
|
|
@@ -11716,7 +11733,7 @@ const types_messageCodec = codec_codec.custom({
|
|
|
11716
11733
|
stateCodec.encode(e, msg.value);
|
|
11717
11734
|
break;
|
|
11718
11735
|
case types_MessageType.Error:
|
|
11719
|
-
|
|
11736
|
+
types_ErrorMessage.Codec.encode(e, msg.value);
|
|
11720
11737
|
break;
|
|
11721
11738
|
default:
|
|
11722
11739
|
throw new Error(`Unknown message type: ${msg}`);
|
|
@@ -11737,7 +11754,7 @@ const types_messageCodec = codec_codec.custom({
|
|
|
11737
11754
|
case types_MessageType.State:
|
|
11738
11755
|
return { type: types_MessageType.State, value: stateCodec.decode(d) };
|
|
11739
11756
|
case types_MessageType.Error:
|
|
11740
|
-
return { type: types_MessageType.Error, value:
|
|
11757
|
+
return { type: types_MessageType.Error, value: types_ErrorMessage.Codec.decode(d) };
|
|
11741
11758
|
default:
|
|
11742
11759
|
throw new Error(`Unknown message type: ${type}`);
|
|
11743
11760
|
}
|
|
@@ -11763,7 +11780,7 @@ const types_messageCodec = codec_codec.custom({
|
|
|
11763
11780
|
stateCodec.View.skip(s);
|
|
11764
11781
|
break;
|
|
11765
11782
|
case types_MessageType.Error:
|
|
11766
|
-
|
|
11783
|
+
types_ErrorMessage.Codec.View.skip(s);
|
|
11767
11784
|
break;
|
|
11768
11785
|
default:
|
|
11769
11786
|
throw new Error(`Unknown message type: ${type}`);
|
|
@@ -11826,35 +11843,59 @@ class FuzzTarget {
|
|
|
11826
11843
|
break;
|
|
11827
11844
|
}
|
|
11828
11845
|
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) {
|
|
11846
|
+
try {
|
|
11847
|
+
const stateRoot = await this.msgHandler.initialize(message.value);
|
|
11839
11848
|
response = {
|
|
11840
11849
|
type: MessageType.StateRoot,
|
|
11841
|
-
value:
|
|
11850
|
+
value: stateRoot,
|
|
11842
11851
|
};
|
|
11843
11852
|
}
|
|
11844
|
-
|
|
11853
|
+
catch (e) {
|
|
11854
|
+
response = {
|
|
11855
|
+
type: MessageType.Error,
|
|
11856
|
+
value: ErrorMessage.create({ message: `initialize error: ${e}` }),
|
|
11857
|
+
};
|
|
11858
|
+
}
|
|
11859
|
+
break;
|
|
11860
|
+
}
|
|
11861
|
+
case MessageType.ImportBlock: {
|
|
11862
|
+
try {
|
|
11863
|
+
const result = await this.msgHandler.importBlock(message.value);
|
|
11864
|
+
if (result.isOk) {
|
|
11865
|
+
response = {
|
|
11866
|
+
type: MessageType.StateRoot,
|
|
11867
|
+
value: result.ok,
|
|
11868
|
+
};
|
|
11869
|
+
}
|
|
11870
|
+
else {
|
|
11871
|
+
response = {
|
|
11872
|
+
type: MessageType.Error,
|
|
11873
|
+
value: result.error,
|
|
11874
|
+
};
|
|
11875
|
+
}
|
|
11876
|
+
}
|
|
11877
|
+
catch (e) {
|
|
11845
11878
|
response = {
|
|
11846
11879
|
type: MessageType.Error,
|
|
11847
|
-
value:
|
|
11880
|
+
value: ErrorMessage.create({ message: `importBlock error: ${e}` }),
|
|
11848
11881
|
};
|
|
11849
11882
|
}
|
|
11850
11883
|
break;
|
|
11851
11884
|
}
|
|
11852
11885
|
case MessageType.GetState: {
|
|
11853
|
-
|
|
11854
|
-
|
|
11855
|
-
|
|
11856
|
-
|
|
11857
|
-
|
|
11886
|
+
try {
|
|
11887
|
+
const state = await this.msgHandler.getSerializedState(message.value);
|
|
11888
|
+
response = {
|
|
11889
|
+
type: MessageType.State,
|
|
11890
|
+
value: state,
|
|
11891
|
+
};
|
|
11892
|
+
}
|
|
11893
|
+
catch (e) {
|
|
11894
|
+
response = {
|
|
11895
|
+
type: MessageType.Error,
|
|
11896
|
+
value: ErrorMessage.create({ message: `getState error: ${e}` }),
|
|
11897
|
+
};
|
|
11898
|
+
}
|
|
11858
11899
|
break;
|
|
11859
11900
|
}
|
|
11860
11901
|
case MessageType.StateRoot: {
|
|
@@ -12314,13 +12355,6 @@ function hashComparator(a, b) {
|
|
|
12314
12355
|
return a.compare(b);
|
|
12315
12356
|
}
|
|
12316
12357
|
|
|
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
12358
|
;// CONCATENATED MODULE: ./packages/jam/state/recent-blocks.ts
|
|
12325
12359
|
|
|
12326
12360
|
|
|
@@ -12575,7 +12609,7 @@ const zeroSizeHint = {
|
|
|
12575
12609
|
/** 0-byte read, return given default value */
|
|
12576
12610
|
const ignoreValueWithDefault = (defaultValue) => Descriptor.new("ignoreValue", zeroSizeHint, (_e, _v) => { }, (_d) => defaultValue, (_s) => { });
|
|
12577
12611
|
/** Encode and decode object with leading version number. */
|
|
12578
|
-
const codecWithVersion = (val) =>
|
|
12612
|
+
const codecWithVersion = (val) => descriptor_Descriptor.new("withVersion", {
|
|
12579
12613
|
bytes: val.sizeHint.bytes + 8,
|
|
12580
12614
|
isExact: false,
|
|
12581
12615
|
}, (e, v) => {
|
|
@@ -12738,8 +12772,6 @@ class LookupHistoryItem {
|
|
|
12738
12772
|
|
|
12739
12773
|
|
|
12740
12774
|
|
|
12741
|
-
|
|
12742
|
-
|
|
12743
12775
|
/**
|
|
12744
12776
|
* Activity Record of a single validator.
|
|
12745
12777
|
*
|
|
@@ -12870,42 +12902,20 @@ class ServiceStatistics {
|
|
|
12870
12902
|
extrinsicCount;
|
|
12871
12903
|
accumulateCount;
|
|
12872
12904
|
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
|
-
},
|
|
12905
|
+
static Codec = codec_codec.Class(ServiceStatistics, {
|
|
12906
|
+
providedCount: codecVarU16,
|
|
12907
|
+
providedSize: codec_codec.varU32,
|
|
12908
|
+
refinementCount: codec_codec.varU32,
|
|
12909
|
+
refinementGasUsed: codecVarGas,
|
|
12910
|
+
imports: codecVarU16,
|
|
12911
|
+
extrinsicCount: codecVarU16,
|
|
12912
|
+
extrinsicSize: codec_codec.varU32,
|
|
12913
|
+
exports: codecVarU16,
|
|
12914
|
+
accumulateCount: codec_codec.varU32,
|
|
12915
|
+
accumulateGasUsed: codecVarGas,
|
|
12906
12916
|
});
|
|
12907
12917
|
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
|
|
12918
|
+
return new ServiceStatistics(v.providedCount, v.providedSize, v.refinementCount, v.refinementGasUsed, v.imports, v.exports, v.extrinsicSize, v.extrinsicCount, v.accumulateCount, v.accumulateGasUsed);
|
|
12909
12919
|
}
|
|
12910
12920
|
constructor(
|
|
12911
12921
|
/** `p.0` */
|
|
@@ -12927,11 +12937,7 @@ class ServiceStatistics {
|
|
|
12927
12937
|
/** `a.0` */
|
|
12928
12938
|
accumulateCount,
|
|
12929
12939
|
/** `a.1` */
|
|
12930
|
-
accumulateGasUsed
|
|
12931
|
-
/** `t.0` @deprecated since 0.7.1 */
|
|
12932
|
-
onTransfersCount,
|
|
12933
|
-
/** `t.1` @deprecated since 0.7.1 */
|
|
12934
|
-
onTransfersGasUsed) {
|
|
12940
|
+
accumulateGasUsed) {
|
|
12935
12941
|
this.providedCount = providedCount;
|
|
12936
12942
|
this.providedSize = providedSize;
|
|
12937
12943
|
this.refinementCount = refinementCount;
|
|
@@ -12942,14 +12948,12 @@ class ServiceStatistics {
|
|
|
12942
12948
|
this.extrinsicCount = extrinsicCount;
|
|
12943
12949
|
this.accumulateCount = accumulateCount;
|
|
12944
12950
|
this.accumulateGasUsed = accumulateGasUsed;
|
|
12945
|
-
this.onTransfersCount = onTransfersCount;
|
|
12946
|
-
this.onTransfersGasUsed = onTransfersGasUsed;
|
|
12947
12951
|
}
|
|
12948
12952
|
static empty() {
|
|
12949
12953
|
const zero = numbers_tryAsU32(0);
|
|
12950
12954
|
const zero16 = numbers_tryAsU16(0);
|
|
12951
12955
|
const zeroGas = tryAsServiceGas(0);
|
|
12952
|
-
return new ServiceStatistics(zero16, zero, zero, zeroGas, zero16, zero16, zero, zero16, zero, zeroGas
|
|
12956
|
+
return new ServiceStatistics(zero16, zero, zero, zeroGas, zero16, zero16, zero, zero16, zero, zeroGas);
|
|
12953
12957
|
}
|
|
12954
12958
|
}
|
|
12955
12959
|
/** `pi`: Statistics of each validator, cores statistics and services statistics. */
|
|
@@ -13048,9 +13052,6 @@ class InMemoryStateView {
|
|
|
13048
13052
|
;// CONCATENATED MODULE: ./packages/jam/state/privileged-services.ts
|
|
13049
13053
|
|
|
13050
13054
|
|
|
13051
|
-
|
|
13052
|
-
|
|
13053
|
-
|
|
13054
13055
|
/**
|
|
13055
13056
|
* https://graypaper.fluffylabs.dev/#/ab2cdbd/114402114402?v=0.7.2
|
|
13056
13057
|
*/
|
|
@@ -13065,9 +13066,7 @@ class PrivilegedServices {
|
|
|
13065
13066
|
manager: codec_codec.u32.asOpaque(),
|
|
13066
13067
|
assigners: codecPerCore(codec_codec.u32.asOpaque()),
|
|
13067
13068
|
delegator: codec_codec.u32.asOpaque(),
|
|
13068
|
-
registrar:
|
|
13069
|
-
? codec_codec.u32.asOpaque()
|
|
13070
|
-
: ignoreValueWithDefault(tryAsServiceId(2 ** 32 - 1)),
|
|
13069
|
+
registrar: codec_codec.u32.asOpaque(),
|
|
13071
13070
|
autoAccumulateServices: codec_codec.dictionary(codec_codec.u32.asOpaque(), codec_codec.u64.asOpaque(), {
|
|
13072
13071
|
sortKeys: (a, b) => a - b,
|
|
13073
13072
|
}),
|
|
@@ -13300,7 +13299,6 @@ class UpdateStorage {
|
|
|
13300
13299
|
|
|
13301
13300
|
|
|
13302
13301
|
|
|
13303
|
-
|
|
13304
13302
|
|
|
13305
13303
|
|
|
13306
13304
|
var UpdateError;
|
|
@@ -13733,7 +13731,7 @@ class InMemoryState extends WithDebug {
|
|
|
13733
13731
|
manager: tryAsServiceId(0),
|
|
13734
13732
|
assigners: tryAsPerCore(new Array(spec.coresCount).fill(tryAsServiceId(0)), spec),
|
|
13735
13733
|
delegator: tryAsServiceId(0),
|
|
13736
|
-
registrar: tryAsServiceId(
|
|
13734
|
+
registrar: tryAsServiceId(numbers_MAX_VALUE_U32),
|
|
13737
13735
|
autoAccumulateServices: new Map(),
|
|
13738
13736
|
}),
|
|
13739
13737
|
accumulationOutputLog: SortedArray.fromArray(accumulationOutputComparator, []),
|
|
@@ -13783,7 +13781,7 @@ const serviceDataCodec = codec_codec.dictionary(codec_codec.u32.asOpaque(), serv
|
|
|
13783
13781
|
|
|
13784
13782
|
class JsonServiceInfo {
|
|
13785
13783
|
static fromJson = json.object({
|
|
13786
|
-
|
|
13784
|
+
version: "number",
|
|
13787
13785
|
code_hash: fromJson.bytes32(),
|
|
13788
13786
|
balance: json.fromNumber((x) => numbers_tryAsU64(x)),
|
|
13789
13787
|
min_item_gas: json.fromNumber((x) => tryAsServiceGas(x)),
|
|
@@ -13836,33 +13834,61 @@ class JsonStorageItem {
|
|
|
13836
13834
|
key;
|
|
13837
13835
|
value;
|
|
13838
13836
|
}
|
|
13839
|
-
const
|
|
13837
|
+
const preimageStatusFromJson = json.object({
|
|
13840
13838
|
key: {
|
|
13841
13839
|
hash: fromJson.bytes32(),
|
|
13842
13840
|
length: "number",
|
|
13843
13841
|
},
|
|
13844
13842
|
value: json.array("number"),
|
|
13845
|
-
}, ({ key, value }) => new LookupHistoryItem(key.hash, key.length, value));
|
|
13846
|
-
|
|
13843
|
+
}, ({ key, value }) => new LookupHistoryItem(key.hash, numbers_tryAsU32(key.length), value));
|
|
13844
|
+
class JsonService {
|
|
13845
|
+
static fromJson = json.object({
|
|
13846
|
+
id: "number",
|
|
13847
|
+
data: {
|
|
13848
|
+
service: JsonServiceInfo.fromJson,
|
|
13849
|
+
storage: json.optional(json.array(JsonStorageItem.fromJson)),
|
|
13850
|
+
preimage_blobs: json.optional(json.array(JsonPreimageItem.fromJson)),
|
|
13851
|
+
preimage_requests: json.optional(json.array(preimageStatusFromJson)),
|
|
13852
|
+
},
|
|
13853
|
+
}, ({ id, data }) => {
|
|
13854
|
+
const preimages = HashDictionary.fromEntries((data.preimage_blobs ?? []).map((x) => [x.hash, x]));
|
|
13855
|
+
const lookupHistory = HashDictionary.new();
|
|
13856
|
+
for (const item of data.preimage_requests ?? []) {
|
|
13857
|
+
const data = lookupHistory.get(item.hash) ?? [];
|
|
13858
|
+
data.push(item);
|
|
13859
|
+
lookupHistory.set(item.hash, data);
|
|
13860
|
+
}
|
|
13861
|
+
const storage = new Map();
|
|
13862
|
+
const entries = (data.storage ?? []).map(({ key, value }) => {
|
|
13863
|
+
const opaqueKey = opaque_asOpaqueType(key);
|
|
13864
|
+
return [opaqueKey, StorageItem.create({ key: opaqueKey, value })];
|
|
13865
|
+
});
|
|
13866
|
+
for (const [key, item] of entries) {
|
|
13867
|
+
storage.set(key.toString(), item);
|
|
13868
|
+
}
|
|
13869
|
+
return new InMemoryService(id, {
|
|
13870
|
+
info: data.service,
|
|
13871
|
+
preimages,
|
|
13872
|
+
storage,
|
|
13873
|
+
lookupHistory,
|
|
13874
|
+
});
|
|
13875
|
+
});
|
|
13876
|
+
id;
|
|
13877
|
+
data;
|
|
13878
|
+
}
|
|
13879
|
+
const preimageStatusFromJson072 = json.object({
|
|
13847
13880
|
hash: fromJson.bytes32(),
|
|
13848
13881
|
status: json.array("number"),
|
|
13849
13882
|
}, ({ hash, status }) => new LookupHistoryItem(hash, numbers_tryAsU32(0), status));
|
|
13850
|
-
class
|
|
13883
|
+
class JsonServicePre072 {
|
|
13851
13884
|
static fromJson = json.object({
|
|
13852
13885
|
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
|
-
},
|
|
13886
|
+
data: {
|
|
13887
|
+
service: JsonServiceInfo.fromJson,
|
|
13888
|
+
storage: json.optional(json.array(JsonStorageItem.fromJson)),
|
|
13889
|
+
preimages_blob: json.optional(json.array(JsonPreimageItem.fromJson)),
|
|
13890
|
+
preimages_status: json.optional(json.array(preimageStatusFromJson072)),
|
|
13891
|
+
},
|
|
13866
13892
|
}, ({ id, data }) => {
|
|
13867
13893
|
const preimages = HashDictionary.fromEntries((data.preimages ?? data.preimages_blob ?? []).map((x) => [x.hash, x]));
|
|
13868
13894
|
const lookupHistory = HashDictionary.new();
|
|
@@ -14021,8 +14047,6 @@ class TicketsOrKeys {
|
|
|
14021
14047
|
|
|
14022
14048
|
|
|
14023
14049
|
|
|
14024
|
-
|
|
14025
|
-
|
|
14026
14050
|
class JsonValidatorStatistics {
|
|
14027
14051
|
static fromJson = json.object({
|
|
14028
14052
|
blocks: "number",
|
|
@@ -14091,13 +14115,7 @@ class JsonServiceStatistics {
|
|
|
14091
14115
|
extrinsic_count: "number",
|
|
14092
14116
|
accumulate_count: "number",
|
|
14093
14117
|
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, }) => {
|
|
14118
|
+
}, ({ provided_count, provided_size, refinement_count, refinement_gas_used, imports, exports, extrinsic_size, extrinsic_count, accumulate_count, accumulate_gas_used, }) => {
|
|
14101
14119
|
return ServiceStatistics.create({
|
|
14102
14120
|
providedCount: provided_count,
|
|
14103
14121
|
providedSize: provided_size,
|
|
@@ -14109,8 +14127,6 @@ class JsonServiceStatistics {
|
|
|
14109
14127
|
extrinsicCount: extrinsic_count,
|
|
14110
14128
|
accumulateCount: accumulate_count,
|
|
14111
14129
|
accumulateGasUsed: accumulate_gas_used,
|
|
14112
|
-
onTransfersCount: on_transfers_count ?? numbers_tryAsU32(0),
|
|
14113
|
-
onTransfersGasUsed: on_transfers_gas_used ?? tryAsServiceGas(0),
|
|
14114
14130
|
});
|
|
14115
14131
|
});
|
|
14116
14132
|
provided_count;
|
|
@@ -14123,8 +14139,6 @@ class JsonServiceStatistics {
|
|
|
14123
14139
|
extrinsic_count;
|
|
14124
14140
|
accumulate_count;
|
|
14125
14141
|
accumulate_gas_used;
|
|
14126
|
-
on_transfers_count;
|
|
14127
|
-
on_transfers_gas_used;
|
|
14128
14142
|
}
|
|
14129
14143
|
const serviceStatisticsEntryFromJson = {
|
|
14130
14144
|
id: "number",
|
|
@@ -14183,7 +14197,6 @@ const validatorDataFromJson = json.object({
|
|
|
14183
14197
|
|
|
14184
14198
|
|
|
14185
14199
|
|
|
14186
|
-
|
|
14187
14200
|
const fullStateDumpFromJson = (spec) => json.object({
|
|
14188
14201
|
alpha: json.array(json.array(fromJson.bytes32())),
|
|
14189
14202
|
varphi: json.array(json.array(fromJson.bytes32())),
|
|
@@ -14205,18 +14218,15 @@ const fullStateDumpFromJson = (spec) => json.object({
|
|
|
14205
14218
|
chi_m: "number",
|
|
14206
14219
|
chi_a: json.array("number"),
|
|
14207
14220
|
chi_v: "number",
|
|
14208
|
-
chi_r:
|
|
14221
|
+
chi_r: "number",
|
|
14209
14222
|
chi_g: json.nullable(json.map("number", json.fromNumber((v) => tryAsServiceGas(v)))),
|
|
14210
14223
|
},
|
|
14211
14224
|
pi: JsonStatisticsData.fromJson,
|
|
14212
14225
|
omega: json.array(json.array(notYetAccumulatedFromJson)),
|
|
14213
14226
|
xi: json.array(json.array(fromJson.bytes32())),
|
|
14214
14227
|
theta: json.nullable(json.array(accumulationOutput)),
|
|
14215
|
-
accounts: json.array(
|
|
14228
|
+
accounts: json.array(JsonServicePre072.fromJson),
|
|
14216
14229
|
}, ({ 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
14230
|
return InMemoryState.new(spec, {
|
|
14221
14231
|
authPools: tryAsPerCore(alpha.map((perCore) => {
|
|
14222
14232
|
if (perCore.length > MAX_AUTH_POOL_SIZE) {
|
|
@@ -14246,7 +14256,7 @@ const fullStateDumpFromJson = (spec) => json.object({
|
|
|
14246
14256
|
manager: chi.chi_m,
|
|
14247
14257
|
assigners: chi.chi_a,
|
|
14248
14258
|
delegator: chi.chi_v,
|
|
14249
|
-
registrar: chi.chi_r
|
|
14259
|
+
registrar: chi.chi_r,
|
|
14250
14260
|
autoAccumulateServices: chi.chi_g ?? new Map(),
|
|
14251
14261
|
}),
|
|
14252
14262
|
statistics: JsonStatisticsData.toStatisticsData(spec, pi),
|
|
@@ -14422,7 +14432,6 @@ function legacyServiceNested(serviceId, hash) {
|
|
|
14422
14432
|
|
|
14423
14433
|
|
|
14424
14434
|
|
|
14425
|
-
|
|
14426
14435
|
/** Serialization for particular state entries. */
|
|
14427
14436
|
var serialize_serialize;
|
|
14428
14437
|
(function (serialize) {
|
|
@@ -14530,24 +14539,22 @@ var serialize_serialize;
|
|
|
14530
14539
|
Codec: codec_codec.sequenceVarLen(AccumulationOutput.Codec).convert((i) => i.array, (o) => SortedArray.fromSortedArray(accumulationOutputComparator, o)),
|
|
14531
14540
|
extract: (s) => s.accumulationOutputLog,
|
|
14532
14541
|
};
|
|
14533
|
-
/** C(255, s): https://graypaper.fluffylabs.dev/#/
|
|
14542
|
+
/** C(255, s): https://graypaper.fluffylabs.dev/#/ab2cdbd/3b7d033b7d03?v=0.7.2 */
|
|
14534
14543
|
serialize.serviceData = (serviceId) => ({
|
|
14535
14544
|
key: stateKeys.serviceInfo(serviceId),
|
|
14536
|
-
Codec:
|
|
14537
|
-
? codecWithVersion(ServiceAccountInfo.Codec)
|
|
14538
|
-
: ServiceAccountInfo.Codec,
|
|
14545
|
+
Codec: codecWithVersion(ServiceAccountInfo.Codec),
|
|
14539
14546
|
});
|
|
14540
|
-
/** https://graypaper.fluffylabs.dev/#/
|
|
14547
|
+
/** https://graypaper.fluffylabs.dev/#/ab2cdbd/3bac033bac03?v=0.7.2 */
|
|
14541
14548
|
serialize.serviceStorage = (blake2b, serviceId, key) => ({
|
|
14542
14549
|
key: stateKeys.serviceStorage(blake2b, serviceId, key),
|
|
14543
14550
|
Codec: dumpCodec,
|
|
14544
14551
|
});
|
|
14545
|
-
/** https://graypaper.fluffylabs.dev/#/
|
|
14552
|
+
/** https://graypaper.fluffylabs.dev/#/ab2cdbd/3bc9033bc903?v=0.7.2 */
|
|
14546
14553
|
serialize.servicePreimages = (blake2b, serviceId, hash) => ({
|
|
14547
14554
|
key: stateKeys.servicePreimage(blake2b, serviceId, hash),
|
|
14548
14555
|
Codec: dumpCodec,
|
|
14549
14556
|
});
|
|
14550
|
-
/** https://graypaper.fluffylabs.dev/#/
|
|
14557
|
+
/** https://graypaper.fluffylabs.dev/#/ab2cdbd/3bea033b0904?v=0.7.2 */
|
|
14551
14558
|
serialize.serviceLookupHistory = (blake2b, serviceId, hash, len) => ({
|
|
14552
14559
|
key: stateKeys.serviceLookupHistory(blake2b, serviceId, hash, len),
|
|
14553
14560
|
Codec: codec_codec.readonlyArray(codec_codec.sequenceVarLen(codec_codec.u32)),
|
|
@@ -14560,7 +14567,7 @@ var serialize_serialize;
|
|
|
14560
14567
|
* determine the boundary of the bytes, so it can only be used
|
|
14561
14568
|
* as the last element of the codec and can't be used in sequences!
|
|
14562
14569
|
*/
|
|
14563
|
-
const dumpCodec =
|
|
14570
|
+
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
14571
|
|
|
14565
14572
|
;// CONCATENATED MODULE: ./packages/jam/state-merkleization/serialized-state-view.ts
|
|
14566
14573
|
|
|
@@ -15888,7 +15895,7 @@ const codecMap = (value, extractKey, { typicalLength = codec_codec.TYPICAL_DICTI
|
|
|
15888
15895
|
}
|
|
15889
15896
|
return Ordering.Equal;
|
|
15890
15897
|
}, } = {}) => {
|
|
15891
|
-
return
|
|
15898
|
+
return descriptor_Descriptor.new(`Map<${value.name}>[?]`, {
|
|
15892
15899
|
bytes: typicalLength * value.sizeHint.bytes,
|
|
15893
15900
|
isExact: false,
|
|
15894
15901
|
}, (e, v) => {
|
|
@@ -16065,11 +16072,11 @@ class StateTransition {
|
|
|
16065
16072
|
static fromJson = {
|
|
16066
16073
|
pre_state: TestState.fromJson,
|
|
16067
16074
|
post_state: TestState.fromJson,
|
|
16068
|
-
block:
|
|
16075
|
+
block: blockViewFromJson(chain_spec_tinyChainSpec),
|
|
16069
16076
|
};
|
|
16070
16077
|
static Codec = codec_codec.object({
|
|
16071
16078
|
pre_state: TestState.Codec,
|
|
16072
|
-
block: Block.Codec,
|
|
16079
|
+
block: Block.Codec.View,
|
|
16073
16080
|
post_state: TestState.Codec,
|
|
16074
16081
|
});
|
|
16075
16082
|
pre_state;
|
|
@@ -16147,41 +16154,21 @@ async function runWorkItemTest(test, { path }) {
|
|
|
16147
16154
|
|
|
16148
16155
|
|
|
16149
16156
|
|
|
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
|
-
}));
|
|
16157
|
+
const workPackageFromJson = json.object({
|
|
16158
|
+
authorization: json.fromString(bytes_BytesBlob.parseBlob),
|
|
16159
|
+
auth_code_host: "number",
|
|
16160
|
+
auth_code_hash: fromJson.bytes32(),
|
|
16161
|
+
authorizer_config: json.fromString(bytes_BytesBlob.parseBlob),
|
|
16162
|
+
context: refineContextFromJson,
|
|
16163
|
+
items: json.array(workItemFromJson),
|
|
16164
|
+
}, ({ authorization, auth_code_host, auth_code_hash, authorizer_config, context, items }) => work_package_WorkPackage.create({
|
|
16165
|
+
authorization,
|
|
16166
|
+
authCodeHost: auth_code_host,
|
|
16167
|
+
authCodeHash: auth_code_hash,
|
|
16168
|
+
parametrization: authorizer_config,
|
|
16169
|
+
context,
|
|
16170
|
+
items: FixedSizeArray.new(items, tryAsWorkItemsCount(items.length)),
|
|
16171
|
+
}));
|
|
16185
16172
|
async function runWorkPackageTest(test, { path: file }) {
|
|
16186
16173
|
runCodecTest(WorkPackage.Codec, test, file);
|
|
16187
16174
|
}
|
|
@@ -17893,22 +17880,22 @@ class memory_builder_MemoryBuilder {
|
|
|
17893
17880
|
* Overflowing addition for two-complement representation of 32-bit signed numbers.
|
|
17894
17881
|
*/
|
|
17895
17882
|
function math_utils_addWithOverflowU32(a, b) {
|
|
17896
|
-
if (a >
|
|
17883
|
+
if (a > MAX_VALUE_U32 - b) {
|
|
17897
17884
|
/**
|
|
17898
|
-
*
|
|
17899
|
-
*
|
|
17900
|
-
* =
|
|
17901
|
-
* =
|
|
17902
|
-
* = a + b -
|
|
17885
|
+
* MAX_VALUE_U32 is equal to 2 ** 32 - 1
|
|
17886
|
+
* MAX_VALUE_U32 - ( (MAX_VALUE_U32 - a) + (MAX_VALUE_U32 - b) ) - 1
|
|
17887
|
+
* = MAX_VALUE_U32 - (2MAX_VALUE_U32 - a - b) -1
|
|
17888
|
+
* = MAX_VALUE_U32 - 2MAX_VALUE_U32 + a + b - 1
|
|
17889
|
+
* = a + b - MAX_VALUE_U32 - 1
|
|
17903
17890
|
* = a + b - 2 ** 32
|
|
17904
|
-
* but we know that
|
|
17891
|
+
* but we know that 2MAX_VALUE_U32 > a + b > MAX_VALUE_U32 so in this case:
|
|
17905
17892
|
* a + b - 2 ** 32 <=> (a + b) % 2 ** 32
|
|
17906
|
-
* = (a + b) % (
|
|
17893
|
+
* = (a + b) % (MAX_VALUE_U32 + 1)
|
|
17907
17894
|
*/
|
|
17908
|
-
const spaceToMaxA =
|
|
17909
|
-
const spaceToMaxB =
|
|
17895
|
+
const spaceToMaxA = MAX_VALUE_U32 - a;
|
|
17896
|
+
const spaceToMaxB = MAX_VALUE_U32 - b;
|
|
17910
17897
|
const overflowSum = spaceToMaxA + spaceToMaxB;
|
|
17911
|
-
return
|
|
17898
|
+
return MAX_VALUE_U32 - overflowSum - 1;
|
|
17912
17899
|
}
|
|
17913
17900
|
return a + b;
|
|
17914
17901
|
}
|
|
@@ -17923,7 +17910,7 @@ function math_utils_addWithOverflowU64(a, b) {
|
|
|
17923
17910
|
*/
|
|
17924
17911
|
function math_utils_subU32(a, b) {
|
|
17925
17912
|
if (b > a) {
|
|
17926
|
-
return
|
|
17913
|
+
return MAX_VALUE_U32 - b + a + 1;
|
|
17927
17914
|
}
|
|
17928
17915
|
return a - b;
|
|
17929
17916
|
}
|
|
@@ -18509,7 +18496,7 @@ class math_ops_MathOps {
|
|
|
18509
18496
|
if (this.regs.getLowerU32(secondIndex) === 0) {
|
|
18510
18497
|
this.regs.setU64(resultIndex, 2n ** 64n - 1n);
|
|
18511
18498
|
}
|
|
18512
|
-
else if (this.regs.getLowerI32(secondIndex) === -1 && this.regs.getLowerI32(firstIndex) ===
|
|
18499
|
+
else if (this.regs.getLowerI32(secondIndex) === -1 && this.regs.getLowerI32(firstIndex) === MIN_VALUE_I32) {
|
|
18513
18500
|
this.regs.setU64(resultIndex, signExtend32To64(this.regs.getLowerU32(firstIndex)));
|
|
18514
18501
|
}
|
|
18515
18502
|
else {
|
|
@@ -18547,7 +18534,7 @@ class math_ops_MathOps {
|
|
|
18547
18534
|
if (this.regs.getLowerU32(secondIndex) === 0) {
|
|
18548
18535
|
this.regs.setU64(resultIndex, BigInt(this.regs.getLowerI32(firstIndex)));
|
|
18549
18536
|
}
|
|
18550
|
-
else if (this.regs.getLowerI32(secondIndex) === -1 && this.regs.getLowerI32(firstIndex) ===
|
|
18537
|
+
else if (this.regs.getLowerI32(secondIndex) === -1 && this.regs.getLowerI32(firstIndex) === MIN_VALUE_I32) {
|
|
18551
18538
|
this.regs.setU64(resultIndex, 0n);
|
|
18552
18539
|
}
|
|
18553
18540
|
else {
|
|
@@ -20273,7 +20260,7 @@ const SUPPORTED_TYPES = [
|
|
|
20273
20260
|
if (option === "as-block") {
|
|
20274
20261
|
return looseType({
|
|
20275
20262
|
encode: Block.Codec,
|
|
20276
|
-
value: test.block,
|
|
20263
|
+
value: test.block.materialize(),
|
|
20277
20264
|
});
|
|
20278
20265
|
}
|
|
20279
20266
|
if (option === "as-fuzz-message") {
|
|
@@ -20281,11 +20268,9 @@ const SUPPORTED_TYPES = [
|
|
|
20281
20268
|
console.warn("⚠️ Warning: 'as-fuzz-message' is deprecated and will be removed in version 0.6.0. Use 'as-block-fuzz-message' instead.");
|
|
20282
20269
|
}
|
|
20283
20270
|
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
20271
|
const msg = {
|
|
20287
20272
|
type: types_MessageType.ImportBlock,
|
|
20288
|
-
value:
|
|
20273
|
+
value: test.block,
|
|
20289
20274
|
};
|
|
20290
20275
|
return looseType({
|
|
20291
20276
|
value: msg,
|
|
@@ -20293,13 +20278,14 @@ const SUPPORTED_TYPES = [
|
|
|
20293
20278
|
});
|
|
20294
20279
|
}
|
|
20295
20280
|
if (option === "as-state-fuzz-message") {
|
|
20281
|
+
const blockHeader = test.block.header.materialize();
|
|
20296
20282
|
const init = Initialize.create({
|
|
20297
20283
|
header: header_Header.empty(),
|
|
20298
20284
|
keyvals: test.pre_state.keyvals,
|
|
20299
20285
|
ancestry: [
|
|
20300
20286
|
AncestryItem.create({
|
|
20301
|
-
headerHash:
|
|
20302
|
-
slot: common_tryAsTimeSlot(Math.max(0,
|
|
20287
|
+
headerHash: blockHeader.parentHeaderHash,
|
|
20288
|
+
slot: common_tryAsTimeSlot(Math.max(0, blockHeader.timeSlotIndex - 1)),
|
|
20303
20289
|
}),
|
|
20304
20290
|
],
|
|
20305
20291
|
});
|