Skip to content

feat: rpc api key support with testnet readiness and performance improvements#7

Open
samclusker wants to merge 3 commits into
flare-foundation:mainfrom
samclusker:rpc-api-key-support
Open

feat: rpc api key support with testnet readiness and performance improvements#7
samclusker wants to merge 3 commits into
flare-foundation:mainfrom
samclusker:rpc-api-key-support

Conversation

@samclusker
Copy link
Copy Markdown
Contributor

  1. Fixes the observer crashing or hanging on Coston and Coston2, and corrects two bugs present on all chains.

Changes

ABI compatibility — Coston / Coston2

Coston and Coston2 have received upgraded VoterRegistry and FlareSystemsCalculator contracts
with a different event ABI from the stable Songbird/Flare versions. Added VoterRegistry_stable.json
and FlareSystemsCalculator_stable.json preserving the Songbird/Flare ABI and updated the upgraded
versions accordingly. Both sets of topic hashes are now registered at runtime so a single binary
handles all chains. VoterRegistered.from_dict updated to handle both the upgraded publicKey struct
and the stable flat fields.

Startup hang — Coston

get_unclaimed_rewards was making a lot of sequential RPC calls in a triple-nested loop, with
the contract object re-instantiated on every iteration - observed blocked startup on a busy RPC. Fixed by:

  • Instantiating the contract once outside the loop
  • Running all calls concurrently via asyncio.gather with a Semaphore(20) to avoid flooding the RPC
  • Wrapping both call sites with a 60s timeout — the check is informational only and must never block startup

time.sleep in async context

Both polling loops used time.sleep(2) inside async def observer_loop, blocking the entire event
loop and preventing aiohttp from running connection cleanup. Replaced with await asyncio.sleep(2).

None medians — testnet only

On Coston/Coston2 some feeds occasionally receive no valid votes. The hard assert median is not None
is preserved on Songbird/Flare; on testnets a DEBUG log is emitted instead. Also fixed a latent
crash where an empty vote set would cause max() to raise on an empty sequence.

  1. RPC API Key support

Added optional support for x-apikey to be used where needed.

  1. Minor
  • WTxData.wrapped: TxData was never read — removed to avoid holding tx objects in memory per voting round - maybe was a cause of high mem usage/OOMKilled observed.
  • Descriptive KeyError raised immediately if the configured identity address is not in the signing policy
  • Startup logging added for signing policy fetch and unclaimed rewards check

Feel free to cherry pick these changes as you see fit - also happy to just roll with my own fork but thought I'd share some findings. 👍

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