Skip to content

feat(telemetry): IsAuthorized/Refine cost sidecar to guarantor layer (#974 Phase 1a)#1007

Merged
yu2C merged 3 commits into
feat/jip3-telemetry-4-pvmcost-packagefrom
feat/jip3-telemetry-5-guarantor-cost-plumbing
Jun 16, 2026
Merged

feat(telemetry): IsAuthorized/Refine cost sidecar to guarantor layer (#974 Phase 1a)#1007
yu2C merged 3 commits into
feat/jip3-telemetry-4-pvmcost-packagefrom
feat/jip3-telemetry-5-guarantor-cost-plumbing

Conversation

@HanaYukii

@HanaYukii HanaYukii commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Phase 1 (guarantor half) of #974. Stacked on #978 — retarget to main after it merges. Plumbing only: cost values stay zero until Phase 2a measures real numbers.

Carries the cost summaries for events 95 (Authorized) and 101 (Refined) from the PVM leaf to the guarantor layer, as a sidecar — never on consensus types:

PVM.Psi_I / RefineInvoke           Cost on transient return types
              │
WorkReportCompute ──▶ types.WorkReport            (consensus, untouched)
                  └─▶ WorkPackageTelemetryCost    (sidecar)
              │
Controller.TelemetryCost           ← #958 bridge will read here

Design points (spec-driven)

  • Refine is per-item, index-aligned with Items — event 101's payload is one RefineCost per work item. Failed items keep their slot.
  • Failure paths discard cost by design: JIP-3 maps guarantor failures to event 92 (reason string, no cost field); 95/101 fire on success only.
  • Process() signature unchanged (sidecar lives on the controller) — auditing / CE134 callers untouched.

Tests: sentinel test plants distinct marker costs at the PVM leaf via a stub executor and asserts they reach the sidecar untouched, including a BadExports item keeping its slot. work_package / pvmcost / telemetry / auditing suites green (WSL); PVM package failures are pre-existing — byte-identical on the base commit.

Not included: event 47 (Accumulate) → Phase 1b (that chain crosses ParallelizedAccumulation, under active refactor in #988 follow-ups). Actual emission → #958.

@HanaYukii HanaYukii marked this pull request as ready for review June 10, 2026 16:05
…layer (#974 Phase 1a)

PVM.Psi_I_ReturnType / PVM.RefineOutput gain an observability-only Cost
field (zero until Phase 2a instrumentation). work_package.WorkReportCompute
collects them into a WorkPackageTelemetryCost sidecar, index-aligned with
Items, and Process stores it on the controller for the future event 95/101
bridge (#958). Cost never rides consensus types (pvmcost CI guard).

Sentinel test plants distinct costs at the PVM leaf via a stub executor and
asserts they reach the sidecar untouched, including for failed work items.
…c contract; fix refineOuput typo

Review follow-up on the Phase 1a sidecar:
- Failure paths discard cost by design: JIP-3 maps guarantor failures to
  event 92 (reason string, no cost field); cost-carrying events 95/101
  fire on success only. Documented at the discard site, on the sidecar
  type, and on Controller.TelemetryCost.
- TelemetryCost doc: not synchronized, read only from the Process caller
  goroutine (note for the #958 bridge).
- Rename refineOuput -> refineOutput in I() (typo, lines already touched
  by this branch).
@HanaYukii HanaYukii force-pushed the feat/jip3-telemetry-5-guarantor-cost-plumbing branch from fe47843 to 251d9ec Compare June 10, 2026 16:25
@YCC3741 YCC3741 requested review from TwEricShen and yu2C June 14, 2026 13:39
Comment on lines +86 to 93
report, cost, err := WorkReportCompute(&workPackage, p.CoreIndex, pa, pc, extrinsicMap, importSegments, delta, workPackageBundle, workPackageHash, p.PVM)
if err != nil {
return types.WorkReport{}, err
}
p.TelemetryCost = cost
cs := blockchain.GetInstance()
newDict, err := cs.SetHashSegmentMapWithLimit(workPackageHash, types.OpaqueHash(report.PackageSpec.ExportsRoot))
if err != nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TelemetryCost assigned before post-compute steps that can still fail
Maybe move p.TelemetryCost = cost to just before the final return report, nil (after segment lookup is attached)?

…ss steps

Review (yu2C): cost was stored before SetHashSegmentMapWithLimit, so a
failure in that step left a stale cost on the controller. Move the assign
to just before the successful return — upholds the sidecar invariant that
cost present implies Process succeeded.
@HanaYukii

Copy link
Copy Markdown
Contributor Author

Fixed in 011291d — moved p.TelemetryCost = cost to after the segment-lookup step so a failed Process never leaves a stale cost. Thanks @yu2C 🙏

@yu2C yu2C merged commit e3e3ede into feat/jip3-telemetry-4-pvmcost-package Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants