You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
src/history_snapshot.rs documents normalize_history() as the way to summarize history "for dashboard telemetry":
/// Summarised view of SLA calculation history./// Provides a lightweight aggregate of the full history without exposing/// individual record details. Suitable for dashboard telemetry.pubstructNormalizedSnapshot{pubcount:u32,pubhas_violations:bool,pubhas_rewards:bool}
Grep shows normalize_history is called only by its own tests. No contract method returns a NormalizedSnapshot, and the type is not #[contracttype], so it cannot cross the contract boundary at all.
Consequences:
The documented dashboard path doesn't exist: the module's usage example (let snapshot = normalize_history(&history);) is library-only; a backend dashboard cannot obtain this aggregate from the contract and must re-implement the scan over get_history (which is the expensive full read — companion issue).
The module duplicates knowledge with get_stats: SLAStats already carries cumulative totals; NormalizedSnapshot's booleans (any violations/rewards) overlap with stats but with different semantics (windowed vs. cumulative), and nothing reconciles the two views.
Root cause
The module was authored as a utility alongside the history work and never wired to a contract endpoint or marked #[contracttype].
Why this is architecturally hard
Exposing it requires a decision: a #[contracttype] aggregate type + a view method (an ABI addition, stability-guarded) that internally does the full-history scan — reintroducing the read-cost problem — or dropping the module in favor of SLAStats (which the contract already exposes).
The "any violation/reward in window" semantics are only meaningful if the window is defined; the module takes the full history with no window parameter, so its dashboard value is unclear.
The fix should reconcile this with get_severity_telemetry (which covers per-severity windows) so the dashboard story is one coherent surface.
Acceptance criteria
NormalizedSnapshot/normalize_history is either exposed as a #[contracttype] view with defined window semantics, or removed with its documentation relocated.
No docs present a dashboard aggregate that the contract cannot return.
The relationship to SLAStats/get_severity_telemetry is documented.
Out of scope
The full-history read cost (companion issue) and new telemetry counters.
Getting started
just test
Good first files to read: apexchainx_calculator/src/history_snapshot.rs, apexchainx_calculator/src/lib.rs (get_stats, get_severity_telemetry).
Problem
src/history_snapshot.rsdocumentsnormalize_history()as the way to summarize history "for dashboard telemetry":Grep shows
normalize_historyis called only by its own tests. No contract method returns aNormalizedSnapshot, and the type is not#[contracttype], so it cannot cross the contract boundary at all.Consequences:
let snapshot = normalize_history(&history);) is library-only; a backend dashboard cannot obtain this aggregate from the contract and must re-implement the scan overget_history(which is the expensive full read — companion issue).NormalizedSnapshotlacks#[contracttype], so it would fail at the host boundary — the same trapConfigBundle's issue fix: config_bundle.rs type mismatch causes runtime deserialization failure #1 hit.get_stats:SLAStatsalready carries cumulative totals;NormalizedSnapshot's booleans (any violations/rewards) overlap with stats but with different semantics (windowed vs. cumulative), and nothing reconciles the two views.Root cause
The module was authored as a utility alongside the history work and never wired to a contract endpoint or marked
#[contracttype].Why this is architecturally hard
#[contracttype]aggregate type + a view method (an ABI addition, stability-guarded) that internally does the full-history scan — reintroducing the read-cost problem — or dropping the module in favor ofSLAStats(which the contract already exposes).get_severity_telemetry(which covers per-severity windows) so the dashboard story is one coherent surface.Acceptance criteria
NormalizedSnapshot/normalize_historyis either exposed as a#[contracttype]view with defined window semantics, or removed with its documentation relocated.SLAStats/get_severity_telemetryis documented.Out of scope
The full-history read cost (companion issue) and new telemetry counters.
Getting started
just testGood first files to read:
apexchainx_calculator/src/history_snapshot.rs,apexchainx_calculator/src/lib.rs(get_stats,get_severity_telemetry).