Skip to content

feat(contract-manager): Pythnet BPF upgrade authority audit tool#3740

Open
jayantk wants to merge 2 commits into
mainfrom
hydra/i-cmecdvqy/head
Open

feat(contract-manager): Pythnet BPF upgrade authority audit tool#3740
jayantk wants to merge 2 commits into
mainfrom
hydra/i-cmecdvqy/head

Conversation

@jayantk
Copy link
Copy Markdown
Contributor

@jayantk jayantk commented May 20, 2026

Summary

  • Adds contract_manager/scripts/list_pythnet_authorities.ts — a new CLI tool that connects to Pythnet, fetches each known Pyth program's BPF upgrade authority, and outputs a JSON report + human-readable table
  • Adds contract_manager/src/core/pythnet-programs.ts — program registry reusing MESSAGE_BUFFER_PROGRAM_ID and REMOTE_EXECUTOR_ADDRESS from @pythnetwork/xc-admin-common
  • Adds decodeProgramAccount() and decodeProgramDataAccount() helpers to governance/xc_admin/packages/xc_admin_common/src/bpf_upgradable_loader.ts
  • Adds fixture-based tests and PYTHNET_AUTHORITIES.md documentation

Validator-tree investigation

Investigated the pythnet validator tree (pyth-v1.14.29/programs). No Pyth oracle programs are baked in as validator builtins. All three programs (Oracle, Remote Executor, Message Buffer) are deployed as standard BPF upgradeable programs with inspectable upgrade authorities.

Test plan

  • pnpm turbo build --filter @pythnetwork/contract-manager succeeds
  • TypeScript type-checks with no errors from new files
  • Fixture tests pass: pnpm --filter @pythnetwork/contract-manager exec tsx scripts/__tests__/list_pythnet_authorities.test.ts
  • Script exits non-zero with unreachable RPC
  • (Manual) Run against live Pythnet RPC to verify authorities are reported

Open in Devin Review

Hydra Worker and others added 2 commits May 20, 2026 21:36
…ade authorities

Scaffold a new CLI tool that connects to Pythnet and reports the BPF
upgrade authority for each known Pyth program. Includes program registry,
ProgramData decoder helpers, fixture-based tests, and documentation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jayantk jayantk requested a review from a team as a code owner May 20, 2026 21:37
@vercel
Copy link
Copy Markdown

vercel Bot commented May 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
api-reference Ready Ready Preview, Comment May 20, 2026 9:41pm
component-library Ready Ready Preview, Comment May 20, 2026 9:41pm
developer-hub Ready Ready Preview, Comment May 20, 2026 9:41pm
proposals Ready Ready Preview, Comment May 20, 2026 9:41pm
3 Skipped Deployments
Project Deployment Actions Updated (UTC)
entropy-explorer Skipped Skipped May 20, 2026 9:41pm
insights Skipped Skipped May 20, 2026 9:41pm
staking Skipped Skipped May 20, 2026 9:41pm

Request Review

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 potential issues.

View 4 additional findings in Devin Review.

Open in Devin Review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚩 Test uses manual assert/console.log instead of the project's Jest framework

The existing tests in this area of the codebase use Jest (see governance/xc_admin/packages/xc_admin_common/src/__tests__/BpfUpgradableLoaderInstruction.test.ts), but this new test uses raw node:assert + console.log with a manual main() runner. This means the tests won't be picked up by the project's standard test runner and won't integrate with CI. Consider converting to Jest test()/expect() patterns for consistency and CI integration.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

);

// Exit non-zero if all programs had errors
const allFailed = entries.every((e) => e.notes.startsWith("error:"));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 entries.every() returns true on empty array, causing false failure exit

If an empty custom programs file ([]) is supplied via --programs, the entries array will be empty. Array.prototype.every() returns true for empty arrays (vacuous truth), so entries.every((e) => e.notes.startsWith("error:")) at line 186 evaluates to true. This causes the script to print "All program queries failed. Check the RPC endpoint." and process.exit(1) even though no programs were queried — the correct behavior would be to succeed (or warn) for an empty list.

Suggested change
const allFailed = entries.every((e) => e.notes.startsWith("error:"));
const allFailed = entries.length > 0 && entries.every((e) => e.notes.startsWith("error:"));
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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