@typeberry/convert 0.1.3-c2321fb → 0.1.3-ca63b35
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/index.js +833 -480
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -4273,8 +4273,9 @@ function parseCurrentVersion(env) {
|
|
|
4273
4273
|
}
|
|
4274
4274
|
}
|
|
4275
4275
|
function parseCurrentSuite(env) {
|
|
4276
|
-
if (env === undefined)
|
|
4276
|
+
if (env === undefined) {
|
|
4277
4277
|
return undefined;
|
|
4278
|
+
}
|
|
4278
4279
|
switch (env) {
|
|
4279
4280
|
case TestSuite.W3F_DAVXY:
|
|
4280
4281
|
case TestSuite.JAMDUNA:
|
|
@@ -4705,10 +4706,12 @@ function test_deepEqual(actual, expected, { context = [], errorsCollector, ignor
|
|
|
4705
4706
|
.sort((a, b) => {
|
|
4706
4707
|
const aKey = `${a.key}`;
|
|
4707
4708
|
const bKey = `${b.key}`;
|
|
4708
|
-
if (aKey < bKey)
|
|
4709
|
+
if (aKey < bKey) {
|
|
4709
4710
|
return -1;
|
|
4710
|
-
|
|
4711
|
+
}
|
|
4712
|
+
if (bKey < aKey) {
|
|
4711
4713
|
return 1;
|
|
4714
|
+
}
|
|
4712
4715
|
return 0;
|
|
4713
4716
|
});
|
|
4714
4717
|
};
|
|
@@ -5725,7 +5728,7 @@ class Skipper {
|
|
|
5725
5728
|
*
|
|
5726
5729
|
* Descriptors can be composed to form more complex typings.
|
|
5727
5730
|
*/
|
|
5728
|
-
class
|
|
5731
|
+
class Descriptor {
|
|
5729
5732
|
name;
|
|
5730
5733
|
sizeHint;
|
|
5731
5734
|
encode;
|
|
@@ -5735,11 +5738,11 @@ class descriptor_Descriptor {
|
|
|
5735
5738
|
View;
|
|
5736
5739
|
/** New descriptor with specialized `View`. */
|
|
5737
5740
|
static withView(name, sizeHint, encode, decode, skip, view) {
|
|
5738
|
-
return new
|
|
5741
|
+
return new Descriptor(name, sizeHint, encode, decode, skip, view);
|
|
5739
5742
|
}
|
|
5740
5743
|
/** Create a new descriptor without a specialized `View`. */
|
|
5741
5744
|
static new(name, sizeHint, encode, decode, skip) {
|
|
5742
|
-
return new
|
|
5745
|
+
return new Descriptor(name, sizeHint, encode, decode, skip, null);
|
|
5743
5746
|
}
|
|
5744
5747
|
constructor(
|
|
5745
5748
|
/** Descriptive name of the coded data. */
|
|
@@ -5776,7 +5779,7 @@ class descriptor_Descriptor {
|
|
|
5776
5779
|
}
|
|
5777
5780
|
/** Return a new descriptor that converts data into some other type. */
|
|
5778
5781
|
convert(input, output) {
|
|
5779
|
-
return new
|
|
5782
|
+
return new Descriptor(this.name, this.sizeHint, (e, elem) => this.encode(e, input(elem)), (d) => output(this.decode(d)), this.skip, this.View);
|
|
5780
5783
|
}
|
|
5781
5784
|
/** Safely cast the descriptor value to a opaque type. */
|
|
5782
5785
|
asOpaque() {
|
|
@@ -6474,51 +6477,51 @@ var descriptors_codec;
|
|
|
6474
6477
|
return (len) => {
|
|
6475
6478
|
let ret = cache.get(len);
|
|
6476
6479
|
if (ret === undefined) {
|
|
6477
|
-
ret =
|
|
6480
|
+
ret = Descriptor.new(`Bytes<${len}>`, exactHint(len), (e, v) => e.bytes(v), (d) => d.bytes(len), (s) => s.bytes(len));
|
|
6478
6481
|
cache.set(len, ret);
|
|
6479
6482
|
}
|
|
6480
6483
|
return ret;
|
|
6481
6484
|
};
|
|
6482
6485
|
})();
|
|
6483
6486
|
/** Variable-length U32. */
|
|
6484
|
-
codec.varU32 =
|
|
6487
|
+
codec.varU32 = Descriptor.new("var_u32", { bytes: 4, isExact: false }, (e, v) => e.varU32(v), (d) => d.varU32(), (d) => d.varU32());
|
|
6485
6488
|
/** Variable-length U64. */
|
|
6486
|
-
codec.varU64 =
|
|
6489
|
+
codec.varU64 = Descriptor.new("var_u64", { bytes: 8, isExact: false }, (e, v) => e.varU64(v), (d) => d.varU64(), (d) => d.varU64());
|
|
6487
6490
|
/** Unsigned 64-bit number. */
|
|
6488
|
-
codec.u64 =
|
|
6491
|
+
codec.u64 = Descriptor.withView("u64", exactHint(8), (e, v) => e.i64(v), (d) => d.u64(), (d) => d.u64(), codec.bytes(8));
|
|
6489
6492
|
/** Unsigned 32-bit number. */
|
|
6490
|
-
codec.u32 =
|
|
6493
|
+
codec.u32 = Descriptor.withView("u32", exactHint(4), (e, v) => e.i32(v), (d) => d.u32(), (d) => d.u32(), codec.bytes(4));
|
|
6491
6494
|
/** Unsigned 24-bit number. */
|
|
6492
|
-
codec.u24 =
|
|
6495
|
+
codec.u24 = Descriptor.withView("u24", exactHint(3), (e, v) => e.i24(v), (d) => d.u24(), (d) => d.u24(), codec.bytes(3));
|
|
6493
6496
|
/** Unsigned 16-bit number. */
|
|
6494
|
-
codec.u16 =
|
|
6497
|
+
codec.u16 = Descriptor.withView("u16", exactHint(2), (e, v) => e.i16(v), (d) => d.u16(), (d) => d.u16(), codec.bytes(2));
|
|
6495
6498
|
/** Unsigned 8-bit number. */
|
|
6496
|
-
codec.u8 =
|
|
6499
|
+
codec.u8 = Descriptor.new("u8", exactHint(1), (e, v) => e.i8(v), (d) => d.u8(), (d) => d.u8());
|
|
6497
6500
|
/** Signed 64-bit number. */
|
|
6498
|
-
codec.i64 =
|
|
6501
|
+
codec.i64 = Descriptor.withView("u64", exactHint(8), (e, v) => e.i64(v), (d) => d.i64(), (s) => s.u64(), codec.bytes(8));
|
|
6499
6502
|
/** Signed 32-bit number. */
|
|
6500
|
-
codec.i32 =
|
|
6503
|
+
codec.i32 = Descriptor.withView("i32", exactHint(4), (e, v) => e.i32(v), (d) => d.i32(), (s) => s.u32(), codec.bytes(4));
|
|
6501
6504
|
/** Signed 24-bit number. */
|
|
6502
|
-
codec.i24 =
|
|
6505
|
+
codec.i24 = Descriptor.withView("i24", exactHint(3), (e, v) => e.i24(v), (d) => d.i24(), (s) => s.u24(), codec.bytes(3));
|
|
6503
6506
|
/** Signed 16-bit number. */
|
|
6504
|
-
codec.i16 =
|
|
6507
|
+
codec.i16 = Descriptor.withView("i16", exactHint(2), (e, v) => e.i16(v), (d) => d.i16(), (s) => s.u16(), codec.bytes(2));
|
|
6505
6508
|
/** Signed 8-bit number. */
|
|
6506
|
-
codec.i8 =
|
|
6509
|
+
codec.i8 = Descriptor.new("i8", exactHint(1), (e, v) => e.i8(v), (d) => d.i8(), (s) => s.u8());
|
|
6507
6510
|
/** 1-byte boolean value. */
|
|
6508
|
-
codec.bool =
|
|
6511
|
+
codec.bool = Descriptor.new("bool", exactHint(1), (e, v) => e.bool(v), (d) => d.bool(), (s) => s.bool());
|
|
6509
6512
|
/** Variable-length bytes blob. */
|
|
6510
|
-
codec.blob =
|
|
6513
|
+
codec.blob = Descriptor.new("BytesBlob", { bytes: TYPICAL_SEQUENCE_LENGTH, isExact: false }, (e, v) => e.bytesBlob(v), (d) => d.bytesBlob(), (s) => s.bytesBlob());
|
|
6511
6514
|
/** String encoded as variable-length bytes blob. */
|
|
6512
|
-
codec.string =
|
|
6515
|
+
codec.string = 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(), codec.blob);
|
|
6513
6516
|
/** Variable-length bit vector. */
|
|
6514
|
-
codec.bitVecVarLen =
|
|
6517
|
+
codec.bitVecVarLen = Descriptor.new("BitVec[?]", { bytes: TYPICAL_SEQUENCE_LENGTH >>> 3, isExact: false }, (e, v) => e.bitVecVarLen(v), (d) => d.bitVecVarLen(), (s) => s.bitVecVarLen());
|
|
6515
6518
|
/** Fixed-length bit vector. */
|
|
6516
|
-
codec.bitVecFixLen = (bitLen) =>
|
|
6519
|
+
codec.bitVecFixLen = (bitLen) => Descriptor.new(`BitVec[${bitLen}]`, exactHint(bitLen >>> 3), (e, v) => e.bitVecFixLen(v), (d) => d.bitVecFixLen(bitLen), (s) => s.bitVecFixLen(bitLen));
|
|
6517
6520
|
/** Optionality wrapper for given type. */
|
|
6518
6521
|
codec.optional = (type) => {
|
|
6519
|
-
const self =
|
|
6522
|
+
const self = 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));
|
|
6520
6523
|
if (hasUniqueView(type)) {
|
|
6521
|
-
return
|
|
6524
|
+
return Descriptor.withView(self.name, self.sizeHint, self.encode, self.decode, self.skip, codec.optional(type.View));
|
|
6522
6525
|
}
|
|
6523
6526
|
return self;
|
|
6524
6527
|
};
|
|
@@ -6529,7 +6532,7 @@ var descriptors_codec;
|
|
|
6529
6532
|
}) => {
|
|
6530
6533
|
const name = `Sequence<${type.name}>[?]`;
|
|
6531
6534
|
const typicalLength = options.typicalLength ?? TYPICAL_SEQUENCE_LENGTH;
|
|
6532
|
-
return
|
|
6535
|
+
return Descriptor.withView(name, { bytes: typicalLength * type.sizeHint.bytes, isExact: false }, (e, v) => {
|
|
6533
6536
|
validateLength(options, v.length, name);
|
|
6534
6537
|
e.sequenceVarLen(type, v);
|
|
6535
6538
|
}, (d) => {
|
|
@@ -6543,10 +6546,10 @@ var descriptors_codec;
|
|
|
6543
6546
|
}, sequenceViewVarLen(type, options));
|
|
6544
6547
|
};
|
|
6545
6548
|
/** Fixed-length sequence of given type. */
|
|
6546
|
-
codec.sequenceFixLen = (type, len) =>
|
|
6549
|
+
codec.sequenceFixLen = (type, len) => 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 }));
|
|
6547
6550
|
/** Small dictionary codec. */
|
|
6548
6551
|
codec.dictionary = (key, value, { sortKeys, fixedLength, }) => {
|
|
6549
|
-
const self =
|
|
6552
|
+
const self = Descriptor.new(`Dictionary<${key.name}, ${value.name}>[${fixedLength ?? "?"}]`, {
|
|
6550
6553
|
bytes: fixedLength !== undefined
|
|
6551
6554
|
? fixedLength * addSizeHints(key.sizeHint, value.sizeHint).bytes
|
|
6552
6555
|
: TYPICAL_DICTIONARY_LENGTH * (addSizeHints(key.sizeHint, value.sizeHint).bytes ?? 0),
|
|
@@ -6585,13 +6588,13 @@ var descriptors_codec;
|
|
|
6585
6588
|
s.sequenceFixLen(value, len);
|
|
6586
6589
|
});
|
|
6587
6590
|
if (hasUniqueView(value)) {
|
|
6588
|
-
return
|
|
6591
|
+
return Descriptor.withView(self.name, self.sizeHint, self.encode, self.decode, self.skip, codec.dictionary(key, value.View, { sortKeys, fixedLength }));
|
|
6589
6592
|
}
|
|
6590
6593
|
return self;
|
|
6591
6594
|
};
|
|
6592
6595
|
/** Encoding of pair of two values. */
|
|
6593
6596
|
codec.pair = (a, b) => {
|
|
6594
|
-
const self =
|
|
6597
|
+
const self = Descriptor.new(`Pair<${a.name}, ${b.name}>`, addSizeHints(a.sizeHint, b.sizeHint), (e, elem) => {
|
|
6595
6598
|
a.encode(e, elem[0]);
|
|
6596
6599
|
b.encode(e, elem[1]);
|
|
6597
6600
|
}, (d) => {
|
|
@@ -6603,14 +6606,14 @@ var descriptors_codec;
|
|
|
6603
6606
|
b.skip(s);
|
|
6604
6607
|
});
|
|
6605
6608
|
if (hasUniqueView(a) && hasUniqueView(b)) {
|
|
6606
|
-
return
|
|
6609
|
+
return Descriptor.withView(self.name, self.sizeHint, self.encode, self.decode, self.skip, codec.pair(a.View, b.View));
|
|
6607
6610
|
}
|
|
6608
6611
|
return self;
|
|
6609
6612
|
};
|
|
6610
6613
|
/** Custom encoding / decoding logic. */
|
|
6611
|
-
codec.custom = ({ name, sizeHint = { bytes: 0, isExact: false }, }, encode, decode, skip) =>
|
|
6614
|
+
codec.custom = ({ name, sizeHint = { bytes: 0, isExact: false }, }, encode, decode, skip) => Descriptor.new(name, sizeHint, encode, decode, skip);
|
|
6612
6615
|
/** Choose a descriptor depending on the encoding/decoding context. */
|
|
6613
|
-
codec.select = ({ name, sizeHint, }, chooser) =>
|
|
6616
|
+
codec.select = ({ name, sizeHint, }, chooser) => 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), chooser(null).View);
|
|
6614
6617
|
/**
|
|
6615
6618
|
* A descriptor for a more complex POJO.
|
|
6616
6619
|
*
|
|
@@ -6647,7 +6650,7 @@ var descriptors_codec;
|
|
|
6647
6650
|
};
|
|
6648
6651
|
const view = objectView(Class, descriptors, sizeHint, skipper);
|
|
6649
6652
|
// and create the descriptor for the entire class.
|
|
6650
|
-
return
|
|
6653
|
+
return Descriptor.withView(Class.name, sizeHint, (e, t) => {
|
|
6651
6654
|
forEachDescriptor(descriptors, (key, descriptor) => {
|
|
6652
6655
|
const value = t[key];
|
|
6653
6656
|
descriptor.encode(e, value);
|
|
@@ -6698,7 +6701,7 @@ function objectView(Class, descriptors, sizeHint, skipper) {
|
|
|
6698
6701
|
});
|
|
6699
6702
|
}
|
|
6700
6703
|
});
|
|
6701
|
-
return
|
|
6704
|
+
return Descriptor.new(`View<${Class.name}>`, sizeHint, (e, t) => {
|
|
6702
6705
|
const encoded = t.encoded();
|
|
6703
6706
|
e.bytes(bytes_Bytes.fromBlob(encoded.raw, encoded.length));
|
|
6704
6707
|
}, (d) => {
|
|
@@ -6717,7 +6720,7 @@ function sequenceViewVarLen(type, options) {
|
|
|
6717
6720
|
validateLength(options, length, name);
|
|
6718
6721
|
return s.sequenceFixLen(type, length);
|
|
6719
6722
|
};
|
|
6720
|
-
return
|
|
6723
|
+
return Descriptor.new(name, sizeHint, (e, t) => {
|
|
6721
6724
|
validateLength(options, t.length, name);
|
|
6722
6725
|
const encoded = t.encoded();
|
|
6723
6726
|
e.bytes(bytes_Bytes.fromBlob(encoded.raw, encoded.length));
|
|
@@ -6733,7 +6736,7 @@ function sequenceViewFixLen(type, { fixedLength }) {
|
|
|
6733
6736
|
const skipper = (s) => s.sequenceFixLen(type, fixedLength);
|
|
6734
6737
|
const view = type.name !== type.View.name ? `, ${type.View.name}` : "";
|
|
6735
6738
|
const name = `SeqView<${type.name}${view}>[${fixedLength}]`;
|
|
6736
|
-
return
|
|
6739
|
+
return Descriptor.new(name, sizeHint, (e, t) => {
|
|
6737
6740
|
const encoded = t.encoded();
|
|
6738
6741
|
e.bytes(bytes_Bytes.fromBlob(encoded.raw, encoded.length));
|
|
6739
6742
|
}, (d) => {
|
|
@@ -7694,6 +7697,49 @@ function keccak_hashBlobs(hasher, blobs) {
|
|
|
7694
7697
|
|
|
7695
7698
|
|
|
7696
7699
|
|
|
7700
|
+
;// CONCATENATED MODULE: ./packages/core/collections/array-view.ts
|
|
7701
|
+
|
|
7702
|
+
/**
|
|
7703
|
+
* A utility class providing a readonly view over a portion of an array without copying it.
|
|
7704
|
+
*/
|
|
7705
|
+
class array_view_ArrayView {
|
|
7706
|
+
start;
|
|
7707
|
+
end;
|
|
7708
|
+
source;
|
|
7709
|
+
length;
|
|
7710
|
+
constructor(source, start, end) {
|
|
7711
|
+
this.start = start;
|
|
7712
|
+
this.end = end;
|
|
7713
|
+
this.source = source;
|
|
7714
|
+
this.length = end - start;
|
|
7715
|
+
}
|
|
7716
|
+
static from(source, start = 0, end = source.length) {
|
|
7717
|
+
debug_check `
|
|
7718
|
+
${start >= 0 && end <= source.length && start <= end}
|
|
7719
|
+
Invalid start (${start})/end (${end}) for ArrayView
|
|
7720
|
+
`;
|
|
7721
|
+
return new array_view_ArrayView(source, start, end);
|
|
7722
|
+
}
|
|
7723
|
+
get(i) {
|
|
7724
|
+
debug_check `
|
|
7725
|
+
${i >= 0 && i < this.length}
|
|
7726
|
+
Index out of bounds: ${i} < ${this.length}
|
|
7727
|
+
`;
|
|
7728
|
+
return this.source[this.start + i];
|
|
7729
|
+
}
|
|
7730
|
+
subview(from, to = this.length) {
|
|
7731
|
+
return array_view_ArrayView.from(this.source, this.start + from, this.start + to);
|
|
7732
|
+
}
|
|
7733
|
+
toArray() {
|
|
7734
|
+
return this.source.slice(this.start, this.end);
|
|
7735
|
+
}
|
|
7736
|
+
*[Symbol.iterator]() {
|
|
7737
|
+
for (let i = this.start; i < this.end; i++) {
|
|
7738
|
+
yield this.source[i];
|
|
7739
|
+
}
|
|
7740
|
+
}
|
|
7741
|
+
}
|
|
7742
|
+
|
|
7697
7743
|
;// CONCATENATED MODULE: ./packages/core/collections/hash-dictionary.ts
|
|
7698
7744
|
/** A map which uses hashes as keys. */
|
|
7699
7745
|
class hash_dictionary_HashDictionary {
|
|
@@ -8305,6 +8351,7 @@ class truncated_hash_dictionary_TruncatedHashDictionary {
|
|
|
8305
8351
|
|
|
8306
8352
|
|
|
8307
8353
|
|
|
8354
|
+
|
|
8308
8355
|
;// CONCATENATED MODULE: ./packages/jam/config/chain-spec.ts
|
|
8309
8356
|
|
|
8310
8357
|
|
|
@@ -8562,7 +8609,7 @@ const codecFixedSizeArray = (val, len) => {
|
|
|
8562
8609
|
};
|
|
8563
8610
|
/** Codec for a hash-dictionary. */
|
|
8564
8611
|
const codecHashDictionary = (value, extractKey, { typicalLength = TYPICAL_DICTIONARY_LENGTH, compare = (a, b) => extractKey(a).compare(extractKey(b)), } = {}) => {
|
|
8565
|
-
return
|
|
8612
|
+
return Descriptor.new(`HashDictionary<${value.name}>[?]`, {
|
|
8566
8613
|
bytes: typicalLength * value.sizeHint.bytes,
|
|
8567
8614
|
isExact: false,
|
|
8568
8615
|
}, (e, v) => {
|
|
@@ -11546,6 +11593,13 @@ const gp_constants_W_T = 128;
|
|
|
11546
11593
|
/** `W_M`: The maximum number of exports in a work-package. */
|
|
11547
11594
|
const gp_constants_W_X = 3_072;
|
|
11548
11595
|
// TODO [ToDr] Not sure where these should live yet :(
|
|
11596
|
+
/**
|
|
11597
|
+
* `S`: The minimum public service index.
|
|
11598
|
+
* Services of indices below these may only be created by the Registrar.
|
|
11599
|
+
*
|
|
11600
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/447a00447a00?v=0.7.2
|
|
11601
|
+
*/
|
|
11602
|
+
const gp_constants_MIN_PUBLIC_SERVICE_INDEX = (/* unused pure expression or super */ null && (2 ** 16));
|
|
11549
11603
|
/**
|
|
11550
11604
|
* `J`: The maximum sum of dependency items in a work-report.
|
|
11551
11605
|
*
|
|
@@ -11557,9 +11611,209 @@ const gp_constants_AUTHORIZATION_QUEUE_SIZE = gp_constants_Q;
|
|
|
11557
11611
|
/** `O`: Maximal authorization pool size. */
|
|
11558
11612
|
const gp_constants_MAX_AUTH_POOL_SIZE = gp_constants_O;
|
|
11559
11613
|
|
|
11614
|
+
;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/ops/math-consts.ts
|
|
11615
|
+
const math_consts_MAX_VALUE = 4294967295;
|
|
11616
|
+
const math_consts_MAX_VALUE_U64 = (/* unused pure expression or super */ null && (2n ** 63n));
|
|
11617
|
+
const math_consts_MIN_VALUE = (/* unused pure expression or super */ null && (-(2 ** 31)));
|
|
11618
|
+
const math_consts_MAX_SHIFT_U32 = 32;
|
|
11619
|
+
const math_consts_MAX_SHIFT_U64 = 64n;
|
|
11620
|
+
|
|
11621
|
+
;// CONCATENATED MODULE: ./packages/jam/state/service.ts
|
|
11622
|
+
|
|
11623
|
+
|
|
11624
|
+
|
|
11625
|
+
|
|
11626
|
+
|
|
11627
|
+
|
|
11628
|
+
/**
|
|
11629
|
+
* `B_S`: The basic minimum balance which all services require.
|
|
11630
|
+
*
|
|
11631
|
+
* https://graypaper.fluffylabs.dev/#/7e6ff6a/445800445800?v=0.6.7
|
|
11632
|
+
*/
|
|
11633
|
+
const service_BASE_SERVICE_BALANCE = 100n;
|
|
11634
|
+
/**
|
|
11635
|
+
* `B_I`: The additional minimum balance required per item of elective service state.
|
|
11636
|
+
*
|
|
11637
|
+
* https://graypaper.fluffylabs.dev/#/7e6ff6a/445000445000?v=0.6.7
|
|
11638
|
+
*/
|
|
11639
|
+
const service_ELECTIVE_ITEM_BALANCE = 10n;
|
|
11640
|
+
/**
|
|
11641
|
+
* `B_L`: The additional minimum balance required per octet of elective service state.
|
|
11642
|
+
*
|
|
11643
|
+
* https://graypaper.fluffylabs.dev/#/7e6ff6a/445400445400?v=0.6.7
|
|
11644
|
+
*/
|
|
11645
|
+
const service_ELECTIVE_BYTE_BALANCE = 1n;
|
|
11646
|
+
const zeroSizeHint = {
|
|
11647
|
+
bytes: 0,
|
|
11648
|
+
isExact: true,
|
|
11649
|
+
};
|
|
11650
|
+
/** 0-byte read, return given default value */
|
|
11651
|
+
const ignoreValueWithDefault = (defaultValue) => Descriptor.new("ignoreValue", zeroSizeHint, (_e, _v) => { }, (_d) => defaultValue, (_s) => { });
|
|
11652
|
+
/** Encode and decode object with leading version number. */
|
|
11653
|
+
const codecWithVersion = (val) => Descriptor.new("withVersion", {
|
|
11654
|
+
bytes: val.sizeHint.bytes + 8,
|
|
11655
|
+
isExact: false,
|
|
11656
|
+
}, (e, v) => {
|
|
11657
|
+
e.varU64(0n);
|
|
11658
|
+
val.encode(e, v);
|
|
11659
|
+
}, (d) => {
|
|
11660
|
+
const version = d.varU64();
|
|
11661
|
+
if (version !== 0n) {
|
|
11662
|
+
throw new Error("Non-zero version is not supported!");
|
|
11663
|
+
}
|
|
11664
|
+
return val.decode(d);
|
|
11665
|
+
}, (s) => {
|
|
11666
|
+
s.varU64();
|
|
11667
|
+
val.skip(s);
|
|
11668
|
+
});
|
|
11669
|
+
/**
|
|
11670
|
+
* Service account details.
|
|
11671
|
+
*
|
|
11672
|
+
* https://graypaper.fluffylabs.dev/#/7e6ff6a/108301108301?v=0.6.7
|
|
11673
|
+
*/
|
|
11674
|
+
class service_ServiceAccountInfo extends WithDebug {
|
|
11675
|
+
codeHash;
|
|
11676
|
+
balance;
|
|
11677
|
+
accumulateMinGas;
|
|
11678
|
+
onTransferMinGas;
|
|
11679
|
+
storageUtilisationBytes;
|
|
11680
|
+
gratisStorage;
|
|
11681
|
+
storageUtilisationCount;
|
|
11682
|
+
created;
|
|
11683
|
+
lastAccumulation;
|
|
11684
|
+
parentService;
|
|
11685
|
+
static Codec = descriptors_codec.Class(service_ServiceAccountInfo, {
|
|
11686
|
+
codeHash: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
11687
|
+
balance: descriptors_codec.u64,
|
|
11688
|
+
accumulateMinGas: descriptors_codec.u64.convert((x) => x, common_tryAsServiceGas),
|
|
11689
|
+
onTransferMinGas: descriptors_codec.u64.convert((x) => x, common_tryAsServiceGas),
|
|
11690
|
+
storageUtilisationBytes: descriptors_codec.u64,
|
|
11691
|
+
gratisStorage: descriptors_codec.u64,
|
|
11692
|
+
storageUtilisationCount: descriptors_codec.u32,
|
|
11693
|
+
created: descriptors_codec.u32.convert((x) => x, common_tryAsTimeSlot),
|
|
11694
|
+
lastAccumulation: descriptors_codec.u32.convert((x) => x, common_tryAsTimeSlot),
|
|
11695
|
+
parentService: descriptors_codec.u32.convert((x) => x, common_tryAsServiceId),
|
|
11696
|
+
});
|
|
11697
|
+
static create(a) {
|
|
11698
|
+
return new service_ServiceAccountInfo(a.codeHash, a.balance, a.accumulateMinGas, a.onTransferMinGas, a.storageUtilisationBytes, a.gratisStorage, a.storageUtilisationCount, a.created, a.lastAccumulation, a.parentService);
|
|
11699
|
+
}
|
|
11700
|
+
/**
|
|
11701
|
+
* `a_t = max(0, BS + BI * a_i + BL * a_o - a_f)`
|
|
11702
|
+
* https://graypaper.fluffylabs.dev/#/7e6ff6a/119e01119e01?v=0.6.7
|
|
11703
|
+
*/
|
|
11704
|
+
static calculateThresholdBalance(items, bytes, gratisStorage) {
|
|
11705
|
+
const storageCost = service_BASE_SERVICE_BALANCE + service_ELECTIVE_ITEM_BALANCE * BigInt(items) + service_ELECTIVE_BYTE_BALANCE * bytes - gratisStorage;
|
|
11706
|
+
if (storageCost < 0n) {
|
|
11707
|
+
return numbers_tryAsU64(0);
|
|
11708
|
+
}
|
|
11709
|
+
if (storageCost >= 2n ** 64n) {
|
|
11710
|
+
return numbers_tryAsU64(2n ** 64n - 1n);
|
|
11711
|
+
}
|
|
11712
|
+
return numbers_tryAsU64(storageCost);
|
|
11713
|
+
}
|
|
11714
|
+
constructor(
|
|
11715
|
+
/** `a_c`: Hash of the service code. */
|
|
11716
|
+
codeHash,
|
|
11717
|
+
/** `a_b`: Current account balance. */
|
|
11718
|
+
balance,
|
|
11719
|
+
/** `a_g`: Minimal gas required to execute Accumulate entrypoint. */
|
|
11720
|
+
accumulateMinGas,
|
|
11721
|
+
/** `a_m`: Minimal gas required to execute On Transfer entrypoint. */
|
|
11722
|
+
onTransferMinGas,
|
|
11723
|
+
/** `a_o`: Total number of octets in storage. */
|
|
11724
|
+
storageUtilisationBytes,
|
|
11725
|
+
/** `a_f`: Cost-free storage. Decreases both storage item count and total byte size. */
|
|
11726
|
+
gratisStorage,
|
|
11727
|
+
/** `a_i`: Number of items in storage. */
|
|
11728
|
+
storageUtilisationCount,
|
|
11729
|
+
/** `a_r`: Creation account time slot. */
|
|
11730
|
+
created,
|
|
11731
|
+
/** `a_a`: Most recent accumulation time slot. */
|
|
11732
|
+
lastAccumulation,
|
|
11733
|
+
/** `a_p`: Parent service ID. */
|
|
11734
|
+
parentService) {
|
|
11735
|
+
super();
|
|
11736
|
+
this.codeHash = codeHash;
|
|
11737
|
+
this.balance = balance;
|
|
11738
|
+
this.accumulateMinGas = accumulateMinGas;
|
|
11739
|
+
this.onTransferMinGas = onTransferMinGas;
|
|
11740
|
+
this.storageUtilisationBytes = storageUtilisationBytes;
|
|
11741
|
+
this.gratisStorage = gratisStorage;
|
|
11742
|
+
this.storageUtilisationCount = storageUtilisationCount;
|
|
11743
|
+
this.created = created;
|
|
11744
|
+
this.lastAccumulation = lastAccumulation;
|
|
11745
|
+
this.parentService = parentService;
|
|
11746
|
+
}
|
|
11747
|
+
}
|
|
11748
|
+
class service_PreimageItem extends WithDebug {
|
|
11749
|
+
hash;
|
|
11750
|
+
blob;
|
|
11751
|
+
static Codec = descriptors_codec.Class(service_PreimageItem, {
|
|
11752
|
+
hash: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
11753
|
+
blob: descriptors_codec.blob,
|
|
11754
|
+
});
|
|
11755
|
+
static create({ hash, blob }) {
|
|
11756
|
+
return new service_PreimageItem(hash, blob);
|
|
11757
|
+
}
|
|
11758
|
+
constructor(hash, blob) {
|
|
11759
|
+
super();
|
|
11760
|
+
this.hash = hash;
|
|
11761
|
+
this.blob = blob;
|
|
11762
|
+
}
|
|
11763
|
+
}
|
|
11764
|
+
class service_StorageItem extends WithDebug {
|
|
11765
|
+
key;
|
|
11766
|
+
value;
|
|
11767
|
+
static Codec = descriptors_codec.Class(service_StorageItem, {
|
|
11768
|
+
key: descriptors_codec.blob.convert((i) => i, (o) => opaque_asOpaqueType(o)),
|
|
11769
|
+
value: descriptors_codec.blob,
|
|
11770
|
+
});
|
|
11771
|
+
static create({ key, value }) {
|
|
11772
|
+
return new service_StorageItem(key, value);
|
|
11773
|
+
}
|
|
11774
|
+
constructor(key, value) {
|
|
11775
|
+
super();
|
|
11776
|
+
this.key = key;
|
|
11777
|
+
this.value = value;
|
|
11778
|
+
}
|
|
11779
|
+
}
|
|
11780
|
+
const MAX_LOOKUP_HISTORY_SLOTS = 3;
|
|
11781
|
+
function service_tryAsLookupHistorySlots(items) {
|
|
11782
|
+
const knownSize = sized_array_asKnownSize(items);
|
|
11783
|
+
if (knownSize.length > MAX_LOOKUP_HISTORY_SLOTS) {
|
|
11784
|
+
throw new Error(`Lookup history items must contain 0-${MAX_LOOKUP_HISTORY_SLOTS} timeslots.`);
|
|
11785
|
+
}
|
|
11786
|
+
return knownSize;
|
|
11787
|
+
}
|
|
11788
|
+
/** https://graypaper.fluffylabs.dev/#/5f542d7/115400115800 */
|
|
11789
|
+
class service_LookupHistoryItem {
|
|
11790
|
+
hash;
|
|
11791
|
+
length;
|
|
11792
|
+
slots;
|
|
11793
|
+
constructor(hash, length,
|
|
11794
|
+
/**
|
|
11795
|
+
* Preimage availability history as a sequence of time slots.
|
|
11796
|
+
* See PreimageStatus and the following GP fragment for more details.
|
|
11797
|
+
* https://graypaper.fluffylabs.dev/#/5f542d7/11780011a500 */
|
|
11798
|
+
slots) {
|
|
11799
|
+
this.hash = hash;
|
|
11800
|
+
this.length = length;
|
|
11801
|
+
this.slots = slots;
|
|
11802
|
+
}
|
|
11803
|
+
static isRequested(item) {
|
|
11804
|
+
if ("slots" in item) {
|
|
11805
|
+
return item.slots.length === 0;
|
|
11806
|
+
}
|
|
11807
|
+
return item.length === 0;
|
|
11808
|
+
}
|
|
11809
|
+
}
|
|
11810
|
+
|
|
11560
11811
|
;// CONCATENATED MODULE: ./packages/jam/state/privileged-services.ts
|
|
11561
11812
|
|
|
11562
11813
|
|
|
11814
|
+
|
|
11815
|
+
|
|
11816
|
+
|
|
11563
11817
|
/** Dictionary entry of services that auto-accumulate every block. */
|
|
11564
11818
|
class privileged_services_AutoAccumulate {
|
|
11565
11819
|
service;
|
|
@@ -11581,39 +11835,50 @@ class privileged_services_AutoAccumulate {
|
|
|
11581
11835
|
}
|
|
11582
11836
|
}
|
|
11583
11837
|
/**
|
|
11584
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
11838
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/114402114402?v=0.7.2
|
|
11585
11839
|
*/
|
|
11586
11840
|
class privileged_services_PrivilegedServices {
|
|
11587
11841
|
manager;
|
|
11588
|
-
|
|
11589
|
-
|
|
11842
|
+
delegator;
|
|
11843
|
+
registrar;
|
|
11844
|
+
assigners;
|
|
11590
11845
|
autoAccumulateServices;
|
|
11846
|
+
/** https://graypaper.fluffylabs.dev/#/ab2cdbd/3bbd023bcb02?v=0.7.2 */
|
|
11591
11847
|
static Codec = descriptors_codec.Class(privileged_services_PrivilegedServices, {
|
|
11592
11848
|
manager: descriptors_codec.u32.asOpaque(),
|
|
11593
|
-
|
|
11594
|
-
|
|
11849
|
+
assigners: codecPerCore(descriptors_codec.u32.asOpaque()),
|
|
11850
|
+
delegator: descriptors_codec.u32.asOpaque(),
|
|
11851
|
+
registrar: compatibility_Compatibility.isGreaterOrEqual(compatibility_GpVersion.V0_7_1)
|
|
11852
|
+
? descriptors_codec.u32.asOpaque()
|
|
11853
|
+
: ignoreValueWithDefault(common_tryAsServiceId(2 ** 32 - 1)),
|
|
11595
11854
|
autoAccumulateServices: readonlyArray(descriptors_codec.sequenceVarLen(privileged_services_AutoAccumulate.Codec)),
|
|
11596
11855
|
});
|
|
11597
|
-
static create(
|
|
11598
|
-
return new privileged_services_PrivilegedServices(manager,
|
|
11856
|
+
static create(a) {
|
|
11857
|
+
return new privileged_services_PrivilegedServices(a.manager, a.delegator, a.registrar, a.assigners, a.autoAccumulateServices);
|
|
11599
11858
|
}
|
|
11600
11859
|
constructor(
|
|
11601
11860
|
/**
|
|
11602
|
-
*
|
|
11603
|
-
* the service able to effect an alteration of χ from block to block,
|
|
11861
|
+
* `χ_M`: Manages alteration of χ from block to block,
|
|
11604
11862
|
* as well as bestow services with storage deposit credits.
|
|
11605
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
11863
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/111502111902?v=0.7.2
|
|
11606
11864
|
*/
|
|
11607
11865
|
manager,
|
|
11608
|
-
/**
|
|
11609
|
-
|
|
11610
|
-
/**
|
|
11611
|
-
|
|
11612
|
-
|
|
11866
|
+
/** `χ_V`: Managers validator keys. */
|
|
11867
|
+
delegator,
|
|
11868
|
+
/**
|
|
11869
|
+
* `χ_R`: Manages the creation of services in protected range.
|
|
11870
|
+
*
|
|
11871
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/111b02111d02?v=0.7.2
|
|
11872
|
+
*/
|
|
11873
|
+
registrar,
|
|
11874
|
+
/** `χ_A`: Manages authorization queue one for each core. */
|
|
11875
|
+
assigners,
|
|
11876
|
+
/** `χ_Z`: Dictionary of services that auto-accumulate every block with their gas limit. */
|
|
11613
11877
|
autoAccumulateServices) {
|
|
11614
11878
|
this.manager = manager;
|
|
11615
|
-
this.
|
|
11616
|
-
this.
|
|
11879
|
+
this.delegator = delegator;
|
|
11880
|
+
this.registrar = registrar;
|
|
11881
|
+
this.assigners = assigners;
|
|
11617
11882
|
this.autoAccumulateServices = autoAccumulateServices;
|
|
11618
11883
|
}
|
|
11619
11884
|
}
|
|
@@ -11701,7 +11966,7 @@ class recent_blocks_RecentBlocks extends WithDebug {
|
|
|
11701
11966
|
*/
|
|
11702
11967
|
class recent_blocks_RecentBlocksHistory extends WithDebug {
|
|
11703
11968
|
current;
|
|
11704
|
-
static Codec =
|
|
11969
|
+
static Codec = Descriptor.new("RecentBlocksHistory", recent_blocks_RecentBlocks.Codec.sizeHint, (encoder, value) => recent_blocks_RecentBlocks.Codec.encode(encoder, value.asCurrent()), (decoder) => {
|
|
11705
11970
|
const recentBlocks = recent_blocks_RecentBlocks.Codec.decode(decoder);
|
|
11706
11971
|
return recent_blocks_RecentBlocksHistory.create(recentBlocks);
|
|
11707
11972
|
}, (skip) => {
|
|
@@ -11816,258 +12081,85 @@ var safrole_data_SafroleSealingKeysKind;
|
|
|
11816
12081
|
const codecBandersnatchKey = descriptors_codec.bytes(bandersnatch_BANDERSNATCH_KEY_BYTES).asOpaque();
|
|
11817
12082
|
class safrole_data_SafroleSealingKeysData extends WithDebug {
|
|
11818
12083
|
kind;
|
|
11819
|
-
keys;
|
|
11820
|
-
tickets;
|
|
11821
|
-
static Codec = codecWithContext((context) => {
|
|
11822
|
-
return descriptors_codec.custom({
|
|
11823
|
-
name: "SafroleSealingKeys",
|
|
11824
|
-
sizeHint: { bytes: 1 + hash_HASH_SIZE * context.epochLength, isExact: false },
|
|
11825
|
-
}, (e, x) => {
|
|
11826
|
-
e.varU32(numbers_tryAsU32(x.kind));
|
|
11827
|
-
if (x.kind === safrole_data_SafroleSealingKeysKind.Keys) {
|
|
11828
|
-
e.sequenceFixLen(codecBandersnatchKey, x.keys);
|
|
11829
|
-
}
|
|
11830
|
-
else {
|
|
11831
|
-
e.sequenceFixLen(Ticket.Codec, x.tickets);
|
|
11832
|
-
}
|
|
11833
|
-
}, (d) => {
|
|
11834
|
-
const epochLength = context.epochLength;
|
|
11835
|
-
const kind = d.varU32();
|
|
11836
|
-
if (kind === safrole_data_SafroleSealingKeysKind.Keys) {
|
|
11837
|
-
const keys = d.sequenceFixLen(codecBandersnatchKey, epochLength);
|
|
11838
|
-
return safrole_data_SafroleSealingKeysData.keys(common_tryAsPerEpochBlock(keys, context));
|
|
11839
|
-
}
|
|
11840
|
-
if (kind === safrole_data_SafroleSealingKeysKind.Tickets) {
|
|
11841
|
-
const tickets = d.sequenceFixLen(Ticket.Codec, epochLength);
|
|
11842
|
-
return safrole_data_SafroleSealingKeysData.tickets(common_tryAsPerEpochBlock(tickets, context));
|
|
11843
|
-
}
|
|
11844
|
-
throw new Error(`Unexpected safrole sealing keys kind: ${kind}`);
|
|
11845
|
-
}, (s) => {
|
|
11846
|
-
const kind = s.decoder.varU32();
|
|
11847
|
-
if (kind === safrole_data_SafroleSealingKeysKind.Keys) {
|
|
11848
|
-
s.sequenceFixLen(codecBandersnatchKey, context.epochLength);
|
|
11849
|
-
return;
|
|
11850
|
-
}
|
|
11851
|
-
if (kind === safrole_data_SafroleSealingKeysKind.Tickets) {
|
|
11852
|
-
s.sequenceFixLen(Ticket.Codec, context.epochLength);
|
|
11853
|
-
return;
|
|
11854
|
-
}
|
|
11855
|
-
throw new Error(`Unexpected safrole sealing keys kind: ${kind}`);
|
|
11856
|
-
});
|
|
11857
|
-
});
|
|
11858
|
-
static keys(keys) {
|
|
11859
|
-
return new safrole_data_SafroleSealingKeysData(safrole_data_SafroleSealingKeysKind.Keys, keys, undefined);
|
|
11860
|
-
}
|
|
11861
|
-
static tickets(tickets) {
|
|
11862
|
-
return new safrole_data_SafroleSealingKeysData(safrole_data_SafroleSealingKeysKind.Tickets, undefined, tickets);
|
|
11863
|
-
}
|
|
11864
|
-
constructor(kind, keys, tickets) {
|
|
11865
|
-
super();
|
|
11866
|
-
this.kind = kind;
|
|
11867
|
-
this.keys = keys;
|
|
11868
|
-
this.tickets = tickets;
|
|
11869
|
-
}
|
|
11870
|
-
}
|
|
11871
|
-
class safrole_data_SafroleData {
|
|
11872
|
-
nextValidatorData;
|
|
11873
|
-
epochRoot;
|
|
11874
|
-
sealingKeySeries;
|
|
11875
|
-
ticketsAccumulator;
|
|
11876
|
-
static Codec = descriptors_codec.Class(safrole_data_SafroleData, {
|
|
11877
|
-
nextValidatorData: codecPerValidator(validator_data_ValidatorData.Codec),
|
|
11878
|
-
epochRoot: descriptors_codec.bytes(BANDERSNATCH_RING_ROOT_BYTES).asOpaque(),
|
|
11879
|
-
sealingKeySeries: safrole_data_SafroleSealingKeysData.Codec,
|
|
11880
|
-
ticketsAccumulator: readonlyArray(descriptors_codec.sequenceVarLen(Ticket.Codec)).convert(seeThrough, sized_array_asKnownSize),
|
|
11881
|
-
});
|
|
11882
|
-
static create({ nextValidatorData, epochRoot, sealingKeySeries, ticketsAccumulator }) {
|
|
11883
|
-
return new safrole_data_SafroleData(nextValidatorData, epochRoot, sealingKeySeries, ticketsAccumulator);
|
|
11884
|
-
}
|
|
11885
|
-
constructor(
|
|
11886
|
-
/** gamma_k */
|
|
11887
|
-
nextValidatorData,
|
|
11888
|
-
/** gamma_z */
|
|
11889
|
-
epochRoot,
|
|
11890
|
-
/** gamma_s */
|
|
11891
|
-
sealingKeySeries,
|
|
11892
|
-
/** gamma_a */
|
|
11893
|
-
ticketsAccumulator) {
|
|
11894
|
-
this.nextValidatorData = nextValidatorData;
|
|
11895
|
-
this.epochRoot = epochRoot;
|
|
11896
|
-
this.sealingKeySeries = sealingKeySeries;
|
|
11897
|
-
this.ticketsAccumulator = ticketsAccumulator;
|
|
11898
|
-
}
|
|
11899
|
-
}
|
|
11900
|
-
|
|
11901
|
-
;// CONCATENATED MODULE: ./packages/jam/state/service.ts
|
|
11902
|
-
|
|
11903
|
-
|
|
11904
|
-
|
|
11905
|
-
|
|
11906
|
-
|
|
11907
|
-
|
|
11908
|
-
/**
|
|
11909
|
-
* `B_S`: The basic minimum balance which all services require.
|
|
11910
|
-
*
|
|
11911
|
-
* https://graypaper.fluffylabs.dev/#/7e6ff6a/445800445800?v=0.6.7
|
|
11912
|
-
*/
|
|
11913
|
-
const service_BASE_SERVICE_BALANCE = 100n;
|
|
11914
|
-
/**
|
|
11915
|
-
* `B_I`: The additional minimum balance required per item of elective service state.
|
|
11916
|
-
*
|
|
11917
|
-
* https://graypaper.fluffylabs.dev/#/7e6ff6a/445000445000?v=0.6.7
|
|
11918
|
-
*/
|
|
11919
|
-
const service_ELECTIVE_ITEM_BALANCE = 10n;
|
|
11920
|
-
/**
|
|
11921
|
-
* `B_L`: The additional minimum balance required per octet of elective service state.
|
|
11922
|
-
*
|
|
11923
|
-
* https://graypaper.fluffylabs.dev/#/7e6ff6a/445400445400?v=0.6.7
|
|
11924
|
-
*/
|
|
11925
|
-
const service_ELECTIVE_BYTE_BALANCE = 1n;
|
|
11926
|
-
const zeroSizeHint = {
|
|
11927
|
-
bytes: 0,
|
|
11928
|
-
isExact: true,
|
|
11929
|
-
};
|
|
11930
|
-
/** 0-byte read, return given default value */
|
|
11931
|
-
const ignoreValueWithDefault = (defaultValue) => Descriptor.new("ignoreValue", zeroSizeHint, (_e, _v) => { }, (_d) => defaultValue, (_s) => { });
|
|
11932
|
-
/**
|
|
11933
|
-
* Service account details.
|
|
11934
|
-
*
|
|
11935
|
-
* https://graypaper.fluffylabs.dev/#/7e6ff6a/108301108301?v=0.6.7
|
|
11936
|
-
*/
|
|
11937
|
-
class service_ServiceAccountInfo extends WithDebug {
|
|
11938
|
-
codeHash;
|
|
11939
|
-
balance;
|
|
11940
|
-
accumulateMinGas;
|
|
11941
|
-
onTransferMinGas;
|
|
11942
|
-
storageUtilisationBytes;
|
|
11943
|
-
gratisStorage;
|
|
11944
|
-
storageUtilisationCount;
|
|
11945
|
-
created;
|
|
11946
|
-
lastAccumulation;
|
|
11947
|
-
parentService;
|
|
11948
|
-
static Codec = descriptors_codec.Class(service_ServiceAccountInfo, {
|
|
11949
|
-
codeHash: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
11950
|
-
balance: descriptors_codec.u64,
|
|
11951
|
-
accumulateMinGas: descriptors_codec.u64.convert((x) => x, common_tryAsServiceGas),
|
|
11952
|
-
onTransferMinGas: descriptors_codec.u64.convert((x) => x, common_tryAsServiceGas),
|
|
11953
|
-
storageUtilisationBytes: descriptors_codec.u64,
|
|
11954
|
-
gratisStorage: descriptors_codec.u64,
|
|
11955
|
-
storageUtilisationCount: descriptors_codec.u32,
|
|
11956
|
-
created: descriptors_codec.u32.convert((x) => x, common_tryAsTimeSlot),
|
|
11957
|
-
lastAccumulation: descriptors_codec.u32.convert((x) => x, common_tryAsTimeSlot),
|
|
11958
|
-
parentService: descriptors_codec.u32.convert((x) => x, common_tryAsServiceId),
|
|
11959
|
-
});
|
|
11960
|
-
static create(a) {
|
|
11961
|
-
return new service_ServiceAccountInfo(a.codeHash, a.balance, a.accumulateMinGas, a.onTransferMinGas, a.storageUtilisationBytes, a.gratisStorage, a.storageUtilisationCount, a.created, a.lastAccumulation, a.parentService);
|
|
11962
|
-
}
|
|
11963
|
-
/**
|
|
11964
|
-
* `a_t = max(0, BS + BI * a_i + BL * a_o - a_f)`
|
|
11965
|
-
* https://graypaper.fluffylabs.dev/#/7e6ff6a/119e01119e01?v=0.6.7
|
|
11966
|
-
*/
|
|
11967
|
-
static calculateThresholdBalance(items, bytes, gratisStorage) {
|
|
11968
|
-
const storageCost = service_BASE_SERVICE_BALANCE + service_ELECTIVE_ITEM_BALANCE * BigInt(items) + service_ELECTIVE_BYTE_BALANCE * bytes - gratisStorage;
|
|
11969
|
-
if (storageCost < 0n) {
|
|
11970
|
-
return numbers_tryAsU64(0);
|
|
11971
|
-
}
|
|
11972
|
-
if (storageCost >= 2n ** 64n) {
|
|
11973
|
-
return numbers_tryAsU64(2n ** 64n - 1n);
|
|
11974
|
-
}
|
|
11975
|
-
return numbers_tryAsU64(storageCost);
|
|
11976
|
-
}
|
|
11977
|
-
constructor(
|
|
11978
|
-
/** `a_c`: Hash of the service code. */
|
|
11979
|
-
codeHash,
|
|
11980
|
-
/** `a_b`: Current account balance. */
|
|
11981
|
-
balance,
|
|
11982
|
-
/** `a_g`: Minimal gas required to execute Accumulate entrypoint. */
|
|
11983
|
-
accumulateMinGas,
|
|
11984
|
-
/** `a_m`: Minimal gas required to execute On Transfer entrypoint. */
|
|
11985
|
-
onTransferMinGas,
|
|
11986
|
-
/** `a_o`: Total number of octets in storage. */
|
|
11987
|
-
storageUtilisationBytes,
|
|
11988
|
-
/** `a_f`: Cost-free storage. Decreases both storage item count and total byte size. */
|
|
11989
|
-
gratisStorage,
|
|
11990
|
-
/** `a_i`: Number of items in storage. */
|
|
11991
|
-
storageUtilisationCount,
|
|
11992
|
-
/** `a_r`: Creation account time slot. */
|
|
11993
|
-
created,
|
|
11994
|
-
/** `a_a`: Most recent accumulation time slot. */
|
|
11995
|
-
lastAccumulation,
|
|
11996
|
-
/** `a_p`: Parent service ID. */
|
|
11997
|
-
parentService) {
|
|
11998
|
-
super();
|
|
11999
|
-
this.codeHash = codeHash;
|
|
12000
|
-
this.balance = balance;
|
|
12001
|
-
this.accumulateMinGas = accumulateMinGas;
|
|
12002
|
-
this.onTransferMinGas = onTransferMinGas;
|
|
12003
|
-
this.storageUtilisationBytes = storageUtilisationBytes;
|
|
12004
|
-
this.gratisStorage = gratisStorage;
|
|
12005
|
-
this.storageUtilisationCount = storageUtilisationCount;
|
|
12006
|
-
this.created = created;
|
|
12007
|
-
this.lastAccumulation = lastAccumulation;
|
|
12008
|
-
this.parentService = parentService;
|
|
12009
|
-
}
|
|
12010
|
-
}
|
|
12011
|
-
class service_PreimageItem extends WithDebug {
|
|
12012
|
-
hash;
|
|
12013
|
-
blob;
|
|
12014
|
-
static Codec = descriptors_codec.Class(service_PreimageItem, {
|
|
12015
|
-
hash: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
12016
|
-
blob: descriptors_codec.blob,
|
|
12084
|
+
keys;
|
|
12085
|
+
tickets;
|
|
12086
|
+
static Codec = codecWithContext((context) => {
|
|
12087
|
+
return descriptors_codec.custom({
|
|
12088
|
+
name: "SafroleSealingKeys",
|
|
12089
|
+
sizeHint: { bytes: 1 + hash_HASH_SIZE * context.epochLength, isExact: false },
|
|
12090
|
+
}, (e, x) => {
|
|
12091
|
+
e.varU32(numbers_tryAsU32(x.kind));
|
|
12092
|
+
if (x.kind === safrole_data_SafroleSealingKeysKind.Keys) {
|
|
12093
|
+
e.sequenceFixLen(codecBandersnatchKey, x.keys);
|
|
12094
|
+
}
|
|
12095
|
+
else {
|
|
12096
|
+
e.sequenceFixLen(Ticket.Codec, x.tickets);
|
|
12097
|
+
}
|
|
12098
|
+
}, (d) => {
|
|
12099
|
+
const epochLength = context.epochLength;
|
|
12100
|
+
const kind = d.varU32();
|
|
12101
|
+
if (kind === safrole_data_SafroleSealingKeysKind.Keys) {
|
|
12102
|
+
const keys = d.sequenceFixLen(codecBandersnatchKey, epochLength);
|
|
12103
|
+
return safrole_data_SafroleSealingKeysData.keys(common_tryAsPerEpochBlock(keys, context));
|
|
12104
|
+
}
|
|
12105
|
+
if (kind === safrole_data_SafroleSealingKeysKind.Tickets) {
|
|
12106
|
+
const tickets = d.sequenceFixLen(Ticket.Codec, epochLength);
|
|
12107
|
+
return safrole_data_SafroleSealingKeysData.tickets(common_tryAsPerEpochBlock(tickets, context));
|
|
12108
|
+
}
|
|
12109
|
+
throw new Error(`Unexpected safrole sealing keys kind: ${kind}`);
|
|
12110
|
+
}, (s) => {
|
|
12111
|
+
const kind = s.decoder.varU32();
|
|
12112
|
+
if (kind === safrole_data_SafroleSealingKeysKind.Keys) {
|
|
12113
|
+
s.sequenceFixLen(codecBandersnatchKey, context.epochLength);
|
|
12114
|
+
return;
|
|
12115
|
+
}
|
|
12116
|
+
if (kind === safrole_data_SafroleSealingKeysKind.Tickets) {
|
|
12117
|
+
s.sequenceFixLen(Ticket.Codec, context.epochLength);
|
|
12118
|
+
return;
|
|
12119
|
+
}
|
|
12120
|
+
throw new Error(`Unexpected safrole sealing keys kind: ${kind}`);
|
|
12121
|
+
});
|
|
12017
12122
|
});
|
|
12018
|
-
static
|
|
12019
|
-
return new
|
|
12020
|
-
}
|
|
12021
|
-
constructor(hash, blob) {
|
|
12022
|
-
super();
|
|
12023
|
-
this.hash = hash;
|
|
12024
|
-
this.blob = blob;
|
|
12123
|
+
static keys(keys) {
|
|
12124
|
+
return new safrole_data_SafroleSealingKeysData(safrole_data_SafroleSealingKeysKind.Keys, keys, undefined);
|
|
12025
12125
|
}
|
|
12026
|
-
|
|
12027
|
-
|
|
12028
|
-
key;
|
|
12029
|
-
value;
|
|
12030
|
-
static Codec = descriptors_codec.Class(service_StorageItem, {
|
|
12031
|
-
key: descriptors_codec.blob.convert((i) => i, (o) => opaque_asOpaqueType(o)),
|
|
12032
|
-
value: descriptors_codec.blob,
|
|
12033
|
-
});
|
|
12034
|
-
static create({ key, value }) {
|
|
12035
|
-
return new service_StorageItem(key, value);
|
|
12126
|
+
static tickets(tickets) {
|
|
12127
|
+
return new safrole_data_SafroleSealingKeysData(safrole_data_SafroleSealingKeysKind.Tickets, undefined, tickets);
|
|
12036
12128
|
}
|
|
12037
|
-
constructor(
|
|
12129
|
+
constructor(kind, keys, tickets) {
|
|
12038
12130
|
super();
|
|
12039
|
-
this.
|
|
12040
|
-
this.
|
|
12041
|
-
|
|
12042
|
-
}
|
|
12043
|
-
const MAX_LOOKUP_HISTORY_SLOTS = 3;
|
|
12044
|
-
function service_tryAsLookupHistorySlots(items) {
|
|
12045
|
-
const knownSize = sized_array_asKnownSize(items);
|
|
12046
|
-
if (knownSize.length > MAX_LOOKUP_HISTORY_SLOTS) {
|
|
12047
|
-
throw new Error(`Lookup history items must contain 0-${MAX_LOOKUP_HISTORY_SLOTS} timeslots.`);
|
|
12131
|
+
this.kind = kind;
|
|
12132
|
+
this.keys = keys;
|
|
12133
|
+
this.tickets = tickets;
|
|
12048
12134
|
}
|
|
12049
|
-
return knownSize;
|
|
12050
12135
|
}
|
|
12051
|
-
|
|
12052
|
-
|
|
12053
|
-
|
|
12054
|
-
|
|
12055
|
-
|
|
12056
|
-
|
|
12057
|
-
|
|
12058
|
-
|
|
12059
|
-
|
|
12060
|
-
|
|
12061
|
-
|
|
12062
|
-
|
|
12063
|
-
|
|
12064
|
-
this.slots = slots;
|
|
12136
|
+
class safrole_data_SafroleData {
|
|
12137
|
+
nextValidatorData;
|
|
12138
|
+
epochRoot;
|
|
12139
|
+
sealingKeySeries;
|
|
12140
|
+
ticketsAccumulator;
|
|
12141
|
+
static Codec = descriptors_codec.Class(safrole_data_SafroleData, {
|
|
12142
|
+
nextValidatorData: codecPerValidator(validator_data_ValidatorData.Codec),
|
|
12143
|
+
epochRoot: descriptors_codec.bytes(BANDERSNATCH_RING_ROOT_BYTES).asOpaque(),
|
|
12144
|
+
sealingKeySeries: safrole_data_SafroleSealingKeysData.Codec,
|
|
12145
|
+
ticketsAccumulator: readonlyArray(descriptors_codec.sequenceVarLen(Ticket.Codec)).convert(seeThrough, sized_array_asKnownSize),
|
|
12146
|
+
});
|
|
12147
|
+
static create({ nextValidatorData, epochRoot, sealingKeySeries, ticketsAccumulator }) {
|
|
12148
|
+
return new safrole_data_SafroleData(nextValidatorData, epochRoot, sealingKeySeries, ticketsAccumulator);
|
|
12065
12149
|
}
|
|
12066
|
-
|
|
12067
|
-
|
|
12068
|
-
|
|
12069
|
-
|
|
12070
|
-
|
|
12150
|
+
constructor(
|
|
12151
|
+
/** gamma_k */
|
|
12152
|
+
nextValidatorData,
|
|
12153
|
+
/** gamma_z */
|
|
12154
|
+
epochRoot,
|
|
12155
|
+
/** gamma_s */
|
|
12156
|
+
sealingKeySeries,
|
|
12157
|
+
/** gamma_a */
|
|
12158
|
+
ticketsAccumulator) {
|
|
12159
|
+
this.nextValidatorData = nextValidatorData;
|
|
12160
|
+
this.epochRoot = epochRoot;
|
|
12161
|
+
this.sealingKeySeries = sealingKeySeries;
|
|
12162
|
+
this.ticketsAccumulator = ticketsAccumulator;
|
|
12071
12163
|
}
|
|
12072
12164
|
}
|
|
12073
12165
|
|
|
@@ -12507,6 +12599,7 @@ class statistics_StatisticsData {
|
|
|
12507
12599
|
|
|
12508
12600
|
|
|
12509
12601
|
|
|
12602
|
+
|
|
12510
12603
|
|
|
12511
12604
|
|
|
12512
12605
|
var in_memory_state_UpdateError;
|
|
@@ -12910,8 +13003,9 @@ class InMemoryState extends WithDebug {
|
|
|
12910
13003
|
epochRoot: bytes_Bytes.zero(BANDERSNATCH_RING_ROOT_BYTES).asOpaque(),
|
|
12911
13004
|
privilegedServices: privileged_services_PrivilegedServices.create({
|
|
12912
13005
|
manager: common_tryAsServiceId(0),
|
|
12913
|
-
|
|
12914
|
-
|
|
13006
|
+
assigners: common_tryAsPerCore(new Array(spec.coresCount).fill(common_tryAsServiceId(0)), spec),
|
|
13007
|
+
delegator: common_tryAsServiceId(0),
|
|
13008
|
+
registrar: common_tryAsServiceId(math_consts_MAX_VALUE),
|
|
12915
13009
|
autoAccumulateServices: [],
|
|
12916
13010
|
}),
|
|
12917
13011
|
accumulationOutputLog: sorted_array_SortedArray.fromArray(accumulation_output_accumulationOutputComparator, []),
|
|
@@ -12957,6 +13051,7 @@ const serviceDataCodec = descriptors_codec.dictionary(descriptors_codec.u32.asOp
|
|
|
12957
13051
|
|
|
12958
13052
|
class JsonServiceInfo {
|
|
12959
13053
|
static fromJson = json.object({
|
|
13054
|
+
...(compatibility_Compatibility.isGreaterOrEqual(compatibility_GpVersion.V0_7_1) ? { version: "number" } : {}),
|
|
12960
13055
|
code_hash: fromJson.bytes32(),
|
|
12961
13056
|
balance: json.fromNumber((x) => numbers_tryAsU64(x)),
|
|
12962
13057
|
min_item_gas: json.fromNumber((x) => common_tryAsServiceGas(x)),
|
|
@@ -12981,6 +13076,7 @@ class JsonServiceInfo {
|
|
|
12981
13076
|
parentService: parent_service,
|
|
12982
13077
|
});
|
|
12983
13078
|
});
|
|
13079
|
+
version;
|
|
12984
13080
|
code_hash;
|
|
12985
13081
|
balance;
|
|
12986
13082
|
min_item_gas;
|
|
@@ -13015,23 +13111,35 @@ const lookupMetaFromJson = json.object({
|
|
|
13015
13111
|
},
|
|
13016
13112
|
value: json.array("number"),
|
|
13017
13113
|
}, ({ key, value }) => new service_LookupHistoryItem(key.hash, key.length, value));
|
|
13114
|
+
const preimageStatusFromJson = json.object({
|
|
13115
|
+
hash: fromJson.bytes32(),
|
|
13116
|
+
status: json.array("number"),
|
|
13117
|
+
}, ({ hash, status }) => new service_LookupHistoryItem(hash, numbers_tryAsU32(0), status));
|
|
13018
13118
|
class JsonService {
|
|
13019
13119
|
static fromJson = json.object({
|
|
13020
13120
|
id: "number",
|
|
13021
|
-
data:
|
|
13022
|
-
|
|
13023
|
-
|
|
13024
|
-
|
|
13025
|
-
|
|
13026
|
-
|
|
13121
|
+
data: compatibility_Compatibility.isLessThan(compatibility_GpVersion.V0_7_1)
|
|
13122
|
+
? {
|
|
13123
|
+
service: JsonServiceInfo.fromJson,
|
|
13124
|
+
preimages: json.optional(json.array(JsonPreimageItem.fromJson)),
|
|
13125
|
+
storage: json.optional(json.array(JsonStorageItem.fromJson)),
|
|
13126
|
+
lookup_meta: json.optional(json.array(lookupMetaFromJson)),
|
|
13127
|
+
}
|
|
13128
|
+
: {
|
|
13129
|
+
service: JsonServiceInfo.fromJson,
|
|
13130
|
+
storage: json.optional(json.array(JsonStorageItem.fromJson)),
|
|
13131
|
+
preimages_blob: json.optional(json.array(JsonPreimageItem.fromJson)),
|
|
13132
|
+
preimages_status: json.optional(json.array(preimageStatusFromJson)),
|
|
13133
|
+
},
|
|
13027
13134
|
}, ({ id, data }) => {
|
|
13135
|
+
const preimages = hash_dictionary_HashDictionary.fromEntries((data.preimages ?? data.preimages_blob ?? []).map((x) => [x.hash, x]));
|
|
13028
13136
|
const lookupHistory = hash_dictionary_HashDictionary.new();
|
|
13029
|
-
for (const item of data.lookup_meta ?? []) {
|
|
13137
|
+
for (const item of data.lookup_meta ?? data.preimages_status ?? []) {
|
|
13030
13138
|
const data = lookupHistory.get(item.hash) ?? [];
|
|
13031
|
-
|
|
13139
|
+
const length = numbers_tryAsU32(preimages.get(item.hash)?.blob.length ?? item.length);
|
|
13140
|
+
data.push(new service_LookupHistoryItem(item.hash, length, item.slots));
|
|
13032
13141
|
lookupHistory.set(item.hash, data);
|
|
13033
13142
|
}
|
|
13034
|
-
const preimages = hash_dictionary_HashDictionary.fromEntries((data.preimages ?? []).map((x) => [x.hash, x]));
|
|
13035
13143
|
const storage = new Map();
|
|
13036
13144
|
const entries = (data.storage ?? []).map(({ key, value }) => {
|
|
13037
13145
|
const opaqueKey = opaque_asOpaqueType(key);
|
|
@@ -13226,6 +13334,8 @@ class TicketsOrKeys {
|
|
|
13226
13334
|
|
|
13227
13335
|
|
|
13228
13336
|
|
|
13337
|
+
|
|
13338
|
+
|
|
13229
13339
|
class JsonValidatorStatistics {
|
|
13230
13340
|
static fromJson = json.object({
|
|
13231
13341
|
blocks: "number",
|
|
@@ -13294,8 +13404,12 @@ class JsonServiceStatistics {
|
|
|
13294
13404
|
extrinsic_count: "number",
|
|
13295
13405
|
accumulate_count: "number",
|
|
13296
13406
|
accumulate_gas_used: json.fromNumber(common_tryAsServiceGas),
|
|
13297
|
-
|
|
13298
|
-
|
|
13407
|
+
...(compatibility_Compatibility.isLessThan(compatibility_GpVersion.V0_7_1)
|
|
13408
|
+
? {
|
|
13409
|
+
on_transfers_count: "number",
|
|
13410
|
+
on_transfers_gas_used: json.fromNumber(common_tryAsServiceGas),
|
|
13411
|
+
}
|
|
13412
|
+
: {}),
|
|
13299
13413
|
}, ({ 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, }) => {
|
|
13300
13414
|
return statistics_ServiceStatistics.create({
|
|
13301
13415
|
providedCount: provided_count,
|
|
@@ -13308,8 +13422,8 @@ class JsonServiceStatistics {
|
|
|
13308
13422
|
extrinsicCount: extrinsic_count,
|
|
13309
13423
|
accumulateCount: accumulate_count,
|
|
13310
13424
|
accumulateGasUsed: accumulate_gas_used,
|
|
13311
|
-
onTransfersCount: on_transfers_count,
|
|
13312
|
-
onTransfersGasUsed: on_transfers_gas_used,
|
|
13425
|
+
onTransfersCount: on_transfers_count ?? numbers_tryAsU32(0),
|
|
13426
|
+
onTransfersGasUsed: on_transfers_gas_used ?? common_tryAsServiceGas(0),
|
|
13313
13427
|
});
|
|
13314
13428
|
});
|
|
13315
13429
|
provided_count;
|
|
@@ -13383,6 +13497,7 @@ const validatorDataFromJson = json.object({
|
|
|
13383
13497
|
|
|
13384
13498
|
|
|
13385
13499
|
|
|
13500
|
+
|
|
13386
13501
|
const fullStateDumpFromJson = (spec) => json.object({
|
|
13387
13502
|
alpha: json.array(json.array(fromJson.bytes32())),
|
|
13388
13503
|
varphi: json.array(json.array(fromJson.bytes32())),
|
|
@@ -13404,6 +13519,7 @@ const fullStateDumpFromJson = (spec) => json.object({
|
|
|
13404
13519
|
chi_m: "number",
|
|
13405
13520
|
chi_a: json.array("number"),
|
|
13406
13521
|
chi_v: "number",
|
|
13522
|
+
chi_r: json.optional("number"),
|
|
13407
13523
|
chi_g: json.nullable(json.array({
|
|
13408
13524
|
service: "number",
|
|
13409
13525
|
gasLimit: json.fromNumber((v) => common_tryAsServiceGas(v)),
|
|
@@ -13415,6 +13531,9 @@ const fullStateDumpFromJson = (spec) => json.object({
|
|
|
13415
13531
|
theta: json.nullable(json.array(accumulationOutput)),
|
|
13416
13532
|
accounts: json.array(JsonService.fromJson),
|
|
13417
13533
|
}, ({ alpha, varphi, beta, gamma, psi, eta, iota, kappa, lambda, rho, tau, chi, pi, omega, xi, theta, accounts, }) => {
|
|
13534
|
+
if (compatibility_Compatibility.isGreaterOrEqual(compatibility_GpVersion.V0_7_1) && chi.chi_r === undefined) {
|
|
13535
|
+
throw new Error("Registrar is required in Privileges GP ^0.7.1");
|
|
13536
|
+
}
|
|
13418
13537
|
return InMemoryState.create({
|
|
13419
13538
|
authPools: common_tryAsPerCore(alpha.map((perCore) => {
|
|
13420
13539
|
if (perCore.length > gp_constants_MAX_AUTH_POOL_SIZE) {
|
|
@@ -13442,8 +13561,9 @@ const fullStateDumpFromJson = (spec) => json.object({
|
|
|
13442
13561
|
timeslot: tau,
|
|
13443
13562
|
privilegedServices: privileged_services_PrivilegedServices.create({
|
|
13444
13563
|
manager: chi.chi_m,
|
|
13445
|
-
|
|
13446
|
-
|
|
13564
|
+
assigners: chi.chi_a,
|
|
13565
|
+
delegator: chi.chi_v,
|
|
13566
|
+
registrar: chi.chi_r ?? common_tryAsServiceId(2 ** 32 - 1),
|
|
13447
13567
|
autoAccumulateServices: chi.chi_g ?? [],
|
|
13448
13568
|
}),
|
|
13449
13569
|
statistics: JsonStatisticsData.toStatisticsData(spec, pi),
|
|
@@ -13643,6 +13763,7 @@ function legacyServiceNested(serviceId, hash) {
|
|
|
13643
13763
|
|
|
13644
13764
|
|
|
13645
13765
|
|
|
13766
|
+
|
|
13646
13767
|
/** Serialization for particular state entries. */
|
|
13647
13768
|
var serialize_serialize;
|
|
13648
13769
|
(function (serialize) {
|
|
@@ -13757,7 +13878,9 @@ var serialize_serialize;
|
|
|
13757
13878
|
/** C(255, s): https://graypaper.fluffylabs.dev/#/85129da/383103383103?v=0.6.3 */
|
|
13758
13879
|
serialize.serviceData = (serviceId) => ({
|
|
13759
13880
|
key: stateKeys.serviceInfo(serviceId),
|
|
13760
|
-
Codec:
|
|
13881
|
+
Codec: compatibility_Compatibility.isGreaterOrEqual(compatibility_GpVersion.V0_7_1)
|
|
13882
|
+
? codecWithVersion(service_ServiceAccountInfo.Codec)
|
|
13883
|
+
: service_ServiceAccountInfo.Codec,
|
|
13761
13884
|
});
|
|
13762
13885
|
/** https://graypaper.fluffylabs.dev/#/85129da/384803384803?v=0.6.3 */
|
|
13763
13886
|
serialize.serviceStorage = (blake2b, serviceId, key) => ({
|
|
@@ -13782,7 +13905,7 @@ var serialize_serialize;
|
|
|
13782
13905
|
* determine the boundary of the bytes, so it can only be used
|
|
13783
13906
|
* as the last element of the codec and can't be used in sequences!
|
|
13784
13907
|
*/
|
|
13785
|
-
const serialize_dumpCodec =
|
|
13908
|
+
const serialize_dumpCodec = 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()));
|
|
13786
13909
|
|
|
13787
13910
|
;// CONCATENATED MODULE: ./packages/jam/state-merkleization/serialized-state.ts
|
|
13788
13911
|
|
|
@@ -14996,7 +15119,7 @@ const codecMap = (value, extractKey, { typicalLength = TYPICAL_DICTIONARY_LENGTH
|
|
|
14996
15119
|
}
|
|
14997
15120
|
return Ordering.Equal;
|
|
14998
15121
|
}, } = {}) => {
|
|
14999
|
-
return
|
|
15122
|
+
return Descriptor.new(`Map<${value.name}>[?]`, {
|
|
15000
15123
|
bytes: typicalLength * value.sizeHint.bytes,
|
|
15001
15124
|
isExact: false,
|
|
15002
15125
|
}, (e, v) => {
|
|
@@ -16645,7 +16768,7 @@ class state_update_AccumulationStateUpdate {
|
|
|
16645
16768
|
if (from.privilegedServices !== null) {
|
|
16646
16769
|
update.privilegedServices = PrivilegedServices.create({
|
|
16647
16770
|
...from.privilegedServices,
|
|
16648
|
-
|
|
16771
|
+
assigners: asKnownSize([...from.privilegedServices.assigners]),
|
|
16649
16772
|
});
|
|
16650
16773
|
}
|
|
16651
16774
|
return update;
|
|
@@ -20513,6 +20636,8 @@ var partial_state_NewServiceError;
|
|
|
20513
20636
|
NewServiceError[NewServiceError["InsufficientFunds"] = 0] = "InsufficientFunds";
|
|
20514
20637
|
/** Service is not privileged to set gratis storage. */
|
|
20515
20638
|
NewServiceError[NewServiceError["UnprivilegedService"] = 1] = "UnprivilegedService";
|
|
20639
|
+
/** Registrar attempting to create a service with already existing id. */
|
|
20640
|
+
NewServiceError[NewServiceError["RegistrarServiceIdAlreadyTaken"] = 2] = "RegistrarServiceIdAlreadyTaken";
|
|
20516
20641
|
})(partial_state_NewServiceError || (partial_state_NewServiceError = {}));
|
|
20517
20642
|
var partial_state_UpdatePrivilegesError;
|
|
20518
20643
|
(function (UpdatePrivilegesError) {
|
|
@@ -20649,7 +20774,7 @@ const results_HostCallResult = {
|
|
|
20649
20774
|
OOB: numbers_tryAsU64(0xfffffffffffffffdn), // 2**64 - 3
|
|
20650
20775
|
/** Index unknown. */
|
|
20651
20776
|
WHO: numbers_tryAsU64(0xfffffffffffffffcn), // 2**64 - 4
|
|
20652
|
-
/** Storage full. */
|
|
20777
|
+
/** Storage full or resource already allocated. */
|
|
20653
20778
|
FULL: numbers_tryAsU64(0xfffffffffffffffbn), // 2**64 - 5
|
|
20654
20779
|
/** Core index unknown. */
|
|
20655
20780
|
CORE: numbers_tryAsU64(0xfffffffffffffffan), // 2**64 - 6
|
|
@@ -20657,7 +20782,7 @@ const results_HostCallResult = {
|
|
|
20657
20782
|
CASH: numbers_tryAsU64(0xfffffffffffffff9n), // 2**64 - 7
|
|
20658
20783
|
/** Gas limit too low. */
|
|
20659
20784
|
LOW: numbers_tryAsU64(0xfffffffffffffff8n), // 2**64 - 8
|
|
20660
|
-
/** The item is already solicited
|
|
20785
|
+
/** The item is already solicited, cannot be forgotten or the operation is invalid due to privilege level. */
|
|
20661
20786
|
HUH: numbers_tryAsU64(0xfffffffffffffff7n), // 2**64 - 9
|
|
20662
20787
|
/** The return value indicating general success. */
|
|
20663
20788
|
OK: numbers_tryAsU64(0n),
|
|
@@ -20711,6 +20836,7 @@ function utils_clampU64ToU32(value) {
|
|
|
20711
20836
|
|
|
20712
20837
|
|
|
20713
20838
|
|
|
20839
|
+
|
|
20714
20840
|
/**
|
|
20715
20841
|
* Number of storage items required for ejection of the service.
|
|
20716
20842
|
*
|
|
@@ -20802,10 +20928,13 @@ class accumulate_externalities_AccumulateExternalities {
|
|
|
20802
20928
|
const isExpired = status.data[1] < t - this.chainSpec.preimageExpungePeriod;
|
|
20803
20929
|
return [isExpired, isExpired ? "" : "not expired"];
|
|
20804
20930
|
}
|
|
20805
|
-
/** `check`: https://graypaper.fluffylabs.dev/#/
|
|
20931
|
+
/** `check`: https://graypaper.fluffylabs.dev/#/ab2cdbd/30c60330c603?v=0.7.2 */
|
|
20806
20932
|
getNextAvailableServiceId(serviceId) {
|
|
20807
20933
|
let currentServiceId = serviceId;
|
|
20808
|
-
const mod =
|
|
20934
|
+
const mod = Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
|
|
20935
|
+
? 2 ** 32 - MIN_PUBLIC_SERVICE_INDEX - 2 ** 8
|
|
20936
|
+
: 2 ** 32 - 2 ** 9;
|
|
20937
|
+
const offset = Compatibility.isGreaterOrEqual(GpVersion.V0_7_1) ? MIN_PUBLIC_SERVICE_INDEX : 2 ** 8;
|
|
20809
20938
|
for (;;) {
|
|
20810
20939
|
const service = this.getServiceInfo(currentServiceId);
|
|
20811
20940
|
// we found an empty id
|
|
@@ -20813,7 +20942,7 @@ class accumulate_externalities_AccumulateExternalities {
|
|
|
20813
20942
|
return currentServiceId;
|
|
20814
20943
|
}
|
|
20815
20944
|
// keep trying
|
|
20816
|
-
currentServiceId = tryAsServiceId(((currentServiceId -
|
|
20945
|
+
currentServiceId = tryAsServiceId(((currentServiceId - offset + 1 + mod) % mod) + offset);
|
|
20817
20946
|
}
|
|
20818
20947
|
}
|
|
20819
20948
|
checkPreimageStatus(hash, length) {
|
|
@@ -20970,8 +21099,7 @@ class accumulate_externalities_AccumulateExternalities {
|
|
|
20970
21099
|
}));
|
|
20971
21100
|
return Result.ok(OK);
|
|
20972
21101
|
}
|
|
20973
|
-
newService(codeHash, codeLength, accumulateMinGas, onTransferMinGas, gratisStorage) {
|
|
20974
|
-
const newServiceId = this.nextNewServiceId;
|
|
21102
|
+
newService(codeHash, codeLength, accumulateMinGas, onTransferMinGas, gratisStorage, wantedServiceId) {
|
|
20975
21103
|
// calculate the threshold. Storage is empty, one preimage requested.
|
|
20976
21104
|
// https://graypaper.fluffylabs.dev/#/7e6ff6a/115901115901?v=0.6.7
|
|
20977
21105
|
const items = tryAsU32(2 * 1 + 0);
|
|
@@ -20992,30 +21120,59 @@ class accumulate_externalities_AccumulateExternalities {
|
|
|
20992
21120
|
if (balanceLeftForCurrent < thresholdForCurrent || bytes.overflow) {
|
|
20993
21121
|
return Result.error(NewServiceError.InsufficientFunds);
|
|
20994
21122
|
}
|
|
21123
|
+
// `a`: https://graypaper.fluffylabs.dev/#/ab2cdbd/366b02366d02?v=0.7.2
|
|
21124
|
+
const newAccount = ServiceAccountInfo.create({
|
|
21125
|
+
codeHash,
|
|
21126
|
+
balance: thresholdForNew,
|
|
21127
|
+
accumulateMinGas,
|
|
21128
|
+
onTransferMinGas,
|
|
21129
|
+
storageUtilisationBytes: bytes.value,
|
|
21130
|
+
storageUtilisationCount: items,
|
|
21131
|
+
gratisStorage,
|
|
21132
|
+
created: this.currentTimeslot,
|
|
21133
|
+
lastAccumulation: tryAsTimeSlot(0),
|
|
21134
|
+
parentService: this.currentServiceId,
|
|
21135
|
+
});
|
|
21136
|
+
const newLookupItem = new LookupHistoryItem(codeHash.asOpaque(), clampedLength, tryAsLookupHistorySlots([]));
|
|
21137
|
+
// `s`: https://graypaper.fluffylabs.dev/#/ab2cdbd/361003361003?v=0.7.2
|
|
21138
|
+
const updatedCurrentAccount = ServiceAccountInfo.create({
|
|
21139
|
+
...currentService,
|
|
21140
|
+
balance: tryAsU64(balanceLeftForCurrent),
|
|
21141
|
+
});
|
|
21142
|
+
if (Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)) {
|
|
21143
|
+
if (wantedServiceId < MIN_PUBLIC_SERVICE_INDEX &&
|
|
21144
|
+
this.currentServiceId === this.updatedState.getPrivilegedServices().registrar) {
|
|
21145
|
+
// NOTE: It's safe to cast to `Number` here, bcs here service ID cannot be bigger than 2**16
|
|
21146
|
+
const newServiceId = tryAsServiceId(Number(wantedServiceId));
|
|
21147
|
+
if (this.getServiceInfo(newServiceId) !== null) {
|
|
21148
|
+
return Result.error(NewServiceError.RegistrarServiceIdAlreadyTaken);
|
|
21149
|
+
}
|
|
21150
|
+
// add the new service with selected ID
|
|
21151
|
+
// https://graypaper.fluffylabs.dev/#/ab2cdbd/36be0336c003?v=0.7.2
|
|
21152
|
+
this.updatedState.stateUpdate.services.servicesUpdates.push(UpdateService.create({
|
|
21153
|
+
serviceId: newServiceId,
|
|
21154
|
+
serviceInfo: newAccount,
|
|
21155
|
+
lookupHistory: newLookupItem,
|
|
21156
|
+
}));
|
|
21157
|
+
// update the balance of current service
|
|
21158
|
+
// https://graypaper.fluffylabs.dev/#/ab2cdbd/36c20336c403?v=0.7.2
|
|
21159
|
+
this.updatedState.updateServiceInfo(this.currentServiceId, updatedCurrentAccount);
|
|
21160
|
+
return Result.ok(newServiceId);
|
|
21161
|
+
}
|
|
21162
|
+
// NOTE: in case the service is not a registrar or the requested serviceId is out of range,
|
|
21163
|
+
// we completely ignore the `wantedServiceId` and assign a random one
|
|
21164
|
+
}
|
|
21165
|
+
const newServiceId = this.nextNewServiceId;
|
|
20995
21166
|
// add the new service
|
|
20996
|
-
// https://graypaper.fluffylabs.dev/#/
|
|
21167
|
+
// https://graypaper.fluffylabs.dev/#/ab2cdbd/36e70336e903?v=0.7.2
|
|
20997
21168
|
this.updatedState.stateUpdate.services.servicesUpdates.push(UpdateService.create({
|
|
20998
21169
|
serviceId: newServiceId,
|
|
20999
|
-
serviceInfo:
|
|
21000
|
-
|
|
21001
|
-
balance: thresholdForNew,
|
|
21002
|
-
accumulateMinGas,
|
|
21003
|
-
onTransferMinGas,
|
|
21004
|
-
storageUtilisationBytes: bytes.value,
|
|
21005
|
-
storageUtilisationCount: items,
|
|
21006
|
-
gratisStorage,
|
|
21007
|
-
created: this.currentTimeslot,
|
|
21008
|
-
lastAccumulation: tryAsTimeSlot(0),
|
|
21009
|
-
parentService: this.currentServiceId,
|
|
21010
|
-
}),
|
|
21011
|
-
lookupHistory: new LookupHistoryItem(codeHash.asOpaque(), clampedLength, tryAsLookupHistorySlots([])),
|
|
21170
|
+
serviceInfo: newAccount,
|
|
21171
|
+
lookupHistory: newLookupItem,
|
|
21012
21172
|
}));
|
|
21013
21173
|
// update the balance of current service
|
|
21014
|
-
// https://graypaper.fluffylabs.dev/#/
|
|
21015
|
-
this.updatedState.updateServiceInfo(this.currentServiceId,
|
|
21016
|
-
...currentService,
|
|
21017
|
-
balance: tryAsU64(balanceLeftForCurrent),
|
|
21018
|
-
}));
|
|
21174
|
+
// https://graypaper.fluffylabs.dev/#/ab2cdbd/36ec0336ee03?v=0.7.2
|
|
21175
|
+
this.updatedState.updateServiceInfo(this.currentServiceId, updatedCurrentAccount);
|
|
21019
21176
|
// update the next service id we are going to create next
|
|
21020
21177
|
// https://graypaper.fluffylabs.dev/#/7e6ff6a/36a70336a703?v=0.6.7
|
|
21021
21178
|
this.nextNewServiceId = this.getNextAvailableServiceId(bumpServiceId(newServiceId));
|
|
@@ -21033,9 +21190,9 @@ class accumulate_externalities_AccumulateExternalities {
|
|
|
21033
21190
|
}
|
|
21034
21191
|
updateValidatorsData(validatorsData) {
|
|
21035
21192
|
/** https://graypaper.fluffylabs.dev/#/7e6ff6a/362802362d02?v=0.6.7 */
|
|
21036
|
-
const
|
|
21037
|
-
if (
|
|
21038
|
-
accumulate_externalities_logger.trace `Current service id (${this.currentServiceId}) is not a validators manager. (expected: ${
|
|
21193
|
+
const currentDelegator = this.updatedState.getPrivilegedServices().delegator;
|
|
21194
|
+
if (currentDelegator !== this.currentServiceId) {
|
|
21195
|
+
accumulate_externalities_logger.trace `Current service id (${this.currentServiceId}) is not a validators manager. (expected: ${currentDelegator}) and cannot update validators data. Ignoring`;
|
|
21039
21196
|
return Result.error(UnprivilegedError);
|
|
21040
21197
|
}
|
|
21041
21198
|
this.updatedState.stateUpdate.validatorsData = validatorsData;
|
|
@@ -21045,34 +21202,38 @@ class accumulate_externalities_AccumulateExternalities {
|
|
|
21045
21202
|
/** https://graypaper.fluffylabs.dev/#/9a08063/362202362202?v=0.6.6 */
|
|
21046
21203
|
this.checkpointedState = AccumulationStateUpdate.copyFrom(this.updatedState.stateUpdate);
|
|
21047
21204
|
}
|
|
21048
|
-
updateAuthorizationQueue(coreIndex, authQueue,
|
|
21205
|
+
updateAuthorizationQueue(coreIndex, authQueue, assigners) {
|
|
21049
21206
|
/** https://graypaper.fluffylabs.dev/#/7e6ff6a/36a40136a401?v=0.6.7 */
|
|
21050
21207
|
// NOTE `coreIndex` is already verified in the HC, so this is infallible.
|
|
21051
|
-
const
|
|
21052
|
-
if (
|
|
21053
|
-
accumulate_externalities_logger.trace `Current service id (${this.currentServiceId}) is not an auth manager of core ${coreIndex} (expected: ${
|
|
21208
|
+
const currentAssigners = this.updatedState.getPrivilegedServices().assigners[coreIndex];
|
|
21209
|
+
if (currentAssigners !== this.currentServiceId) {
|
|
21210
|
+
accumulate_externalities_logger.trace `Current service id (${this.currentServiceId}) is not an auth manager of core ${coreIndex} (expected: ${currentAssigners}) and cannot update authorization queue.`;
|
|
21054
21211
|
return Result.error(UpdatePrivilegesError.UnprivilegedService);
|
|
21055
21212
|
}
|
|
21056
|
-
if (
|
|
21057
|
-
accumulate_externalities_logger.trace `The new auth manager is not a valid service id
|
|
21213
|
+
if (assigners === null && Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)) {
|
|
21214
|
+
accumulate_externalities_logger.trace `The new auth manager is not a valid service id.`;
|
|
21058
21215
|
return Result.error(UpdatePrivilegesError.InvalidServiceId);
|
|
21059
21216
|
}
|
|
21060
21217
|
this.updatedState.stateUpdate.authorizationQueues.set(coreIndex, authQueue);
|
|
21061
21218
|
return Result.ok(OK);
|
|
21062
21219
|
}
|
|
21063
|
-
updatePrivilegedServices(manager, authorizers,
|
|
21220
|
+
updatePrivilegedServices(manager, authorizers, delegator, registrar, autoAccumulate) {
|
|
21064
21221
|
/** https://graypaper.fluffylabs.dev/#/7e6ff6a/36d90036de00?v=0.6.7 */
|
|
21065
21222
|
const currentManager = this.updatedState.getPrivilegedServices().manager;
|
|
21066
21223
|
if (currentManager !== this.currentServiceId) {
|
|
21067
21224
|
return Result.error(UpdatePrivilegesError.UnprivilegedService);
|
|
21068
21225
|
}
|
|
21069
|
-
if (manager === null ||
|
|
21070
|
-
return Result.error(UpdatePrivilegesError.InvalidServiceId);
|
|
21226
|
+
if (manager === null || delegator === null) {
|
|
21227
|
+
return Result.error(UpdatePrivilegesError.InvalidServiceId, "Either manager or delegator is not valid service id.");
|
|
21228
|
+
}
|
|
21229
|
+
if (Compatibility.isGreaterOrEqual(GpVersion.V0_7_1) && registrar === null) {
|
|
21230
|
+
return Result.error(UpdatePrivilegesError.InvalidServiceId, "Register manager is not valid service id.");
|
|
21071
21231
|
}
|
|
21072
21232
|
this.updatedState.stateUpdate.privilegedServices = PrivilegedServices.create({
|
|
21073
21233
|
manager,
|
|
21074
|
-
|
|
21075
|
-
|
|
21234
|
+
assigners: authorizers,
|
|
21235
|
+
delegator,
|
|
21236
|
+
registrar: registrar ?? tryAsServiceId(0), // introduced in 0.7.1
|
|
21076
21237
|
autoAccumulateServices: autoAccumulate.map(([service, gasLimit]) => AutoAccumulate.create({ service, gasLimit })),
|
|
21077
21238
|
});
|
|
21078
21239
|
return Result.ok(OK);
|
|
@@ -21188,8 +21349,11 @@ class accumulate_externalities_AccumulateExternalities {
|
|
|
21188
21349
|
}
|
|
21189
21350
|
}
|
|
21190
21351
|
function bumpServiceId(serviceId) {
|
|
21191
|
-
const mod =
|
|
21192
|
-
|
|
21352
|
+
const mod = Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
|
|
21353
|
+
? 2 ** 32 - MIN_PUBLIC_SERVICE_INDEX - 2 ** 8
|
|
21354
|
+
: 2 ** 32 - 2 ** 9;
|
|
21355
|
+
const offset = Compatibility.isGreaterOrEqual(GpVersion.V0_7_1) ? MIN_PUBLIC_SERVICE_INDEX : 2 ** 8;
|
|
21356
|
+
return tryAsServiceId(offset + ((serviceId - offset + 42 + mod) % mod));
|
|
21193
21357
|
}
|
|
21194
21358
|
|
|
21195
21359
|
;// CONCATENATED MODULE: ./packages/jam/transition/accumulate/operand.ts
|
|
@@ -21428,6 +21592,44 @@ function signingPayload(blake2b, anchor, blob) {
|
|
|
21428
21592
|
|
|
21429
21593
|
|
|
21430
21594
|
|
|
21595
|
+
var TransferOperandKind;
|
|
21596
|
+
(function (TransferOperandKind) {
|
|
21597
|
+
TransferOperandKind[TransferOperandKind["OPERAND"] = 0] = "OPERAND";
|
|
21598
|
+
TransferOperandKind[TransferOperandKind["TRANSFER"] = 1] = "TRANSFER";
|
|
21599
|
+
})(TransferOperandKind || (TransferOperandKind = {}));
|
|
21600
|
+
const TRANSFER_OR_OPERAND = descriptors_codec.custom({
|
|
21601
|
+
name: "TransferOrOperand",
|
|
21602
|
+
sizeHint: { bytes: 1, isExact: false },
|
|
21603
|
+
}, (e, x) => {
|
|
21604
|
+
e.varU32(numbers_tryAsU32(x.kind));
|
|
21605
|
+
if (x.kind === TransferOperandKind.OPERAND) {
|
|
21606
|
+
e.object(operand_Operand.Codec, x.value);
|
|
21607
|
+
}
|
|
21608
|
+
if (x.kind === TransferOperandKind.TRANSFER) {
|
|
21609
|
+
e.object(pending_transfer_PendingTransfer.Codec, x.value);
|
|
21610
|
+
}
|
|
21611
|
+
}, (d) => {
|
|
21612
|
+
const kind = d.varU32();
|
|
21613
|
+
if (kind === TransferOperandKind.OPERAND) {
|
|
21614
|
+
return {
|
|
21615
|
+
kind: TransferOperandKind.OPERAND,
|
|
21616
|
+
value: d.object(operand_Operand.Codec),
|
|
21617
|
+
};
|
|
21618
|
+
}
|
|
21619
|
+
if (kind === TransferOperandKind.TRANSFER) {
|
|
21620
|
+
return { kind: TransferOperandKind.TRANSFER, value: d.object(pending_transfer_PendingTransfer.Codec) };
|
|
21621
|
+
}
|
|
21622
|
+
throw new Error(`Unable to decode TransferOrOperand. Invalid kind: ${kind}.`);
|
|
21623
|
+
}, (s) => {
|
|
21624
|
+
const kind = s.decoder.varU32();
|
|
21625
|
+
if (kind === TransferOperandKind.OPERAND) {
|
|
21626
|
+
s.object(operand_Operand.Codec);
|
|
21627
|
+
}
|
|
21628
|
+
if (kind === TransferOperandKind.TRANSFER) {
|
|
21629
|
+
s.object(pending_transfer_PendingTransfer.Codec);
|
|
21630
|
+
}
|
|
21631
|
+
});
|
|
21632
|
+
const TRANSFERS_AND_OPERANDS = descriptors_codec.sequenceVarLen(TRANSFER_OR_OPERAND);
|
|
21431
21633
|
// https://github.com/gavofyork/graypaper/pull/414
|
|
21432
21634
|
// 0.7.0 encoding is used for prior versions as well.
|
|
21433
21635
|
const CONSTANTS_CODEC = descriptors_codec.object({
|
|
@@ -21512,7 +21714,10 @@ function getEncodedConstants(chainSpec) {
|
|
|
21512
21714
|
var FetchContext;
|
|
21513
21715
|
(function (FetchContext) {
|
|
21514
21716
|
FetchContext[FetchContext["Accumulate"] = 0] = "Accumulate";
|
|
21515
|
-
|
|
21717
|
+
/** @deprecated since 0.7.1 */
|
|
21718
|
+
FetchContext[FetchContext["LegacyAccumulate"] = 1] = "LegacyAccumulate";
|
|
21719
|
+
/** @deprecated since 0.7.1 */
|
|
21720
|
+
FetchContext[FetchContext["LegacyOnTransfer"] = 2] = "LegacyOnTransfer";
|
|
21516
21721
|
})(FetchContext || (FetchContext = {}));
|
|
21517
21722
|
class fetch_externalities_FetchExternalities {
|
|
21518
21723
|
fetchData;
|
|
@@ -21521,11 +21726,14 @@ class fetch_externalities_FetchExternalities {
|
|
|
21521
21726
|
this.fetchData = fetchData;
|
|
21522
21727
|
this.chainSpec = chainSpec;
|
|
21523
21728
|
}
|
|
21729
|
+
static createForPre071Accumulate(fetchData, chainSpec) {
|
|
21730
|
+
return new fetch_externalities_FetchExternalities({ context: FetchContext.LegacyAccumulate, ...fetchData }, chainSpec);
|
|
21731
|
+
}
|
|
21524
21732
|
static createForAccumulate(fetchData, chainSpec) {
|
|
21525
21733
|
return new fetch_externalities_FetchExternalities({ context: FetchContext.Accumulate, ...fetchData }, chainSpec);
|
|
21526
21734
|
}
|
|
21527
21735
|
static createForOnTransfer(fetchData, chainSpec) {
|
|
21528
|
-
return new fetch_externalities_FetchExternalities({ context: FetchContext.
|
|
21736
|
+
return new fetch_externalities_FetchExternalities({ context: FetchContext.LegacyOnTransfer, ...fetchData }, chainSpec);
|
|
21529
21737
|
}
|
|
21530
21738
|
constants() {
|
|
21531
21739
|
return getEncodedConstants(this.chainSpec);
|
|
@@ -21568,46 +21776,73 @@ class fetch_externalities_FetchExternalities {
|
|
|
21568
21776
|
return null;
|
|
21569
21777
|
}
|
|
21570
21778
|
allOperands() {
|
|
21571
|
-
if (this.fetchData.context
|
|
21572
|
-
|
|
21779
|
+
if (this.fetchData.context === FetchContext.LegacyAccumulate) {
|
|
21780
|
+
const operands = this.fetchData.operands;
|
|
21781
|
+
return Encoder.encodeObject(codec.sequenceVarLen(Operand.Codec), operands, this.chainSpec);
|
|
21573
21782
|
}
|
|
21574
|
-
|
|
21575
|
-
return Encoder.encodeObject(codec.sequenceVarLen(Operand.Codec), operands, this.chainSpec);
|
|
21783
|
+
return null;
|
|
21576
21784
|
}
|
|
21577
21785
|
oneOperand(operandIndex) {
|
|
21578
|
-
if (this.fetchData.context
|
|
21579
|
-
|
|
21580
|
-
|
|
21581
|
-
|
|
21582
|
-
|
|
21583
|
-
|
|
21584
|
-
|
|
21585
|
-
|
|
21586
|
-
|
|
21587
|
-
return
|
|
21786
|
+
if (this.fetchData.context === FetchContext.LegacyAccumulate) {
|
|
21787
|
+
const { operands } = this.fetchData;
|
|
21788
|
+
if (operandIndex >= 2n ** 32n) {
|
|
21789
|
+
return null;
|
|
21790
|
+
}
|
|
21791
|
+
const operand = operands[Number(operandIndex)];
|
|
21792
|
+
if (operand === undefined) {
|
|
21793
|
+
return null;
|
|
21794
|
+
}
|
|
21795
|
+
return Encoder.encodeObject(Operand.Codec, operand, this.chainSpec);
|
|
21588
21796
|
}
|
|
21589
|
-
return
|
|
21797
|
+
return null;
|
|
21590
21798
|
}
|
|
21591
21799
|
allTransfers() {
|
|
21592
|
-
if (this.fetchData.context
|
|
21593
|
-
|
|
21800
|
+
if (this.fetchData.context === FetchContext.LegacyOnTransfer) {
|
|
21801
|
+
const { transfers } = this.fetchData;
|
|
21802
|
+
return Encoder.encodeObject(codec.sequenceVarLen(PendingTransfer.Codec), transfers, this.chainSpec);
|
|
21594
21803
|
}
|
|
21595
|
-
|
|
21596
|
-
return Encoder.encodeObject(codec.sequenceVarLen(PendingTransfer.Codec), transfers, this.chainSpec);
|
|
21804
|
+
return null;
|
|
21597
21805
|
}
|
|
21598
21806
|
oneTransfer(transferIndex) {
|
|
21599
|
-
if (this.fetchData.context
|
|
21600
|
-
|
|
21807
|
+
if (this.fetchData.context === FetchContext.LegacyOnTransfer) {
|
|
21808
|
+
const { transfers } = this.fetchData;
|
|
21809
|
+
if (transferIndex >= 2n ** 32n) {
|
|
21810
|
+
return null;
|
|
21811
|
+
}
|
|
21812
|
+
const transfer = transfers[Number(transferIndex)];
|
|
21813
|
+
if (transfer === undefined) {
|
|
21814
|
+
return null;
|
|
21815
|
+
}
|
|
21816
|
+
return Encoder.encodeObject(PendingTransfer.Codec, transfer, this.chainSpec);
|
|
21601
21817
|
}
|
|
21602
|
-
|
|
21603
|
-
|
|
21604
|
-
|
|
21818
|
+
return null;
|
|
21819
|
+
}
|
|
21820
|
+
allTransfersAndOperands() {
|
|
21821
|
+
if (this.fetchData.context === FetchContext.Accumulate) {
|
|
21822
|
+
const { transfers, operands } = this.fetchData;
|
|
21823
|
+
const transfersAndOperands = transfers
|
|
21824
|
+
.map((transfer) => ({ kind: TransferOperandKind.TRANSFER, value: transfer }))
|
|
21825
|
+
.concat(operands.map((operand) => ({ kind: TransferOperandKind.OPERAND, value: operand })));
|
|
21826
|
+
return Encoder.encodeObject(TRANSFERS_AND_OPERANDS, transfersAndOperands, this.chainSpec);
|
|
21605
21827
|
}
|
|
21606
|
-
|
|
21607
|
-
|
|
21608
|
-
|
|
21828
|
+
return null;
|
|
21829
|
+
}
|
|
21830
|
+
oneTransferOrOperand(index) {
|
|
21831
|
+
if (this.fetchData.context === FetchContext.Accumulate) {
|
|
21832
|
+
const { operands, transfers } = this.fetchData;
|
|
21833
|
+
if (index >= operands.length + transfers.length) {
|
|
21834
|
+
return null;
|
|
21835
|
+
}
|
|
21836
|
+
const kind = index < operands.length ? TransferOperandKind.OPERAND : TransferOperandKind.TRANSFER;
|
|
21837
|
+
const transferOrOperand = kind === TransferOperandKind.OPERAND
|
|
21838
|
+
? { kind: TransferOperandKind.OPERAND, value: operands[Number(index)] }
|
|
21839
|
+
: { kind: TransferOperandKind.TRANSFER, value: transfers[Number(index) - operands.length] };
|
|
21840
|
+
if (transferOrOperand.value === undefined) {
|
|
21841
|
+
return null;
|
|
21842
|
+
}
|
|
21843
|
+
return Encoder.encodeObject(TRANSFER_OR_OPERAND, transferOrOperand, this.chainSpec);
|
|
21609
21844
|
}
|
|
21610
|
-
return
|
|
21845
|
+
return null;
|
|
21611
21846
|
}
|
|
21612
21847
|
}
|
|
21613
21848
|
|
|
@@ -21640,31 +21875,45 @@ class AccumulateDataItem {
|
|
|
21640
21875
|
*/
|
|
21641
21876
|
class accumulate_data_AccumulateData {
|
|
21642
21877
|
reportsDataByServiceId;
|
|
21878
|
+
transfersByServiceId;
|
|
21643
21879
|
autoAccumulateServicesByServiceId;
|
|
21644
21880
|
serviceIds;
|
|
21645
|
-
constructor(reports, autoAccumulateServices) {
|
|
21881
|
+
constructor(reports, transfers, autoAccumulateServices) {
|
|
21646
21882
|
const { autoAccumulateServicesByServiceId, serviceIds: serviceIdsFromAutoAccumulate } = this.transformAutoAccumulateServices(autoAccumulateServices);
|
|
21647
21883
|
this.autoAccumulateServicesByServiceId = autoAccumulateServicesByServiceId;
|
|
21648
21884
|
const { reportsDataByServiceId, serviceIds: serviceIdsFromReports } = this.transformReports(reports);
|
|
21649
21885
|
this.reportsDataByServiceId = reportsDataByServiceId;
|
|
21886
|
+
const { transfersByServiceId, serviceIds: serviceIdsFromTransfers } = this.transformTransfers(transfers);
|
|
21887
|
+
this.transfersByServiceId = transfersByServiceId;
|
|
21650
21888
|
/**
|
|
21651
|
-
* Merge service ids from reports
|
|
21889
|
+
* Merge service ids from reports, auto-accumulate services and transfers.
|
|
21652
21890
|
*
|
|
21653
21891
|
* https://graypaper.fluffylabs.dev/#/68eaa1f/175f01175f01?v=0.6.4
|
|
21654
21892
|
*/
|
|
21655
|
-
this.serviceIds = this.mergeServiceIds(serviceIdsFromReports, serviceIdsFromAutoAccumulate);
|
|
21893
|
+
this.serviceIds = this.mergeServiceIds(serviceIdsFromReports, serviceIdsFromAutoAccumulate, serviceIdsFromTransfers);
|
|
21656
21894
|
}
|
|
21657
21895
|
/** Merge two sets of service ids */
|
|
21658
|
-
mergeServiceIds(
|
|
21896
|
+
mergeServiceIds(...sources) {
|
|
21659
21897
|
const merged = new Set();
|
|
21660
|
-
for (const
|
|
21661
|
-
|
|
21662
|
-
|
|
21663
|
-
|
|
21664
|
-
merged.add(serviceId);
|
|
21898
|
+
for (const source of sources) {
|
|
21899
|
+
for (const serviceId of source) {
|
|
21900
|
+
merged.add(serviceId);
|
|
21901
|
+
}
|
|
21665
21902
|
}
|
|
21666
21903
|
return Array.from(merged);
|
|
21667
21904
|
}
|
|
21905
|
+
transformTransfers(transfersToTransform) {
|
|
21906
|
+
const transfersByServiceId = new Map();
|
|
21907
|
+
const serviceIds = new Set();
|
|
21908
|
+
for (const transfer of transfersToTransform) {
|
|
21909
|
+
const serviceId = transfer.destination;
|
|
21910
|
+
const transfers = transfersByServiceId.get(serviceId) ?? [];
|
|
21911
|
+
transfers.push(transfer);
|
|
21912
|
+
transfersByServiceId.set(serviceId, transfers);
|
|
21913
|
+
serviceIds.add(serviceId);
|
|
21914
|
+
}
|
|
21915
|
+
return { transfersByServiceId, serviceIds };
|
|
21916
|
+
}
|
|
21668
21917
|
/** Transform the list of auto-accumulate services into a map by service id. */
|
|
21669
21918
|
transformAutoAccumulateServices(autoAccumulateServices) {
|
|
21670
21919
|
const serviceIds = new Set();
|
|
@@ -21728,6 +21977,10 @@ class accumulate_data_AccumulateData {
|
|
|
21728
21977
|
getOperands(serviceId) {
|
|
21729
21978
|
return this.reportsDataByServiceId.get(serviceId)?.operands ?? [];
|
|
21730
21979
|
}
|
|
21980
|
+
/** Returns the list of transfers for a given service id */
|
|
21981
|
+
getTransfers(serviceId) {
|
|
21982
|
+
return this.transfersByServiceId.get(serviceId) ?? [];
|
|
21983
|
+
}
|
|
21731
21984
|
/** Returns the number of reports to acccumulate for a given service id */
|
|
21732
21985
|
getReportsLength(serviceId) {
|
|
21733
21986
|
return this.reportsDataByServiceId.get(serviceId)?.reportsLength ?? tryAsU32(0);
|
|
@@ -21752,6 +22005,8 @@ class accumulate_data_AccumulateData {
|
|
|
21752
22005
|
|
|
21753
22006
|
|
|
21754
22007
|
|
|
22008
|
+
|
|
22009
|
+
|
|
21755
22010
|
/**
|
|
21756
22011
|
* A function that removes duplicates but does not change order - it keeps the first occurence.
|
|
21757
22012
|
*/
|
|
@@ -21781,7 +22036,7 @@ const NEXT_ID_CODEC = descriptors_codec.object({
|
|
|
21781
22036
|
*
|
|
21782
22037
|
* Please not that it does not call `check` function!
|
|
21783
22038
|
*
|
|
21784
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
22039
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/2fa9042fc304?v=0.7.2
|
|
21785
22040
|
*/
|
|
21786
22041
|
function accumulate_utils_generateNextServiceId({ serviceId, entropy, timeslot }, chainSpec, blake2b) {
|
|
21787
22042
|
const encoded = Encoder.encodeObject(NEXT_ID_CODEC, {
|
|
@@ -21791,7 +22046,11 @@ function accumulate_utils_generateNextServiceId({ serviceId, entropy, timeslot }
|
|
|
21791
22046
|
}, chainSpec);
|
|
21792
22047
|
const result = blake2b.hashBytes(encoded).raw.subarray(0, 4);
|
|
21793
22048
|
const number = leBytesAsU32(result) >>> 0;
|
|
21794
|
-
|
|
22049
|
+
const mod = Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
|
|
22050
|
+
? 2 ** 32 - MIN_PUBLIC_SERVICE_INDEX - 2 ** 8
|
|
22051
|
+
: 2 ** 32 - 2 ** 9;
|
|
22052
|
+
const offset = Compatibility.isGreaterOrEqual(GpVersion.V0_7_1) ? MIN_PUBLIC_SERVICE_INDEX : 2 ** 8;
|
|
22053
|
+
return tryAsServiceId((number % mod) + offset);
|
|
21795
22054
|
}
|
|
21796
22055
|
|
|
21797
22056
|
;// CONCATENATED MODULE: ./packages/jam/transition/accumulate/accumulate-queue.ts
|
|
@@ -22203,7 +22462,7 @@ class Assign {
|
|
|
22203
22462
|
// o
|
|
22204
22463
|
const authorizationQueueStart = regs.get(8);
|
|
22205
22464
|
// a
|
|
22206
|
-
const
|
|
22465
|
+
const assigners = getServiceId(regs.get(9));
|
|
22207
22466
|
const res = safe_alloc_uint8array_safeAllocUint8Array(hash_HASH_SIZE * gp_constants_AUTHORIZATION_QUEUE_SIZE);
|
|
22208
22467
|
const memoryReadResult = memory.loadInto(res, authorizationQueueStart);
|
|
22209
22468
|
// error while reading the memory.
|
|
@@ -22220,7 +22479,7 @@ class Assign {
|
|
|
22220
22479
|
const decoder = decoder_Decoder.fromBlob(res);
|
|
22221
22480
|
const authQueue = decoder.sequenceFixLen(descriptors_codec.bytes(hash_HASH_SIZE), gp_constants_AUTHORIZATION_QUEUE_SIZE);
|
|
22222
22481
|
const fixedSizeAuthQueue = sized_array_FixedSizeArray.new(authQueue, gp_constants_AUTHORIZATION_QUEUE_SIZE);
|
|
22223
|
-
const result = this.partialState.updateAuthorizationQueue(coreIndex, fixedSizeAuthQueue,
|
|
22482
|
+
const result = this.partialState.updateAuthorizationQueue(coreIndex, fixedSizeAuthQueue, assigners);
|
|
22224
22483
|
if (result.isOk) {
|
|
22225
22484
|
regs.set(IN_OUT_REG, results_HostCallResult.OK);
|
|
22226
22485
|
logger_logger.trace `ASSIGN(${coreIndex}, ${fixedSizeAuthQueue}) <- OK`;
|
|
@@ -22269,7 +22528,9 @@ class Bless {
|
|
|
22269
22528
|
chainSpec;
|
|
22270
22529
|
index = host_call_handler_tryAsHostCallIndex(14);
|
|
22271
22530
|
basicGasCost = gas_tryAsSmallGas(10);
|
|
22272
|
-
tracedRegisters =
|
|
22531
|
+
tracedRegisters = compatibility_Compatibility.isGreaterOrEqual(compatibility_GpVersion.V0_7_1)
|
|
22532
|
+
? host_call_handler_traceRegisters(bless_IN_OUT_REG, 8, 9, 10, 11, 12)
|
|
22533
|
+
: host_call_handler_traceRegisters(bless_IN_OUT_REG, 8, 9, 10, 11);
|
|
22273
22534
|
constructor(currentServiceId, partialState, chainSpec) {
|
|
22274
22535
|
this.currentServiceId = currentServiceId;
|
|
22275
22536
|
this.partialState = partialState;
|
|
@@ -22279,14 +22540,17 @@ class Bless {
|
|
|
22279
22540
|
// `m`: manager service (can change privileged services)
|
|
22280
22541
|
const manager = getServiceId(regs.get(bless_IN_OUT_REG));
|
|
22281
22542
|
// `a`: manages authorization queue
|
|
22282
|
-
// NOTE It can be either ServiceId (pre GP 067) or memory index (GP ^067)
|
|
22283
22543
|
const authorization = regs.get(8);
|
|
22284
22544
|
// `v`: manages validator keys
|
|
22285
|
-
const
|
|
22545
|
+
const delegator = getServiceId(regs.get(9));
|
|
22546
|
+
// `r`: manages creation of new services with id within protected range
|
|
22547
|
+
const registrar = compatibility_Compatibility.isGreaterOrEqual(compatibility_GpVersion.V0_7_1)
|
|
22548
|
+
? getServiceId(regs.get(10))
|
|
22549
|
+
: common_tryAsServiceId(2 ** 32 - 1);
|
|
22286
22550
|
// `o`: memory offset
|
|
22287
|
-
const sourceStart = regs.get(10);
|
|
22551
|
+
const sourceStart = compatibility_Compatibility.isGreaterOrEqual(compatibility_GpVersion.V0_7_1) ? regs.get(11) : regs.get(10);
|
|
22288
22552
|
// `n`: number of items in the auto-accumulate dictionary
|
|
22289
|
-
const numberOfItems = regs.get(11);
|
|
22553
|
+
const numberOfItems = compatibility_Compatibility.isGreaterOrEqual(compatibility_GpVersion.V0_7_1) ? regs.get(12) : regs.get(11);
|
|
22290
22554
|
/*
|
|
22291
22555
|
* `z`: array of key-value pairs serviceId -> gas that auto-accumulate every block
|
|
22292
22556
|
* https://graypaper.fluffylabs.dev/#/7e6ff6a/368100368100?v=0.6.7
|
|
@@ -22300,7 +22564,7 @@ class Bless {
|
|
|
22300
22564
|
decoder.resetTo(0);
|
|
22301
22565
|
const memoryReadResult = memory.loadInto(result, memIndex);
|
|
22302
22566
|
if (memoryReadResult.isError) {
|
|
22303
|
-
logger_logger.trace `BLESS(${manager}, ${
|
|
22567
|
+
logger_logger.trace `BLESS(${manager}, ${delegator}, ${registrar}) <- PANIC`;
|
|
22304
22568
|
return host_call_handler_PvmExecution.Panic;
|
|
22305
22569
|
}
|
|
22306
22570
|
const { serviceId, gas } = decoder.object(serviceIdAndGasCodec);
|
|
@@ -22313,24 +22577,25 @@ class Bless {
|
|
|
22313
22577
|
const authorizersDecoder = decoder_Decoder.fromBlob(res);
|
|
22314
22578
|
const memoryReadResult = memory.loadInto(res, authorization);
|
|
22315
22579
|
if (memoryReadResult.isError) {
|
|
22316
|
-
logger_logger.trace `BLESS(${manager}, ${
|
|
22580
|
+
logger_logger.trace `BLESS(${manager}, ${delegator}, ${registrar}, ${autoAccumulateEntries}) <- PANIC`;
|
|
22317
22581
|
return host_call_handler_PvmExecution.Panic;
|
|
22318
22582
|
}
|
|
22583
|
+
// `a`
|
|
22319
22584
|
const authorizers = common_tryAsPerCore(authorizersDecoder.sequenceFixLen(descriptors_codec.u32.asOpaque(), this.chainSpec.coresCount), this.chainSpec);
|
|
22320
|
-
const updateResult = this.partialState.updatePrivilegedServices(manager, authorizers,
|
|
22585
|
+
const updateResult = this.partialState.updatePrivilegedServices(manager, authorizers, delegator, registrar, autoAccumulateEntries);
|
|
22321
22586
|
if (updateResult.isOk) {
|
|
22322
|
-
logger_logger.trace `BLESS(${manager}, ${authorizers}, ${
|
|
22587
|
+
logger_logger.trace `BLESS(${manager}, ${authorizers}, ${delegator}, ${registrar}, ${autoAccumulateEntries}) <- OK`;
|
|
22323
22588
|
regs.set(bless_IN_OUT_REG, results_HostCallResult.OK);
|
|
22324
22589
|
return;
|
|
22325
22590
|
}
|
|
22326
22591
|
const e = updateResult.error;
|
|
22327
22592
|
if (e === partial_state_UpdatePrivilegesError.UnprivilegedService) {
|
|
22328
|
-
logger_logger.trace `BLESS(${manager}, ${authorizers}, ${
|
|
22593
|
+
logger_logger.trace `BLESS(${manager}, ${authorizers}, ${delegator}, ${registrar}, ${autoAccumulateEntries}) <- HUH`;
|
|
22329
22594
|
regs.set(bless_IN_OUT_REG, results_HostCallResult.HUH);
|
|
22330
22595
|
return;
|
|
22331
22596
|
}
|
|
22332
22597
|
if (e === partial_state_UpdatePrivilegesError.InvalidServiceId) {
|
|
22333
|
-
logger_logger.trace `BLESS(${manager}, ${authorizers}, ${
|
|
22598
|
+
logger_logger.trace `BLESS(${manager}, ${authorizers}, ${delegator}, ${registrar}, ${autoAccumulateEntries}) <- WHO`;
|
|
22334
22599
|
regs.set(bless_IN_OUT_REG, results_HostCallResult.WHO);
|
|
22335
22600
|
return;
|
|
22336
22601
|
}
|
|
@@ -22582,7 +22847,9 @@ class New {
|
|
|
22582
22847
|
partialState;
|
|
22583
22848
|
index = host_call_handler_tryAsHostCallIndex(18);
|
|
22584
22849
|
basicGasCost = gas_tryAsSmallGas(10);
|
|
22585
|
-
tracedRegisters =
|
|
22850
|
+
tracedRegisters = compatibility_Compatibility.isGreaterOrEqual(compatibility_GpVersion.V0_7_1)
|
|
22851
|
+
? host_call_handler_traceRegisters(new_IN_OUT_REG, 8, 9, 10, 11, 12)
|
|
22852
|
+
: host_call_handler_traceRegisters(new_IN_OUT_REG, 8, 9, 10, 11);
|
|
22586
22853
|
constructor(currentServiceId, partialState) {
|
|
22587
22854
|
this.currentServiceId = currentServiceId;
|
|
22588
22855
|
this.partialState = partialState;
|
|
@@ -22598,16 +22865,18 @@ class New {
|
|
|
22598
22865
|
const allowance = common_tryAsServiceGas(regs.get(10));
|
|
22599
22866
|
// `f`
|
|
22600
22867
|
const gratisStorage = regs.get(11);
|
|
22868
|
+
// `i`: requested service id. Ignored if current service is not registrar or value is bigger than `S`.
|
|
22869
|
+
const requestedServiceId = regs.get(12);
|
|
22601
22870
|
// `c`
|
|
22602
22871
|
const codeHash = bytes_Bytes.zero(hash_HASH_SIZE);
|
|
22603
22872
|
const memoryReadResult = memory.loadInto(codeHash.raw, codeHashStart);
|
|
22604
22873
|
// error while reading the memory.
|
|
22605
22874
|
if (memoryReadResult.isError) {
|
|
22606
|
-
logger_logger.trace `NEW(${codeHash}, ${codeLength}, ${gas}, ${allowance}, ${gratisStorage}) <- PANIC`;
|
|
22875
|
+
logger_logger.trace `NEW(${codeHash}, ${codeLength}, ${gas}, ${allowance}, ${gratisStorage}, ${requestedServiceId}) <- PANIC`;
|
|
22607
22876
|
return host_call_handler_PvmExecution.Panic;
|
|
22608
22877
|
}
|
|
22609
|
-
const assignedId = this.partialState.newService(codeHash.asOpaque(), codeLength, gas, allowance, gratisStorage);
|
|
22610
|
-
logger_logger.trace `NEW(${codeHash}, ${codeLength}, ${gas}, ${allowance}, ${gratisStorage}) <- ${result_resultToString(assignedId)}`;
|
|
22878
|
+
const assignedId = this.partialState.newService(codeHash.asOpaque(), codeLength, gas, allowance, gratisStorage, requestedServiceId);
|
|
22879
|
+
logger_logger.trace `NEW(${codeHash}, ${codeLength}, ${gas}, ${allowance}, ${gratisStorage}, ${requestedServiceId}) <- ${result_resultToString(assignedId)}`;
|
|
22611
22880
|
if (assignedId.isOk) {
|
|
22612
22881
|
regs.set(new_IN_OUT_REG, numbers_tryAsU64(assignedId.ok));
|
|
22613
22882
|
return;
|
|
@@ -22621,6 +22890,11 @@ class New {
|
|
|
22621
22890
|
regs.set(new_IN_OUT_REG, results_HostCallResult.HUH);
|
|
22622
22891
|
return;
|
|
22623
22892
|
}
|
|
22893
|
+
// Post 0.7.1
|
|
22894
|
+
if (e === partial_state_NewServiceError.RegistrarServiceIdAlreadyTaken) {
|
|
22895
|
+
regs.set(new_IN_OUT_REG, results_HostCallResult.FULL);
|
|
22896
|
+
return;
|
|
22897
|
+
}
|
|
22624
22898
|
debug_assertNever(e);
|
|
22625
22899
|
}
|
|
22626
22900
|
}
|
|
@@ -22990,6 +23264,7 @@ class Yield {
|
|
|
22990
23264
|
|
|
22991
23265
|
|
|
22992
23266
|
|
|
23267
|
+
|
|
22993
23268
|
const fetch_IN_OUT_REG = 7;
|
|
22994
23269
|
/**
|
|
22995
23270
|
* https://graypaper.fluffylabs.dev/#/7e6ff6a/324000324000?v=0.6.7
|
|
@@ -23078,19 +23353,30 @@ class fetch_Fetch {
|
|
|
23078
23353
|
const workItem = regs.get(11);
|
|
23079
23354
|
return this.fetch.workItemPayload(workItem);
|
|
23080
23355
|
}
|
|
23081
|
-
if (
|
|
23082
|
-
|
|
23083
|
-
|
|
23084
|
-
|
|
23085
|
-
|
|
23086
|
-
|
|
23087
|
-
|
|
23088
|
-
|
|
23089
|
-
return this.fetch.allTransfers();
|
|
23356
|
+
if (Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)) {
|
|
23357
|
+
if (kind === FetchKind.AllTransfersAndOperands) {
|
|
23358
|
+
return this.fetch.allTransfersAndOperands();
|
|
23359
|
+
}
|
|
23360
|
+
if (kind === FetchKind.OneTransferOrOperand) {
|
|
23361
|
+
const index = regs.get(11);
|
|
23362
|
+
return this.fetch.oneTransferOrOperand(index);
|
|
23363
|
+
}
|
|
23090
23364
|
}
|
|
23091
|
-
|
|
23092
|
-
|
|
23093
|
-
|
|
23365
|
+
else {
|
|
23366
|
+
if (kind === FetchKind.LegacyAllOperands) {
|
|
23367
|
+
return this.fetch.allOperands();
|
|
23368
|
+
}
|
|
23369
|
+
if (kind === FetchKind.LegacyOneOperand) {
|
|
23370
|
+
const index = regs.get(11);
|
|
23371
|
+
return this.fetch.oneOperand(index);
|
|
23372
|
+
}
|
|
23373
|
+
if (kind === FetchKind.LegacyAllTransfers) {
|
|
23374
|
+
return this.fetch.allTransfers();
|
|
23375
|
+
}
|
|
23376
|
+
if (kind === FetchKind.LegacyOneTransfer) {
|
|
23377
|
+
const index = regs.get(11);
|
|
23378
|
+
return this.fetch.oneTransfer(index);
|
|
23379
|
+
}
|
|
23094
23380
|
}
|
|
23095
23381
|
return null;
|
|
23096
23382
|
}
|
|
@@ -23111,10 +23397,12 @@ var FetchKind;
|
|
|
23111
23397
|
FetchKind[FetchKind["AllWorkItems"] = 11] = "AllWorkItems";
|
|
23112
23398
|
FetchKind[FetchKind["OneWorkItem"] = 12] = "OneWorkItem";
|
|
23113
23399
|
FetchKind[FetchKind["WorkItemPayload"] = 13] = "WorkItemPayload";
|
|
23114
|
-
FetchKind[FetchKind["
|
|
23115
|
-
FetchKind[FetchKind["
|
|
23116
|
-
FetchKind[FetchKind["
|
|
23117
|
-
FetchKind[FetchKind["
|
|
23400
|
+
FetchKind[FetchKind["LegacyAllOperands"] = 14] = "LegacyAllOperands";
|
|
23401
|
+
FetchKind[FetchKind["AllTransfersAndOperands"] = 14] = "AllTransfersAndOperands";
|
|
23402
|
+
FetchKind[FetchKind["LegacyOneOperand"] = 15] = "LegacyOneOperand";
|
|
23403
|
+
FetchKind[FetchKind["OneTransferOrOperand"] = 15] = "OneTransferOrOperand";
|
|
23404
|
+
FetchKind[FetchKind["LegacyAllTransfers"] = 16] = "LegacyAllTransfers";
|
|
23405
|
+
FetchKind[FetchKind["LegacyOneTransfer"] = 17] = "LegacyOneTransfer";
|
|
23118
23406
|
})(FetchKind || (FetchKind = {}));
|
|
23119
23407
|
|
|
23120
23408
|
;// CONCATENATED MODULE: ./packages/jam/jam-host-calls/info.ts
|
|
@@ -23677,7 +23965,7 @@ const accumulate_logger = Logger.new(import.meta.filename, "accumulate");
|
|
|
23677
23965
|
const ARGS_CODEC = descriptors_codec.object({
|
|
23678
23966
|
slot: descriptors_codec.varU32.asOpaque(),
|
|
23679
23967
|
serviceId: descriptors_codec.varU32.asOpaque(),
|
|
23680
|
-
|
|
23968
|
+
argsLength: descriptors_codec.varU32,
|
|
23681
23969
|
});
|
|
23682
23970
|
class accumulate_Accumulate {
|
|
23683
23971
|
chainSpec;
|
|
@@ -23697,7 +23985,7 @@ class accumulate_Accumulate {
|
|
|
23697
23985
|
const reportsLength = reports.length;
|
|
23698
23986
|
let currentGas = 0n;
|
|
23699
23987
|
for (let i = 0; i < reportsLength; i++) {
|
|
23700
|
-
const report = reports
|
|
23988
|
+
const report = reports.get(i);
|
|
23701
23989
|
const resultsGas = report.results.map((result) => result.gas).reduce((a, b) => a + b, 0n);
|
|
23702
23990
|
if (currentGas + resultsGas > gasLimit) {
|
|
23703
23991
|
return i;
|
|
@@ -23711,7 +23999,7 @@ class accumulate_Accumulate {
|
|
|
23711
23999
|
*
|
|
23712
24000
|
* https://graypaper.fluffylabs.dev/#/7e6ff6a/2fdb012fdb01?v=0.6.7
|
|
23713
24001
|
*/
|
|
23714
|
-
async pvmAccumulateInvocation(slot, serviceId, operands, gas, entropy, inputStateUpdate) {
|
|
24002
|
+
async pvmAccumulateInvocation(slot, serviceId, transfers, operands, gas, entropy, inputStateUpdate) {
|
|
23715
24003
|
const service = this.state.getService(serviceId);
|
|
23716
24004
|
if (service === null) {
|
|
23717
24005
|
accumulate_logger.log `Service with id ${serviceId} not found.`;
|
|
@@ -23730,14 +24018,21 @@ class accumulate_Accumulate {
|
|
|
23730
24018
|
}
|
|
23731
24019
|
const nextServiceId = generateNextServiceId({ serviceId, entropy, timeslot: slot }, this.chainSpec, this.blake2b);
|
|
23732
24020
|
const partialState = new AccumulateExternalities(this.chainSpec, this.blake2b, new PartiallyUpdatedState(this.state, inputStateUpdate), serviceId, nextServiceId, slot);
|
|
24021
|
+
const fetchExternalities = Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
|
|
24022
|
+
? FetchExternalities.createForAccumulate({ entropy, transfers, operands }, this.chainSpec)
|
|
24023
|
+
: FetchExternalities.createForPre071Accumulate({ entropy, operands }, this.chainSpec);
|
|
23733
24024
|
const externalities = {
|
|
23734
24025
|
partialState,
|
|
23735
24026
|
serviceExternalities: partialState,
|
|
23736
|
-
fetchExternalities
|
|
24027
|
+
fetchExternalities,
|
|
23737
24028
|
};
|
|
23738
24029
|
const executor = PvmExecutor.createAccumulateExecutor(serviceId, code, externalities, this.chainSpec);
|
|
23739
|
-
const
|
|
23740
|
-
|
|
24030
|
+
const invocationArgs = Encoder.encodeObject(ARGS_CODEC, {
|
|
24031
|
+
slot,
|
|
24032
|
+
serviceId,
|
|
24033
|
+
argsLength: tryAsU32(transfers.length + operands.length),
|
|
24034
|
+
});
|
|
24035
|
+
const result = await executor.run(invocationArgs, tryAsGas(gas));
|
|
23741
24036
|
const [newState, checkpoint] = partialState.getStateUpdates();
|
|
23742
24037
|
/**
|
|
23743
24038
|
* PVM invocation returned and error so we return the checkpoint
|
|
@@ -23774,9 +24069,9 @@ class accumulate_Accumulate {
|
|
|
23774
24069
|
*
|
|
23775
24070
|
* https://graypaper.fluffylabs.dev/#/7e6ff6a/18d70118d701?v=0.6.7
|
|
23776
24071
|
*/
|
|
23777
|
-
async accumulateSingleService(serviceId, operands, gasCost, slot, entropy, inputStateUpdate) {
|
|
23778
|
-
accumulate_logger.log `Accumulating service ${serviceId},
|
|
23779
|
-
const result = await this.pvmAccumulateInvocation(slot, serviceId, operands, gasCost, entropy, inputStateUpdate);
|
|
24072
|
+
async accumulateSingleService(serviceId, transfers, operands, gasCost, slot, entropy, inputStateUpdate) {
|
|
24073
|
+
accumulate_logger.log `Accumulating service ${serviceId}, transfers: ${transfers.length} operands: ${operands.length} at slot: ${slot}.`;
|
|
24074
|
+
const result = await this.pvmAccumulateInvocation(slot, serviceId, transfers, operands, gasCost, entropy, inputStateUpdate);
|
|
23780
24075
|
if (result.isError) {
|
|
23781
24076
|
// https://graypaper.fluffylabs.dev/#/7e6ff6a/2fb6012fb601?v=0.6.7
|
|
23782
24077
|
accumulate_logger.log `Accumulation failed for ${serviceId}.`;
|
|
@@ -23793,7 +24088,7 @@ class accumulate_Accumulate {
|
|
|
23793
24088
|
*
|
|
23794
24089
|
* https://graypaper.fluffylabs.dev/#/7e6ff6a/179d00179d00?v=0.6.7
|
|
23795
24090
|
*/
|
|
23796
|
-
async
|
|
24091
|
+
async accumulateSequentiallyLegacy(gasLimit, reports, slot, entropy, statistics, stateUpdate, autoAccumulateServices) {
|
|
23797
24092
|
const i = this.findReportCutoffIndex(gasLimit, reports);
|
|
23798
24093
|
if (i === 0) {
|
|
23799
24094
|
return {
|
|
@@ -23802,14 +24097,46 @@ class accumulate_Accumulate {
|
|
|
23802
24097
|
state: stateUpdate,
|
|
23803
24098
|
};
|
|
23804
24099
|
}
|
|
23805
|
-
const reportsToAccumulateInParallel = reports.
|
|
23806
|
-
const
|
|
23807
|
-
const
|
|
23808
|
-
const
|
|
24100
|
+
const reportsToAccumulateInParallel = reports.subview(0, i);
|
|
24101
|
+
const accumulateData = new AccumulateData(reportsToAccumulateInParallel, [], autoAccumulateServices);
|
|
24102
|
+
const reportsToAccumulateSequentially = reports.subview(i);
|
|
24103
|
+
const { gasCost, state: stateAfterParallelAcc, ...rest } = await this.accumulateInParallel(accumulateData, slot, entropy, statistics, stateUpdate);
|
|
24104
|
+
assertEmpty(rest);
|
|
24105
|
+
// NOTE [ToDr] recursive invocation
|
|
24106
|
+
const { accumulatedReports, gasCost: seqGasCost, state, ...seqRest } = await this.accumulateSequentiallyLegacy(tryAsServiceGas(gasLimit - gasCost), reportsToAccumulateSequentially, slot, entropy, statistics, stateAfterParallelAcc, []);
|
|
24107
|
+
assertEmpty(seqRest);
|
|
24108
|
+
return {
|
|
24109
|
+
accumulatedReports: tryAsU32(i + accumulatedReports),
|
|
24110
|
+
gasCost: tryAsServiceGas(gasCost + seqGasCost),
|
|
24111
|
+
state,
|
|
24112
|
+
};
|
|
24113
|
+
}
|
|
24114
|
+
/**
|
|
24115
|
+
* The outer accumulation function ∆+ which transforms a gas-limit, a sequence of work-reports,
|
|
24116
|
+
* an initial partial-state and a dictionary of services enjoying free accumulation,
|
|
24117
|
+
* into a tuple of the number of work-results accumulated, a posterior state-context,
|
|
24118
|
+
* the resultant deferred-transfers and accumulation-output pairing.
|
|
24119
|
+
*
|
|
24120
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/172901172901?v=0.7.2
|
|
24121
|
+
*/
|
|
24122
|
+
async accumulateSequentially(gasLimit, reports, transfers, slot, entropy, statistics, stateUpdate, autoAccumulateServices) {
|
|
24123
|
+
const i = this.findReportCutoffIndex(gasLimit, reports);
|
|
24124
|
+
const n = transfers.length + i + reports.length;
|
|
24125
|
+
if (n === 0) {
|
|
24126
|
+
return {
|
|
24127
|
+
accumulatedReports: tryAsU32(0),
|
|
24128
|
+
gasCost: tryAsServiceGas(0),
|
|
24129
|
+
state: stateUpdate,
|
|
24130
|
+
};
|
|
24131
|
+
}
|
|
24132
|
+
const reportsToAccumulateInParallel = reports.subview(0, i);
|
|
24133
|
+
const accumulateData = new AccumulateData(reportsToAccumulateInParallel, transfers, autoAccumulateServices);
|
|
24134
|
+
const reportsToAccumulateSequentially = reports.subview(i);
|
|
23809
24135
|
const { gasCost, state: stateAfterParallelAcc, ...rest } = await this.accumulateInParallel(accumulateData, slot, entropy, statistics, stateUpdate);
|
|
24136
|
+
const newTransfers = stateAfterParallelAcc.transfers;
|
|
23810
24137
|
assertEmpty(rest);
|
|
23811
24138
|
// NOTE [ToDr] recursive invocation
|
|
23812
|
-
const { accumulatedReports, gasCost: seqGasCost, state, ...seqRest } = await this.accumulateSequentially(tryAsServiceGas(gasLimit - gasCost), reportsToAccumulateSequentially, slot, entropy, statistics, stateAfterParallelAcc);
|
|
24139
|
+
const { accumulatedReports, gasCost: seqGasCost, state, ...seqRest } = await this.accumulateSequentially(tryAsServiceGas(gasLimit - gasCost), reportsToAccumulateSequentially, newTransfers, slot, entropy, statistics, stateAfterParallelAcc, []);
|
|
23813
24140
|
assertEmpty(seqRest);
|
|
23814
24141
|
return {
|
|
23815
24142
|
accumulatedReports: tryAsU32(i + accumulatedReports),
|
|
@@ -23825,7 +24152,7 @@ class accumulate_Accumulate {
|
|
|
23825
24152
|
* into a tuple of the total gas utilized in pvm execution u, a posterior state-context
|
|
23826
24153
|
* and the resultant accumulation-output pairings b and deferred-transfers.
|
|
23827
24154
|
*
|
|
23828
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
24155
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/174602174602?v=0.7.2
|
|
23829
24156
|
*/
|
|
23830
24157
|
async accumulateInParallel(accumulateData, slot, entropy, statistics, inputStateUpdate) {
|
|
23831
24158
|
const serviceIds = accumulateData.getServiceIds();
|
|
@@ -23834,7 +24161,7 @@ class accumulate_Accumulate {
|
|
|
23834
24161
|
const currentManager = (inputStateUpdate.privilegedServices ?? this.state.privilegedServices).manager;
|
|
23835
24162
|
for (const serviceId of serviceIds) {
|
|
23836
24163
|
const checkpoint = AccumulationStateUpdate.copyFrom(currentState);
|
|
23837
|
-
const { consumedGas, stateUpdate } = await this.accumulateSingleService(serviceId, accumulateData.getOperands(serviceId), accumulateData.getGasCost(serviceId), slot, entropy, currentState);
|
|
24164
|
+
const { consumedGas, stateUpdate } = await this.accumulateSingleService(serviceId, accumulateData.getTransfers(serviceId), accumulateData.getOperands(serviceId), accumulateData.getGasCost(serviceId), slot, entropy, currentState);
|
|
23838
24165
|
gasCost = tryAsServiceGas(gasCost + consumedGas);
|
|
23839
24166
|
const serviceStatistics = statistics.get(serviceId) ?? { count: tryAsU32(0), gasUsed: tryAsServiceGas(0) };
|
|
23840
24167
|
serviceStatistics.count = tryAsU32(serviceStatistics.count + accumulateData.getReportsLength(serviceId));
|
|
@@ -23842,17 +24169,17 @@ class accumulate_Accumulate {
|
|
|
23842
24169
|
statistics.set(serviceId, serviceStatistics);
|
|
23843
24170
|
currentState = stateUpdate === null ? checkpoint : stateUpdate;
|
|
23844
24171
|
if (Compatibility.is(GpVersion.V0_7_0) && serviceId === currentManager) {
|
|
23845
|
-
const newV = currentState.privilegedServices?.
|
|
24172
|
+
const newV = currentState.privilegedServices?.delegator;
|
|
23846
24173
|
if (currentState.privilegedServices !== null && newV !== undefined && serviceIds.includes(newV)) {
|
|
23847
|
-
accumulate_logger.info `Entering completely incorrect code that probably reverts
|
|
24174
|
+
accumulate_logger.info `Entering completely incorrect code that probably reverts delegator change. This is valid in 0.7.0 only and incorrect in 0.7.1+`;
|
|
23848
24175
|
// Since serviceIds already contains newV, this service gets accumulated twice.
|
|
23849
24176
|
// To avoid double-counting, we skip stats and gas cost tracking here.
|
|
23850
|
-
// We need this accumulation to get the correct `
|
|
23851
|
-
const { stateUpdate } = await this.accumulateSingleService(newV, accumulateData.getOperands(newV), accumulateData.getGasCost(newV), slot, entropy, checkpoint);
|
|
23852
|
-
const correctV = stateUpdate?.privilegedServices?.
|
|
24177
|
+
// We need this accumulation to get the correct `delegator`
|
|
24178
|
+
const { stateUpdate } = await this.accumulateSingleService(newV, [], accumulateData.getOperands(newV), accumulateData.getGasCost(newV), slot, entropy, checkpoint);
|
|
24179
|
+
const correctV = stateUpdate?.privilegedServices?.delegator ?? this.state.privilegedServices.delegator;
|
|
23853
24180
|
currentState.privilegedServices = PrivilegedServices.create({
|
|
23854
24181
|
...currentState.privilegedServices,
|
|
23855
|
-
|
|
24182
|
+
delegator: correctV,
|
|
23856
24183
|
});
|
|
23857
24184
|
}
|
|
23858
24185
|
}
|
|
@@ -23908,7 +24235,7 @@ class accumulate_Accumulate {
|
|
|
23908
24235
|
*
|
|
23909
24236
|
* Please note it cannot overflow because we use `BigInt`, and the final result is clamped to `maxBlockGas` (W_G).
|
|
23910
24237
|
*
|
|
23911
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
24238
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/183402184502?v=0.7.2
|
|
23912
24239
|
*/
|
|
23913
24240
|
getGasLimit() {
|
|
23914
24241
|
const calculatedGasLimit = GAS_TO_INVOKE_WORK_REPORT * BigInt(this.chainSpec.coresCount) +
|
|
@@ -23916,6 +24243,20 @@ class accumulate_Accumulate {
|
|
|
23916
24243
|
const gasLimit = tryAsServiceGas(this.chainSpec.maxBlockGas > calculatedGasLimit ? this.chainSpec.maxBlockGas : calculatedGasLimit);
|
|
23917
24244
|
return tryAsServiceGas(gasLimit);
|
|
23918
24245
|
}
|
|
24246
|
+
hasDuplicatedServicesCreated(updateServices) {
|
|
24247
|
+
const createdServiceIds = new Set();
|
|
24248
|
+
for (const update of updateServices) {
|
|
24249
|
+
if (update.action.kind === UpdateServiceKind.Create) {
|
|
24250
|
+
const serviceId = update.serviceId;
|
|
24251
|
+
if (createdServiceIds.has(serviceId)) {
|
|
24252
|
+
accumulate_logger.log `Duplicated Service creation detected ${serviceId}. Block is invalid.`;
|
|
24253
|
+
return true;
|
|
24254
|
+
}
|
|
24255
|
+
createdServiceIds.add(serviceId);
|
|
24256
|
+
}
|
|
24257
|
+
}
|
|
24258
|
+
return false;
|
|
24259
|
+
}
|
|
23919
24260
|
async transition({ reports, slot, entropy }) {
|
|
23920
24261
|
const statistics = new Map();
|
|
23921
24262
|
const accumulateQueue = new AccumulateQueue(this.chainSpec, this.state);
|
|
@@ -23924,16 +24265,22 @@ class accumulate_Accumulate {
|
|
|
23924
24265
|
const queueFromState = accumulateQueue.getQueueFromState(slot);
|
|
23925
24266
|
const toEnqueue = pruneQueue(queueFromState.concat(toAccumulateLater), getWorkPackageHashes(toAccumulateImmediately));
|
|
23926
24267
|
const queue = accumulateQueue.enqueueReports(toEnqueue);
|
|
23927
|
-
const accumulatableReports = toAccumulateImmediately.concat(queue);
|
|
24268
|
+
const accumulatableReports = ArrayView.from(toAccumulateImmediately.concat(queue));
|
|
23928
24269
|
const gasLimit = this.getGasLimit();
|
|
23929
|
-
const
|
|
24270
|
+
const autoAccumulateServices = this.state.privilegedServices.autoAccumulateServices;
|
|
24271
|
+
const { accumulatedReports, gasCost, state, ...rest } = Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
|
|
24272
|
+
? await this.accumulateSequentially(gasLimit, accumulatableReports, [], slot, entropy, statistics, AccumulationStateUpdate.empty(), autoAccumulateServices)
|
|
24273
|
+
: await this.accumulateSequentiallyLegacy(gasLimit, accumulatableReports, slot, entropy, statistics, AccumulationStateUpdate.empty(), autoAccumulateServices);
|
|
23930
24274
|
// we can safely ignore top-level gas cost from accSequentially.
|
|
23931
24275
|
const _gasCost = gasCost;
|
|
23932
24276
|
assertEmpty(rest);
|
|
23933
|
-
const accumulated = accumulatableReports.
|
|
24277
|
+
const accumulated = accumulatableReports.subview(0, accumulatedReports);
|
|
23934
24278
|
const { services, yieldedRoots, transfers, validatorsData, privilegedServices, authorizationQueues, ...stateUpdateRest } = state;
|
|
23935
24279
|
assertEmpty(stateUpdateRest);
|
|
23936
|
-
|
|
24280
|
+
if (this.hasDuplicatedServicesCreated(services.servicesUpdates)) {
|
|
24281
|
+
return Result.error(ACCUMULATION_ERROR);
|
|
24282
|
+
}
|
|
24283
|
+
const accStateUpdate = this.getAccumulationStateUpdate(accumulated.toArray(), toAccumulateLater, slot, Array.from(statistics.keys()), services);
|
|
23937
24284
|
const accumulationOutputUnsorted = Array.from(yieldedRoots.entries()).map(([serviceId, root]) => {
|
|
23938
24285
|
return { serviceId, output: root.asOpaque() };
|
|
23939
24286
|
});
|
|
@@ -25565,18 +25912,24 @@ class chain_stf_OnChain {
|
|
|
25565
25912
|
}
|
|
25566
25913
|
const { stateUpdate: accumulateUpdate, accumulationStatistics, pendingTransfers, accumulationOutputLog, ...accumulateRest } = accumulateResult.ok;
|
|
25567
25914
|
assertEmpty(accumulateRest);
|
|
25568
|
-
const { privilegedServices: maybePrivilegedServices, authQueues: maybeAuthorizationQueues, designatedValidatorData: maybeDesignatedValidatorData, preimages: accumulatePreimages, accumulationQueue, recentlyAccumulated, ...
|
|
25569
|
-
|
|
25570
|
-
|
|
25571
|
-
|
|
25572
|
-
|
|
25573
|
-
|
|
25574
|
-
|
|
25575
|
-
|
|
25576
|
-
|
|
25915
|
+
const { privilegedServices: maybePrivilegedServices, authQueues: maybeAuthorizationQueues, designatedValidatorData: maybeDesignatedValidatorData, preimages: accumulatePreimages, accumulationQueue, recentlyAccumulated, ...servicesUpdateFromAccumulate } = accumulateUpdate;
|
|
25916
|
+
let transferStatistics = new Map();
|
|
25917
|
+
let servicesUpdate = { ...servicesUpdateFromAccumulate, preimages: accumulatePreimages };
|
|
25918
|
+
if (Compatibility.isLessThan(GpVersion.V0_7_1)) {
|
|
25919
|
+
const deferredTransfersResult = await this.deferredTransfers.transition({
|
|
25920
|
+
entropy: entropy[0],
|
|
25921
|
+
pendingTransfers,
|
|
25922
|
+
servicesUpdate,
|
|
25923
|
+
timeslot: timeSlot,
|
|
25924
|
+
});
|
|
25925
|
+
if (deferredTransfersResult.isError) {
|
|
25926
|
+
return stfError(StfErrorKind.DeferredTransfers, deferredTransfersResult);
|
|
25927
|
+
}
|
|
25928
|
+
const { servicesUpdate: servicesUpdateFromDeferredTransfers, transferStatistics: transferStatisticsFromDeferredTransfers, ...deferredTransfersRest } = deferredTransfersResult.ok;
|
|
25929
|
+
transferStatistics = transferStatisticsFromDeferredTransfers;
|
|
25930
|
+
servicesUpdate = servicesUpdateFromDeferredTransfers;
|
|
25931
|
+
assertEmpty(deferredTransfersRest);
|
|
25577
25932
|
}
|
|
25578
|
-
const { servicesUpdate: newServicesUpdate, transferStatistics, ...deferredTransfersRest } = deferredTransfersResult.ok;
|
|
25579
|
-
assertEmpty(deferredTransfersRest);
|
|
25580
25933
|
const accumulateRoot = await this.accumulateOutput.transition({ accumulationOutputLog });
|
|
25581
25934
|
// recent history
|
|
25582
25935
|
const recentHistoryUpdate = this.recentHistory.transition({
|
|
@@ -25626,7 +25979,7 @@ class chain_stf_OnChain {
|
|
|
25626
25979
|
accumulationQueue,
|
|
25627
25980
|
recentlyAccumulated,
|
|
25628
25981
|
accumulationOutputLog,
|
|
25629
|
-
...
|
|
25982
|
+
...servicesUpdate,
|
|
25630
25983
|
preimages: preimages.concat(accumulatePreimages),
|
|
25631
25984
|
});
|
|
25632
25985
|
}
|