Skip to content

builder-stake: move the instruction builders into the crate - #4303

Merged
bgm-malbeclabs merged 2 commits into
mainfrom
feat/builder-stake-instruction-builders
Sep 9, 2026
Merged

builder-stake: move the instruction builders into the crate#4303
bgm-malbeclabs merged 2 commits into
mainfrom
feat/builder-stake-instruction-builders

Conversation

@bgm-malbeclabs

Copy link
Copy Markdown
Contributor

A move, not a rewrite. 155 lines out of the test harness and into instruction::builders.

Why now

The harness carried a note saying to do this when something outside the tests needed them:

Instruction builders live here rather than in the crate because tests are the only caller so far. Move them into the crate when the relayer or a CLI needs them.

Something does now. A caller in another crate has to post a real bond to test what it then does with the account, and hand-encoding those accounts there would put the processor's account order in two places with nothing keeping them in step. A reordered account would break one copy silently.

What moved

initialize_program, set_admin, set_paused, set_tier_parameters, initialize_builder_stake, post_bond, withdraw, set_hold_expiry. Every dependency they need was already a normal dependency of the crate, so nothing new is pulled in.

The harness re-exports them, so every test that used them reads unchanged.

Testing Verification

All 21 builder-stake tests pass with the builders coming from the crate rather than the harness. That is the assertion that matters: the tests exercise the same account orders through the moved code.

One local note that cost me a wrong answer before I checked it. The ProgramTest tests fail on my machine with Program processor not available unless BPF_OUT_DIR points at the built .so. That failure reproduces identically on an unmodified main, so it is my environment and not this change. With BPF_OUT_DIR set, all 21 pass on both.

cargo clippy --all-targets -p doublezero-builder-stake -- -Dwarnings and cargo fmt --all --check pass in the solana/ workspace.

The harness said to do this when something outside the tests needed them,
and something does. A caller in another repository has to post a bond to
test what it does with the account, and hand-encoding the accounts there
would put the processor's account order in two places, in two repositories,
with nothing to keep them in step.

A move, not a rewrite. The harness re-exports them, so every test that used
them reads unchanged, and all 21 still pass.
@bgm-malbeclabs
bgm-malbeclabs requested review from a team and a lite review from Copilot September 9, 2026 19:39

Copilot AI left a comment

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.

🟡 Changes recommended

The newly public set_admin builder hard-codes the upgrade authority signer and the new admin value to the same key, which does not match the processor’s API shape and limits external callers.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR moves the builder-stake instruction builder helpers out of the test harness and into the onchain program crate under instruction::builders, so other crates can reuse the canonical account ordering when constructing transactions.

Changes:

  • Added solana/programs/builder-stake/src/instruction/builders.rs with public instruction builder functions.
  • Updated the test harness to re-export the crate builders so existing tests keep the same call sites.
  • Documented the move in CHANGELOG.md.
File summaries
File Description
solana/programs/builder-stake/tests/common/mod.rs Removes in-test builders and re-exports instruction::builders from the crate.
solana/programs/builder-stake/src/instruction/mod.rs Exposes the new builders module.
solana/programs/builder-stake/src/instruction/builders.rs New shared instruction builders that centralize processor account ordering.
CHANGELOG.md Adds an entry noting the new crate-level builders.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread solana/programs/builder-stake/src/instruction/builders.rs Outdated
The processor reads two keys and the builder took one. Account 1 is the
upgrade authority, checked against the program data account, and the
instruction data is the value written to the config. Collapsing them meant
the builder could only ever say "make the upgrade authority the admin",
which is not what a deployment wants.

Every existing call site set them to the same key, which is what hid it. A
new assertion covers the case that was inexpressible: the upgrade authority
naming a different key, so an upgrade key can stay in cold storage while a
warmer one runs the program.

The other seven builders were checked for the same conflation. Each takes
its signer and its data separately already, or reuses one key because the
processor derives an address from it.
@bgm-malbeclabs
bgm-malbeclabs enabled auto-merge (squash) September 9, 2026 19:55
@bgm-malbeclabs
bgm-malbeclabs merged commit 9aa5c97 into main Sep 9, 2026
52 of 54 checks passed
@bgm-malbeclabs
bgm-malbeclabs deleted the feat/builder-stake-instruction-builders branch September 9, 2026 20:22
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.

3 participants