@typeberry/jam 0.4.0-5a35a0a → 0.4.0-da92f56
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 +10 -8
- package/bootstrap-generator.mjs.map +1 -1
- package/bootstrap-importer.mjs +44 -39
- package/bootstrap-importer.mjs.map +1 -1
- package/bootstrap-network.mjs +9 -8
- package/bootstrap-network.mjs.map +1 -1
- package/index.js +46 -41
- package/index.js.map +1 -1
- package/package.json +1 -1
package/bootstrap-importer.mjs
CHANGED
|
@@ -3550,7 +3550,11 @@ var TestSuite;
|
|
|
3550
3550
|
})(TestSuite || (TestSuite = {}));
|
|
3551
3551
|
const ALL_VERSIONS_IN_ORDER = [compatibility_GpVersion.V0_6_7, compatibility_GpVersion.V0_7_0, compatibility_GpVersion.V0_7_1, compatibility_GpVersion.V0_7_2];
|
|
3552
3552
|
const DEFAULT_SUITE = TestSuite.W3F_DAVXY;
|
|
3553
|
-
|
|
3553
|
+
/**
|
|
3554
|
+
* Current version is set to track the jam-conformance testing.
|
|
3555
|
+
* Since we are currently at 0.7.1 not 0.7.2, we set our default version accordingly.
|
|
3556
|
+
*/
|
|
3557
|
+
const DEFAULT_VERSION = compatibility_GpVersion.V0_7_1;
|
|
3554
3558
|
const env = typeof process === "undefined" ? {} : process.env;
|
|
3555
3559
|
let CURRENT_VERSION = parseCurrentVersion(env.GP_VERSION) ?? DEFAULT_VERSION;
|
|
3556
3560
|
let CURRENT_SUITE = parseCurrentSuite(env.TEST_SUITE) ?? DEFAULT_SUITE;
|
|
@@ -3609,8 +3613,8 @@ class compatibility_Compatibility {
|
|
|
3609
3613
|
/**
|
|
3610
3614
|
* Allows selecting different values for different Gray Paper versions from one record.
|
|
3611
3615
|
*
|
|
3612
|
-
*
|
|
3613
|
-
*
|
|
3616
|
+
* fallback The default value to return if no value is found for the current.
|
|
3617
|
+
* versions A record mapping versions to values, checking if the version is greater or equal to the current version.
|
|
3614
3618
|
* @returns The value for the current version, or the default value.
|
|
3615
3619
|
*/
|
|
3616
3620
|
static selectIfGreaterOrEqual({ fallback, versions, }) {
|
|
@@ -3773,7 +3777,7 @@ const workspacePathFix = dev_env.NODE_ENV === "development"
|
|
|
3773
3777
|
|
|
3774
3778
|
;// CONCATENATED MODULE: ./packages/core/utils/opaque.ts
|
|
3775
3779
|
/**
|
|
3776
|
-
*
|
|
3780
|
+
* `Opaque<Type, Token>` constructs a unique type which is a subset of Type with a
|
|
3777
3781
|
* specified unique token Token. It means that base type cannot be assigned to unique type by accident.
|
|
3778
3782
|
* Good examples of opaque types include:
|
|
3779
3783
|
* - JWTs or other tokens - these are special kinds of string used for authorization purposes.
|
|
@@ -7100,11 +7104,9 @@ function sequenceViewFixLen(type, { fixedLength }) {
|
|
|
7100
7104
|
|
|
7101
7105
|
/** Helper function to create most used hashes in the block */
|
|
7102
7106
|
class TransitionHasher {
|
|
7103
|
-
context;
|
|
7104
7107
|
keccakHasher;
|
|
7105
7108
|
blake2b;
|
|
7106
|
-
constructor(
|
|
7107
|
-
this.context = context;
|
|
7109
|
+
constructor(keccakHasher, blake2b) {
|
|
7108
7110
|
this.keccakHasher = keccakHasher;
|
|
7109
7111
|
this.blake2b = blake2b;
|
|
7110
7112
|
}
|
|
@@ -13212,7 +13214,6 @@ class LeafNode {
|
|
|
13212
13214
|
/**
|
|
13213
13215
|
* Get the byte length of embedded value.
|
|
13214
13216
|
*
|
|
13215
|
-
* @remark
|
|
13216
13217
|
* Note in case this node only contains hash this is going to be 0.
|
|
13217
13218
|
*/
|
|
13218
13219
|
getValueLength() {
|
|
@@ -13223,7 +13224,6 @@ class LeafNode {
|
|
|
13223
13224
|
/**
|
|
13224
13225
|
* Returns the embedded value.
|
|
13225
13226
|
*
|
|
13226
|
-
* @remark
|
|
13227
13227
|
* Note that this is going to be empty for a regular leaf node (i.e. containing a hash).
|
|
13228
13228
|
*/
|
|
13229
13229
|
getValue() {
|
|
@@ -13233,7 +13233,6 @@ class LeafNode {
|
|
|
13233
13233
|
/**
|
|
13234
13234
|
* Returns contained value hash.
|
|
13235
13235
|
*
|
|
13236
|
-
* @remark
|
|
13237
13236
|
* Note that for embedded value this is going to be full 0-padded 32 bytes.
|
|
13238
13237
|
*/
|
|
13239
13238
|
getValueHash() {
|
|
@@ -20816,13 +20815,11 @@ class AccumulateDataItem {
|
|
|
20816
20815
|
* - gas cost and reports length for each service (statistics)
|
|
20817
20816
|
*/
|
|
20818
20817
|
class AccumulateData {
|
|
20819
|
-
autoAccumulateServicesByServiceId;
|
|
20820
20818
|
reportsDataByServiceId;
|
|
20821
20819
|
transfersByServiceId;
|
|
20822
20820
|
serviceIds;
|
|
20823
20821
|
gasLimitByServiceId;
|
|
20824
20822
|
constructor(reports, transfers, autoAccumulateServicesByServiceId) {
|
|
20825
|
-
this.autoAccumulateServicesByServiceId = autoAccumulateServicesByServiceId;
|
|
20826
20823
|
const serviceIdsFromAutoAccumulate = new Set(autoAccumulateServicesByServiceId.keys());
|
|
20827
20824
|
const { reportsDataByServiceId, serviceIds: serviceIdsFromReports, gasLimitByServiceId: reportsGasLimitByServiceId, } = this.transformReports(reports);
|
|
20828
20825
|
this.reportsDataByServiceId = reportsDataByServiceId;
|
|
@@ -21142,12 +21139,12 @@ function createMergeContext(chainSpec, state, inputState, results) {
|
|
|
21142
21139
|
}
|
|
21143
21140
|
function updatePrivilegedService(currentServiceId, serviceIdUpdatedByManager, selfUpdatedServiceId) {
|
|
21144
21141
|
if (currentServiceId === serviceIdUpdatedByManager) {
|
|
21145
|
-
return
|
|
21142
|
+
return selfUpdatedServiceId;
|
|
21146
21143
|
}
|
|
21147
|
-
return
|
|
21144
|
+
return serviceIdUpdatedByManager;
|
|
21148
21145
|
}
|
|
21149
21146
|
function mergePrivilegedServices(mergeContext, [serviceId, { stateUpdate }]) {
|
|
21150
|
-
const { outputState, currentPrivilegedServices, chainSpec } = mergeContext;
|
|
21147
|
+
const { outputState, currentPrivilegedServices, chainSpec, privilegedServicesUpdatedByManager } = mergeContext;
|
|
21151
21148
|
const currentManager = currentPrivilegedServices.manager;
|
|
21152
21149
|
const currentRegistrar = currentPrivilegedServices.registrar;
|
|
21153
21150
|
const currentDelegator = currentPrivilegedServices.delegator;
|
|
@@ -21165,28 +21162,35 @@ function mergePrivilegedServices(mergeContext, [serviceId, { stateUpdate }]) {
|
|
|
21165
21162
|
});
|
|
21166
21163
|
}
|
|
21167
21164
|
if (serviceId === currentRegistrar) {
|
|
21168
|
-
const newRegistrar = updatePrivilegedService(currentPrivilegedServices.registrar,
|
|
21165
|
+
const newRegistrar = updatePrivilegedService(currentPrivilegedServices.registrar, privilegedServicesUpdatedByManager.registrar, privilegedServices.registrar);
|
|
21169
21166
|
outputState.privilegedServices = PrivilegedServices.create({
|
|
21170
21167
|
...outputState.privilegedServices,
|
|
21171
21168
|
registrar: newRegistrar,
|
|
21172
21169
|
});
|
|
21173
21170
|
}
|
|
21174
21171
|
if (serviceId === currentDelegator) {
|
|
21175
|
-
const newDelegator = updatePrivilegedService(currentPrivilegedServices.delegator,
|
|
21172
|
+
const newDelegator = updatePrivilegedService(currentPrivilegedServices.delegator, privilegedServicesUpdatedByManager.delegator, privilegedServices.delegator);
|
|
21176
21173
|
outputState.privilegedServices = PrivilegedServices.create({
|
|
21177
21174
|
...outputState.privilegedServices,
|
|
21178
21175
|
delegator: newDelegator,
|
|
21179
21176
|
});
|
|
21180
21177
|
}
|
|
21181
|
-
|
|
21182
|
-
const newAssigners = currentAssigners.map((currentAssigner, coreIndex) =>
|
|
21183
|
-
|
|
21184
|
-
|
|
21185
|
-
|
|
21186
|
-
|
|
21187
|
-
|
|
21188
|
-
|
|
21178
|
+
let shouldUpdateAssigners = false;
|
|
21179
|
+
const newAssigners = currentAssigners.map((currentAssigner, coreIndex) => {
|
|
21180
|
+
if (serviceId === currentAssigner) {
|
|
21181
|
+
const newAssigner = updatePrivilegedService(currentPrivilegedServices.assigners[coreIndex], privilegedServicesUpdatedByManager.assigners[coreIndex], privilegedServices.assigners[coreIndex]);
|
|
21182
|
+
shouldUpdateAssigners = shouldUpdateAssigners || newAssigner !== currentAssigner;
|
|
21183
|
+
return newAssigner;
|
|
21184
|
+
}
|
|
21185
|
+
return currentAssigner;
|
|
21189
21186
|
});
|
|
21187
|
+
if (shouldUpdateAssigners) {
|
|
21188
|
+
const newAssignersPerCore = tryAsPerCore(newAssigners, chainSpec);
|
|
21189
|
+
outputState.privilegedServices = PrivilegedServices.create({
|
|
21190
|
+
...outputState.privilegedServices,
|
|
21191
|
+
assigners: newAssignersPerCore,
|
|
21192
|
+
});
|
|
21193
|
+
}
|
|
21190
21194
|
}
|
|
21191
21195
|
}
|
|
21192
21196
|
function mergeValidatorsData(mergeContext, [serviceId, { stateUpdate }]) {
|
|
@@ -22968,19 +22972,19 @@ class Accumulate {
|
|
|
22968
22972
|
for (let serviceIndex = 0; serviceIndex < serviceIdsLength; serviceIndex += 1) {
|
|
22969
22973
|
const serviceId = serviceIds[serviceIndex];
|
|
22970
22974
|
const checkpoint = AccumulationStateUpdate.copyFrom(inputStateUpdate);
|
|
22971
|
-
const promise = this.accumulateSingleService(serviceId, accumulateData.getTransfers(serviceId), accumulateData.getOperands(serviceId), accumulateData.getGasLimit(serviceId), slot, entropy, AccumulationStateUpdate.copyFrom(inputStateUpdate)).then(({ consumedGas, stateUpdate }) =>
|
|
22972
|
-
|
|
22973
|
-
|
|
22974
|
-
|
|
22975
|
+
const promise = this.accumulateSingleService(serviceId, accumulateData.getTransfers(serviceId), accumulateData.getOperands(serviceId), accumulateData.getGasLimit(serviceId), slot, entropy, AccumulationStateUpdate.copyFrom(inputStateUpdate)).then(({ consumedGas, stateUpdate }) => {
|
|
22976
|
+
const resultEntry = [
|
|
22977
|
+
serviceId,
|
|
22978
|
+
{
|
|
22979
|
+
consumedGas,
|
|
22980
|
+
stateUpdate: stateUpdate === null ? checkpoint : stateUpdate,
|
|
22981
|
+
},
|
|
22982
|
+
];
|
|
22983
|
+
return resultEntry;
|
|
22984
|
+
});
|
|
22975
22985
|
resultPromises[serviceIndex] = promise;
|
|
22976
22986
|
}
|
|
22977
|
-
return Promise.all(resultPromises).then((results) =>
|
|
22978
|
-
const map = new Map();
|
|
22979
|
-
for (let serviceIndex = 0; serviceIndex < serviceIdsLength; serviceIndex += 1) {
|
|
22980
|
-
map.set(serviceIds[serviceIndex], results[serviceIndex]);
|
|
22981
|
-
}
|
|
22982
|
-
return map;
|
|
22983
|
-
});
|
|
22987
|
+
return Promise.all(resultPromises).then((results) => new Map(results));
|
|
22984
22988
|
}
|
|
22985
22989
|
/**
|
|
22986
22990
|
* A method that updates `recentlyAccumulated`, `accumulationQueue` and `timeslot` in state
|
|
@@ -23069,9 +23073,10 @@ class Accumulate {
|
|
|
23069
23073
|
const _gasCost = gasCost;
|
|
23070
23074
|
assertEmpty(rest);
|
|
23071
23075
|
const accumulated = accumulatableReports.subview(0, accumulatedReports);
|
|
23072
|
-
const { yieldedRoot, services, transfers
|
|
23076
|
+
const { yieldedRoot, services, transfers, validatorsData, privilegedServices, authorizationQueues, ...stateUpdateRest } = state;
|
|
23073
23077
|
assertEmpty(stateUpdateRest);
|
|
23074
|
-
// yielded root
|
|
23078
|
+
// transfers and yielded root are retrieved after each pvm invocation so we can ignore it here
|
|
23079
|
+
const _transfers = transfers;
|
|
23075
23080
|
const _yieldedRoot = yieldedRoot;
|
|
23076
23081
|
if (this.hasDuplicatedServiceIdCreated(services.created)) {
|
|
23077
23082
|
accumulate_logger.trace `Duplicated Service creation detected. Block is invalid.`;
|
|
@@ -25002,7 +25007,7 @@ async function createImporter(config) {
|
|
|
25002
25007
|
const interpreter = config.workerParams.pvm;
|
|
25003
25008
|
const blocks = db.getBlocksDb();
|
|
25004
25009
|
const states = db.getStatesDb();
|
|
25005
|
-
const hasher = new TransitionHasher(
|
|
25010
|
+
const hasher = new TransitionHasher(await keccakHasher, await blake2b);
|
|
25006
25011
|
const importer = new Importer(chainSpec, interpreter, hasher, main_logger, blocks, states);
|
|
25007
25012
|
return {
|
|
25008
25013
|
importer,
|