@typeberry/jam 0.1.2-e085a64 → 0.1.2-ef67dce
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/bootstrap-generator.mjs +101 -69
- package/bootstrap-generator.mjs.map +1 -1
- package/bootstrap-importer.mjs +103 -71
- package/bootstrap-importer.mjs.map +1 -1
- package/bootstrap-network.mjs +81 -61
- package/bootstrap-network.mjs.map +1 -1
- package/index.js +136 -130
- package/index.js.map +1 -1
- package/package.json +1 -1
package/bootstrap-generator.mjs
CHANGED
|
@@ -7970,6 +7970,45 @@ const assurancesExtrinsicCodec = codecWithContext((context) => {
|
|
|
7970
7970
|
}, AssurancesExtrinsicBounds);
|
|
7971
7971
|
});
|
|
7972
7972
|
|
|
7973
|
+
;// CONCATENATED MODULE: ./packages/jam/block/common.ts
|
|
7974
|
+
|
|
7975
|
+
|
|
7976
|
+
|
|
7977
|
+
|
|
7978
|
+
/** Attempt to convert a number into `TimeSlot`. */
|
|
7979
|
+
const common_tryAsTimeSlot = (v) => opaque_asOpaqueType(numbers_tryAsU32(v));
|
|
7980
|
+
/** Attempt to convert a number into `ValidatorIndex`. */
|
|
7981
|
+
const tryAsValidatorIndex = (v) => opaque_asOpaqueType(numbers_tryAsU16(v));
|
|
7982
|
+
/** Attempt to convert a number into `ServiceId`. */
|
|
7983
|
+
const common_tryAsServiceId = (v) => opaque_asOpaqueType(numbers_tryAsU32(v));
|
|
7984
|
+
const common_tryAsServiceGas = (v) => opaque_asOpaqueType(numbers_tryAsU64(v));
|
|
7985
|
+
/** Attempt to convert a number into `CoreIndex`. */
|
|
7986
|
+
const common_tryAsCoreIndex = (v) => opaque_asOpaqueType(numbers_tryAsU16(v));
|
|
7987
|
+
/** Attempt to convert a number into `Epoch`. */
|
|
7988
|
+
const tryAsEpoch = (v) => asOpaqueType(tryAsU32(v));
|
|
7989
|
+
function tryAsPerValidator(array, spec) {
|
|
7990
|
+
debug_check `
|
|
7991
|
+
${array.length === spec.validatorsCount}
|
|
7992
|
+
Invalid per-validator array length. Expected ${spec.validatorsCount}, got: ${array.length}
|
|
7993
|
+
`;
|
|
7994
|
+
return sized_array_asKnownSize(array);
|
|
7995
|
+
}
|
|
7996
|
+
const codecPerValidator = (val) => codecWithContext((context) => {
|
|
7997
|
+
return codecKnownSizeArray(val, {
|
|
7998
|
+
fixedLength: context.validatorsCount,
|
|
7999
|
+
});
|
|
8000
|
+
});
|
|
8001
|
+
function tryAsPerEpochBlock(array, spec) {
|
|
8002
|
+
debug_check `
|
|
8003
|
+
${array.length === spec.epochLength}
|
|
8004
|
+
Invalid per-epoch-block array length. Expected ${spec.epochLength}, got: ${array.length}
|
|
8005
|
+
`;
|
|
8006
|
+
return sized_array_asKnownSize(array);
|
|
8007
|
+
}
|
|
8008
|
+
const codecPerEpochBlock = (val) => codecWithContext((context) => {
|
|
8009
|
+
return codecKnownSizeArray(val, { fixedLength: context.epochLength });
|
|
8010
|
+
});
|
|
8011
|
+
|
|
7973
8012
|
;// CONCATENATED MODULE: ./packages/jam/block/disputes.ts
|
|
7974
8013
|
|
|
7975
8014
|
|
|
@@ -8159,45 +8198,6 @@ class DisputesExtrinsic extends WithDebug {
|
|
|
8159
8198
|
}
|
|
8160
8199
|
}
|
|
8161
8200
|
|
|
8162
|
-
;// CONCATENATED MODULE: ./packages/jam/block/common.ts
|
|
8163
|
-
|
|
8164
|
-
|
|
8165
|
-
|
|
8166
|
-
|
|
8167
|
-
/** Attempt to convert a number into `TimeSlot`. */
|
|
8168
|
-
const tryAsTimeSlot = (v) => opaque_asOpaqueType(numbers_tryAsU32(v));
|
|
8169
|
-
/** Attempt to convert a number into `ValidatorIndex`. */
|
|
8170
|
-
const tryAsValidatorIndex = (v) => opaque_asOpaqueType(numbers_tryAsU16(v));
|
|
8171
|
-
/** Attempt to convert a number into `ServiceId`. */
|
|
8172
|
-
const common_tryAsServiceId = (v) => opaque_asOpaqueType(numbers_tryAsU32(v));
|
|
8173
|
-
const common_tryAsServiceGas = (v) => opaque_asOpaqueType(numbers_tryAsU64(v));
|
|
8174
|
-
/** Attempt to convert a number into `CoreIndex`. */
|
|
8175
|
-
const common_tryAsCoreIndex = (v) => opaque_asOpaqueType(numbers_tryAsU16(v));
|
|
8176
|
-
/** Attempt to convert a number into `Epoch`. */
|
|
8177
|
-
const tryAsEpoch = (v) => asOpaqueType(tryAsU32(v));
|
|
8178
|
-
function tryAsPerValidator(array, spec) {
|
|
8179
|
-
debug_check `
|
|
8180
|
-
${array.length === spec.validatorsCount}
|
|
8181
|
-
Invalid per-validator array length. Expected ${spec.validatorsCount}, got: ${array.length}
|
|
8182
|
-
`;
|
|
8183
|
-
return sized_array_asKnownSize(array);
|
|
8184
|
-
}
|
|
8185
|
-
const codecPerValidator = (val) => codecWithContext((context) => {
|
|
8186
|
-
return codecKnownSizeArray(val, {
|
|
8187
|
-
fixedLength: context.validatorsCount,
|
|
8188
|
-
});
|
|
8189
|
-
});
|
|
8190
|
-
function tryAsPerEpochBlock(array, spec) {
|
|
8191
|
-
debug_check `
|
|
8192
|
-
${array.length === spec.epochLength}
|
|
8193
|
-
Invalid per-epoch-block array length. Expected ${spec.epochLength}, got: ${array.length}
|
|
8194
|
-
`;
|
|
8195
|
-
return sized_array_asKnownSize(array);
|
|
8196
|
-
}
|
|
8197
|
-
const codecPerEpochBlock = (val) => codecWithContext((context) => {
|
|
8198
|
-
return codecKnownSizeArray(val, { fixedLength: context.epochLength });
|
|
8199
|
-
});
|
|
8200
|
-
|
|
8201
8201
|
;// CONCATENATED MODULE: ./packages/jam/block/refine-context.ts
|
|
8202
8202
|
|
|
8203
8203
|
|
|
@@ -9096,8 +9096,8 @@ const legacyDescriptor = {
|
|
|
9096
9096
|
*
|
|
9097
9097
|
* https://graypaper.fluffylabs.dev/#/579bd12/0c66000c7200
|
|
9098
9098
|
*/
|
|
9099
|
-
class
|
|
9100
|
-
static Codec = descriptors_codec.Class(
|
|
9099
|
+
class header_Header extends WithDebug {
|
|
9100
|
+
static Codec = descriptors_codec.Class(header_Header, Compatibility.isLessThan(GpVersion.V0_7_0)
|
|
9101
9101
|
? legacyDescriptor
|
|
9102
9102
|
: {
|
|
9103
9103
|
parentHeaderHash: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
@@ -9112,7 +9112,7 @@ class Header extends WithDebug {
|
|
|
9112
9112
|
seal: descriptors_codec.bytes(bandersnatch_BANDERSNATCH_VRF_SIGNATURE_BYTES).asOpaque(),
|
|
9113
9113
|
});
|
|
9114
9114
|
static create(h) {
|
|
9115
|
-
return Object.assign(
|
|
9115
|
+
return Object.assign(header_Header.empty(), h);
|
|
9116
9116
|
}
|
|
9117
9117
|
/**
|
|
9118
9118
|
* `H_p`: Hash of the parent header.
|
|
@@ -9125,7 +9125,7 @@ class Header extends WithDebug {
|
|
|
9125
9125
|
/** `H_x`: The hash of block extrinsic. */
|
|
9126
9126
|
extrinsicHash = bytes_Bytes.zero(hash_HASH_SIZE).asOpaque();
|
|
9127
9127
|
/** `H_t`: JAM time-slot index. */
|
|
9128
|
-
timeSlotIndex =
|
|
9128
|
+
timeSlotIndex = common_tryAsTimeSlot(0);
|
|
9129
9129
|
/**
|
|
9130
9130
|
* `H_e`: Key and entropy relevant to the following epoch in case the ticket
|
|
9131
9131
|
* contest does not complete adequately.
|
|
@@ -9153,7 +9153,7 @@ class Header extends WithDebug {
|
|
|
9153
9153
|
}
|
|
9154
9154
|
/** Create an empty header with some dummy values. */
|
|
9155
9155
|
static empty() {
|
|
9156
|
-
return new
|
|
9156
|
+
return new header_Header();
|
|
9157
9157
|
}
|
|
9158
9158
|
}
|
|
9159
9159
|
/**
|
|
@@ -9166,7 +9166,7 @@ class Header extends WithDebug {
|
|
|
9166
9166
|
class HeaderViewWithHash extends WithHash {
|
|
9167
9167
|
static Codec = descriptors_codec.Class(HeaderViewWithHash, {
|
|
9168
9168
|
hash: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
9169
|
-
data:
|
|
9169
|
+
data: header_Header.Codec.View,
|
|
9170
9170
|
});
|
|
9171
9171
|
static create({ hash, data }) {
|
|
9172
9172
|
return new WithHash(hash, data);
|
|
@@ -9214,6 +9214,8 @@ const preimagesExtrinsicCodec = descriptors_codec.sequenceVarLen(Preimage.Codec)
|
|
|
9214
9214
|
|
|
9215
9215
|
|
|
9216
9216
|
|
|
9217
|
+
|
|
9218
|
+
|
|
9217
9219
|
/**
|
|
9218
9220
|
* Extrinsic part of the block - the input data being external to the system.
|
|
9219
9221
|
*
|
|
@@ -9281,7 +9283,7 @@ class Block extends WithDebug {
|
|
|
9281
9283
|
header;
|
|
9282
9284
|
extrinsic;
|
|
9283
9285
|
static Codec = descriptors_codec.Class(Block, {
|
|
9284
|
-
header:
|
|
9286
|
+
header: header_Header.Codec,
|
|
9285
9287
|
extrinsic: Extrinsic.Codec,
|
|
9286
9288
|
});
|
|
9287
9289
|
static create({ header, extrinsic }) {
|
|
@@ -9297,6 +9299,24 @@ class Block extends WithDebug {
|
|
|
9297
9299
|
this.extrinsic = extrinsic;
|
|
9298
9300
|
}
|
|
9299
9301
|
}
|
|
9302
|
+
function emptyBlock(slot = tryAsTimeSlot(0)) {
|
|
9303
|
+
const header = Header.empty();
|
|
9304
|
+
header.timeSlotIndex = slot;
|
|
9305
|
+
return Block.create({
|
|
9306
|
+
header,
|
|
9307
|
+
extrinsic: Extrinsic.create({
|
|
9308
|
+
tickets: asKnownSize([]),
|
|
9309
|
+
preimages: [],
|
|
9310
|
+
assurances: asKnownSize([]),
|
|
9311
|
+
guarantees: asKnownSize([]),
|
|
9312
|
+
disputes: {
|
|
9313
|
+
verdicts: [],
|
|
9314
|
+
culprits: [],
|
|
9315
|
+
faults: [],
|
|
9316
|
+
},
|
|
9317
|
+
}),
|
|
9318
|
+
});
|
|
9319
|
+
}
|
|
9300
9320
|
|
|
9301
9321
|
;// CONCATENATED MODULE: ./packages/jam/block/index.ts
|
|
9302
9322
|
|
|
@@ -9378,7 +9398,7 @@ class LmdbBlocks {
|
|
|
9378
9398
|
if (data === undefined) {
|
|
9379
9399
|
return null;
|
|
9380
9400
|
}
|
|
9381
|
-
return decoder_Decoder.decodeObject(
|
|
9401
|
+
return decoder_Decoder.decodeObject(header_Header.Codec.View, data, this.chainSpec);
|
|
9382
9402
|
}
|
|
9383
9403
|
getExtrinsic(hash) {
|
|
9384
9404
|
const data = this.extrinsics.get(hash.raw);
|
|
@@ -10220,8 +10240,8 @@ class ServiceAccountInfo extends WithDebug {
|
|
|
10220
10240
|
storageUtilisationBytes: descriptors_codec.u64,
|
|
10221
10241
|
gratisStorage: descriptors_codec.u64,
|
|
10222
10242
|
storageUtilisationCount: descriptors_codec.u32,
|
|
10223
|
-
created: descriptors_codec.u32.convert((x) => x,
|
|
10224
|
-
lastAccumulation: descriptors_codec.u32.convert((x) => x,
|
|
10243
|
+
created: descriptors_codec.u32.convert((x) => x, common_tryAsTimeSlot),
|
|
10244
|
+
lastAccumulation: descriptors_codec.u32.convert((x) => x, common_tryAsTimeSlot),
|
|
10225
10245
|
parentService: descriptors_codec.u32.convert((x) => x, common_tryAsServiceId),
|
|
10226
10246
|
});
|
|
10227
10247
|
static create(a) {
|
|
@@ -11159,7 +11179,7 @@ class InMemoryState extends WithDebug {
|
|
|
11159
11179
|
wonkySet: SortedSet.fromSortedArray(hashComparator, []),
|
|
11160
11180
|
punishSet: SortedSet.fromSortedArray(hashComparator, []),
|
|
11161
11181
|
}),
|
|
11162
|
-
timeslot:
|
|
11182
|
+
timeslot: common_tryAsTimeSlot(0),
|
|
11163
11183
|
entropy: sized_array_FixedSizeArray.fill(() => bytes_Bytes.zero(hash_HASH_SIZE).asOpaque(), ENTROPY_ENTRIES),
|
|
11164
11184
|
authPools: tryAsPerCore(Array.from({ length: spec.coresCount }, () => sized_array_asKnownSize([])), spec),
|
|
11165
11185
|
authQueues: tryAsPerCore(Array.from({ length: spec.coresCount }, () => sized_array_FixedSizeArray.fill(() => bytes_Bytes.zero(hash_HASH_SIZE).asOpaque(), AUTHORIZATION_QUEUE_SIZE)), spec),
|
|
@@ -11590,7 +11610,7 @@ class SerializedService {
|
|
|
11590
11610
|
if (rawSlots === undefined) {
|
|
11591
11611
|
return null;
|
|
11592
11612
|
}
|
|
11593
|
-
return tryAsLookupHistorySlots(rawSlots.map(
|
|
11613
|
+
return tryAsLookupHistorySlots(rawSlots.map(common_tryAsTimeSlot));
|
|
11594
11614
|
}
|
|
11595
11615
|
}
|
|
11596
11616
|
|
|
@@ -12987,8 +13007,8 @@ function print(level, levelAndName, strings, data) {
|
|
|
12987
13007
|
return;
|
|
12988
13008
|
}
|
|
12989
13009
|
const lvlText = Level[level].padEnd(5);
|
|
12990
|
-
const val = strings.map((v, idx) => `${v}${data[idx]}`);
|
|
12991
|
-
const msg = `${lvlText} [${levelAndName[1]}] ${val}`;
|
|
13010
|
+
const val = strings.map((v, idx) => `${v}${idx < data.length ? data[idx] : ""}`);
|
|
13011
|
+
const msg = `${lvlText} [${levelAndName[1]}] ${val.join("")}`;
|
|
12992
13012
|
if (level === Level.WARN) {
|
|
12993
13013
|
console.warn(msg);
|
|
12994
13014
|
}
|
|
@@ -13959,7 +13979,7 @@ class State {
|
|
|
13959
13979
|
|
|
13960
13980
|
|
|
13961
13981
|
|
|
13962
|
-
;// CONCATENATED MODULE: ./workers/generic/finished.ts
|
|
13982
|
+
;// CONCATENATED MODULE: ./packages/workers/generic/finished.ts
|
|
13963
13983
|
|
|
13964
13984
|
class Finished extends State {
|
|
13965
13985
|
constructor() {
|
|
@@ -13975,7 +13995,7 @@ class Finished extends State {
|
|
|
13975
13995
|
}
|
|
13976
13996
|
}
|
|
13977
13997
|
|
|
13978
|
-
;// CONCATENATED MODULE: ./workers/generic/main-init.ts
|
|
13998
|
+
;// CONCATENATED MODULE: ./packages/workers/generic/main-init.ts
|
|
13979
13999
|
|
|
13980
14000
|
|
|
13981
14001
|
function stateMachineMain(name, readyName, ready) {
|
|
@@ -13998,7 +14018,7 @@ class MainInit extends State {
|
|
|
13998
14018
|
}
|
|
13999
14019
|
}
|
|
14000
14020
|
|
|
14001
|
-
;// CONCATENATED MODULE: ./workers/generic/worker-init.ts
|
|
14021
|
+
;// CONCATENATED MODULE: ./packages/workers/generic/worker-init.ts
|
|
14002
14022
|
|
|
14003
14023
|
class WorkerInit extends State {
|
|
14004
14024
|
workerReadyName;
|
|
@@ -14020,7 +14040,7 @@ class WorkerInit extends State {
|
|
|
14020
14040
|
}
|
|
14021
14041
|
}
|
|
14022
14042
|
|
|
14023
|
-
;// CONCATENATED MODULE: ./workers/generic/worker-spawn.ts
|
|
14043
|
+
;// CONCATENATED MODULE: ./packages/workers/generic/worker-spawn.ts
|
|
14024
14044
|
|
|
14025
14045
|
|
|
14026
14046
|
|
|
@@ -14032,7 +14052,7 @@ async function spawnWorkerGeneric(bootstrapPath, logger, mainReadyName, mainRead
|
|
|
14032
14052
|
return channel;
|
|
14033
14053
|
}
|
|
14034
14054
|
|
|
14035
|
-
;// CONCATENATED MODULE: ./workers/generic/index.ts
|
|
14055
|
+
;// CONCATENATED MODULE: ./packages/workers/generic/index.ts
|
|
14036
14056
|
|
|
14037
14057
|
|
|
14038
14058
|
|
|
@@ -15478,6 +15498,17 @@ class page_range_PageRange {
|
|
|
15478
15498
|
}
|
|
15479
15499
|
return new page_range_PageRange(start, length);
|
|
15480
15500
|
}
|
|
15501
|
+
/** Returns true if the page range is wrapped (`start` >= `end`) and is not empty */
|
|
15502
|
+
isWrapped() {
|
|
15503
|
+
return this.start >= this.end && !this.isEmpty();
|
|
15504
|
+
}
|
|
15505
|
+
/** Checks if given page number is within the range */
|
|
15506
|
+
isInRange(page) {
|
|
15507
|
+
if (this.isWrapped()) {
|
|
15508
|
+
return page >= this.start || page < this.end;
|
|
15509
|
+
}
|
|
15510
|
+
return page >= this.start && page < this.end;
|
|
15511
|
+
}
|
|
15481
15512
|
/** Checks if a range is empty (`length === 0`) */
|
|
15482
15513
|
isEmpty() {
|
|
15483
15514
|
return this.length === 0;
|
|
@@ -15857,10 +15888,11 @@ class memory_builder_MemoryBuilder {
|
|
|
15857
15888
|
startHeapIndex (${startHeapIndex}) has to be less than or equal to endHeapIndex (${endHeapIndex})
|
|
15858
15889
|
`;
|
|
15859
15890
|
this.ensureNotFinalized();
|
|
15860
|
-
const
|
|
15861
|
-
const
|
|
15862
|
-
|
|
15863
|
-
|
|
15891
|
+
const heapRange = MemoryRange.fromStartAndLength(startHeapIndex, endHeapIndex - startHeapIndex);
|
|
15892
|
+
const heapPagesRange = PageRange.fromMemoryRange(heapRange);
|
|
15893
|
+
const initializedPageNumbers = Array.from(this.initialMemory.keys());
|
|
15894
|
+
for (const pageNumber of initializedPageNumbers) {
|
|
15895
|
+
if (heapPagesRange.isInRange(pageNumber)) {
|
|
15864
15896
|
throw new IncorrectSbrkIndex();
|
|
15865
15897
|
}
|
|
15866
15898
|
}
|
|
@@ -18377,7 +18409,7 @@ class PvmExecutor {
|
|
|
18377
18409
|
|
|
18378
18410
|
|
|
18379
18411
|
|
|
18380
|
-
;// CONCATENATED MODULE: ./workers/block-generator/generator.ts
|
|
18412
|
+
;// CONCATENATED MODULE: ./packages/workers/block-generator/generator.ts
|
|
18381
18413
|
|
|
18382
18414
|
|
|
18383
18415
|
|
|
@@ -18468,11 +18500,11 @@ class Generator {
|
|
|
18468
18500
|
e.i32(newTimeSlot);
|
|
18469
18501
|
e.i16(validatorId);
|
|
18470
18502
|
// create header
|
|
18471
|
-
const header =
|
|
18503
|
+
const header = header_Header.create({
|
|
18472
18504
|
parentHeaderHash,
|
|
18473
18505
|
priorStateRoot: await stateRoot,
|
|
18474
18506
|
extrinsicHash,
|
|
18475
|
-
timeSlotIndex:
|
|
18507
|
+
timeSlotIndex: common_tryAsTimeSlot(newTimeSlot),
|
|
18476
18508
|
epochMarker: null,
|
|
18477
18509
|
ticketsMarker: null,
|
|
18478
18510
|
offendersMarker: [],
|
|
@@ -18483,15 +18515,15 @@ class Generator {
|
|
|
18483
18515
|
// TODO [MaSo] IDK if this is ok to update it here.
|
|
18484
18516
|
// This function utility is to create a block
|
|
18485
18517
|
// not to update any logic.
|
|
18486
|
-
const encoded = encoder_Encoder.encodeObject(
|
|
18487
|
-
const headerView = decoder_Decoder.decodeObject(
|
|
18518
|
+
const encoded = encoder_Encoder.encodeObject(header_Header.Codec, header, this.chainSpec);
|
|
18519
|
+
const headerView = decoder_Decoder.decodeObject(header_Header.Codec.View, encoded, this.chainSpec);
|
|
18488
18520
|
this.lastHeaderHash = hasher.header(headerView).hash;
|
|
18489
18521
|
this.lastHeader = header;
|
|
18490
18522
|
return Block.create({ header, extrinsic });
|
|
18491
18523
|
}
|
|
18492
18524
|
}
|
|
18493
18525
|
|
|
18494
|
-
;// CONCATENATED MODULE: ./workers/block-generator/state-machine.ts
|
|
18526
|
+
;// CONCATENATED MODULE: ./packages/workers/block-generator/state-machine.ts
|
|
18495
18527
|
|
|
18496
18528
|
|
|
18497
18529
|
|
|
@@ -18556,7 +18588,7 @@ class GeneratorReady extends State {
|
|
|
18556
18588
|
}
|
|
18557
18589
|
}
|
|
18558
18590
|
|
|
18559
|
-
;// CONCATENATED MODULE: ./workers/block-generator/index.ts
|
|
18591
|
+
;// CONCATENATED MODULE: ./packages/workers/block-generator/index.ts
|
|
18560
18592
|
|
|
18561
18593
|
|
|
18562
18594
|
|