Skip to content

ReserveGrid OS v0.2.2

Choose a tag to compare

@LeavesJ LeavesJ released this 23 Feb 03:55

ReserveGrid OS v0.2.2 — Foresight

Scope

v0.2.2 introduces consensus safety primitives into the policy layer, grounded in real world mining pool failure modes observed across the last two years. Weight ratio enforcement and template staleness checks activate using fields already present in the protocol. Sigops and coinbase accounting fields land as optional forward compatible additions with observe only logging, no enforcement until 0.2.3. All new checks default to observe only mode and require explicit operator opt in for rejection. The built-in dashboard ships a consensus safety panel and collapsible aggregate reason categories. The public observe mode dashboard reaches full feature parity with the built-in dashboard, adds enforcement mode badges, mempool context, CSV/NDJSON export links, and hardens the auth bypass to localhost only.

rg-protocol consensus safety fields

New optional fields on TemplatePropose

  • total_sigops: Option<u32> total signature operations across all transactions in the template
  • coinbase_sigops: Option<u32> signature operations attributed to the coinbase transaction
  • template_weight: Option<u64> total serialized weight reported by getblocktemplate
  • All three use #[serde(default)] for backward compatibility with older senders
  • No protocol version bump required

New VerdictReason variants

  • WeightRatioExceeded (weight_ratio_exceeded) template weight exceeds safety.max_weight_ratio of consensus max
  • TemplateStale (template_stale) template age exceeds safety.max_template_age_ms
  • SigopsBudgetWarning (sigops_budget_warning) observe only, total sigops approaching consensus limit
  • CoinbaseSigopsAbnormal (coinbase_sigops_abnormal) observe only, coinbase sigops outside expected reservation range
  • VerdictReason::ALL and VerdictReason::ALL_CODES updated, length assertion bumped from 11 to 15

Template manager GBT field extraction

Sigops and weight extraction

  • Parses sigops and weight from each transaction entry in the GBT response
  • Sums total sigops across all non-coinbase transactions
  • coinbase_sigops set to None in 0.2.2 because bitcoincore-rpc 0.18.0 does not expose the coinbase transaction on the GBT result struct (tracked for 0.2.3 via raw JSON parsing or crate upgrade)
  • Populates template_weight from per-transaction weight field summation

Template timestamp

  • created_at_unix_ms now stamped on every TemplatePropose at creation time
  • Enables downstream staleness detection without clock synchronization assumptions

Pool verifier policy enforcement

Enforced checks (opt in, default observe only)

  • weight_ratio_exceeded activates when observed_weight or template_weight divided by max block weight (4,000,000 WU) exceeds safety.max_weight_ratio
  • template_stale activates when current time minus created_at_unix_ms exceeds safety.max_template_age_ms
  • Each check gated by safety.enforce_weight_ratio and safety.enforce_template_age booleans in policy TOML, both default false
  • When enforce = false, structured warning log emitted with metric values but verdict stays accept

Observed checks (log and dashboard only, no rejection path)

  • Sigops headroom: warns when total_sigops exceeds safety.warn_sigops_ratio of the 80,000 consensus limit
  • Coinbase sigops anomaly: warns when coinbase_sigops exceeds safety.warn_coinbase_sigops_max
  • Both thresholds configurable under [policy.safety]
  • Warnings carry full policy context for traceability

Policy TOML additions under [policy.safety]

  • max_weight_ratio float, default 0.999
  • max_template_age_ms maximum acceptable template age in milliseconds
  • enforce_weight_ratio boolean, default false
  • enforce_template_age boolean, default false
  • warn_sigops_ratio float, default 0.95 (warn at 95% of consensus limit)
  • warn_coinbase_sigops_max integer, default 400

Deterministic evaluation

  • evaluate_dynamic accepts explicit now_ms: u64 parameter for testability
  • evaluate() wrapper calls now_unix_ms() internally, preserving existing call sites
  • Safety checks run after existing 8 economic and structural checks in fixed order

CSV export completeness

  • /verdicts.csv header and row formatting include all v0.2.2 fields: template_weight, total_sigops, coinbase_sigops, created_at_unix_ms, safety_warnings

Dashboard (built-in)

Consensus safety panel

  • Weight utilization gauge showing template weight as percentage of 4,000,000 WU max
  • Sigops headroom bar showing total sigops as percentage of 80,000 limit
  • Template age display for most recent verdict
  • Coinbase sigops reservation indicator
  • Color thresholds: red at >99% weight, >95% sigops, >30s template age, >400 coinbase sigops
  • All metrics live even in observe only mode

Aggregate reason categories rework

  • Reason aggregates now display as collapsible categories sorted by count
  • Clicking a category expands to show the last 15 matching verdicts with template id, block height, timestamp, and reason detail
  • Overflow indicator shows count of remaining verdicts beyond the visible 15
  • Accepted ("ok") category displayed as count only, not expandable
  • Expand state persists across 3 second refresh cycles
  • Chevron rotation animates via CSS transition

Observe mode (veldra-site-v3)

Full v0.2.2 feature parity with built-in dashboard

  • Consensus safety panel with weight utilization gauge, sigops headroom gauge, template age, and coinbase sigops
  • Collapsible aggregate reason categories with verdict drill-down (last 10 per reason code)
  • Safety warning lines displayed on verdict rows
  • Four new reason codes in the catalog table with Safety category badge (weight_ratio_exceeded, template_stale, sigops_budget_warning, coinbase_sigops_abnormal)
  • Updated mock data and policy for demo mode with v0.2.2 fields
  • "How It Works" flow updated to mention consensus safety checks

Enforcement mode badges

  • Each safety gauge displays an "enforced" or "observe" badge pulled from the /policy response
  • Weight ratio and template age reflect their enforce_* flags
  • Sigops and coinbase always show "observe" in 0.2.2

Mempool context bar

  • Displays live mempool tx count, memory usage percentage, and derived fee tier
  • Tier derived from policy low_mempool_tx and high_mempool_tx thresholds
  • Freshness indicator shows seconds since last mempool snapshot
  • Hidden when mempool endpoint is unavailable (demo mode or disconnected)

CSV and NDJSON export links

  • Export bar appears below the verdict stream when connected to a live backend
  • Links point directly to /verdicts.csv and /verdicts/log on the configured API endpoint
  • Hidden in demo mode since there is no backend to export from

Security hardening

  • ?noauth bypass restricted to localhost and 127.0.0.1 only; ignored on production domains
  • Mixed content warning displayed when the page is served over https but the API URL uses http

Stale data overlay

  • When data is older than 30 seconds, opacity dim now applies to all panels: stats grid, verdict stream, reason chart, safety panel, tier cards, and mempool bar
  • Previously only the stats grid was affected

sv2-bridge compatibility

  • TemplatePropose construction updated with total_sigops: None, coinbase_sigops: None, template_weight: None
  • Synthetic bridge has no real consensus data; fields set to None so the verifier knows values are unavailable

Repo policy files

  • All four profiles updated with [policy.safety] section: policy.toml, demo-showcase-policy.toml, demo-strict-policy.toml, demo-open-policy.toml
  • Strict profile enables enforcement: enforce_weight_ratio = true, enforce_template_age = true, tighter thresholds (max_weight_ratio = 0.95, warn_sigops_ratio = 0.90)
  • Base and demo profiles default to observe only

Test matrix

  • weight_ratio_exceeded_enforced
  • weight_ratio_exceeded_observe_only
  • weight_ratio_under_limit_no_warning
  • template_stale_enforced
  • template_stale_observe_only
  • sigops_warning_fires_above_threshold
  • sigops_warning_silent_below_threshold
  • coinbase_sigops_anomaly_detection
  • new_fields_backward_compatible_serde
  • all_codes_match_as_str (updated for new variants)
  • all_constant_covers_every_variant (length bumped to 15)