@typeberry/jam 0.4.1-0a3acb2 → 0.4.1-818bae8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -0
- package/bootstrap-generator.mjs +14214 -1026
- package/bootstrap-generator.mjs.map +1 -1
- package/bootstrap-importer.mjs +11733 -11369
- package/bootstrap-importer.mjs.map +1 -1
- package/bootstrap-network.mjs +762 -413
- package/bootstrap-network.mjs.map +1 -1
- package/index.js +3836 -3457
- package/index.js.map +1 -1
- package/package.json +1 -1
package/bootstrap-network.mjs
CHANGED
|
@@ -15433,6 +15433,349 @@ exports.fromBER = fromBER;
|
|
|
15433
15433
|
exports.verifySchema = verifySchema;
|
|
15434
15434
|
|
|
15435
15435
|
|
|
15436
|
+
/***/ }),
|
|
15437
|
+
|
|
15438
|
+
/***/ 952:
|
|
15439
|
+
/***/ ((module) => {
|
|
15440
|
+
|
|
15441
|
+
|
|
15442
|
+
|
|
15443
|
+
var has = Object.prototype.hasOwnProperty
|
|
15444
|
+
, prefix = '~';
|
|
15445
|
+
|
|
15446
|
+
/**
|
|
15447
|
+
* Constructor to create a storage for our `EE` objects.
|
|
15448
|
+
* An `Events` instance is a plain object whose properties are event names.
|
|
15449
|
+
*
|
|
15450
|
+
* @constructor
|
|
15451
|
+
* @private
|
|
15452
|
+
*/
|
|
15453
|
+
function Events() {}
|
|
15454
|
+
|
|
15455
|
+
//
|
|
15456
|
+
// We try to not inherit from `Object.prototype`. In some engines creating an
|
|
15457
|
+
// instance in this way is faster than calling `Object.create(null)` directly.
|
|
15458
|
+
// If `Object.create(null)` is not supported we prefix the event names with a
|
|
15459
|
+
// character to make sure that the built-in object properties are not
|
|
15460
|
+
// overridden or used as an attack vector.
|
|
15461
|
+
//
|
|
15462
|
+
if (Object.create) {
|
|
15463
|
+
Events.prototype = Object.create(null);
|
|
15464
|
+
|
|
15465
|
+
//
|
|
15466
|
+
// This hack is needed because the `__proto__` property is still inherited in
|
|
15467
|
+
// some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
|
|
15468
|
+
//
|
|
15469
|
+
if (!new Events().__proto__) prefix = false;
|
|
15470
|
+
}
|
|
15471
|
+
|
|
15472
|
+
/**
|
|
15473
|
+
* Representation of a single event listener.
|
|
15474
|
+
*
|
|
15475
|
+
* @param {Function} fn The listener function.
|
|
15476
|
+
* @param {*} context The context to invoke the listener with.
|
|
15477
|
+
* @param {Boolean} [once=false] Specify if the listener is a one-time listener.
|
|
15478
|
+
* @constructor
|
|
15479
|
+
* @private
|
|
15480
|
+
*/
|
|
15481
|
+
function EE(fn, context, once) {
|
|
15482
|
+
this.fn = fn;
|
|
15483
|
+
this.context = context;
|
|
15484
|
+
this.once = once || false;
|
|
15485
|
+
}
|
|
15486
|
+
|
|
15487
|
+
/**
|
|
15488
|
+
* Add a listener for a given event.
|
|
15489
|
+
*
|
|
15490
|
+
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
15491
|
+
* @param {(String|Symbol)} event The event name.
|
|
15492
|
+
* @param {Function} fn The listener function.
|
|
15493
|
+
* @param {*} context The context to invoke the listener with.
|
|
15494
|
+
* @param {Boolean} once Specify if the listener is a one-time listener.
|
|
15495
|
+
* @returns {EventEmitter}
|
|
15496
|
+
* @private
|
|
15497
|
+
*/
|
|
15498
|
+
function addListener(emitter, event, fn, context, once) {
|
|
15499
|
+
if (typeof fn !== 'function') {
|
|
15500
|
+
throw new TypeError('The listener must be a function');
|
|
15501
|
+
}
|
|
15502
|
+
|
|
15503
|
+
var listener = new EE(fn, context || emitter, once)
|
|
15504
|
+
, evt = prefix ? prefix + event : event;
|
|
15505
|
+
|
|
15506
|
+
if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
|
|
15507
|
+
else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
|
|
15508
|
+
else emitter._events[evt] = [emitter._events[evt], listener];
|
|
15509
|
+
|
|
15510
|
+
return emitter;
|
|
15511
|
+
}
|
|
15512
|
+
|
|
15513
|
+
/**
|
|
15514
|
+
* Clear event by name.
|
|
15515
|
+
*
|
|
15516
|
+
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
15517
|
+
* @param {(String|Symbol)} evt The Event name.
|
|
15518
|
+
* @private
|
|
15519
|
+
*/
|
|
15520
|
+
function clearEvent(emitter, evt) {
|
|
15521
|
+
if (--emitter._eventsCount === 0) emitter._events = new Events();
|
|
15522
|
+
else delete emitter._events[evt];
|
|
15523
|
+
}
|
|
15524
|
+
|
|
15525
|
+
/**
|
|
15526
|
+
* Minimal `EventEmitter` interface that is molded against the Node.js
|
|
15527
|
+
* `EventEmitter` interface.
|
|
15528
|
+
*
|
|
15529
|
+
* @constructor
|
|
15530
|
+
* @public
|
|
15531
|
+
*/
|
|
15532
|
+
function EventEmitter() {
|
|
15533
|
+
this._events = new Events();
|
|
15534
|
+
this._eventsCount = 0;
|
|
15535
|
+
}
|
|
15536
|
+
|
|
15537
|
+
/**
|
|
15538
|
+
* Return an array listing the events for which the emitter has registered
|
|
15539
|
+
* listeners.
|
|
15540
|
+
*
|
|
15541
|
+
* @returns {Array}
|
|
15542
|
+
* @public
|
|
15543
|
+
*/
|
|
15544
|
+
EventEmitter.prototype.eventNames = function eventNames() {
|
|
15545
|
+
var names = []
|
|
15546
|
+
, events
|
|
15547
|
+
, name;
|
|
15548
|
+
|
|
15549
|
+
if (this._eventsCount === 0) return names;
|
|
15550
|
+
|
|
15551
|
+
for (name in (events = this._events)) {
|
|
15552
|
+
if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
|
|
15553
|
+
}
|
|
15554
|
+
|
|
15555
|
+
if (Object.getOwnPropertySymbols) {
|
|
15556
|
+
return names.concat(Object.getOwnPropertySymbols(events));
|
|
15557
|
+
}
|
|
15558
|
+
|
|
15559
|
+
return names;
|
|
15560
|
+
};
|
|
15561
|
+
|
|
15562
|
+
/**
|
|
15563
|
+
* Return the listeners registered for a given event.
|
|
15564
|
+
*
|
|
15565
|
+
* @param {(String|Symbol)} event The event name.
|
|
15566
|
+
* @returns {Array} The registered listeners.
|
|
15567
|
+
* @public
|
|
15568
|
+
*/
|
|
15569
|
+
EventEmitter.prototype.listeners = function listeners(event) {
|
|
15570
|
+
var evt = prefix ? prefix + event : event
|
|
15571
|
+
, handlers = this._events[evt];
|
|
15572
|
+
|
|
15573
|
+
if (!handlers) return [];
|
|
15574
|
+
if (handlers.fn) return [handlers.fn];
|
|
15575
|
+
|
|
15576
|
+
for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
|
|
15577
|
+
ee[i] = handlers[i].fn;
|
|
15578
|
+
}
|
|
15579
|
+
|
|
15580
|
+
return ee;
|
|
15581
|
+
};
|
|
15582
|
+
|
|
15583
|
+
/**
|
|
15584
|
+
* Return the number of listeners listening to a given event.
|
|
15585
|
+
*
|
|
15586
|
+
* @param {(String|Symbol)} event The event name.
|
|
15587
|
+
* @returns {Number} The number of listeners.
|
|
15588
|
+
* @public
|
|
15589
|
+
*/
|
|
15590
|
+
EventEmitter.prototype.listenerCount = function listenerCount(event) {
|
|
15591
|
+
var evt = prefix ? prefix + event : event
|
|
15592
|
+
, listeners = this._events[evt];
|
|
15593
|
+
|
|
15594
|
+
if (!listeners) return 0;
|
|
15595
|
+
if (listeners.fn) return 1;
|
|
15596
|
+
return listeners.length;
|
|
15597
|
+
};
|
|
15598
|
+
|
|
15599
|
+
/**
|
|
15600
|
+
* Calls each of the listeners registered for a given event.
|
|
15601
|
+
*
|
|
15602
|
+
* @param {(String|Symbol)} event The event name.
|
|
15603
|
+
* @returns {Boolean} `true` if the event had listeners, else `false`.
|
|
15604
|
+
* @public
|
|
15605
|
+
*/
|
|
15606
|
+
EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
15607
|
+
var evt = prefix ? prefix + event : event;
|
|
15608
|
+
|
|
15609
|
+
if (!this._events[evt]) return false;
|
|
15610
|
+
|
|
15611
|
+
var listeners = this._events[evt]
|
|
15612
|
+
, len = arguments.length
|
|
15613
|
+
, args
|
|
15614
|
+
, i;
|
|
15615
|
+
|
|
15616
|
+
if (listeners.fn) {
|
|
15617
|
+
if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
|
|
15618
|
+
|
|
15619
|
+
switch (len) {
|
|
15620
|
+
case 1: return listeners.fn.call(listeners.context), true;
|
|
15621
|
+
case 2: return listeners.fn.call(listeners.context, a1), true;
|
|
15622
|
+
case 3: return listeners.fn.call(listeners.context, a1, a2), true;
|
|
15623
|
+
case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
|
|
15624
|
+
case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
|
|
15625
|
+
case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
|
|
15626
|
+
}
|
|
15627
|
+
|
|
15628
|
+
for (i = 1, args = new Array(len -1); i < len; i++) {
|
|
15629
|
+
args[i - 1] = arguments[i];
|
|
15630
|
+
}
|
|
15631
|
+
|
|
15632
|
+
listeners.fn.apply(listeners.context, args);
|
|
15633
|
+
} else {
|
|
15634
|
+
var length = listeners.length
|
|
15635
|
+
, j;
|
|
15636
|
+
|
|
15637
|
+
for (i = 0; i < length; i++) {
|
|
15638
|
+
if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
|
|
15639
|
+
|
|
15640
|
+
switch (len) {
|
|
15641
|
+
case 1: listeners[i].fn.call(listeners[i].context); break;
|
|
15642
|
+
case 2: listeners[i].fn.call(listeners[i].context, a1); break;
|
|
15643
|
+
case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
|
|
15644
|
+
case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
|
|
15645
|
+
default:
|
|
15646
|
+
if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
|
|
15647
|
+
args[j - 1] = arguments[j];
|
|
15648
|
+
}
|
|
15649
|
+
|
|
15650
|
+
listeners[i].fn.apply(listeners[i].context, args);
|
|
15651
|
+
}
|
|
15652
|
+
}
|
|
15653
|
+
}
|
|
15654
|
+
|
|
15655
|
+
return true;
|
|
15656
|
+
};
|
|
15657
|
+
|
|
15658
|
+
/**
|
|
15659
|
+
* Add a listener for a given event.
|
|
15660
|
+
*
|
|
15661
|
+
* @param {(String|Symbol)} event The event name.
|
|
15662
|
+
* @param {Function} fn The listener function.
|
|
15663
|
+
* @param {*} [context=this] The context to invoke the listener with.
|
|
15664
|
+
* @returns {EventEmitter} `this`.
|
|
15665
|
+
* @public
|
|
15666
|
+
*/
|
|
15667
|
+
EventEmitter.prototype.on = function on(event, fn, context) {
|
|
15668
|
+
return addListener(this, event, fn, context, false);
|
|
15669
|
+
};
|
|
15670
|
+
|
|
15671
|
+
/**
|
|
15672
|
+
* Add a one-time listener for a given event.
|
|
15673
|
+
*
|
|
15674
|
+
* @param {(String|Symbol)} event The event name.
|
|
15675
|
+
* @param {Function} fn The listener function.
|
|
15676
|
+
* @param {*} [context=this] The context to invoke the listener with.
|
|
15677
|
+
* @returns {EventEmitter} `this`.
|
|
15678
|
+
* @public
|
|
15679
|
+
*/
|
|
15680
|
+
EventEmitter.prototype.once = function once(event, fn, context) {
|
|
15681
|
+
return addListener(this, event, fn, context, true);
|
|
15682
|
+
};
|
|
15683
|
+
|
|
15684
|
+
/**
|
|
15685
|
+
* Remove the listeners of a given event.
|
|
15686
|
+
*
|
|
15687
|
+
* @param {(String|Symbol)} event The event name.
|
|
15688
|
+
* @param {Function} fn Only remove the listeners that match this function.
|
|
15689
|
+
* @param {*} context Only remove the listeners that have this context.
|
|
15690
|
+
* @param {Boolean} once Only remove one-time listeners.
|
|
15691
|
+
* @returns {EventEmitter} `this`.
|
|
15692
|
+
* @public
|
|
15693
|
+
*/
|
|
15694
|
+
EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
15695
|
+
var evt = prefix ? prefix + event : event;
|
|
15696
|
+
|
|
15697
|
+
if (!this._events[evt]) return this;
|
|
15698
|
+
if (!fn) {
|
|
15699
|
+
clearEvent(this, evt);
|
|
15700
|
+
return this;
|
|
15701
|
+
}
|
|
15702
|
+
|
|
15703
|
+
var listeners = this._events[evt];
|
|
15704
|
+
|
|
15705
|
+
if (listeners.fn) {
|
|
15706
|
+
if (
|
|
15707
|
+
listeners.fn === fn &&
|
|
15708
|
+
(!once || listeners.once) &&
|
|
15709
|
+
(!context || listeners.context === context)
|
|
15710
|
+
) {
|
|
15711
|
+
clearEvent(this, evt);
|
|
15712
|
+
}
|
|
15713
|
+
} else {
|
|
15714
|
+
for (var i = 0, events = [], length = listeners.length; i < length; i++) {
|
|
15715
|
+
if (
|
|
15716
|
+
listeners[i].fn !== fn ||
|
|
15717
|
+
(once && !listeners[i].once) ||
|
|
15718
|
+
(context && listeners[i].context !== context)
|
|
15719
|
+
) {
|
|
15720
|
+
events.push(listeners[i]);
|
|
15721
|
+
}
|
|
15722
|
+
}
|
|
15723
|
+
|
|
15724
|
+
//
|
|
15725
|
+
// Reset the array, or remove it completely if we have no more listeners.
|
|
15726
|
+
//
|
|
15727
|
+
if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
|
|
15728
|
+
else clearEvent(this, evt);
|
|
15729
|
+
}
|
|
15730
|
+
|
|
15731
|
+
return this;
|
|
15732
|
+
};
|
|
15733
|
+
|
|
15734
|
+
/**
|
|
15735
|
+
* Remove all listeners, or those of the specified event.
|
|
15736
|
+
*
|
|
15737
|
+
* @param {(String|Symbol)} [event] The event name.
|
|
15738
|
+
* @returns {EventEmitter} `this`.
|
|
15739
|
+
* @public
|
|
15740
|
+
*/
|
|
15741
|
+
EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
15742
|
+
var evt;
|
|
15743
|
+
|
|
15744
|
+
if (event) {
|
|
15745
|
+
evt = prefix ? prefix + event : event;
|
|
15746
|
+
if (this._events[evt]) clearEvent(this, evt);
|
|
15747
|
+
} else {
|
|
15748
|
+
this._events = new Events();
|
|
15749
|
+
this._eventsCount = 0;
|
|
15750
|
+
}
|
|
15751
|
+
|
|
15752
|
+
return this;
|
|
15753
|
+
};
|
|
15754
|
+
|
|
15755
|
+
//
|
|
15756
|
+
// Alias methods names because people roll like that.
|
|
15757
|
+
//
|
|
15758
|
+
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
|
|
15759
|
+
EventEmitter.prototype.addListener = EventEmitter.prototype.on;
|
|
15760
|
+
|
|
15761
|
+
//
|
|
15762
|
+
// Expose the prefix.
|
|
15763
|
+
//
|
|
15764
|
+
EventEmitter.prefixed = prefix;
|
|
15765
|
+
|
|
15766
|
+
//
|
|
15767
|
+
// Allow `EventEmitter` to be imported as module namespace.
|
|
15768
|
+
//
|
|
15769
|
+
EventEmitter.EventEmitter = EventEmitter;
|
|
15770
|
+
|
|
15771
|
+
//
|
|
15772
|
+
// Expose the module.
|
|
15773
|
+
//
|
|
15774
|
+
if (true) {
|
|
15775
|
+
module.exports = EventEmitter;
|
|
15776
|
+
}
|
|
15777
|
+
|
|
15778
|
+
|
|
15436
15779
|
/***/ }),
|
|
15437
15780
|
|
|
15438
15781
|
/***/ 1681:
|
|
@@ -24027,7 +24370,11 @@ __nccwpck_require__.d(__webpack_exports__, {
|
|
|
24027
24370
|
TB: () => (/* reexport */ protocol)
|
|
24028
24371
|
});
|
|
24029
24372
|
|
|
24373
|
+
;// CONCATENATED MODULE: ./packages/core/utils/env.ts
|
|
24374
|
+
const env = typeof process === "undefined" ? {} : process.env;
|
|
24375
|
+
|
|
24030
24376
|
;// CONCATENATED MODULE: ./packages/core/utils/compatibility.ts
|
|
24377
|
+
|
|
24031
24378
|
var GpVersion;
|
|
24032
24379
|
(function (GpVersion) {
|
|
24033
24380
|
GpVersion["V0_6_7"] = "0.6.7";
|
|
@@ -24047,7 +24394,6 @@ const DEFAULT_SUITE = TestSuite.W3F_DAVXY;
|
|
|
24047
24394
|
* Since we are currently at 0.7.1 not 0.7.2, we set our default version accordingly.
|
|
24048
24395
|
*/
|
|
24049
24396
|
const DEFAULT_VERSION = GpVersion.V0_7_1;
|
|
24050
|
-
const env = typeof process === "undefined" ? {} : process.env;
|
|
24051
24397
|
let CURRENT_VERSION = parseCurrentVersion(env.GP_VERSION) ?? DEFAULT_VERSION;
|
|
24052
24398
|
let CURRENT_SUITE = parseCurrentSuite(env.TEST_SUITE) ?? DEFAULT_SUITE;
|
|
24053
24399
|
function parseCurrentVersion(env) {
|
|
@@ -24240,7 +24586,7 @@ function lazyInspect(obj) {
|
|
|
24240
24586
|
}
|
|
24241
24587
|
|
|
24242
24588
|
;// CONCATENATED MODULE: ./packages/core/utils/dev.ts
|
|
24243
|
-
|
|
24589
|
+
|
|
24244
24590
|
/**
|
|
24245
24591
|
* The function will produce relative path resolver that is adjusted
|
|
24246
24592
|
* for package location within the workspace.
|
|
@@ -24258,7 +24604,7 @@ const dev_env = typeof process === "undefined" ? {} : process.env;
|
|
|
24258
24604
|
* NOTE: the translation happens only for development build! When
|
|
24259
24605
|
* we build a single library from our project, we no longer mangle the paths.
|
|
24260
24606
|
*/
|
|
24261
|
-
const workspacePathFix =
|
|
24607
|
+
const workspacePathFix = env.NODE_ENV === "development"
|
|
24262
24608
|
? (workspacePath) => (p) => {
|
|
24263
24609
|
if (p.startsWith("/")) {
|
|
24264
24610
|
return p;
|
|
@@ -26239,7 +26585,7 @@ const TYPICAL_SEQUENCE_LENGTH = 64;
|
|
|
26239
26585
|
* For the size hint for encoding typical dictionaries.
|
|
26240
26586
|
* TODO [ToDr] [opti] This value should be updated when we run some real-data bechmarks.
|
|
26241
26587
|
*/
|
|
26242
|
-
const
|
|
26588
|
+
const TYPICAL_DICTIONARY_LENGTH = 32;
|
|
26243
26589
|
/**
|
|
26244
26590
|
* Convert a descriptor for regular array into readonly one.
|
|
26245
26591
|
*
|
|
@@ -26265,213 +26611,209 @@ function exactHint(bytes) {
|
|
|
26265
26611
|
isExact: true,
|
|
26266
26612
|
};
|
|
26267
26613
|
}
|
|
26268
|
-
/**
|
|
26269
|
-
|
|
26270
|
-
|
|
26271
|
-
|
|
26272
|
-
|
|
26273
|
-
|
|
26274
|
-
|
|
26275
|
-
|
|
26276
|
-
if (ret === undefined) {
|
|
26277
|
-
ret = descriptor_Descriptor.new(`Bytes<${len}>`, exactHint(len), (e, v) => e.bytes(v), (d) => d.bytes(len), (s) => s.bytes(len));
|
|
26278
|
-
cache.set(len, ret);
|
|
26279
|
-
}
|
|
26280
|
-
return ret;
|
|
26281
|
-
};
|
|
26282
|
-
})();
|
|
26283
|
-
/** Zero-size `void` value. */
|
|
26284
|
-
codec.nothing = descriptor_Descriptor.new("void", { bytes: 0, isExact: true }, (_e, _v) => { }, (_d) => { }, (_s) => { });
|
|
26285
|
-
/** Variable-length U32. */
|
|
26286
|
-
codec.varU32 = descriptor_Descriptor.new("var_u32", { bytes: 4, isExact: false }, (e, v) => e.varU32(v), (d) => d.varU32(), (d) => d.varU32());
|
|
26287
|
-
/** Variable-length U64. */
|
|
26288
|
-
codec.varU64 = descriptor_Descriptor.new("var_u64", { bytes: 8, isExact: false }, (e, v) => e.varU64(v), (d) => d.varU64(), (d) => d.varU64());
|
|
26289
|
-
/** Unsigned 64-bit number. */
|
|
26290
|
-
codec.u64 = descriptor_Descriptor.withView("u64", exactHint(8), (e, v) => e.i64(v), (d) => d.u64(), (d) => d.u64(), codec.bytes(8));
|
|
26291
|
-
/** Unsigned 32-bit number. */
|
|
26292
|
-
codec.u32 = descriptor_Descriptor.withView("u32", exactHint(4), (e, v) => e.i32(v), (d) => d.u32(), (d) => d.u32(), codec.bytes(4));
|
|
26293
|
-
/** Unsigned 24-bit number. */
|
|
26294
|
-
codec.u24 = descriptor_Descriptor.withView("u24", exactHint(3), (e, v) => e.i24(v), (d) => d.u24(), (d) => d.u24(), codec.bytes(3));
|
|
26295
|
-
/** Unsigned 16-bit number. */
|
|
26296
|
-
codec.u16 = descriptor_Descriptor.withView("u16", exactHint(2), (e, v) => e.i16(v), (d) => d.u16(), (d) => d.u16(), codec.bytes(2));
|
|
26297
|
-
/** Unsigned 8-bit number. */
|
|
26298
|
-
codec.u8 = descriptor_Descriptor.new("u8", exactHint(1), (e, v) => e.i8(v), (d) => d.u8(), (d) => d.u8());
|
|
26299
|
-
/** Signed 64-bit number. */
|
|
26300
|
-
codec.i64 = descriptor_Descriptor.withView("u64", exactHint(8), (e, v) => e.i64(v), (d) => d.i64(), (s) => s.u64(), codec.bytes(8));
|
|
26301
|
-
/** Signed 32-bit number. */
|
|
26302
|
-
codec.i32 = descriptor_Descriptor.withView("i32", exactHint(4), (e, v) => e.i32(v), (d) => d.i32(), (s) => s.u32(), codec.bytes(4));
|
|
26303
|
-
/** Signed 24-bit number. */
|
|
26304
|
-
codec.i24 = descriptor_Descriptor.withView("i24", exactHint(3), (e, v) => e.i24(v), (d) => d.i24(), (s) => s.u24(), codec.bytes(3));
|
|
26305
|
-
/** Signed 16-bit number. */
|
|
26306
|
-
codec.i16 = descriptor_Descriptor.withView("i16", exactHint(2), (e, v) => e.i16(v), (d) => d.i16(), (s) => s.u16(), codec.bytes(2));
|
|
26307
|
-
/** Signed 8-bit number. */
|
|
26308
|
-
codec.i8 = descriptor_Descriptor.new("i8", exactHint(1), (e, v) => e.i8(v), (d) => d.i8(), (s) => s.u8());
|
|
26309
|
-
/** 1-byte boolean value. */
|
|
26310
|
-
codec.bool = descriptor_Descriptor.new("bool", exactHint(1), (e, v) => e.bool(v), (d) => d.bool(), (s) => s.bool());
|
|
26311
|
-
/** Variable-length bytes blob. */
|
|
26312
|
-
codec.blob = descriptor_Descriptor.new("BytesBlob", { bytes: TYPICAL_SEQUENCE_LENGTH, isExact: false }, (e, v) => e.bytesBlob(v), (d) => d.bytesBlob(), (s) => s.bytesBlob());
|
|
26313
|
-
/** String encoded as variable-length bytes blob. */
|
|
26314
|
-
codec.string = descriptor_Descriptor.withView("string", { bytes: TYPICAL_SEQUENCE_LENGTH, isExact: false }, (e, v) => e.bytesBlob(bytes_BytesBlob.blobFrom(new TextEncoder().encode(v))), (d) => new TextDecoder("utf8", { fatal: true }).decode(d.bytesBlob().raw), (s) => s.bytesBlob(), codec.blob);
|
|
26315
|
-
/** Variable-length bit vector. */
|
|
26316
|
-
codec.bitVecVarLen = descriptor_Descriptor.new("BitVec[?]", { bytes: TYPICAL_SEQUENCE_LENGTH >>> 3, isExact: false }, (e, v) => e.bitVecVarLen(v), (d) => d.bitVecVarLen(), (s) => s.bitVecVarLen());
|
|
26317
|
-
/** Fixed-length bit vector. */
|
|
26318
|
-
codec.bitVecFixLen = (bitLen) => descriptor_Descriptor.new(`BitVec[${bitLen}]`, exactHint(bitLen >>> 3), (e, v) => e.bitVecFixLen(v), (d) => d.bitVecFixLen(bitLen), (s) => s.bitVecFixLen(bitLen));
|
|
26319
|
-
/** Optionality wrapper for given type. */
|
|
26320
|
-
codec.optional = (type) => {
|
|
26321
|
-
const self = descriptor_Descriptor.new(`Optional<${type.name}>`, addSizeHints({ bytes: 1, isExact: false }, type.sizeHint), (e, v) => e.optional(type, v), (d) => d.optional(type), (s) => s.optional(type));
|
|
26322
|
-
if (hasUniqueView(type)) {
|
|
26323
|
-
return descriptor_Descriptor.withView(self.name, self.sizeHint, self.encode, self.decode, self.skip, codec.optional(type.View));
|
|
26324
|
-
}
|
|
26325
|
-
return self;
|
|
26326
|
-
};
|
|
26327
|
-
/** Variable-length sequence of given type. */
|
|
26328
|
-
codec.sequenceVarLen = (type, options = {
|
|
26329
|
-
minLength: 0,
|
|
26330
|
-
maxLength: 2 ** 32 - 1,
|
|
26331
|
-
}) => {
|
|
26332
|
-
const name = `Sequence<${type.name}>[?]`;
|
|
26333
|
-
const typicalLength = options.typicalLength ?? TYPICAL_SEQUENCE_LENGTH;
|
|
26334
|
-
return descriptor_Descriptor.withView(name, { bytes: typicalLength * type.sizeHint.bytes, isExact: false }, (e, v) => {
|
|
26335
|
-
validateLength(options, v.length, name);
|
|
26336
|
-
e.sequenceVarLen(type, v);
|
|
26337
|
-
}, (d) => {
|
|
26338
|
-
const len = d.varU32();
|
|
26339
|
-
validateLength(options, len, name);
|
|
26340
|
-
return d.sequenceFixLen(type, len);
|
|
26341
|
-
}, (s) => {
|
|
26342
|
-
const len = s.decoder.varU32();
|
|
26343
|
-
validateLength(options, len, name);
|
|
26344
|
-
return s.sequenceFixLen(type, len);
|
|
26345
|
-
}, sequenceViewVarLen(type, options));
|
|
26346
|
-
};
|
|
26347
|
-
/** Fixed-length sequence of given type. */
|
|
26348
|
-
codec.sequenceFixLen = (type, len) => descriptor_Descriptor.withView(`Sequence<${type.name}>[${len}]`, { bytes: len * type.sizeHint.bytes, isExact: type.sizeHint.isExact }, (e, v) => e.sequenceFixLen(type, v), (d) => d.sequenceFixLen(type, len), (s) => s.sequenceFixLen(type, len), sequenceViewFixLen(type, { fixedLength: len }));
|
|
26349
|
-
/** Small dictionary codec. */
|
|
26350
|
-
codec.dictionary = (key, value, { sortKeys, fixedLength, }) => {
|
|
26351
|
-
const self = descriptor_Descriptor.new(`Dictionary<${key.name}, ${value.name}>[${fixedLength ?? "?"}]`, {
|
|
26352
|
-
bytes: fixedLength !== undefined
|
|
26353
|
-
? fixedLength * addSizeHints(key.sizeHint, value.sizeHint).bytes
|
|
26354
|
-
: descriptors_TYPICAL_DICTIONARY_LENGTH * (addSizeHints(key.sizeHint, value.sizeHint).bytes ?? 0),
|
|
26355
|
-
isExact: fixedLength !== undefined ? key.sizeHint.isExact && value.sizeHint.isExact : false,
|
|
26356
|
-
}, (e, v) => {
|
|
26357
|
-
const data = Array.from(v.entries());
|
|
26358
|
-
data.sort((a, b) => sortKeys(a[0], b[0]));
|
|
26359
|
-
// length prefix
|
|
26360
|
-
if (fixedLength === undefined || fixedLength === 0) {
|
|
26361
|
-
e.varU32(numbers_tryAsU32(data.length));
|
|
26362
|
-
}
|
|
26363
|
-
for (const [k, v] of data) {
|
|
26364
|
-
key.encode(e, k);
|
|
26365
|
-
value.encode(e, v);
|
|
26366
|
-
}
|
|
26367
|
-
}, (d) => {
|
|
26368
|
-
const map = new Map();
|
|
26369
|
-
const len = fixedLength ?? d.varU32();
|
|
26370
|
-
let prevKey = null;
|
|
26371
|
-
for (let i = 0; i < len; i += 1) {
|
|
26372
|
-
const k = key.decode(d);
|
|
26373
|
-
const v = value.decode(d);
|
|
26374
|
-
if (map.has(k)) {
|
|
26375
|
-
throw new Error(`Duplicate item in the dictionary encoding: "${k}"!`);
|
|
26376
|
-
}
|
|
26377
|
-
if (prevKey !== null && sortKeys(prevKey, k) >= 0) {
|
|
26378
|
-
throw new Error(`The keys in dictionary encoding are not sorted "${prevKey}" >= "${k}"!`);
|
|
26379
|
-
}
|
|
26380
|
-
map.set(k, v);
|
|
26381
|
-
prevKey = k;
|
|
26382
|
-
}
|
|
26383
|
-
return map;
|
|
26384
|
-
}, (s) => {
|
|
26385
|
-
const len = fixedLength ?? s.decoder.varU32();
|
|
26386
|
-
s.sequenceFixLen(key, len);
|
|
26387
|
-
s.sequenceFixLen(value, len);
|
|
26388
|
-
});
|
|
26389
|
-
if (hasUniqueView(value)) {
|
|
26390
|
-
return descriptor_Descriptor.withView(self.name, self.sizeHint, self.encode, self.decode, self.skip, codec.dictionary(key, value.View, { sortKeys, fixedLength }));
|
|
26614
|
+
/** Fixed-length bytes sequence. */
|
|
26615
|
+
const bytes = (() => {
|
|
26616
|
+
const cache = new Map();
|
|
26617
|
+
return (len) => {
|
|
26618
|
+
let ret = cache.get(len);
|
|
26619
|
+
if (ret === undefined) {
|
|
26620
|
+
ret = descriptor_Descriptor.new(`Bytes<${len}>`, exactHint(len), (e, v) => e.bytes(v), (d) => d.bytes(len), (s) => s.bytes(len));
|
|
26621
|
+
cache.set(len, ret);
|
|
26391
26622
|
}
|
|
26392
|
-
return
|
|
26623
|
+
return ret;
|
|
26393
26624
|
};
|
|
26394
|
-
|
|
26395
|
-
|
|
26396
|
-
|
|
26397
|
-
|
|
26398
|
-
|
|
26399
|
-
|
|
26400
|
-
|
|
26401
|
-
|
|
26402
|
-
|
|
26403
|
-
|
|
26404
|
-
|
|
26405
|
-
|
|
26406
|
-
|
|
26407
|
-
|
|
26408
|
-
|
|
26625
|
+
})();
|
|
26626
|
+
/** Zero-size `void` value. */
|
|
26627
|
+
const nothing = descriptor_Descriptor.new("void", { bytes: 0, isExact: true }, (_e, _v) => { }, (_d) => { }, (_s) => { });
|
|
26628
|
+
/** Variable-length U32. */
|
|
26629
|
+
const varU32 = descriptor_Descriptor.new("var_u32", { bytes: 4, isExact: false }, (e, v) => e.varU32(v), (d) => d.varU32(), (d) => d.varU32());
|
|
26630
|
+
/** Variable-length U64. */
|
|
26631
|
+
const varU64 = descriptor_Descriptor.new("var_u64", { bytes: 8, isExact: false }, (e, v) => e.varU64(v), (d) => d.varU64(), (d) => d.varU64());
|
|
26632
|
+
/** Unsigned 64-bit number. */
|
|
26633
|
+
const u64 = descriptor_Descriptor.withView("u64", exactHint(8), (e, v) => e.i64(v), (d) => d.u64(), (d) => d.u64(), bytes(8));
|
|
26634
|
+
/** Unsigned 32-bit number. */
|
|
26635
|
+
const u32 = descriptor_Descriptor.withView("u32", exactHint(4), (e, v) => e.i32(v), (d) => d.u32(), (d) => d.u32(), bytes(4));
|
|
26636
|
+
/** Unsigned 24-bit number. */
|
|
26637
|
+
const u24 = descriptor_Descriptor.withView("u24", exactHint(3), (e, v) => e.i24(v), (d) => d.u24(), (d) => d.u24(), bytes(3));
|
|
26638
|
+
/** Unsigned 16-bit number. */
|
|
26639
|
+
const u16 = descriptor_Descriptor.withView("u16", exactHint(2), (e, v) => e.i16(v), (d) => d.u16(), (d) => d.u16(), bytes(2));
|
|
26640
|
+
/** Unsigned 8-bit number. */
|
|
26641
|
+
const u8 = descriptor_Descriptor.new("u8", exactHint(1), (e, v) => e.i8(v), (d) => d.u8(), (d) => d.u8());
|
|
26642
|
+
/** Signed 64-bit number. */
|
|
26643
|
+
const i64 = descriptor_Descriptor.withView("i64", exactHint(8), (e, v) => e.i64(v), (d) => d.i64(), (s) => s.u64(), bytes(8));
|
|
26644
|
+
/** Signed 32-bit number. */
|
|
26645
|
+
const i32 = descriptor_Descriptor.withView("i32", exactHint(4), (e, v) => e.i32(v), (d) => d.i32(), (s) => s.u32(), bytes(4));
|
|
26646
|
+
/** Signed 24-bit number. */
|
|
26647
|
+
const i24 = descriptor_Descriptor.withView("i24", exactHint(3), (e, v) => e.i24(v), (d) => d.i24(), (s) => s.u24(), bytes(3));
|
|
26648
|
+
/** Signed 16-bit number. */
|
|
26649
|
+
const i16 = descriptor_Descriptor.withView("i16", exactHint(2), (e, v) => e.i16(v), (d) => d.i16(), (s) => s.u16(), bytes(2));
|
|
26650
|
+
/** Signed 8-bit number. */
|
|
26651
|
+
const i8 = descriptor_Descriptor.new("i8", exactHint(1), (e, v) => e.i8(v), (d) => d.i8(), (s) => s.u8());
|
|
26652
|
+
/** 1-byte boolean value. */
|
|
26653
|
+
const bool = descriptor_Descriptor.new("bool", exactHint(1), (e, v) => e.bool(v), (d) => d.bool(), (s) => s.bool());
|
|
26654
|
+
/** Variable-length bytes blob. */
|
|
26655
|
+
const blob = descriptor_Descriptor.new("BytesBlob", { bytes: TYPICAL_SEQUENCE_LENGTH, isExact: false }, (e, v) => e.bytesBlob(v), (d) => d.bytesBlob(), (s) => s.bytesBlob());
|
|
26656
|
+
/** String encoded as variable-length bytes blob. */
|
|
26657
|
+
const string = descriptor_Descriptor.withView("string", { bytes: TYPICAL_SEQUENCE_LENGTH, isExact: false }, (e, v) => e.bytesBlob(bytes_BytesBlob.blobFrom(new TextEncoder().encode(v))), (d) => new TextDecoder("utf8", { fatal: true }).decode(d.bytesBlob().raw), (s) => s.bytesBlob(), blob);
|
|
26658
|
+
/** Variable-length bit vector. */
|
|
26659
|
+
const bitVecVarLen = descriptor_Descriptor.new("BitVec[?]", { bytes: TYPICAL_SEQUENCE_LENGTH >>> 3, isExact: false }, (e, v) => e.bitVecVarLen(v), (d) => d.bitVecVarLen(), (s) => s.bitVecVarLen());
|
|
26660
|
+
/** Fixed-length bit vector. */
|
|
26661
|
+
const bitVecFixLen = (bitLen) => descriptor_Descriptor.new(`BitVec[${bitLen}]`, exactHint(bitLen >>> 3), (e, v) => e.bitVecFixLen(v), (d) => d.bitVecFixLen(bitLen), (s) => s.bitVecFixLen(bitLen));
|
|
26662
|
+
/** Optionality wrapper for given type. */
|
|
26663
|
+
const optional = (type) => {
|
|
26664
|
+
const self = descriptor_Descriptor.new(`Optional<${type.name}>`, addSizeHints({ bytes: 1, isExact: false }, type.sizeHint), (e, v) => e.optional(type, v), (d) => d.optional(type), (s) => s.optional(type));
|
|
26665
|
+
if (hasUniqueView(type)) {
|
|
26666
|
+
return descriptor_Descriptor.withView(self.name, self.sizeHint, self.encode, self.decode, self.skip, optional(type.View));
|
|
26667
|
+
}
|
|
26668
|
+
return self;
|
|
26669
|
+
};
|
|
26670
|
+
/** Variable-length sequence of given type. */
|
|
26671
|
+
const sequenceVarLen = (type, options = {
|
|
26672
|
+
minLength: 0,
|
|
26673
|
+
maxLength: 2 ** 32 - 1,
|
|
26674
|
+
}) => {
|
|
26675
|
+
const name = `Sequence<${type.name}>[?]`;
|
|
26676
|
+
const typicalLength = options.typicalLength ?? TYPICAL_SEQUENCE_LENGTH;
|
|
26677
|
+
return descriptor_Descriptor.withView(name, { bytes: typicalLength * type.sizeHint.bytes, isExact: false }, (e, v) => {
|
|
26678
|
+
validateLength(options, v.length, name);
|
|
26679
|
+
e.sequenceVarLen(type, v);
|
|
26680
|
+
}, (d) => {
|
|
26681
|
+
const len = d.varU32();
|
|
26682
|
+
validateLength(options, len, name);
|
|
26683
|
+
return d.sequenceFixLen(type, len);
|
|
26684
|
+
}, (s) => {
|
|
26685
|
+
const len = s.decoder.varU32();
|
|
26686
|
+
validateLength(options, len, name);
|
|
26687
|
+
return s.sequenceFixLen(type, len);
|
|
26688
|
+
}, sequenceViewVarLen(type, options));
|
|
26689
|
+
};
|
|
26690
|
+
/** Fixed-length sequence of given type. */
|
|
26691
|
+
const sequenceFixLen = (type, len) => descriptor_Descriptor.withView(`Sequence<${type.name}>[${len}]`, { bytes: len * type.sizeHint.bytes, isExact: type.sizeHint.isExact }, (e, v) => e.sequenceFixLen(type, v), (d) => d.sequenceFixLen(type, len), (s) => s.sequenceFixLen(type, len), sequenceViewFixLen(type, { fixedLength: len }));
|
|
26692
|
+
/** Small dictionary codec. */
|
|
26693
|
+
const dictionary = (key, value, { sortKeys, fixedLength, }) => {
|
|
26694
|
+
const self = descriptor_Descriptor.new(`Dictionary<${key.name}, ${value.name}>[${fixedLength ?? "?"}]`, {
|
|
26695
|
+
bytes: fixedLength !== undefined
|
|
26696
|
+
? fixedLength * addSizeHints(key.sizeHint, value.sizeHint).bytes
|
|
26697
|
+
: TYPICAL_DICTIONARY_LENGTH * (addSizeHints(key.sizeHint, value.sizeHint).bytes ?? 0),
|
|
26698
|
+
isExact: fixedLength !== undefined ? key.sizeHint.isExact && value.sizeHint.isExact : false,
|
|
26699
|
+
}, (e, v) => {
|
|
26700
|
+
const data = Array.from(v.entries());
|
|
26701
|
+
data.sort((a, b) => sortKeys(a[0], b[0]));
|
|
26702
|
+
// length prefix
|
|
26703
|
+
if (fixedLength === undefined) {
|
|
26704
|
+
e.varU32(numbers_tryAsU32(data.length));
|
|
26705
|
+
}
|
|
26706
|
+
for (const [k, v] of data) {
|
|
26707
|
+
key.encode(e, k);
|
|
26708
|
+
value.encode(e, v);
|
|
26409
26709
|
}
|
|
26410
|
-
|
|
26411
|
-
|
|
26412
|
-
|
|
26413
|
-
|
|
26414
|
-
|
|
26415
|
-
|
|
26416
|
-
|
|
26417
|
-
|
|
26418
|
-
|
|
26419
|
-
name: Self.View.name,
|
|
26420
|
-
sizeHint: Self.View.sizeHint,
|
|
26421
|
-
}, (ctx) => chooser(ctx).View)
|
|
26422
|
-
: Self.View);
|
|
26423
|
-
};
|
|
26424
|
-
/**
|
|
26425
|
-
* A descriptor for a more complex POJO.
|
|
26426
|
-
*
|
|
26427
|
-
* This descriptor is very similar to `Class`, but it DOES NOT maintain the
|
|
26428
|
-
* prototype chain of the resulting object - we only care about the shape of
|
|
26429
|
-
* the object here.
|
|
26430
|
-
*/
|
|
26431
|
-
codec.object = (descriptors, name = "object", create = (o) => o) => {
|
|
26432
|
-
return codec.Class({ name, create }, descriptors);
|
|
26433
|
-
};
|
|
26434
|
-
/**
|
|
26435
|
-
* A descriptor for a more complex class type.
|
|
26436
|
-
*
|
|
26437
|
-
* The resulting descriptor is able to encode & decode all of the public fields of
|
|
26438
|
-
* the class, given the map of descriptors for each one of them.
|
|
26439
|
-
*
|
|
26440
|
-
* The resulting decoded object will be an instance of given `Class` unlike simpler,
|
|
26441
|
-
* shape-based `object` method.
|
|
26442
|
-
*/
|
|
26443
|
-
codec.Class = (Class, descriptors) => {
|
|
26444
|
-
// Calculate a size hint for this class.
|
|
26445
|
-
let sizeHint = exactHint(0);
|
|
26446
|
-
forEachDescriptor(descriptors, (_k, val) => {
|
|
26447
|
-
sizeHint = addSizeHints(sizeHint, val.sizeHint);
|
|
26448
|
-
});
|
|
26449
|
-
const skipper = (s) => {
|
|
26450
|
-
// optimized case for fixed size complex values.
|
|
26451
|
-
if (sizeHint.isExact) {
|
|
26452
|
-
return s.decoder.skip(sizeHint.bytes);
|
|
26710
|
+
}, (d) => {
|
|
26711
|
+
const map = new Map();
|
|
26712
|
+
const len = fixedLength ?? d.varU32();
|
|
26713
|
+
let prevKey = null;
|
|
26714
|
+
for (let i = 0; i < len; i += 1) {
|
|
26715
|
+
const k = key.decode(d);
|
|
26716
|
+
const v = value.decode(d);
|
|
26717
|
+
if (map.has(k)) {
|
|
26718
|
+
throw new Error(`Duplicate item in the dictionary encoding: "${k}"!`);
|
|
26453
26719
|
}
|
|
26454
|
-
|
|
26455
|
-
|
|
26456
|
-
}
|
|
26457
|
-
|
|
26458
|
-
|
|
26459
|
-
|
|
26460
|
-
return
|
|
26461
|
-
|
|
26462
|
-
|
|
26463
|
-
|
|
26464
|
-
|
|
26465
|
-
|
|
26466
|
-
|
|
26467
|
-
|
|
26468
|
-
|
|
26469
|
-
|
|
26470
|
-
|
|
26471
|
-
|
|
26472
|
-
|
|
26720
|
+
if (prevKey !== null && sortKeys(prevKey, k) >= 0) {
|
|
26721
|
+
throw new Error(`The keys in dictionary encoding are not sorted "${prevKey}" >= "${k}"!`);
|
|
26722
|
+
}
|
|
26723
|
+
map.set(k, v);
|
|
26724
|
+
prevKey = k;
|
|
26725
|
+
}
|
|
26726
|
+
return map;
|
|
26727
|
+
}, (s) => {
|
|
26728
|
+
const len = fixedLength ?? s.decoder.varU32();
|
|
26729
|
+
s.sequenceFixLen(key, len);
|
|
26730
|
+
s.sequenceFixLen(value, len);
|
|
26731
|
+
});
|
|
26732
|
+
if (hasUniqueView(value)) {
|
|
26733
|
+
return descriptor_Descriptor.withView(self.name, self.sizeHint, self.encode, self.decode, self.skip, dictionary(key, value.View, { sortKeys, fixedLength }));
|
|
26734
|
+
}
|
|
26735
|
+
return self;
|
|
26736
|
+
};
|
|
26737
|
+
/** Encoding of pair of two values. */
|
|
26738
|
+
const pair = (a, b) => {
|
|
26739
|
+
const self = descriptor_Descriptor.new(`Pair<${a.name}, ${b.name}>`, addSizeHints(a.sizeHint, b.sizeHint), (e, elem) => {
|
|
26740
|
+
a.encode(e, elem[0]);
|
|
26741
|
+
b.encode(e, elem[1]);
|
|
26742
|
+
}, (d) => {
|
|
26743
|
+
const aValue = a.decode(d);
|
|
26744
|
+
const bValue = b.decode(d);
|
|
26745
|
+
return [aValue, bValue];
|
|
26746
|
+
}, (s) => {
|
|
26747
|
+
a.skip(s);
|
|
26748
|
+
b.skip(s);
|
|
26749
|
+
});
|
|
26750
|
+
if (hasUniqueView(a) && hasUniqueView(b)) {
|
|
26751
|
+
return descriptor_Descriptor.withView(self.name, self.sizeHint, self.encode, self.decode, self.skip, pair(a.View, b.View));
|
|
26752
|
+
}
|
|
26753
|
+
return self;
|
|
26754
|
+
};
|
|
26755
|
+
/** Custom encoding / decoding logic. */
|
|
26756
|
+
const custom = ({ name, sizeHint = { bytes: 0, isExact: false }, }, encode, decode, skip) => descriptor_Descriptor.new(name, sizeHint, encode, decode, skip);
|
|
26757
|
+
/** Choose a descriptor depending on the encoding/decoding context. */
|
|
26758
|
+
const descriptors_select = ({ name, sizeHint, }, chooser) => {
|
|
26759
|
+
const Self = chooser(null);
|
|
26760
|
+
return descriptor_Descriptor.withView(name, sizeHint, (e, x) => chooser(e.getContext()).encode(e, x), (d) => chooser(d.getContext()).decode(d), (s) => chooser(s.decoder.getContext()).skip(s), hasUniqueView(Self)
|
|
26761
|
+
? descriptors_select({
|
|
26762
|
+
name: Self.View.name,
|
|
26763
|
+
sizeHint: Self.View.sizeHint,
|
|
26764
|
+
}, (ctx) => chooser(ctx).View)
|
|
26765
|
+
: Self.View);
|
|
26766
|
+
};
|
|
26767
|
+
/**
|
|
26768
|
+
* A descriptor for a more complex POJO.
|
|
26769
|
+
*
|
|
26770
|
+
* This descriptor is very similar to `Class`, but it DOES NOT maintain the
|
|
26771
|
+
* prototype chain of the resulting object - we only care about the shape of
|
|
26772
|
+
* the object here.
|
|
26773
|
+
*/
|
|
26774
|
+
const object = (descriptors, name = "object", create = (o) => o) => {
|
|
26775
|
+
return Class({ name, create }, descriptors);
|
|
26776
|
+
};
|
|
26777
|
+
/**
|
|
26778
|
+
* A descriptor for a more complex class type.
|
|
26779
|
+
*
|
|
26780
|
+
* The resulting descriptor is able to encode & decode all of the public fields of
|
|
26781
|
+
* the class, given the map of descriptors for each one of them.
|
|
26782
|
+
*
|
|
26783
|
+
* The resulting decoded object will be an instance of given `Class` unlike simpler,
|
|
26784
|
+
* shape-based `object` method.
|
|
26785
|
+
*/
|
|
26786
|
+
const Class = (Class, descriptors) => {
|
|
26787
|
+
// Calculate a size hint for this class.
|
|
26788
|
+
let sizeHint = exactHint(0);
|
|
26789
|
+
forEachDescriptor(descriptors, (_k, val) => {
|
|
26790
|
+
sizeHint = addSizeHints(sizeHint, val.sizeHint);
|
|
26791
|
+
});
|
|
26792
|
+
const skipper = (s) => {
|
|
26793
|
+
// optimized case for fixed size complex values.
|
|
26794
|
+
if (sizeHint.isExact) {
|
|
26795
|
+
return s.decoder.skip(sizeHint.bytes);
|
|
26796
|
+
}
|
|
26797
|
+
forEachDescriptor(descriptors, (_key, descriptor) => {
|
|
26798
|
+
descriptor.skip(s);
|
|
26799
|
+
});
|
|
26473
26800
|
};
|
|
26474
|
-
|
|
26801
|
+
const view = objectView(Class, descriptors, sizeHint, skipper);
|
|
26802
|
+
// and create the descriptor for the entire class.
|
|
26803
|
+
return descriptor_Descriptor.withView(Class.name, sizeHint, (e, t) => {
|
|
26804
|
+
forEachDescriptor(descriptors, (key, descriptor) => {
|
|
26805
|
+
const value = t[key];
|
|
26806
|
+
descriptor.encode(e, value);
|
|
26807
|
+
});
|
|
26808
|
+
}, (d) => {
|
|
26809
|
+
const constructorParams = {};
|
|
26810
|
+
forEachDescriptor(descriptors, (key, descriptor) => {
|
|
26811
|
+
const value = descriptor.decode(d);
|
|
26812
|
+
constructorParams[key] = value;
|
|
26813
|
+
});
|
|
26814
|
+
return Class.create(constructorParams);
|
|
26815
|
+
}, skipper, view);
|
|
26816
|
+
};
|
|
26475
26817
|
/** Typesafe iteration of every descriptor in the record object. */
|
|
26476
26818
|
function forEachDescriptor(descriptors, f) {
|
|
26477
26819
|
for (const key in descriptors) {
|
|
@@ -29214,7 +29556,7 @@ var PvmBackend;
|
|
|
29214
29556
|
|
|
29215
29557
|
|
|
29216
29558
|
|
|
29217
|
-
;// CONCATENATED MODULE: ./packages/jam/block/codec.ts
|
|
29559
|
+
;// CONCATENATED MODULE: ./packages/jam/block/codec-utils.ts
|
|
29218
29560
|
|
|
29219
29561
|
|
|
29220
29562
|
|
|
@@ -29229,7 +29571,7 @@ function codecWithContext(chooser) {
|
|
|
29229
29571
|
const defaultContext = fullChainSpec;
|
|
29230
29572
|
const { name, sizeHint } = chooser(defaultContext);
|
|
29231
29573
|
const cache = new Map();
|
|
29232
|
-
return
|
|
29574
|
+
return descriptors_select({
|
|
29233
29575
|
name,
|
|
29234
29576
|
sizeHint: { bytes: sizeHint.bytes, isExact: false },
|
|
29235
29577
|
}, (context) => {
|
|
@@ -29256,9 +29598,9 @@ function codecWithContext(chooser) {
|
|
|
29256
29598
|
/** Codec for a known-size array with length validation. */
|
|
29257
29599
|
const codecKnownSizeArray = (val, options, _id) => {
|
|
29258
29600
|
if ("fixedLength" in options) {
|
|
29259
|
-
return readonlyArray(
|
|
29601
|
+
return readonlyArray(sequenceFixLen(val, options.fixedLength)).convert(seeThrough, sized_array_asKnownSize);
|
|
29260
29602
|
}
|
|
29261
|
-
return readonlyArray(
|
|
29603
|
+
return readonlyArray(sequenceVarLen(val, options)).convert(seeThrough, sized_array_asKnownSize);
|
|
29262
29604
|
};
|
|
29263
29605
|
/** Codec for a fixed-size array with length validation. */
|
|
29264
29606
|
const codecFixedSizeArray = (val, len) => {
|
|
@@ -29276,7 +29618,7 @@ const codecFixedSizeArray = (val, len) => {
|
|
|
29276
29618
|
});
|
|
29277
29619
|
};
|
|
29278
29620
|
/** Codec for a hash-dictionary. */
|
|
29279
|
-
const codecHashDictionary = (value, extractKey, { typicalLength = TYPICAL_DICTIONARY_LENGTH, compare = (a, b) => extractKey(a).compare(extractKey(b)), } = {}) => {
|
|
29621
|
+
const codecHashDictionary = (value, extractKey, { typicalLength = codec.TYPICAL_DICTIONARY_LENGTH, compare = (a, b) => extractKey(a).compare(extractKey(b)), } = {}) => {
|
|
29280
29622
|
return Descriptor.new(`HashDictionary<${value.name}>[?]`, {
|
|
29281
29623
|
bytes: typicalLength * value.sizeHint.bytes,
|
|
29282
29624
|
isExact: false,
|
|
@@ -29328,13 +29670,13 @@ class assurances_AvailabilityAssurance extends WithDebug {
|
|
|
29328
29670
|
bitfield;
|
|
29329
29671
|
validatorIndex;
|
|
29330
29672
|
signature;
|
|
29331
|
-
static Codec =
|
|
29332
|
-
anchor:
|
|
29673
|
+
static Codec = Class(assurances_AvailabilityAssurance, {
|
|
29674
|
+
anchor: bytes(hash_HASH_SIZE).asOpaque(),
|
|
29333
29675
|
bitfield: codecWithContext((context) => {
|
|
29334
|
-
return
|
|
29676
|
+
return bitVecFixLen(context.coresCount);
|
|
29335
29677
|
}),
|
|
29336
|
-
validatorIndex:
|
|
29337
|
-
signature:
|
|
29678
|
+
validatorIndex: u16.asOpaque(),
|
|
29679
|
+
signature: bytes(ED25519_SIGNATURE_BYTES).asOpaque(),
|
|
29338
29680
|
});
|
|
29339
29681
|
static create({ anchor, bitfield, validatorIndex, signature }) {
|
|
29340
29682
|
return new assurances_AvailabilityAssurance(anchor, bitfield, validatorIndex, signature);
|
|
@@ -29626,10 +29968,10 @@ function tryAsTicketAttempt(x) {
|
|
|
29626
29968
|
class SignedTicket extends WithDebug {
|
|
29627
29969
|
attempt;
|
|
29628
29970
|
signature;
|
|
29629
|
-
static Codec =
|
|
29971
|
+
static Codec = Class(SignedTicket, {
|
|
29630
29972
|
// TODO [ToDr] we should verify that attempt is either 0|1|2.
|
|
29631
|
-
attempt:
|
|
29632
|
-
signature:
|
|
29973
|
+
attempt: u8.asOpaque(),
|
|
29974
|
+
signature: bytes(BANDERSNATCH_PROOF_BYTES).asOpaque(),
|
|
29633
29975
|
});
|
|
29634
29976
|
static create({ attempt, signature }) {
|
|
29635
29977
|
return new SignedTicket(attempt, signature);
|
|
@@ -29648,10 +29990,10 @@ class SignedTicket extends WithDebug {
|
|
|
29648
29990
|
class Ticket extends WithDebug {
|
|
29649
29991
|
id;
|
|
29650
29992
|
attempt;
|
|
29651
|
-
static Codec =
|
|
29652
|
-
id:
|
|
29993
|
+
static Codec = Class(Ticket, {
|
|
29994
|
+
id: bytes(hash_HASH_SIZE),
|
|
29653
29995
|
// TODO [ToDr] we should verify that attempt is either 0|1|2.
|
|
29654
|
-
attempt:
|
|
29996
|
+
attempt: u8.asOpaque(),
|
|
29655
29997
|
});
|
|
29656
29998
|
static create({ id, attempt }) {
|
|
29657
29999
|
return new Ticket(id, attempt);
|
|
@@ -29797,11 +30139,11 @@ class Fault extends WithDebug {
|
|
|
29797
30139
|
wasConsideredValid;
|
|
29798
30140
|
key;
|
|
29799
30141
|
signature;
|
|
29800
|
-
static Codec =
|
|
29801
|
-
workReportHash:
|
|
29802
|
-
wasConsideredValid:
|
|
29803
|
-
key:
|
|
29804
|
-
signature:
|
|
30142
|
+
static Codec = Class(Fault, {
|
|
30143
|
+
workReportHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
30144
|
+
wasConsideredValid: bool,
|
|
30145
|
+
key: bytes(ED25519_KEY_BYTES).asOpaque(),
|
|
30146
|
+
signature: bytes(ED25519_SIGNATURE_BYTES).asOpaque(),
|
|
29805
30147
|
});
|
|
29806
30148
|
static create({ workReportHash, wasConsideredValid, key, signature }) {
|
|
29807
30149
|
return new Fault(workReportHash, wasConsideredValid, key, signature);
|
|
@@ -29829,10 +30171,10 @@ class Culprit extends WithDebug {
|
|
|
29829
30171
|
workReportHash;
|
|
29830
30172
|
key;
|
|
29831
30173
|
signature;
|
|
29832
|
-
static Codec =
|
|
29833
|
-
workReportHash:
|
|
29834
|
-
key:
|
|
29835
|
-
signature:
|
|
30174
|
+
static Codec = Class(Culprit, {
|
|
30175
|
+
workReportHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
30176
|
+
key: bytes(ED25519_KEY_BYTES).asOpaque(),
|
|
30177
|
+
signature: bytes(ED25519_SIGNATURE_BYTES).asOpaque(),
|
|
29836
30178
|
});
|
|
29837
30179
|
static create({ workReportHash, key, signature }) {
|
|
29838
30180
|
return new Culprit(workReportHash, key, signature);
|
|
@@ -29857,10 +30199,10 @@ class Judgement extends WithDebug {
|
|
|
29857
30199
|
isWorkReportValid;
|
|
29858
30200
|
index;
|
|
29859
30201
|
signature;
|
|
29860
|
-
static Codec =
|
|
29861
|
-
isWorkReportValid:
|
|
29862
|
-
index:
|
|
29863
|
-
signature:
|
|
30202
|
+
static Codec = Class(Judgement, {
|
|
30203
|
+
isWorkReportValid: bool,
|
|
30204
|
+
index: u16.asOpaque(),
|
|
30205
|
+
signature: bytes(ED25519_SIGNATURE_BYTES).asOpaque(),
|
|
29864
30206
|
});
|
|
29865
30207
|
static create({ isWorkReportValid, index, signature }) {
|
|
29866
30208
|
return new Judgement(isWorkReportValid, index, signature);
|
|
@@ -29889,11 +30231,12 @@ class Verdict extends WithDebug {
|
|
|
29889
30231
|
workReportHash;
|
|
29890
30232
|
votesEpoch;
|
|
29891
30233
|
votes;
|
|
29892
|
-
static Codec =
|
|
29893
|
-
workReportHash:
|
|
29894
|
-
votesEpoch:
|
|
30234
|
+
static Codec = Class(Verdict, {
|
|
30235
|
+
workReportHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
30236
|
+
votesEpoch: u32.asOpaque(),
|
|
29895
30237
|
votes: codecWithContext((context) => {
|
|
29896
|
-
return readonlyArray(
|
|
30238
|
+
return readonlyArray(sequenceFixLen(Judgement.Codec, context.validatorsSuperMajority))
|
|
30239
|
+
.convert(seeThrough, sized_array_asKnownSize);
|
|
29897
30240
|
}),
|
|
29898
30241
|
});
|
|
29899
30242
|
static create({ workReportHash, votesEpoch, votes }) {
|
|
@@ -29934,10 +30277,10 @@ class DisputesExtrinsic extends WithDebug {
|
|
|
29934
30277
|
verdicts;
|
|
29935
30278
|
culprits;
|
|
29936
30279
|
faults;
|
|
29937
|
-
static Codec =
|
|
29938
|
-
verdicts:
|
|
29939
|
-
culprits:
|
|
29940
|
-
faults:
|
|
30280
|
+
static Codec = Class(DisputesExtrinsic, {
|
|
30281
|
+
verdicts: sequenceVarLen(Verdict.Codec),
|
|
30282
|
+
culprits: sequenceVarLen(Culprit.Codec),
|
|
30283
|
+
faults: sequenceVarLen(Fault.Codec),
|
|
29941
30284
|
});
|
|
29942
30285
|
static create({ verdicts, culprits, faults }) {
|
|
29943
30286
|
return new DisputesExtrinsic(verdicts, culprits, faults);
|
|
@@ -29983,9 +30326,9 @@ class DisputesExtrinsic extends WithDebug {
|
|
|
29983
30326
|
class WorkPackageInfo extends WithDebug {
|
|
29984
30327
|
workPackageHash;
|
|
29985
30328
|
segmentTreeRoot;
|
|
29986
|
-
static Codec =
|
|
29987
|
-
workPackageHash:
|
|
29988
|
-
segmentTreeRoot:
|
|
30329
|
+
static Codec = Class(WorkPackageInfo, {
|
|
30330
|
+
workPackageHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
30331
|
+
segmentTreeRoot: bytes(hash_HASH_SIZE).asOpaque(),
|
|
29989
30332
|
});
|
|
29990
30333
|
constructor(
|
|
29991
30334
|
/** Hash of the described work package. */
|
|
@@ -30013,13 +30356,13 @@ class RefineContext extends WithDebug {
|
|
|
30013
30356
|
lookupAnchor;
|
|
30014
30357
|
lookupAnchorSlot;
|
|
30015
30358
|
prerequisites;
|
|
30016
|
-
static Codec =
|
|
30017
|
-
anchor:
|
|
30018
|
-
stateRoot:
|
|
30019
|
-
beefyRoot:
|
|
30020
|
-
lookupAnchor:
|
|
30021
|
-
lookupAnchorSlot:
|
|
30022
|
-
prerequisites:
|
|
30359
|
+
static Codec = Class(RefineContext, {
|
|
30360
|
+
anchor: bytes(hash_HASH_SIZE).asOpaque(),
|
|
30361
|
+
stateRoot: bytes(hash_HASH_SIZE).asOpaque(),
|
|
30362
|
+
beefyRoot: bytes(hash_HASH_SIZE).asOpaque(),
|
|
30363
|
+
lookupAnchor: bytes(hash_HASH_SIZE).asOpaque(),
|
|
30364
|
+
lookupAnchorSlot: u32.asOpaque(),
|
|
30365
|
+
prerequisites: sequenceVarLen(bytes(hash_HASH_SIZE).asOpaque()),
|
|
30023
30366
|
});
|
|
30024
30367
|
static create({ anchor, stateRoot, beefyRoot, lookupAnchor, lookupAnchorSlot, prerequisites, }) {
|
|
30025
30368
|
return new RefineContext(anchor, stateRoot, beefyRoot, lookupAnchor, lookupAnchorSlot, prerequisites);
|
|
@@ -30076,9 +30419,9 @@ const tryAsSegmentIndex = (v) => asOpaqueType(tryAsU16(v));
|
|
|
30076
30419
|
class ImportSpec extends WithDebug {
|
|
30077
30420
|
treeRoot;
|
|
30078
30421
|
index;
|
|
30079
|
-
static Codec =
|
|
30080
|
-
treeRoot:
|
|
30081
|
-
index:
|
|
30422
|
+
static Codec = Class(ImportSpec, {
|
|
30423
|
+
treeRoot: bytes(hash_HASH_SIZE),
|
|
30424
|
+
index: u16.asOpaque(),
|
|
30082
30425
|
});
|
|
30083
30426
|
static create({ treeRoot, index }) {
|
|
30084
30427
|
return new ImportSpec(treeRoot, index);
|
|
@@ -30100,9 +30443,9 @@ class ImportSpec extends WithDebug {
|
|
|
30100
30443
|
class WorkItemExtrinsicSpec extends WithDebug {
|
|
30101
30444
|
hash;
|
|
30102
30445
|
len;
|
|
30103
|
-
static Codec =
|
|
30104
|
-
hash:
|
|
30105
|
-
len:
|
|
30446
|
+
static Codec = Class(WorkItemExtrinsicSpec, {
|
|
30447
|
+
hash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
30448
|
+
len: u32,
|
|
30106
30449
|
});
|
|
30107
30450
|
static create({ hash, len }) {
|
|
30108
30451
|
return new WorkItemExtrinsicSpec(hash, len);
|
|
@@ -30163,33 +30506,33 @@ class WorkItem extends WithDebug {
|
|
|
30163
30506
|
extrinsic;
|
|
30164
30507
|
exportCount;
|
|
30165
30508
|
static Codec = Compatibility.isGreaterOrEqual(GpVersion.V0_7_0)
|
|
30166
|
-
?
|
|
30167
|
-
service:
|
|
30168
|
-
codeHash:
|
|
30169
|
-
refineGasLimit:
|
|
30170
|
-
accumulateGasLimit:
|
|
30171
|
-
exportCount:
|
|
30172
|
-
payload:
|
|
30509
|
+
? Class(WorkItem, {
|
|
30510
|
+
service: u32.asOpaque(),
|
|
30511
|
+
codeHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
30512
|
+
refineGasLimit: u64.asOpaque(),
|
|
30513
|
+
accumulateGasLimit: u64.asOpaque(),
|
|
30514
|
+
exportCount: u16,
|
|
30515
|
+
payload: blob,
|
|
30173
30516
|
importSegments: codecKnownSizeArray(ImportSpec.Codec, {
|
|
30174
30517
|
minLength: 0,
|
|
30175
30518
|
maxLength: MAX_NUMBER_OF_SEGMENTS,
|
|
30176
30519
|
typicalLength: MAX_NUMBER_OF_SEGMENTS,
|
|
30177
30520
|
}),
|
|
30178
|
-
extrinsic:
|
|
30521
|
+
extrinsic: sequenceVarLen(WorkItemExtrinsicSpec.Codec),
|
|
30179
30522
|
})
|
|
30180
|
-
:
|
|
30181
|
-
service:
|
|
30182
|
-
codeHash:
|
|
30183
|
-
payload:
|
|
30184
|
-
refineGasLimit:
|
|
30185
|
-
accumulateGasLimit:
|
|
30523
|
+
: Class(WorkItem, {
|
|
30524
|
+
service: u32.asOpaque(),
|
|
30525
|
+
codeHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
30526
|
+
payload: blob,
|
|
30527
|
+
refineGasLimit: u64.asOpaque(),
|
|
30528
|
+
accumulateGasLimit: u64.asOpaque(),
|
|
30186
30529
|
importSegments: codecKnownSizeArray(ImportSpec.Codec, {
|
|
30187
30530
|
minLength: 0,
|
|
30188
30531
|
maxLength: MAX_NUMBER_OF_SEGMENTS,
|
|
30189
30532
|
typicalLength: MAX_NUMBER_OF_SEGMENTS,
|
|
30190
30533
|
}),
|
|
30191
|
-
extrinsic:
|
|
30192
|
-
exportCount:
|
|
30534
|
+
extrinsic: sequenceVarLen(WorkItemExtrinsicSpec.Codec),
|
|
30535
|
+
exportCount: u16,
|
|
30193
30536
|
});
|
|
30194
30537
|
static create({ service, codeHash, payload, refineGasLimit, accumulateGasLimit, importSegments, extrinsic, exportCount, }) {
|
|
30195
30538
|
return new WorkItem(service, codeHash, payload, refineGasLimit, accumulateGasLimit, importSegments, extrinsic, exportCount);
|
|
@@ -30263,21 +30606,21 @@ class WorkPackage extends WithDebug {
|
|
|
30263
30606
|
context;
|
|
30264
30607
|
items;
|
|
30265
30608
|
static Codec = Compatibility.isGreaterOrEqual(GpVersion.V0_7_0)
|
|
30266
|
-
?
|
|
30267
|
-
authCodeHost:
|
|
30268
|
-
authCodeHash:
|
|
30609
|
+
? Class(WorkPackage, {
|
|
30610
|
+
authCodeHost: u32.asOpaque(),
|
|
30611
|
+
authCodeHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
30269
30612
|
context: RefineContext.Codec,
|
|
30270
|
-
authorization:
|
|
30271
|
-
parametrization:
|
|
30272
|
-
items:
|
|
30613
|
+
authorization: blob,
|
|
30614
|
+
parametrization: blob,
|
|
30615
|
+
items: sequenceVarLen(WorkItem.Codec).convert((x) => x, (items) => sized_array_FixedSizeArray.new(items, tryAsWorkItemsCount(items.length))),
|
|
30273
30616
|
})
|
|
30274
|
-
:
|
|
30275
|
-
authorization:
|
|
30276
|
-
authCodeHost:
|
|
30277
|
-
authCodeHash:
|
|
30278
|
-
parametrization:
|
|
30617
|
+
: Class(WorkPackage, {
|
|
30618
|
+
authorization: blob,
|
|
30619
|
+
authCodeHost: u32.asOpaque(),
|
|
30620
|
+
authCodeHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
30621
|
+
parametrization: blob,
|
|
30279
30622
|
context: RefineContext.Codec,
|
|
30280
|
-
items:
|
|
30623
|
+
items: sequenceVarLen(WorkItem.Codec).convert((x) => x, (items) => sized_array_FixedSizeArray.new(items, tryAsWorkItemsCount(items.length))),
|
|
30281
30624
|
});
|
|
30282
30625
|
static create({ authorization, authCodeHost, authCodeHash, parametrization, context, items, }) {
|
|
30283
30626
|
return new WorkPackage(authorization, authCodeHost, authCodeHash, parametrization, context, items);
|
|
@@ -30337,7 +30680,7 @@ var WorkExecResultKind;
|
|
|
30337
30680
|
class WorkExecResult extends WithDebug {
|
|
30338
30681
|
kind;
|
|
30339
30682
|
okBlob;
|
|
30340
|
-
static Codec =
|
|
30683
|
+
static Codec = custom({
|
|
30341
30684
|
name: "WorkExecResult",
|
|
30342
30685
|
sizeHint: { bytes: 1, isExact: false },
|
|
30343
30686
|
}, (e, x) => {
|
|
@@ -30384,12 +30727,12 @@ class WorkRefineLoad extends WithDebug {
|
|
|
30384
30727
|
extrinsicCount;
|
|
30385
30728
|
extrinsicSize;
|
|
30386
30729
|
exportedSegments;
|
|
30387
|
-
static Codec =
|
|
30388
|
-
gasUsed:
|
|
30389
|
-
importedSegments:
|
|
30390
|
-
extrinsicCount:
|
|
30391
|
-
extrinsicSize:
|
|
30392
|
-
exportedSegments:
|
|
30730
|
+
static Codec = Class(WorkRefineLoad, {
|
|
30731
|
+
gasUsed: varU64.asOpaque(),
|
|
30732
|
+
importedSegments: varU32,
|
|
30733
|
+
extrinsicCount: varU32,
|
|
30734
|
+
extrinsicSize: varU32,
|
|
30735
|
+
exportedSegments: varU32,
|
|
30393
30736
|
});
|
|
30394
30737
|
static create({ gasUsed, importedSegments, extrinsicCount, extrinsicSize, exportedSegments, }) {
|
|
30395
30738
|
return new WorkRefineLoad(gasUsed, importedSegments, extrinsicCount, extrinsicSize, exportedSegments);
|
|
@@ -30425,11 +30768,11 @@ class WorkResult {
|
|
|
30425
30768
|
gas;
|
|
30426
30769
|
result;
|
|
30427
30770
|
load;
|
|
30428
|
-
static Codec =
|
|
30429
|
-
serviceId:
|
|
30430
|
-
codeHash:
|
|
30431
|
-
payloadHash:
|
|
30432
|
-
gas:
|
|
30771
|
+
static Codec = Class(WorkResult, {
|
|
30772
|
+
serviceId: u32.asOpaque(),
|
|
30773
|
+
codeHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
30774
|
+
payloadHash: bytes(hash_HASH_SIZE),
|
|
30775
|
+
gas: u64.asOpaque(),
|
|
30433
30776
|
result: WorkExecResult.Codec,
|
|
30434
30777
|
load: WorkRefineLoad.Codec,
|
|
30435
30778
|
});
|
|
@@ -30496,12 +30839,12 @@ class WorkPackageSpec extends WithDebug {
|
|
|
30496
30839
|
erasureRoot;
|
|
30497
30840
|
exportsRoot;
|
|
30498
30841
|
exportsCount;
|
|
30499
|
-
static Codec =
|
|
30500
|
-
hash:
|
|
30501
|
-
length:
|
|
30502
|
-
erasureRoot:
|
|
30503
|
-
exportsRoot:
|
|
30504
|
-
exportsCount:
|
|
30842
|
+
static Codec = Class(WorkPackageSpec, {
|
|
30843
|
+
hash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
30844
|
+
length: u32,
|
|
30845
|
+
erasureRoot: bytes(hash_HASH_SIZE),
|
|
30846
|
+
exportsRoot: bytes(hash_HASH_SIZE).asOpaque(),
|
|
30847
|
+
exportsCount: u16,
|
|
30505
30848
|
});
|
|
30506
30849
|
static create({ hash, length, erasureRoot, exportsRoot, exportsCount }) {
|
|
30507
30850
|
return new WorkPackageSpec(hash, length, erasureRoot, exportsRoot, exportsCount);
|
|
@@ -30573,35 +30916,35 @@ class WorkReportNoCodec extends WithDebug {
|
|
|
30573
30916
|
this.authorizationGasUsed = authorizationGasUsed;
|
|
30574
30917
|
}
|
|
30575
30918
|
}
|
|
30576
|
-
const WorkReportCodec =
|
|
30919
|
+
const WorkReportCodec = Class(WorkReportNoCodec, {
|
|
30577
30920
|
workPackageSpec: WorkPackageSpec.Codec,
|
|
30578
30921
|
context: RefineContext.Codec,
|
|
30579
|
-
coreIndex:
|
|
30922
|
+
coreIndex: varU32.convert((o) => numbers_tryAsU32(o), (i) => {
|
|
30580
30923
|
if (!isU16(i)) {
|
|
30581
30924
|
throw new Error(`Core index exceeds U16: ${i}`);
|
|
30582
30925
|
}
|
|
30583
30926
|
return tryAsCoreIndex(i);
|
|
30584
30927
|
}),
|
|
30585
|
-
authorizerHash:
|
|
30586
|
-
authorizationGasUsed:
|
|
30587
|
-
authorizationOutput:
|
|
30588
|
-
segmentRootLookup: readonlyArray(
|
|
30589
|
-
results:
|
|
30928
|
+
authorizerHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
30929
|
+
authorizationGasUsed: varU64.asOpaque(),
|
|
30930
|
+
authorizationOutput: blob,
|
|
30931
|
+
segmentRootLookup: readonlyArray(sequenceVarLen(WorkPackageInfo.Codec)),
|
|
30932
|
+
results: sequenceVarLen(WorkResult.Codec).convert((x) => x, (items) => sized_array_FixedSizeArray.new(items, tryAsWorkItemsCount(items.length))),
|
|
30590
30933
|
});
|
|
30591
|
-
const WorkReportCodecPre070 =
|
|
30934
|
+
const WorkReportCodecPre070 = Class(WorkReportNoCodec, {
|
|
30592
30935
|
workPackageSpec: WorkPackageSpec.Codec,
|
|
30593
30936
|
context: RefineContext.Codec,
|
|
30594
|
-
coreIndex:
|
|
30937
|
+
coreIndex: varU32.convert((o) => numbers_tryAsU32(o), (i) => {
|
|
30595
30938
|
if (!isU16(i)) {
|
|
30596
30939
|
throw new Error(`Core index exceeds U16: ${i}`);
|
|
30597
30940
|
}
|
|
30598
30941
|
return tryAsCoreIndex(i);
|
|
30599
30942
|
}),
|
|
30600
|
-
authorizerHash:
|
|
30601
|
-
authorizationOutput:
|
|
30602
|
-
segmentRootLookup: readonlyArray(
|
|
30603
|
-
results:
|
|
30604
|
-
authorizationGasUsed:
|
|
30943
|
+
authorizerHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
30944
|
+
authorizationOutput: blob,
|
|
30945
|
+
segmentRootLookup: readonlyArray(sequenceVarLen(WorkPackageInfo.Codec)),
|
|
30946
|
+
results: sequenceVarLen(WorkResult.Codec).convert((x) => x, (items) => sized_array_FixedSizeArray.new(items, tryAsWorkItemsCount(items.length))),
|
|
30947
|
+
authorizationGasUsed: varU64.asOpaque(),
|
|
30605
30948
|
});
|
|
30606
30949
|
class WorkReport extends WorkReportNoCodec {
|
|
30607
30950
|
static Codec = Compatibility.isGreaterOrEqual(GpVersion.V0_7_0)
|
|
@@ -30620,9 +30963,9 @@ const REQUIRED_CREDENTIALS_RANGE = [2, 3];
|
|
|
30620
30963
|
class Credential extends WithDebug {
|
|
30621
30964
|
validatorIndex;
|
|
30622
30965
|
signature;
|
|
30623
|
-
static Codec =
|
|
30624
|
-
validatorIndex:
|
|
30625
|
-
signature:
|
|
30966
|
+
static Codec = Class(Credential, {
|
|
30967
|
+
validatorIndex: u16.asOpaque(),
|
|
30968
|
+
signature: bytes(ED25519_SIGNATURE_BYTES).asOpaque(),
|
|
30626
30969
|
});
|
|
30627
30970
|
static create({ validatorIndex, signature }) {
|
|
30628
30971
|
return new Credential(validatorIndex, signature);
|
|
@@ -30646,9 +30989,9 @@ class ReportGuarantee extends WithDebug {
|
|
|
30646
30989
|
report;
|
|
30647
30990
|
slot;
|
|
30648
30991
|
credentials;
|
|
30649
|
-
static Codec =
|
|
30992
|
+
static Codec = Class(ReportGuarantee, {
|
|
30650
30993
|
report: WorkReport.Codec,
|
|
30651
|
-
slot:
|
|
30994
|
+
slot: u32.asOpaque(),
|
|
30652
30995
|
credentials: codecKnownSizeArray(Credential.Codec, {
|
|
30653
30996
|
minLength: REQUIRED_CREDENTIALS_RANGE[0],
|
|
30654
30997
|
maxLength: REQUIRED_CREDENTIALS_RANGE[1],
|
|
@@ -30700,9 +31043,9 @@ const guaranteesExtrinsicCodec = codecWithContext((context) => codecKnownSizeArr
|
|
|
30700
31043
|
class ValidatorKeys extends WithDebug {
|
|
30701
31044
|
bandersnatch;
|
|
30702
31045
|
ed25519;
|
|
30703
|
-
static Codec =
|
|
30704
|
-
bandersnatch:
|
|
30705
|
-
ed25519:
|
|
31046
|
+
static Codec = Class(ValidatorKeys, {
|
|
31047
|
+
bandersnatch: bytes(BANDERSNATCH_KEY_BYTES).asOpaque(),
|
|
31048
|
+
ed25519: bytes(ED25519_KEY_BYTES).asOpaque(),
|
|
30706
31049
|
});
|
|
30707
31050
|
static create({ bandersnatch, ed25519 }) {
|
|
30708
31051
|
return new ValidatorKeys(bandersnatch, ed25519);
|
|
@@ -30719,7 +31062,7 @@ class ValidatorKeys extends WithDebug {
|
|
|
30719
31062
|
}
|
|
30720
31063
|
class TicketsMarker extends WithDebug {
|
|
30721
31064
|
tickets;
|
|
30722
|
-
static Codec =
|
|
31065
|
+
static Codec = Class(TicketsMarker, {
|
|
30723
31066
|
tickets: codecPerEpochBlock(Ticket.Codec),
|
|
30724
31067
|
});
|
|
30725
31068
|
static create({ tickets }) {
|
|
@@ -30741,9 +31084,9 @@ class EpochMarker extends WithDebug {
|
|
|
30741
31084
|
entropy;
|
|
30742
31085
|
ticketsEntropy;
|
|
30743
31086
|
validators;
|
|
30744
|
-
static Codec =
|
|
30745
|
-
entropy:
|
|
30746
|
-
ticketsEntropy:
|
|
31087
|
+
static Codec = Class(EpochMarker, {
|
|
31088
|
+
entropy: bytes(hash_HASH_SIZE).asOpaque(),
|
|
31089
|
+
ticketsEntropy: bytes(hash_HASH_SIZE).asOpaque(),
|
|
30747
31090
|
validators: codecPerValidator(ValidatorKeys.Codec),
|
|
30748
31091
|
});
|
|
30749
31092
|
static create({ entropy, ticketsEntropy, validators }) {
|
|
@@ -30778,16 +31121,16 @@ const encodeUnsealedHeader = (view) => {
|
|
|
30778
31121
|
* Codec descriptor with pre 0.7.0 encoding order
|
|
30779
31122
|
*/
|
|
30780
31123
|
const legacyDescriptor = {
|
|
30781
|
-
parentHeaderHash:
|
|
30782
|
-
priorStateRoot:
|
|
30783
|
-
extrinsicHash:
|
|
30784
|
-
timeSlotIndex:
|
|
30785
|
-
epochMarker:
|
|
30786
|
-
ticketsMarker:
|
|
30787
|
-
offendersMarker:
|
|
30788
|
-
bandersnatchBlockAuthorIndex:
|
|
30789
|
-
entropySource:
|
|
30790
|
-
seal:
|
|
31124
|
+
parentHeaderHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
31125
|
+
priorStateRoot: bytes(hash_HASH_SIZE).asOpaque(),
|
|
31126
|
+
extrinsicHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
31127
|
+
timeSlotIndex: u32.asOpaque(),
|
|
31128
|
+
epochMarker: optional(EpochMarker.Codec),
|
|
31129
|
+
ticketsMarker: optional(TicketsMarker.Codec),
|
|
31130
|
+
offendersMarker: sequenceVarLen(bytes(ED25519_KEY_BYTES).asOpaque()),
|
|
31131
|
+
bandersnatchBlockAuthorIndex: u16.asOpaque(),
|
|
31132
|
+
entropySource: bytes(bandersnatch_BANDERSNATCH_VRF_SIGNATURE_BYTES).asOpaque(),
|
|
31133
|
+
seal: bytes(bandersnatch_BANDERSNATCH_VRF_SIGNATURE_BYTES).asOpaque(),
|
|
30791
31134
|
};
|
|
30792
31135
|
/**
|
|
30793
31136
|
* The header of the JAM block.
|
|
@@ -30795,19 +31138,19 @@ const legacyDescriptor = {
|
|
|
30795
31138
|
* https://graypaper.fluffylabs.dev/#/579bd12/0c66000c7200
|
|
30796
31139
|
*/
|
|
30797
31140
|
class header_Header extends WithDebug {
|
|
30798
|
-
static Codec =
|
|
31141
|
+
static Codec = Class(header_Header, Compatibility.isLessThan(GpVersion.V0_7_0)
|
|
30799
31142
|
? legacyDescriptor
|
|
30800
31143
|
: {
|
|
30801
|
-
parentHeaderHash:
|
|
30802
|
-
priorStateRoot:
|
|
30803
|
-
extrinsicHash:
|
|
30804
|
-
timeSlotIndex:
|
|
30805
|
-
epochMarker:
|
|
30806
|
-
ticketsMarker:
|
|
30807
|
-
bandersnatchBlockAuthorIndex:
|
|
30808
|
-
entropySource:
|
|
30809
|
-
offendersMarker:
|
|
30810
|
-
seal:
|
|
31144
|
+
parentHeaderHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
31145
|
+
priorStateRoot: bytes(hash_HASH_SIZE).asOpaque(),
|
|
31146
|
+
extrinsicHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
31147
|
+
timeSlotIndex: u32.asOpaque(),
|
|
31148
|
+
epochMarker: optional(EpochMarker.Codec),
|
|
31149
|
+
ticketsMarker: optional(TicketsMarker.Codec),
|
|
31150
|
+
bandersnatchBlockAuthorIndex: u16.asOpaque(),
|
|
31151
|
+
entropySource: bytes(bandersnatch_BANDERSNATCH_VRF_SIGNATURE_BYTES).asOpaque(),
|
|
31152
|
+
offendersMarker: sequenceVarLen(bytes(ED25519_KEY_BYTES).asOpaque()),
|
|
31153
|
+
seal: bytes(bandersnatch_BANDERSNATCH_VRF_SIGNATURE_BYTES).asOpaque(),
|
|
30811
31154
|
});
|
|
30812
31155
|
static create(h) {
|
|
30813
31156
|
return Object.assign(header_Header.empty(), h);
|
|
@@ -30862,8 +31205,8 @@ class header_Header extends WithDebug {
|
|
|
30862
31205
|
* `DescriptorRecord` or `CodecRecord` for some reason.
|
|
30863
31206
|
*/
|
|
30864
31207
|
class HeaderViewWithHash extends WithHash {
|
|
30865
|
-
static Codec =
|
|
30866
|
-
hash:
|
|
31208
|
+
static Codec = Class(HeaderViewWithHash, {
|
|
31209
|
+
hash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
30867
31210
|
data: header_Header.Codec.View,
|
|
30868
31211
|
});
|
|
30869
31212
|
static create({ hash, data }) {
|
|
@@ -30884,9 +31227,9 @@ const headerViewWithHashCodec = HeaderViewWithHash.Codec;
|
|
|
30884
31227
|
class Preimage extends WithDebug {
|
|
30885
31228
|
requester;
|
|
30886
31229
|
blob;
|
|
30887
|
-
static Codec =
|
|
30888
|
-
requester:
|
|
30889
|
-
blob:
|
|
31230
|
+
static Codec = Class(Preimage, {
|
|
31231
|
+
requester: u32.asOpaque(),
|
|
31232
|
+
blob: blob,
|
|
30890
31233
|
});
|
|
30891
31234
|
static create({ requester, blob }) {
|
|
30892
31235
|
return new Preimage(requester, blob);
|
|
@@ -30901,7 +31244,7 @@ class Preimage extends WithDebug {
|
|
|
30901
31244
|
this.blob = blob;
|
|
30902
31245
|
}
|
|
30903
31246
|
}
|
|
30904
|
-
const preimagesExtrinsicCodec =
|
|
31247
|
+
const preimagesExtrinsicCodec = sequenceVarLen(Preimage.Codec);
|
|
30905
31248
|
|
|
30906
31249
|
;// CONCATENATED MODULE: ./packages/jam/block/block.ts
|
|
30907
31250
|
|
|
@@ -30927,7 +31270,7 @@ class block_Extrinsic extends WithDebug {
|
|
|
30927
31270
|
guarantees;
|
|
30928
31271
|
assurances;
|
|
30929
31272
|
disputes;
|
|
30930
|
-
static Codec =
|
|
31273
|
+
static Codec = Class(block_Extrinsic, {
|
|
30931
31274
|
tickets: ticketsExtrinsicCodec,
|
|
30932
31275
|
preimages: preimagesExtrinsicCodec,
|
|
30933
31276
|
guarantees: guaranteesExtrinsicCodec,
|
|
@@ -30980,7 +31323,7 @@ class block_Extrinsic extends WithDebug {
|
|
|
30980
31323
|
class block_Block extends WithDebug {
|
|
30981
31324
|
header;
|
|
30982
31325
|
extrinsic;
|
|
30983
|
-
static Codec =
|
|
31326
|
+
static Codec = Class(block_Block, {
|
|
30984
31327
|
header: header_Header.Codec,
|
|
30985
31328
|
extrinsic: block_Extrinsic.Codec,
|
|
30986
31329
|
});
|
|
@@ -33519,9 +33862,9 @@ class BlockRequest extends WithDebug {
|
|
|
33519
33862
|
headerHash;
|
|
33520
33863
|
direction;
|
|
33521
33864
|
maxBlocks;
|
|
33522
|
-
static Codec =
|
|
33523
|
-
headerHash:
|
|
33524
|
-
direction:
|
|
33865
|
+
static Codec = Class(BlockRequest, {
|
|
33866
|
+
headerHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
33867
|
+
direction: u8.convert((i) => tryAsU8(i), (i) => {
|
|
33525
33868
|
switch (i) {
|
|
33526
33869
|
case Direction.AscExcl:
|
|
33527
33870
|
return Direction.AscExcl;
|
|
@@ -33531,7 +33874,7 @@ class BlockRequest extends WithDebug {
|
|
|
33531
33874
|
throw new Error(`Invalid 'Direction' value: ${i}`);
|
|
33532
33875
|
}
|
|
33533
33876
|
}),
|
|
33534
|
-
maxBlocks:
|
|
33877
|
+
maxBlocks: u32,
|
|
33535
33878
|
});
|
|
33536
33879
|
static create({ headerHash, direction, maxBlocks }) {
|
|
33537
33880
|
return new BlockRequest(headerHash, direction, maxBlocks);
|
|
@@ -33556,7 +33899,7 @@ class ServerHandler {
|
|
|
33556
33899
|
const request = decoder_Decoder.decodeObject(BlockRequest.Codec, message);
|
|
33557
33900
|
ce_128_block_request_logger.log `[${sender.streamId}] Client has requested: ${request}`;
|
|
33558
33901
|
const blocks = this.getBlockSequence(sender.streamId, request.headerHash, request.direction, request.maxBlocks);
|
|
33559
|
-
sender.bufferAndSend(encoder_Encoder.encodeObject(
|
|
33902
|
+
sender.bufferAndSend(encoder_Encoder.encodeObject(sequenceFixLen(block_Block.Codec.View, blocks.length), blocks, this.chainSpec));
|
|
33560
33903
|
sender.close();
|
|
33561
33904
|
}
|
|
33562
33905
|
onClose() { }
|
|
@@ -33879,13 +34222,13 @@ class LeafNode {
|
|
|
33879
34222
|
*/
|
|
33880
34223
|
const ce_129_state_request_STREAM_KIND = tryAsStreamKind(129);
|
|
33881
34224
|
const ce_129_state_request_TRIE_NODE_BYTES = 64;
|
|
33882
|
-
const trieNodeCodec =
|
|
34225
|
+
const trieNodeCodec = bytes(ce_129_state_request_TRIE_NODE_BYTES).convert((i) => bytes_Bytes.fromBlob(i.raw, ce_129_state_request_TRIE_NODE_BYTES), (i) => new TrieNode(i.raw));
|
|
33883
34226
|
class KeyValuePair extends WithDebug {
|
|
33884
34227
|
key;
|
|
33885
34228
|
value;
|
|
33886
|
-
static Codec =
|
|
33887
|
-
key:
|
|
33888
|
-
value:
|
|
34229
|
+
static Codec = Class(KeyValuePair, {
|
|
34230
|
+
key: bytes(TRUNCATED_KEY_BYTES),
|
|
34231
|
+
value: blob,
|
|
33889
34232
|
});
|
|
33890
34233
|
static create({ key, value }) {
|
|
33891
34234
|
return new KeyValuePair(key, value);
|
|
@@ -33898,8 +34241,8 @@ class KeyValuePair extends WithDebug {
|
|
|
33898
34241
|
}
|
|
33899
34242
|
class StateResponse extends WithDebug {
|
|
33900
34243
|
keyValuePairs;
|
|
33901
|
-
static Codec =
|
|
33902
|
-
keyValuePairs:
|
|
34244
|
+
static Codec = Class(StateResponse, {
|
|
34245
|
+
keyValuePairs: sequenceVarLen(KeyValuePair.Codec),
|
|
33903
34246
|
});
|
|
33904
34247
|
static create({ keyValuePairs }) {
|
|
33905
34248
|
return new StateResponse(keyValuePairs);
|
|
@@ -33914,11 +34257,11 @@ class StateRequest extends WithDebug {
|
|
|
33914
34257
|
startKey;
|
|
33915
34258
|
endKey;
|
|
33916
34259
|
maximumSize;
|
|
33917
|
-
static Codec =
|
|
33918
|
-
headerHash:
|
|
33919
|
-
startKey:
|
|
33920
|
-
endKey:
|
|
33921
|
-
maximumSize:
|
|
34260
|
+
static Codec = Class(StateRequest, {
|
|
34261
|
+
headerHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
34262
|
+
startKey: bytes(TRUNCATED_KEY_BYTES),
|
|
34263
|
+
endKey: bytes(TRUNCATED_KEY_BYTES),
|
|
34264
|
+
maximumSize: u32,
|
|
33922
34265
|
});
|
|
33923
34266
|
static create({ headerHash, startKey, endKey, maximumSize }) {
|
|
33924
34267
|
return new StateRequest(headerHash, startKey, endKey, maximumSize);
|
|
@@ -34002,8 +34345,8 @@ const STREAM_KIND_PROXY_TO_ALL = tryAsStreamKind(132);
|
|
|
34002
34345
|
class TicketDistributionRequest extends WithDebug {
|
|
34003
34346
|
epochIndex;
|
|
34004
34347
|
ticket;
|
|
34005
|
-
static Codec =
|
|
34006
|
-
epochIndex:
|
|
34348
|
+
static Codec = Class(TicketDistributionRequest, {
|
|
34349
|
+
epochIndex: u32.asOpaque(),
|
|
34007
34350
|
ticket: SignedTicket.Codec,
|
|
34008
34351
|
});
|
|
34009
34352
|
static create({ epochIndex, ticket }) {
|
|
@@ -34066,8 +34409,8 @@ const ce_133_work_package_submission_STREAM_KIND = tryAsStreamKind(133);
|
|
|
34066
34409
|
class CoreWorkPackage extends WithDebug {
|
|
34067
34410
|
coreIndex;
|
|
34068
34411
|
workPackage;
|
|
34069
|
-
static Codec =
|
|
34070
|
-
coreIndex:
|
|
34412
|
+
static Codec = Class(CoreWorkPackage, {
|
|
34413
|
+
coreIndex: u16.asOpaque(),
|
|
34071
34414
|
workPackage: WorkPackage.Codec,
|
|
34072
34415
|
});
|
|
34073
34416
|
static create({ coreIndex, workPackage }) {
|
|
@@ -34133,14 +34476,14 @@ class ce_133_work_package_submission_ClientHandler {
|
|
|
34133
34476
|
|
|
34134
34477
|
|
|
34135
34478
|
|
|
34136
|
-
const WorkPackageBundleCodec =
|
|
34479
|
+
const WorkPackageBundleCodec = blob;
|
|
34137
34480
|
const ce_134_work_package_sharing_STREAM_KIND = tryAsStreamKind(134);
|
|
34138
34481
|
class WorkPackageSharingRequest extends WithDebug {
|
|
34139
34482
|
coreIndex;
|
|
34140
34483
|
segmentsRootMappings;
|
|
34141
|
-
static Codec =
|
|
34142
|
-
coreIndex:
|
|
34143
|
-
segmentsRootMappings:
|
|
34484
|
+
static Codec = Class(WorkPackageSharingRequest, {
|
|
34485
|
+
coreIndex: u16.asOpaque(),
|
|
34486
|
+
segmentsRootMappings: sequenceVarLen(WorkPackageInfo.Codec),
|
|
34144
34487
|
});
|
|
34145
34488
|
static create({ coreIndex, segmentsRootMappings }) {
|
|
34146
34489
|
return new WorkPackageSharingRequest(coreIndex, segmentsRootMappings);
|
|
@@ -34154,9 +34497,9 @@ class WorkPackageSharingRequest extends WithDebug {
|
|
|
34154
34497
|
class WorkPackageSharingResponse extends WithDebug {
|
|
34155
34498
|
workReportHash;
|
|
34156
34499
|
signature;
|
|
34157
|
-
static Codec =
|
|
34158
|
-
workReportHash:
|
|
34159
|
-
signature:
|
|
34500
|
+
static Codec = Class(WorkPackageSharingResponse, {
|
|
34501
|
+
workReportHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
34502
|
+
signature: bytes(ED25519_SIGNATURE_BYTES).asOpaque(),
|
|
34160
34503
|
});
|
|
34161
34504
|
static create({ workReportHash, signature }) {
|
|
34162
34505
|
return new WorkPackageSharingResponse(workReportHash, signature);
|
|
@@ -34254,9 +34597,9 @@ class GuaranteedWorkReport extends WithDebug {
|
|
|
34254
34597
|
report;
|
|
34255
34598
|
slot;
|
|
34256
34599
|
signatures;
|
|
34257
|
-
static Codec =
|
|
34600
|
+
static Codec = Class(GuaranteedWorkReport, {
|
|
34258
34601
|
report: WorkReport.Codec,
|
|
34259
|
-
slot:
|
|
34602
|
+
slot: u32.asOpaque(),
|
|
34260
34603
|
signatures: codecWithContext((context) => {
|
|
34261
34604
|
return codecKnownSizeArray(Credential.Codec, {
|
|
34262
34605
|
minLength: 0,
|
|
@@ -34328,9 +34671,9 @@ const up_0_block_announcement_STREAM_KIND = tryAsStreamKind(0);
|
|
|
34328
34671
|
class HashAndSlot extends WithDebug {
|
|
34329
34672
|
hash;
|
|
34330
34673
|
slot;
|
|
34331
|
-
static Codec =
|
|
34332
|
-
hash:
|
|
34333
|
-
slot:
|
|
34674
|
+
static Codec = Class(HashAndSlot, {
|
|
34675
|
+
hash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
34676
|
+
slot: u32.asOpaque(),
|
|
34334
34677
|
});
|
|
34335
34678
|
static create({ hash, slot }) {
|
|
34336
34679
|
return new HashAndSlot(hash, slot);
|
|
@@ -34347,9 +34690,9 @@ class HashAndSlot extends WithDebug {
|
|
|
34347
34690
|
class Handshake {
|
|
34348
34691
|
final;
|
|
34349
34692
|
leafs;
|
|
34350
|
-
static Codec =
|
|
34693
|
+
static Codec = Class(Handshake, {
|
|
34351
34694
|
final: HashAndSlot.Codec,
|
|
34352
|
-
leafs:
|
|
34695
|
+
leafs: sequenceVarLen(HashAndSlot.Codec),
|
|
34353
34696
|
});
|
|
34354
34697
|
static create({ final, leafs }) {
|
|
34355
34698
|
return new Handshake(final, leafs);
|
|
@@ -34370,7 +34713,7 @@ class Handshake {
|
|
|
34370
34713
|
class Announcement extends WithDebug {
|
|
34371
34714
|
header;
|
|
34372
34715
|
final;
|
|
34373
|
-
static Codec =
|
|
34716
|
+
static Codec = Class(Announcement, {
|
|
34374
34717
|
header: header_Header.Codec,
|
|
34375
34718
|
final: HashAndSlot.Codec,
|
|
34376
34719
|
});
|
|
@@ -34856,12 +35199,9 @@ async function main(config, comms) {
|
|
|
34856
35199
|
main_logger.info `🛜 Network worker finished. Closing channel.`;
|
|
34857
35200
|
}
|
|
34858
35201
|
|
|
34859
|
-
;// CONCATENATED MODULE: external "node:worker_threads"
|
|
34860
|
-
const external_node_worker_threads_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:worker_threads");
|
|
34861
35202
|
;// CONCATENATED MODULE: ./packages/workers/api/channel.ts
|
|
34862
35203
|
|
|
34863
35204
|
|
|
34864
|
-
|
|
34865
35205
|
const channel_logger = Logger.new(import.meta.filename, "workers");
|
|
34866
35206
|
/**
|
|
34867
35207
|
* Wraps a protocol definition and a communication port into a properly
|
|
@@ -34928,10 +35268,10 @@ class channel_Channel {
|
|
|
34928
35268
|
// listen to request incoming to worker
|
|
34929
35269
|
this.port.on(key, val.request, async ({ responseId, data }) => {
|
|
34930
35270
|
try {
|
|
34931
|
-
console.log(`[${threadId}] handling ${key}. Responseid: ${responseId}`);
|
|
35271
|
+
console.log(`[${this.port.threadId}] handling ${key}. Responseid: ${responseId}`);
|
|
34932
35272
|
// handle them
|
|
34933
35273
|
const response = await handler(data);
|
|
34934
|
-
console.log(`[${threadId}] sending response: ${responseId}`);
|
|
35274
|
+
console.log(`[${this.port.threadId}] sending response: ${responseId}`);
|
|
34935
35275
|
// and send response back on dedicated event
|
|
34936
35276
|
this.port.postMessage(responseId, val.response, {
|
|
34937
35277
|
responseId,
|
|
@@ -34949,14 +35289,14 @@ class channel_Channel {
|
|
|
34949
35289
|
return (data) => {
|
|
34950
35290
|
this.nextResponseId++;
|
|
34951
35291
|
const responseId = `${key}:${this.nextResponseId}`;
|
|
34952
|
-
console.log(`[${threadId}] will wait for ${key}`);
|
|
35292
|
+
console.log(`[${this.port.threadId}] will wait for ${key}`);
|
|
34953
35293
|
return new Promise((resolve, reject) => {
|
|
34954
35294
|
this.pendingPromises.add(reject);
|
|
34955
35295
|
// attach response listener first
|
|
34956
35296
|
this.port.once(responseId, val.response, (msg) => {
|
|
34957
35297
|
// we got response, so will resolve
|
|
34958
35298
|
this.pendingPromises.delete(reject);
|
|
34959
|
-
console.log(`[${threadId}] got ${key}`);
|
|
35299
|
+
console.log(`[${this.port.threadId}] got ${key}`);
|
|
34960
35300
|
resolve(msg.data);
|
|
34961
35301
|
});
|
|
34962
35302
|
// send message to the port
|
|
@@ -34981,6 +35321,14 @@ function isMessageCodecs(val) {
|
|
|
34981
35321
|
return val !== null && typeof val === "object" && "request" in val && "response" in val;
|
|
34982
35322
|
}
|
|
34983
35323
|
|
|
35324
|
+
// EXTERNAL MODULE: ./node_modules/eventemitter3/index.js
|
|
35325
|
+
var eventemitter3 = __nccwpck_require__(952);
|
|
35326
|
+
;// CONCATENATED MODULE: ./node_modules/eventemitter3/index.mjs
|
|
35327
|
+
|
|
35328
|
+
|
|
35329
|
+
|
|
35330
|
+
/* harmony default export */ const node_modules_eventemitter3 = ((/* unused pure expression or super */ null && (EventEmitter)));
|
|
35331
|
+
|
|
34984
35332
|
;// CONCATENATED MODULE: ./packages/workers/api/port.ts
|
|
34985
35333
|
|
|
34986
35334
|
/**
|
|
@@ -34991,6 +35339,7 @@ function isMessageCodecs(val) {
|
|
|
34991
35339
|
*/
|
|
34992
35340
|
class port_DirectPort {
|
|
34993
35341
|
events;
|
|
35342
|
+
threadId = 0;
|
|
34994
35343
|
/** Create a pair of symmetrical inter-connected ports. */
|
|
34995
35344
|
static pair() {
|
|
34996
35345
|
const events = new EventEmitter();
|
|
@@ -35068,12 +35417,12 @@ class NetworkingConfig extends WithDebug {
|
|
|
35068
35417
|
host;
|
|
35069
35418
|
port;
|
|
35070
35419
|
bootnodes;
|
|
35071
|
-
static Codec =
|
|
35072
|
-
genesisHeaderHash:
|
|
35073
|
-
key:
|
|
35074
|
-
host:
|
|
35075
|
-
port:
|
|
35076
|
-
bootnodes:
|
|
35420
|
+
static Codec = Class(NetworkingConfig, {
|
|
35421
|
+
genesisHeaderHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
35422
|
+
key: bytes(ED25519_PRIV_KEY_BYTES).asOpaque(),
|
|
35423
|
+
host: string,
|
|
35424
|
+
port: u16,
|
|
35425
|
+
bootnodes: sequenceVarLen(string),
|
|
35077
35426
|
});
|
|
35078
35427
|
static create({ genesisHeaderHash, key, host, port, bootnodes }) {
|
|
35079
35428
|
return new NetworkingConfig(genesisHeaderHash, key, host, port, bootnodes);
|
|
@@ -35101,17 +35450,17 @@ const protocol = createProtocol("net", {
|
|
|
35101
35450
|
toWorker: {
|
|
35102
35451
|
newHeader: {
|
|
35103
35452
|
request: headerViewWithHashCodec,
|
|
35104
|
-
response:
|
|
35453
|
+
response: nothing,
|
|
35105
35454
|
},
|
|
35106
35455
|
finish: {
|
|
35107
|
-
request:
|
|
35108
|
-
response:
|
|
35456
|
+
request: nothing,
|
|
35457
|
+
response: nothing,
|
|
35109
35458
|
},
|
|
35110
35459
|
},
|
|
35111
35460
|
fromWorker: {
|
|
35112
35461
|
blocks: {
|
|
35113
|
-
request:
|
|
35114
|
-
response:
|
|
35462
|
+
request: sequenceVarLen(block_Block.Codec.View),
|
|
35463
|
+
response: nothing,
|
|
35115
35464
|
},
|
|
35116
35465
|
},
|
|
35117
35466
|
});
|