Skip to content

fix(snapshot): import pm_oracle oracle-metrics fields (P1-P5) - #136

Merged
On1x merged 1 commit into
VIZ-Blockchain:pmfrom
web3blind:fix/pm-oracle-metrics-snapshot-import
Aug 6, 2026
Merged

fix(snapshot): import pm_oracle oracle-metrics fields (P1-P5)#136
On1x merged 1 commit into
VIZ-Blockchain:pmfrom
web3blind:fix/pm-oracle-metrics-snapshot-import

Conversation

@web3blind

Copy link
Copy Markdown

Summary

Follow-up to the P1-P5 oracle-metrics commits on pm (#124): import_pm_oracles() in plugins/snapshot/plugin.cpp skipped the five new display-only pm_oracle_object fields, so a snapshot taken after the upgrade lost them on import.

Why it matters

  • Gauges (markets_in_dispute_window, disputes_awaiting_response, disputes_awaiting_decision): were only recoverable when dgpo.pm_oracle_gauges_seeded was absent; if a post-upgrade snapshot carried the seeded flag, they stayed zeroed.
  • resolved_late_count + resolution_time_hist: forward-accumulating (no seed) — previously impossible to recover on snapshot import; the histogram and late counter silently reset to 0.

Change

plugins/snapshot/plugin.cpp, inside import_pm_oracles():

if (v.get_object().contains("markets_in_dispute_window"))
    obj.markets_in_dispute_window  = static_cast<uint32_t>(v["markets_in_dispute_window"].as_uint64());
if (v.get_object().contains("disputes_awaiting_response"))
    obj.disputes_awaiting_response = static_cast<uint32_t>(v["disputes_awaiting_response"].as_uint64());
if (v.get_object().contains("disputes_awaiting_decision"))
    obj.disputes_awaiting_decision = static_cast<uint32_t>(v["disputes_awaiting_decision"].as_uint64());
if (v.get_object().contains("resolved_late_count"))
    obj.resolved_late_count  = static_cast<uint32_t>(v["resolved_late_count"].as_uint64());
if (v.get_object().contains("resolution_time_hist"))
    obj.resolution_time_hist = v["resolution_time_hist"].as<fc::array<share_type, 8>>();

Forward-compatible: contains() guards mean pre-upgrade snapshots (fields absent) import cleanly and keep the existing seed-on-first-block behavior; post-upgrade snapshots preserve gauges and the histogram.

fc::array<share_type, 8> serializes through FC_REFLECT as a base64 vector<char> and reads back via the generic from_variant (already used in this plugin for packed_trx etc.).

Verification

  • git diff --check clean; single file, 13 insertions, no other changes.
  • Display-only fields; no consensus impact (P1-P5 commits explicitly marked them non-gating).
  • Full C++ build not run here (no local Boost toolchain); the change mirrors the surrounding contains()-guarded import style exactly.

import_pm_oracles() previously skipped the oracle-metrics fields added
by the P1-P5 commits (markets_in_dispute_window, disputes_awaiting_
response/decision, resolved_late_count, resolution_time_hist), so a
snapshot taken after the upgrade lost them on import (gauges were
re-derived by pm_seed_oracle_gauges only when dgpo.pm_oracle_gauges_
seeded was absent, and the forward-accumulating histogram/late counter
were never recoverable).

Forward-compatible import: fields are read only when present, so old
snapshots (pre-upgrade) still import cleanly and keep the existing
seed-on-first-block behavior; new snapshots preserve the gauges and the
resolution-latency histogram.

Display-only; no consensus impact. Matches the fc::array<share_type,8>
serialization used by FC_REFLECT (base64 vector<char> via from_variant).
@On1x
On1x merged commit d0f7294 into VIZ-Blockchain:pm Aug 6, 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