@typeberry/jam 0.1.1-127cc86 → 0.1.1-4a6ffa9

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/importer/index.js CHANGED
@@ -4436,6 +4436,34 @@ class WithDebug {
4436
4436
  }
4437
4437
  }
4438
4438
 
4439
+ ;// CONCATENATED MODULE: ./packages/core/utils/dev.ts
4440
+ const dev_env = typeof process === "undefined" ? {} : process.env;
4441
+ /**
4442
+ * The function will produce relative path resolver that is adjusted
4443
+ * for package location within the workspace.
4444
+ *
4445
+ * Example:
4446
+ * $ npm start -w @typeberry/jam
4447
+ *
4448
+ * The above command will run `./bin/jam/index.js`, however we would
4449
+ * still want relative paths to be resolved according to top-level workspace
4450
+ * directory.
4451
+ *
4452
+ * So the caller, passes the absolute workspace path as argument and get's
4453
+ * a function that can properly resolve relative paths.
4454
+ *
4455
+ * NOTE: the translation happens only for development build! When
4456
+ * we build a single library from our project, we no longer mangle the paths.
4457
+ */
4458
+ const workspacePathFix = dev_env.NODE_ENV === "development"
4459
+ ? (workspacePath) => (p) => {
4460
+ if (p.startsWith("/")) {
4461
+ return p;
4462
+ }
4463
+ return `${workspacePath}/${p}`;
4464
+ }
4465
+ : () => (p) => p;
4466
+
4439
4467
  ;// CONCATENATED MODULE: ./packages/core/utils/opaque.ts
4440
4468
  /**
4441
4469
  * @fileoverview `Opaque<Type, Token>` constructs a unique type which is a subset of Type with a
@@ -4779,6 +4807,7 @@ function isResult(x) {
4779
4807
 
4780
4808
 
4781
4809
 
4810
+
4782
4811
  ;// CONCATENATED MODULE: ./packages/core/bytes/bitvec.ts
4783
4812
 
4784
4813
  /**
@@ -23352,6 +23381,7 @@ class Accumulate {
23352
23381
  const serviceIds = accumulateData.getServiceIds();
23353
23382
  let gasCost = common_tryAsServiceGas(0);
23354
23383
  let currentState = inputStateUpdate;
23384
+ const currentManager = (inputStateUpdate.privilegedServices ?? this.state.privilegedServices).manager;
23355
23385
  for (const serviceId of serviceIds) {
23356
23386
  const checkpoint = AccumulationStateUpdate.copyFrom(currentState);
23357
23387
  const { consumedGas, stateUpdate } = await this.accumulateSingleService(serviceId, accumulateData.getOperands(serviceId), accumulateData.getGasCost(serviceId), slot, entropy, currentState);
@@ -23361,6 +23391,21 @@ class Accumulate {
23361
23391
  serviceStatistics.gasUsed = common_tryAsServiceGas(serviceStatistics.gasUsed + consumedGas);
23362
23392
  statistics.set(serviceId, serviceStatistics);
23363
23393
  currentState = stateUpdate === null ? checkpoint : stateUpdate;
23394
+ if (Compatibility.is(GpVersion.V0_7_0) && serviceId === currentManager) {
23395
+ const newV = currentState.privilegedServices?.validatorsManager;
23396
+ if (currentState.privilegedServices !== null && newV !== undefined && serviceIds.includes(newV)) {
23397
+ accumulate_logger.info("Entering completely incorrect code that probably reverts validatorsManager change. This is valid in 0.7.0 only and incorrect in 0.7.1+");
23398
+ // Since serviceIds already contains newV, this service gets accumulated twice.
23399
+ // To avoid double-counting, we skip stats and gas cost tracking here.
23400
+ // We need this accumulation to get the correct `validatorsManager`
23401
+ const { stateUpdate } = await this.accumulateSingleService(newV, accumulateData.getOperands(newV), accumulateData.getGasCost(newV), slot, entropy, checkpoint);
23402
+ const correctV = stateUpdate?.privilegedServices?.validatorsManager ?? this.state.privilegedServices.validatorsManager;
23403
+ currentState.privilegedServices = PrivilegedServices.create({
23404
+ ...currentState.privilegedServices,
23405
+ validatorsManager: correctV,
23406
+ });
23407
+ }
23408
+ }
23364
23409
  }
23365
23410
  return {
23366
23411
  state: currentState,
@@ -23505,11 +23550,14 @@ class DeferredTransfers {
23505
23550
  async transition({ pendingTransfers, timeslot, servicesUpdate: inputServicesUpdate, entropy, }) {
23506
23551
  // https://graypaper.fluffylabs.dev/#/7e6ff6a/187a03187a03?v=0.6.7
23507
23552
  const transferStatistics = new Map();
23508
- const services = uniquePreserveOrder(pendingTransfers.flatMap((x) => [x.source, x.destination]));
23553
+ const services = uniquePreserveOrder(pendingTransfers.map((x) => x.destination));
23509
23554
  let currentStateUpdate = AccumulationStateUpdate.new(inputServicesUpdate);
23510
23555
  for (const serviceId of services) {
23511
23556
  const partiallyUpdatedState = new PartiallyUpdatedState(this.state, currentStateUpdate);
23512
- const transfers = pendingTransfers.filter((pendingTransfer) => pendingTransfer.destination === serviceId);
23557
+ // https://graypaper.fluffylabs.dev/#/38c4e62/18750318ae03?v=0.7.0
23558
+ const transfers = pendingTransfers
23559
+ .filter((pendingTransfer) => pendingTransfer.destination === serviceId)
23560
+ .toSorted((a, b) => a.source - b.source);
23513
23561
  const info = partiallyUpdatedState.getServiceInfo(serviceId);
23514
23562
  if (info === null) {
23515
23563
  return result_Result.error(DeferredTransfersErrorCode.ServiceInfoNotExist);