Skip to content

serviceability: scaffold Rust instruction-builder crate + common helpers + exemplar builders #4015

Description

@juan-malbeclabs

Part of #4014.

Scaffold the new doublezero_serviceability_instruction crate at crates/doublezero-serviceability-instruction/ and establish the pattern every later PR copies.

Scope

  • New crate + Cargo.toml; register it as a workspace member. Dependencies limited to doublezero-serviceability, solana-program, doublezero-program-common (no solana-client/tokio/backon).
  • src/common.rs: the build(program_id, instruction, accounts, payer) helper (the single place that appends the trailing [payer(signer,writable), system_program]). The read-only Permission PDA is derived from the payer inside build and appended last, but ships commented out until each instruction's authorize() migration is activated — it is never a caller-supplied parameter. Also compute_budget_prelude() -> [Instruction; 2] (CU 1_400_000, heap 256 KiB).
  • src/lib.rs: module wiring, re-exports, and a documented list of excluded deprecated variants.
  • 4 exemplar builders, one per family, to prove the shape end to end:
    • create_device — variable dz_prefix blocks (builder fixes resource_count).
    • create_link — fixed accounts.
    • delete_device — variable-account builder with a legacy/atomic-close split and RPC-read resource-owner accounts (replaces the originally-planned suspend_device, which is a deprecated variant — SuspendDevice/ResumeDevice return DoubleZeroError::Deprecated; suspend/resume now go through UpdateDevice{desired_status}).
    • create_subscribe_user — length-detected feed (no permission parameter; never appends a Permission account).

Acceptance

  • Builders return a single unsigned Instruction with accounts in exact processor order incl. trailing accounts; no RPC.
  • Unit tests assert the account list (ported from the existing mockall command expectations) and data[0] == <tag>.
  • First ix_*.bin/.json golden fixtures emitted for the exemplars (see RF).
  • make rust-build, make rust-test, make rust-fmt clean.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions