@typeberry/jam 0.1.3-0eba10b → 0.1.3-2fdafd6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bootstrap-importer.mjs +68 -13
- package/bootstrap-importer.mjs.map +1 -1
- package/index.js +68 -13
- package/index.js.map +1 -1
- package/package.json +1 -1
package/bootstrap-importer.mjs
CHANGED
|
@@ -19901,24 +19901,78 @@ class AccumulateExternalities {
|
|
|
19901
19901
|
this.updatedState.stateUpdate.authorizationQueues.set(coreIndex, authQueue);
|
|
19902
19902
|
return result_Result.ok(result_OK);
|
|
19903
19903
|
}
|
|
19904
|
+
updatePrivilegedServiceId(
|
|
19905
|
+
// The id that privileged service wants to be updated to
|
|
19906
|
+
newId,
|
|
19907
|
+
// Current id of privileged service (updated state)
|
|
19908
|
+
currentId, {
|
|
19909
|
+
// is current service id a manager (can update anything)
|
|
19910
|
+
isManager,
|
|
19911
|
+
// is current service attempting to update itself (privileged are owned)
|
|
19912
|
+
isSelf,
|
|
19913
|
+
// is the service id already changed in this block
|
|
19914
|
+
isAlreadyChanged, }) {
|
|
19915
|
+
if (isManager) {
|
|
19916
|
+
return newId;
|
|
19917
|
+
}
|
|
19918
|
+
// current service can update itself, only if it was a privileged
|
|
19919
|
+
// service at the start of the block. I.e. owned privileges cannot
|
|
19920
|
+
// be transfered multiple times in a block.
|
|
19921
|
+
if (isSelf && !isAlreadyChanged) {
|
|
19922
|
+
return newId;
|
|
19923
|
+
}
|
|
19924
|
+
return currentId;
|
|
19925
|
+
}
|
|
19904
19926
|
updatePrivilegedServices(manager, authorizers, delegator, registrar, autoAccumulate) {
|
|
19905
19927
|
/** https://graypaper.fluffylabs.dev/#/7e6ff6a/36d90036de00?v=0.6.7 */
|
|
19906
|
-
const
|
|
19907
|
-
|
|
19908
|
-
|
|
19909
|
-
|
|
19910
|
-
|
|
19911
|
-
|
|
19928
|
+
const current = this.updatedState.getPrivilegedServices();
|
|
19929
|
+
const isManager = current.manager === this.currentServiceId;
|
|
19930
|
+
if (Compatibility.isLessThan(GpVersion.V0_7_1)) {
|
|
19931
|
+
if (!isManager) {
|
|
19932
|
+
return result_Result.error(UpdatePrivilegesError.UnprivilegedService);
|
|
19933
|
+
}
|
|
19934
|
+
if (manager === null || delegator === null) {
|
|
19935
|
+
return result_Result.error(UpdatePrivilegesError.InvalidServiceId, "Either manager or delegator is not a valid service id.");
|
|
19936
|
+
}
|
|
19937
|
+
this.updatedState.stateUpdate.privilegedServices = PrivilegedServices.create({
|
|
19938
|
+
manager,
|
|
19939
|
+
assigners: authorizers,
|
|
19940
|
+
delegator: delegator,
|
|
19941
|
+
registrar: registrar ?? tryAsServiceId(0),
|
|
19942
|
+
autoAccumulateServices: autoAccumulate.map(([service, gasLimit]) => AutoAccumulate.create({ service, gasLimit })),
|
|
19943
|
+
});
|
|
19944
|
+
return result_Result.ok(result_OK);
|
|
19912
19945
|
}
|
|
19913
|
-
|
|
19914
|
-
|
|
19946
|
+
const original = this.updatedState.state.privilegedServices;
|
|
19947
|
+
if (manager === null || delegator === null || registrar === null) {
|
|
19948
|
+
return result_Result.error(UpdatePrivilegesError.InvalidServiceId, "Either manager or delegator or registrar is not a valid service id.");
|
|
19915
19949
|
}
|
|
19950
|
+
const newDelegator = this.updatePrivilegedServiceId(delegator, current.delegator, {
|
|
19951
|
+
isManager,
|
|
19952
|
+
isSelf: this.currentServiceId === current.delegator,
|
|
19953
|
+
isAlreadyChanged: current.delegator !== original.delegator,
|
|
19954
|
+
});
|
|
19955
|
+
const newRegistrar = this.updatePrivilegedServiceId(registrar, current.registrar, {
|
|
19956
|
+
isManager,
|
|
19957
|
+
isSelf: this.currentServiceId === current.registrar,
|
|
19958
|
+
isAlreadyChanged: current.registrar !== original.registrar,
|
|
19959
|
+
});
|
|
19960
|
+
const newAssigners = current.assigners.map((currentAssigner, index) => this.updatePrivilegedServiceId(authorizers[index], currentAssigner, {
|
|
19961
|
+
isManager,
|
|
19962
|
+
isSelf: this.currentServiceId === currentAssigner,
|
|
19963
|
+
isAlreadyChanged: currentAssigner !== original.assigners[index],
|
|
19964
|
+
}));
|
|
19965
|
+
const newManager = isManager ? manager : current.manager;
|
|
19966
|
+
const newAutoAccumulateServices = isManager
|
|
19967
|
+
? autoAccumulate.map(([service, gasLimit]) => AutoAccumulate.create({ service, gasLimit }))
|
|
19968
|
+
: current.autoAccumulateServices;
|
|
19969
|
+
// finally update the privileges
|
|
19916
19970
|
this.updatedState.stateUpdate.privilegedServices = PrivilegedServices.create({
|
|
19917
|
-
manager,
|
|
19918
|
-
assigners:
|
|
19919
|
-
delegator,
|
|
19920
|
-
registrar:
|
|
19921
|
-
autoAccumulateServices:
|
|
19971
|
+
manager: newManager,
|
|
19972
|
+
assigners: tryAsPerCore(newAssigners, this.chainSpec),
|
|
19973
|
+
delegator: newDelegator,
|
|
19974
|
+
registrar: newRegistrar,
|
|
19975
|
+
autoAccumulateServices: newAutoAccumulateServices,
|
|
19922
19976
|
});
|
|
19923
19977
|
return result_Result.ok(result_OK);
|
|
19924
19978
|
}
|
|
@@ -21277,6 +21331,7 @@ class Bless {
|
|
|
21277
21331
|
return;
|
|
21278
21332
|
}
|
|
21279
21333
|
const e = updateResult.error;
|
|
21334
|
+
// NOTE: `UpdatePrivilegesError.UnprivilegedService` won't happen in 0.7.1+
|
|
21280
21335
|
if (e === UpdatePrivilegesError.UnprivilegedService) {
|
|
21281
21336
|
logger_logger.trace `BLESS(${manager}, ${authorizers}, ${delegator}, ${registrar}, ${autoAccumulateEntries}) <- HUH`;
|
|
21282
21337
|
regs.set(bless_IN_OUT_REG, HostCallResult.HUH);
|