@typeberry/jam 0.3.1-27dfdd9 → 0.4.0-13b653d
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 +5 -0
- package/bootstrap-generator.mjs +5 -7
- package/bootstrap-generator.mjs.map +1 -1
- package/bootstrap-importer.mjs +39 -38
- package/bootstrap-importer.mjs.map +1 -1
- package/bootstrap-network.mjs +4 -7
- package/bootstrap-network.mjs.map +1 -1
- package/index.js +43 -42
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -24373,8 +24373,8 @@ class Compatibility {
|
|
|
24373
24373
|
/**
|
|
24374
24374
|
* Allows selecting different values for different Gray Paper versions from one record.
|
|
24375
24375
|
*
|
|
24376
|
-
*
|
|
24377
|
-
*
|
|
24376
|
+
* fallback The default value to return if no value is found for the current.
|
|
24377
|
+
* versions A record mapping versions to values, checking if the version is greater or equal to the current version.
|
|
24378
24378
|
* @returns The value for the current version, or the default value.
|
|
24379
24379
|
*/
|
|
24380
24380
|
static selectIfGreaterOrEqual({ fallback, versions, }) {
|
|
@@ -24537,7 +24537,7 @@ const workspacePathFix = dev_env.NODE_ENV === "development"
|
|
|
24537
24537
|
|
|
24538
24538
|
;// CONCATENATED MODULE: ./packages/core/utils/opaque.ts
|
|
24539
24539
|
/**
|
|
24540
|
-
*
|
|
24540
|
+
* `Opaque<Type, Token>` constructs a unique type which is a subset of Type with a
|
|
24541
24541
|
* specified unique token Token. It means that base type cannot be assigned to unique type by accident.
|
|
24542
24542
|
* Good examples of opaque types include:
|
|
24543
24543
|
* - JWTs or other tokens - these are special kinds of string used for authorization purposes.
|
|
@@ -31185,7 +31185,7 @@ function jip_chain_spec_parseBootnode(v) {
|
|
|
31185
31185
|
if (name === "" || ip === "" || port === "") {
|
|
31186
31186
|
throw new Error(`Invalid bootnode format, expected: <name>@<ip>:<port>, got: "${v}"`);
|
|
31187
31187
|
}
|
|
31188
|
-
const portNumber = Number.parseInt(port);
|
|
31188
|
+
const portNumber = Number.parseInt(port, 10);
|
|
31189
31189
|
if (!isU16(portNumber)) {
|
|
31190
31190
|
throw new Error(`Invalid port number: "${port}"`);
|
|
31191
31191
|
}
|
|
@@ -35445,7 +35445,6 @@ class LeafNode {
|
|
|
35445
35445
|
/**
|
|
35446
35446
|
* Get the byte length of embedded value.
|
|
35447
35447
|
*
|
|
35448
|
-
* @remark
|
|
35449
35448
|
* Note in case this node only contains hash this is going to be 0.
|
|
35450
35449
|
*/
|
|
35451
35450
|
getValueLength() {
|
|
@@ -35456,7 +35455,6 @@ class LeafNode {
|
|
|
35456
35455
|
/**
|
|
35457
35456
|
* Returns the embedded value.
|
|
35458
35457
|
*
|
|
35459
|
-
* @remark
|
|
35460
35458
|
* Note that this is going to be empty for a regular leaf node (i.e. containing a hash).
|
|
35461
35459
|
*/
|
|
35462
35460
|
getValue() {
|
|
@@ -35466,7 +35464,6 @@ class LeafNode {
|
|
|
35466
35464
|
/**
|
|
35467
35465
|
* Returns contained value hash.
|
|
35468
35466
|
*
|
|
35469
|
-
* @remark
|
|
35470
35467
|
* Note that for embedded value this is going to be full 0-padded 32 bytes.
|
|
35471
35468
|
*/
|
|
35472
35469
|
getValueHash() {
|
|
@@ -37588,11 +37585,9 @@ class JamConfig {
|
|
|
37588
37585
|
|
|
37589
37586
|
/** Helper function to create most used hashes in the block */
|
|
37590
37587
|
class hasher_TransitionHasher {
|
|
37591
|
-
context;
|
|
37592
37588
|
keccakHasher;
|
|
37593
37589
|
blake2b;
|
|
37594
|
-
constructor(
|
|
37595
|
-
this.context = context;
|
|
37590
|
+
constructor(keccakHasher, blake2b) {
|
|
37596
37591
|
this.keccakHasher = keccakHasher;
|
|
37597
37592
|
this.blake2b = blake2b;
|
|
37598
37593
|
}
|
|
@@ -45578,13 +45573,11 @@ class AccumulateDataItem {
|
|
|
45578
45573
|
* - gas cost and reports length for each service (statistics)
|
|
45579
45574
|
*/
|
|
45580
45575
|
class AccumulateData {
|
|
45581
|
-
autoAccumulateServicesByServiceId;
|
|
45582
45576
|
reportsDataByServiceId;
|
|
45583
45577
|
transfersByServiceId;
|
|
45584
45578
|
serviceIds;
|
|
45585
45579
|
gasLimitByServiceId;
|
|
45586
45580
|
constructor(reports, transfers, autoAccumulateServicesByServiceId) {
|
|
45587
|
-
this.autoAccumulateServicesByServiceId = autoAccumulateServicesByServiceId;
|
|
45588
45581
|
const serviceIdsFromAutoAccumulate = new Set(autoAccumulateServicesByServiceId.keys());
|
|
45589
45582
|
const { reportsDataByServiceId, serviceIds: serviceIdsFromReports, gasLimitByServiceId: reportsGasLimitByServiceId, } = this.transformReports(reports);
|
|
45590
45583
|
this.reportsDataByServiceId = reportsDataByServiceId;
|
|
@@ -45904,12 +45897,12 @@ function createMergeContext(chainSpec, state, inputState, results) {
|
|
|
45904
45897
|
}
|
|
45905
45898
|
function updatePrivilegedService(currentServiceId, serviceIdUpdatedByManager, selfUpdatedServiceId) {
|
|
45906
45899
|
if (currentServiceId === serviceIdUpdatedByManager) {
|
|
45907
|
-
return
|
|
45900
|
+
return selfUpdatedServiceId;
|
|
45908
45901
|
}
|
|
45909
|
-
return
|
|
45902
|
+
return serviceIdUpdatedByManager;
|
|
45910
45903
|
}
|
|
45911
45904
|
function mergePrivilegedServices(mergeContext, [serviceId, { stateUpdate }]) {
|
|
45912
|
-
const { outputState, currentPrivilegedServices, chainSpec } = mergeContext;
|
|
45905
|
+
const { outputState, currentPrivilegedServices, chainSpec, privilegedServicesUpdatedByManager } = mergeContext;
|
|
45913
45906
|
const currentManager = currentPrivilegedServices.manager;
|
|
45914
45907
|
const currentRegistrar = currentPrivilegedServices.registrar;
|
|
45915
45908
|
const currentDelegator = currentPrivilegedServices.delegator;
|
|
@@ -45927,28 +45920,35 @@ function mergePrivilegedServices(mergeContext, [serviceId, { stateUpdate }]) {
|
|
|
45927
45920
|
});
|
|
45928
45921
|
}
|
|
45929
45922
|
if (serviceId === currentRegistrar) {
|
|
45930
|
-
const newRegistrar = updatePrivilegedService(currentPrivilegedServices.registrar,
|
|
45923
|
+
const newRegistrar = updatePrivilegedService(currentPrivilegedServices.registrar, privilegedServicesUpdatedByManager.registrar, privilegedServices.registrar);
|
|
45931
45924
|
outputState.privilegedServices = PrivilegedServices.create({
|
|
45932
45925
|
...outputState.privilegedServices,
|
|
45933
45926
|
registrar: newRegistrar,
|
|
45934
45927
|
});
|
|
45935
45928
|
}
|
|
45936
45929
|
if (serviceId === currentDelegator) {
|
|
45937
|
-
const newDelegator = updatePrivilegedService(currentPrivilegedServices.delegator,
|
|
45930
|
+
const newDelegator = updatePrivilegedService(currentPrivilegedServices.delegator, privilegedServicesUpdatedByManager.delegator, privilegedServices.delegator);
|
|
45938
45931
|
outputState.privilegedServices = PrivilegedServices.create({
|
|
45939
45932
|
...outputState.privilegedServices,
|
|
45940
45933
|
delegator: newDelegator,
|
|
45941
45934
|
});
|
|
45942
45935
|
}
|
|
45943
|
-
|
|
45944
|
-
const newAssigners = currentAssigners.map((currentAssigner, coreIndex) =>
|
|
45945
|
-
|
|
45946
|
-
|
|
45947
|
-
|
|
45948
|
-
|
|
45949
|
-
|
|
45950
|
-
|
|
45936
|
+
let shouldUpdateAssigners = false;
|
|
45937
|
+
const newAssigners = currentAssigners.map((currentAssigner, coreIndex) => {
|
|
45938
|
+
if (serviceId === currentAssigner) {
|
|
45939
|
+
const newAssigner = updatePrivilegedService(currentPrivilegedServices.assigners[coreIndex], privilegedServicesUpdatedByManager.assigners[coreIndex], privilegedServices.assigners[coreIndex]);
|
|
45940
|
+
shouldUpdateAssigners = shouldUpdateAssigners || newAssigner !== currentAssigner;
|
|
45941
|
+
return newAssigner;
|
|
45942
|
+
}
|
|
45943
|
+
return currentAssigner;
|
|
45951
45944
|
});
|
|
45945
|
+
if (shouldUpdateAssigners) {
|
|
45946
|
+
const newAssignersPerCore = tryAsPerCore(newAssigners, chainSpec);
|
|
45947
|
+
outputState.privilegedServices = PrivilegedServices.create({
|
|
45948
|
+
...outputState.privilegedServices,
|
|
45949
|
+
assigners: newAssignersPerCore,
|
|
45950
|
+
});
|
|
45951
|
+
}
|
|
45952
45952
|
}
|
|
45953
45953
|
}
|
|
45954
45954
|
function mergeValidatorsData(mergeContext, [serviceId, { stateUpdate }]) {
|
|
@@ -47730,19 +47730,19 @@ class Accumulate {
|
|
|
47730
47730
|
for (let serviceIndex = 0; serviceIndex < serviceIdsLength; serviceIndex += 1) {
|
|
47731
47731
|
const serviceId = serviceIds[serviceIndex];
|
|
47732
47732
|
const checkpoint = AccumulationStateUpdate.copyFrom(inputStateUpdate);
|
|
47733
|
-
const promise = this.accumulateSingleService(serviceId, accumulateData.getTransfers(serviceId), accumulateData.getOperands(serviceId), accumulateData.getGasLimit(serviceId), slot, entropy, AccumulationStateUpdate.copyFrom(inputStateUpdate)).then(({ consumedGas, stateUpdate }) =>
|
|
47734
|
-
|
|
47735
|
-
|
|
47736
|
-
|
|
47733
|
+
const promise = this.accumulateSingleService(serviceId, accumulateData.getTransfers(serviceId), accumulateData.getOperands(serviceId), accumulateData.getGasLimit(serviceId), slot, entropy, AccumulationStateUpdate.copyFrom(inputStateUpdate)).then(({ consumedGas, stateUpdate }) => {
|
|
47734
|
+
const resultEntry = [
|
|
47735
|
+
serviceId,
|
|
47736
|
+
{
|
|
47737
|
+
consumedGas,
|
|
47738
|
+
stateUpdate: stateUpdate === null ? checkpoint : stateUpdate,
|
|
47739
|
+
},
|
|
47740
|
+
];
|
|
47741
|
+
return resultEntry;
|
|
47742
|
+
});
|
|
47737
47743
|
resultPromises[serviceIndex] = promise;
|
|
47738
47744
|
}
|
|
47739
|
-
return Promise.all(resultPromises).then((results) =>
|
|
47740
|
-
const map = new Map();
|
|
47741
|
-
for (let serviceIndex = 0; serviceIndex < serviceIdsLength; serviceIndex += 1) {
|
|
47742
|
-
map.set(serviceIds[serviceIndex], results[serviceIndex]);
|
|
47743
|
-
}
|
|
47744
|
-
return map;
|
|
47745
|
-
});
|
|
47745
|
+
return Promise.all(resultPromises).then((results) => new Map(results));
|
|
47746
47746
|
}
|
|
47747
47747
|
/**
|
|
47748
47748
|
* A method that updates `recentlyAccumulated`, `accumulationQueue` and `timeslot` in state
|
|
@@ -47831,9 +47831,10 @@ class Accumulate {
|
|
|
47831
47831
|
const _gasCost = gasCost;
|
|
47832
47832
|
assertEmpty(rest);
|
|
47833
47833
|
const accumulated = accumulatableReports.subview(0, accumulatedReports);
|
|
47834
|
-
const { yieldedRoot, services, transfers
|
|
47834
|
+
const { yieldedRoot, services, transfers, validatorsData, privilegedServices, authorizationQueues, ...stateUpdateRest } = state;
|
|
47835
47835
|
assertEmpty(stateUpdateRest);
|
|
47836
|
-
// yielded root
|
|
47836
|
+
// transfers and yielded root are retrieved after each pvm invocation so we can ignore it here
|
|
47837
|
+
const _transfers = transfers;
|
|
47837
47838
|
const _yieldedRoot = yieldedRoot;
|
|
47838
47839
|
if (this.hasDuplicatedServiceIdCreated(services.created)) {
|
|
47839
47840
|
accumulate_logger.trace `Duplicated Service creation detected. Block is invalid.`;
|
|
@@ -49764,7 +49765,7 @@ async function createImporter(config) {
|
|
|
49764
49765
|
const interpreter = config.workerParams.pvm;
|
|
49765
49766
|
const blocks = db.getBlocksDb();
|
|
49766
49767
|
const states = db.getStatesDb();
|
|
49767
|
-
const hasher = new hasher_TransitionHasher(
|
|
49768
|
+
const hasher = new hasher_TransitionHasher(await keccakHasher, await blake2b);
|
|
49768
49769
|
const importer = new Importer(chainSpec, interpreter, hasher, main_logger, blocks, states);
|
|
49769
49770
|
return {
|
|
49770
49771
|
importer,
|
|
@@ -52421,7 +52422,7 @@ function initializeExtensions(api) {
|
|
|
52421
52422
|
}
|
|
52422
52423
|
|
|
52423
52424
|
;// CONCATENATED MODULE: ./packages/jam/node/package.json
|
|
52424
|
-
const package_namespaceObject = {"rE":"0.
|
|
52425
|
+
const package_namespaceObject = {"rE":"0.4.0"};
|
|
52425
52426
|
;// CONCATENATED MODULE: ./packages/workers/block-generator/generator.ts
|
|
52426
52427
|
|
|
52427
52428
|
|
|
@@ -52488,7 +52489,7 @@ class generator_Generator {
|
|
|
52488
52489
|
// select validator for block
|
|
52489
52490
|
const validatorId = tryAsValidatorIndex(newTimeSlot % 6);
|
|
52490
52491
|
// retriev data from previous block
|
|
52491
|
-
const hasher = new TransitionHasher(this.
|
|
52492
|
+
const hasher = new TransitionHasher(this.keccakHasher, this.blake2b);
|
|
52492
52493
|
const parentHeaderHash = this.lastHeaderHash;
|
|
52493
52494
|
const stateRoot = this.states.getStateRoot(this.lastState);
|
|
52494
52495
|
// create extrinsic
|
|
@@ -53055,7 +53056,7 @@ function readJsonBlock(file, chainSpec) {
|
|
|
53055
53056
|
var minimist = __nccwpck_require__(8595);
|
|
53056
53057
|
var minimist_default = /*#__PURE__*/__nccwpck_require__.n(minimist);
|
|
53057
53058
|
;// CONCATENATED MODULE: ./bin/jam/package.json
|
|
53058
|
-
const jam_package_namespaceObject = {"rE":"0.
|
|
53059
|
+
const jam_package_namespaceObject = {"rE":"0.4.0"};
|
|
53059
53060
|
;// CONCATENATED MODULE: ./bin/jam/args.ts
|
|
53060
53061
|
|
|
53061
53062
|
|