Skip to content

fix(rpc): honor requested chain id in RCManager.GetValidatorSet - #585

Closed
ezeike wants to merge 1 commit into
developmentfrom
fix/rc-validator-set-foreign-chain-id
Closed

fix(rpc): honor requested chain id in RCManager.GetValidatorSet#585
ezeike wants to merge 1 commit into
developmentfrom
fix/rc-validator-set-foreign-chain-id

Conversation

@ezeike

@ezeike ezeike commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

What Changed

  • RCManager.GetValidatorSet no longer serves the cached fast path for a chain id other than the subscription's own — it now checks id == sub.chainId before touching sub.Info
  • Added a small single-slot committeeCache (mirrors the existing lottery/dexBatch/orders caches) so repeated lookups of the same foreign chain id at a fixed height skip the remote round-trip; height 0 ("latest") is excluded from caching since it can move between calls

Why

sub.Info.ValidatorSet is only ever populated for the subscription's own chain (set at dial time from r.c.ChainId). The fast path ignored the id argument entirely, so any caller requesting a different chain's committee at the cached height silently got back its own chain's validators instead — no error, just wrong data. No current caller hits this (LoadCommittee and the consensus.go call site both always pass their own chain id), but it's a live footgun for any future caller that queries another chain's committee.

Fixes & How They Work

  • Silent wrong-committee return for a foreign id: gated the cached path on id == sub.chainId; any other id now always falls through to a remote lookup (with its own small cache), never the local subscription cache.

The cached fast path always returned sub.Info.ValidatorSet regardless
of the id argument, since sub.Info is only ever populated for the
subscription's own chain. A caller requesting a different chain's
committee at the cached height silently got its own chain's
validators back instead.

Gate the cached path on id == sub.chainId and fall through to a
remote lookup otherwise. Add a committeeCache (mirroring the existing
lottery/dexBatch/orders caches) so repeated lookups of the same
foreign chain id at a fixed height don't repeat the round-trip;
height 0 ('latest') is excluded from the cache since it can move
between calls.
@ezeike
ezeike force-pushed the fix/rc-validator-set-foreign-chain-id branch from 8c83fb4 to 775c60b Compare September 4, 2026 09:45
@ezeike ezeike closed this Sep 4, 2026
@ezeike
ezeike deleted the fix/rc-validator-set-foreign-chain-id branch September 4, 2026 11:39
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