@secondlayer/cli 19.0.0 → 19.0.2

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/dist/cli.js CHANGED
@@ -9666,7 +9666,8 @@ var require_http_cache_semantics = __commonJS(function(exports, module) {
9666
9666
  _evaluateRequestHitResult(revalidation) {
9667
9667
  return {
9668
9668
  response: {
9669
- headers: this.responseHeaders()
9669
+ headers: this.responseHeaders(),
9670
+ status: this._status
9670
9671
  },
9671
9672
  revalidation
9672
9673
  };
@@ -9723,13 +9724,16 @@ var require_http_cache_semantics = __commonJS(function(exports, module) {
9723
9724
  if (!this._resHeaders.vary) {
9724
9725
  return true;
9725
9726
  }
9726
- if (this._resHeaders.vary === "*") {
9727
- return false;
9728
- }
9729
9727
  const fields = this._resHeaders.vary.trim().toLowerCase().split(/\s*,\s*/);
9730
9728
  for (const name of fields) {
9731
- if (req.headers[name] !== this._reqHeaders[name])
9729
+ if (name === "*") {
9732
9730
  return false;
9731
+ }
9732
+ const newReq = Object.prototype.hasOwnProperty.call(req.headers, name) && req.headers[name];
9733
+ const cachedReq = Object.prototype.hasOwnProperty.call(this._reqHeaders, name) && this._reqHeaders[name];
9734
+ if (newReq !== cachedReq) {
9735
+ return false;
9736
+ }
9733
9737
  }
9734
9738
  return true;
9735
9739
  }
@@ -9768,6 +9772,9 @@ var require_http_cache_semantics = __commonJS(function(exports, module) {
9768
9772
  headers.date = new Date(this.now()).toUTCString();
9769
9773
  return headers;
9770
9774
  }
9775
+ status() {
9776
+ return this._status;
9777
+ }
9771
9778
  date() {
9772
9779
  const serverDate = Date.parse(this._resHeaders.date);
9773
9780
  if (isFinite(serverDate)) {
@@ -202495,7 +202502,7 @@ var {
202495
202502
  // package.json
202496
202503
  var package_default = {
202497
202504
  name: "@secondlayer/cli",
202498
- version: "19.0.0",
202505
+ version: "19.0.2",
202499
202506
  description: "Run a Stacks index on your own hardware — set it up, restore verified history, and keep it current.",
202500
202507
  repository: {
202501
202508
  type: "git",
@@ -202534,10 +202541,10 @@ var package_default = {
202534
202541
  "@inquirer/prompts": "^8.2.0",
202535
202542
  "@secondlayer/bundler": "^0.6.1",
202536
202543
  "@secondlayer/scaffold": "^1.6.1",
202537
- "@secondlayer/sdk": "^13.0.0",
202538
- "@secondlayer/shared": "^11.15.1",
202539
- "@secondlayer/stacks": "^6.1.0",
202540
- "@secondlayer/subgraphs": "^6.2.5",
202544
+ "@secondlayer/sdk": "^14.0.0",
202545
+ "@secondlayer/shared": "^11.19.1",
202546
+ "@secondlayer/stacks": "^6.1.1",
202547
+ "@secondlayer/subgraphs": "^6.3.2",
202541
202548
  esbuild: "^0.28.2",
202542
202549
  "smol-toml": "^1.8.0",
202543
202550
  zod: "^4.3.6"
@@ -203561,8 +203568,13 @@ async function applyChildRangeFix(rawClient, reference, mismatch, gate) {
203561
203568
  const evPartition = findChildPartition(partitions, "events", mismatch.from_block, mismatch.to_block);
203562
203569
  const txBytes = txPartition ? await fetchVerifiedPartition(reference, txPartition, gate) : null;
203563
203570
  const evBytes = evPartition ? await fetchVerifiedPartition(reference, evPartition, gate) : null;
203564
- const written = { transactions: 0, events: 0 };
203571
+ const written = {
203572
+ transactions: 0,
203573
+ events: 0,
203574
+ vm_events: { restored: 0, dropped: 0 }
203575
+ };
203565
203576
  await rawClient.begin(async (tx) => {
203577
+ await tx.unsafe("CREATE TEMP TABLE repair_vm_events_keep ON COMMIT DROP AS SELECT * FROM vm_events WHERE block_height BETWEEN $1 AND $2", [mismatch.from_block, mismatch.to_block]);
203566
203578
  await tx.unsafe("DELETE FROM events WHERE block_height BETWEEN $1 AND $2", [
203567
203579
  mismatch.from_block,
203568
203580
  mismatch.to_block
@@ -203584,6 +203596,13 @@ async function applyChildRangeFix(rawClient, reference, mismatch, gate) {
203584
203596
  rows: readPartitionRows(evBytes, `repair-events-${mismatch.from_block}`)
203585
203597
  });
203586
203598
  }
203599
+ const kept = await tx.unsafe("SELECT count(*)::int AS n FROM repair_vm_events_keep");
203600
+ const keptCount = Number(kept[0]?.n ?? 0);
203601
+ if (keptCount > 0) {
203602
+ const restored = await tx.unsafe("INSERT INTO vm_events SELECT k.* FROM repair_vm_events_keep k JOIN transactions t ON t.tx_id = k.tx_id AND t.block_height = k.block_height");
203603
+ written.vm_events.restored = restored.count;
203604
+ written.vm_events.dropped = keptCount - restored.count;
203605
+ }
203587
203606
  });
203588
203607
  return written;
203589
203608
  }
@@ -203631,12 +203650,15 @@ async function runChildOnlyRepair(params) {
203631
203650
  gate = createGatedFetcher(fetchPaths, "repair");
203632
203651
  }
203633
203652
  const applied = { transactions: 0, events: 0 };
203653
+ const vmEvents = { restored: 0, dropped: 0 };
203634
203654
  if (apply) {
203635
203655
  const rawClient = getRawClient2("source");
203636
203656
  for (const mismatch of childMismatches) {
203637
203657
  const result = await applyChildRangeFix(rawClient, reference, mismatch, gate);
203638
203658
  applied.transactions += result.transactions;
203639
203659
  applied.events += result.events;
203660
+ vmEvents.restored += result.vm_events.restored;
203661
+ vmEvents.dropped += result.vm_events.dropped;
203640
203662
  }
203641
203663
  }
203642
203664
  const db = getDb2();
@@ -203667,13 +203689,17 @@ async function runChildOnlyRepair(params) {
203667
203689
  heights_missing_child_partitions: [],
203668
203690
  child_partition_mismatches: childMismatches,
203669
203691
  fixes: [],
203670
- metered: quoteLine ?? null
203692
+ metered: quoteLine ?? null,
203693
+ ...vmEvents.restored + vmEvents.dropped > 0 ? { vm_events: vmEvents } : {}
203671
203694
  };
203672
203695
  output({
203673
203696
  json,
203674
203697
  data: report,
203675
203698
  human: () => {
203676
203699
  if (apply) {
203700
+ if (vmEvents.dropped > 0) {
203701
+ warn(`Dropped ${vmEvents.dropped} vm_events row(s) whose transaction is not in the archive; vm_events can't be refetched from the archive.`);
203702
+ }
203677
203703
  const written = `${applied.transactions} transactions, ${applied.events} events`;
203678
203704
  if (complete) {
203679
203705
  success(`Repaired ${childMismatches.length} range(s) (rewrote ${written}); blocks were already correct.`);
@@ -208263,6 +208289,9 @@ services:
208263
208289
  POSTGRES_USER: \${POSTGRES_USER:-secondlayer}
208264
208290
  POSTGRES_PASSWORD: \${POSTGRES_PASSWORD:-secondlayer}
208265
208291
  POSTGRES_DB: \${POSTGRES_DB:-secondlayer}
208292
+ # Postgres ships with a 128 MB cache, too small for a full-chain sync:
208293
+ # inserts stall on index reads from disk. ~25% of RAM is the usual size.
208294
+ command: ["postgres", "-c", "shared_buffers=\${POSTGRES_SHARED_BUFFERS:-1GB}"]
208266
208295
  volumes:
208267
208296
  - postgres_data:/var/lib/postgresql/data
208268
208297
  ports:
@@ -209253,5 +209282,5 @@ registerCreditsCommand(program);
209253
209282
  registerArchiveCommand(program);
209254
209283
  program.parse();
209255
209284
 
209256
- //# debugId=840D684799E83C9864756E2164756E21
209285
+ //# debugId=5ADFA0DD3928ADD764756E2164756E21
209257
209286
  //# sourceMappingURL=cli.js.map