Skip to content

improve(providers): add per-provider delta to quorum-mismatch warn log#1442

Open
droplet-rl wants to merge 1 commit into
masterfrom
droplet/T90K0AL22-C06Q1V9RUN4-1779567099-731319
Open

improve(providers): add per-provider delta to quorum-mismatch warn log#1442
droplet-rl wants to merge 1 commit into
masterfrom
droplet/T90K0AL22-C06Q1V9RUN4-1779567099-731319

Conversation

@droplet-rl
Copy link
Copy Markdown
Contributor

@droplet-rl droplet-rl commented May 24, 2026

Summary

Surface the exact source of provider disagreement when the RetryProvider's quorum check fails. The existing Some providers mismatched with the quorum result or failed 🚸 warn only listed which RPC origins disagreed — operators had no signal about what differed. This PR adds a new mismatchDetails field to the warn payload mapping each mismatched provider's origin to a compact, JSON-safe delta vs the quorum result.

Per method:

  • eth_getLogs — per-log onlyInA / onlyInB / differing (with fieldDiffs: { field: { a, b } }), keyed by transactionHash:logIndex. Strips the same IGNORED_FIELDS the equality check strips, so noise like blockTimestamp doesn't show up. Each bucket is capped at 5 entries with a truncated counter so payloads stay bounded even when a provider returns thousands of stale logs.
  • eth_getBlockByNumber — per-key { a, b } for non-ignored fields.
  • any other method — path-keyed deep diff (e.g. "receipt.logs[0].data": { a, b }).

Scope

Intentionally minimal — small, additive change to a load-bearing component:

  • compareRpcResults keeps its boolean return type. No signature change, no caller updates beyond retryProvider.ts.
  • RetryProvider.send keeps its current structure. The new code only adds a per-provider getMismatchDetails(values) helper alongside the existing getMismatchedProviders(values), and threads the result into the existing logQuorumMismatchOrFailureDetails call as one new field.
  • Existing fields (quorumProviders, mismatchedProviders, erroringProviders) are unchanged — mismatchDetails is purely additive for log consumers.

Production code change: retryProvider.ts +37 / -6, utils.ts purely additive.

Performance

  • Equal path (all-providers-agree, the hot path): zero overhead. The new code only runs inside the warn-emit branches, which only fire on mismatch or provider error.
  • Mismatch path: one extra per-provider walk to build the delta. Bounded by provider count (typically 2-4) and capped output (5 entries / bucket for eth_getLogs). Fields that are equal don't appear in the output — only divergent ones.

Test plan

  • yarn hardhat test test/providers/utils.test.ts — 16/16 passing (covers ignored-field handling, per-log diffs, truncation, undefined inputs, block-level diffs, generic deep diff, primitive root, type-mismatch).
  • yarn lint-check — clean.
  • Confirm the next real quorum mismatch in zion-across-relayer-primary carries an actionable mismatchDetails payload.

The `Some providers mismatched with the quorum result or failed 🚸` warn used
to list which RPC origins disagreed but not what they disagreed about,
forcing operators to guess at the divergence.

Add a `diffRpcResults(method, a, b)` helper in providers/utils.ts that
returns a compact, JSON-safe delta, and thread per-provider deltas into the
existing `logQuorumMismatchOrFailureDetails` as a new `mismatchDetails`
field (origin URL -> delta). Per method:

- eth_getLogs: per-log onlyInA / onlyInB / differing, keyed by
  `transactionHash:logIndex`, with per-log `fieldDiffs`. Strips the same
  IGNORED_FIELDS the equality check strips. Each bucket capped at 5
  entries with a `truncated` counter so payloads stay bounded.
- eth_getBlockByNumber: per-key `{ a, b }` for non-ignored field diffs.
- any other method: path-keyed deep diff (e.g.
  `"receipt.logs[0].data": { a, b }`).

`compareRpcResults` is untouched (still returns `boolean`). `send()` is
untouched. Existing log fields (`quorumProviders`, `mismatchedProviders`,
`erroringProviders`) are unchanged — `mismatchDetails` is purely additive
for log consumers.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@droplet-rl droplet-rl force-pushed the droplet/T90K0AL22-C06Q1V9RUN4-1779567099-731319 branch from c50e092 to 7f71030 Compare May 24, 2026 06:28
@droplet-rl droplet-rl changed the title improve(providers): surface per-provider delta in quorum-mismatch logs improve(providers): add per-provider delta to quorum-mismatch warn log May 24, 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.

1 participant