Skip to content

fix(pyth): automate router set rotation via vaa - #2081

Open
chalabi2 wants to merge 2 commits into
mainfrom
chalabi/pyth-router-set-rotation-fix
Open

fix(pyth): automate router set rotation via vaa#2081
chalabi2 wants to merge 2 commits into
mainfrom
chalabi/pyth-router-set-rotation-fix

Conversation

@chalabi2

@chalabi2 chalabi2 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • automate pyth_vaa router-set rotation through the existing submit_v_a_a path
  • accept signed router-set upgrade VAAs from Hermes instead of requiring a manual config update
  • store router sets by index and advance the active set when the submitted rotation VAA is valid
  • preserve the get_config response shape that pyth_pro and Hermes use at runtime

Validation

  • cargo fmt -p pyth_vaa -- --check
  • cargo test -p pyth_vaa
  • cargo clippy -p pyth_vaa --all-targets -- -D warnings
  • local Akash chain + Hermes one-shot update
  • Dockerized Hermes one-shot update after local router-set rotation

Local validation reproduced the stale-router failure, submitted the router-set
rotation through submit_v_a_a, then confirmed Hermes price updates succeeded
against pyth_pro and x/oracle after the rotation.

Router sets must not be changed through ordinary config updates. Store router
sets separately and require submit_v_a_a to verify the current router set
before advancing to the next index.

This keeps the new pyth_vaa contract aligned with the previous guarded
Wormhole rotation behavior while preserving the operational VAA submit
shape.

Signed-off-by: Joseph Chalabi <chalabi.joseph@gmail.com>
@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: 8f01631b-4420-44f2-b9fc-6081b8f06f29

📥 Commits

Reviewing files that changed from the base of the PR and between 096bff5 and 223416a.

📒 Files selected for processing (5)
  • contracts/pyth_vaa/src/contract.rs
  • contracts/pyth_vaa/src/error.rs
  • contracts/pyth_vaa/src/msg.rs
  • contracts/pyth_vaa/src/router.rs
  • contracts/pyth_vaa/src/state.rs

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


Walkthrough

The contract now stores router sets by index and rotates them through signed governance VAAs. It adds governance-chain validation, migration from the legacy configuration, indexed router-set parsing, new errors, query fields, and tests for rotation and rejection paths.

Changes

Router rotation and migration

Layer / File(s) Summary
State and message contracts
contracts/pyth_vaa/src/state.rs, contracts/pyth_vaa/src/msg.rs, contracts/pyth_vaa/src/error.rs
Configuration now stores governance and emitter settings. Router state and indexed router sets use separate storage. Messages support governance-chain configuration, migration, and SubmitVAA. New errors cover invalid governance updates and router-set transitions.
Governance router-set parsing
contracts/pyth_vaa/src/router.rs
Governance packets now validate the module, action, target chain, router-set index, router count, address length, and duplicate addresses.
VAA rotation and migration flow
contracts/pyth_vaa/src/contract.rs
Instantiation and migration populate indexed router state. SubmitVAA verifies governance packets, requires the next index, stores the new router set, and updates the active index. Queries and verification load the active router set. Tests cover rotation, rejection paths, replay, and migration.

Estimated code review effort: 4 (Complex) | ~45 minutes

Merge Risk: ⚪ Minimal · up to 22341

Router-set rotation now requires current-router signatures, validates governance targets, and advances sequentially while preserving the existing configuration response shape. No current merge-blocking risk is identified.

Suggested reviewers: boz, chainzero, cloud-j-luna

Poem

A rabbit checks the router trail
Signed packets guide the changing sail
Old state hops to storage new
Indexes rise from one to two
Safe paths bloom in governance light

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 39 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the main change: automated router-set rotation through VAA submission.
Description check ✅ Passed The description directly explains the router-set rotation changes and documents relevant validation, including tests and local Hermes/Akash scenarios.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chalabi/pyth-router-set-rotation-fix

Comment @coderabbitai help to get the list of available commands.

Move the active router index out of config storage and validate the governance target chain before accepting router-set rotation VAAs. This restores the sender-independent but signature-gated rotation behavior used by the legacy verifier.\n\nSigned-off-by: Joseph Chalabi <chalabi.joseph@gmail.com>
@chalabi2
chalabi2 marked this pull request as ready for review September 4, 2026 20:17
@chalabi2
chalabi2 requested a review from a team as a code owner September 4, 2026 20:17
@chalabi2 chalabi2 closed this Sep 4, 2026
@troian
troian deleted the chalabi/pyth-router-set-rotation-fix branch September 4, 2026 20:27
@troian troian changed the title fix(pyth): guard router set rotation via vaa fix(pyth): automate router set rotation via vaa Sep 4, 2026
@troian
troian restored the chalabi/pyth-router-set-rotation-fix branch September 4, 2026 20:31
@troian troian reopened this Sep 4, 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