← Back to Pull requests

refactor(runtime): remove dead native stake/ALT implementations #1641

Merged
hamza-syndica merged 12 files (6511 lines) on Jul 10, 2026 13:00 UTC
View on GitHub
hamza-syndica hamza-syndica commented on Jun 30, 2026 08:22 UTC
Author

Closes #1627 (PR 1)

Removes ~4800 lines of dead code after hardcoding the core-BPF migrations in #1618.

  • Remove stake and address_lookup_table from NATIVE dispatch map

  • Delete address_lookup_table/execute.zig

  • Strip stake/lib.zig to module shell (keep ID, state, type re-exports)

  • Delete SOURCE_ID from stake, ALT, and config
  • Diff: 6511 lines (+753 / -5758) across 12 files Reviewer: yewman Review duration: 14677m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.59) × (1 − Review Confidence (0.68)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.59 · 6511 lines diff across 12 files
    0.59
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.35 · 5 substantive comment(s)
    0.35
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    68%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.400
    Real PR Conversation Timeline
    18 items
    hamza-syndica hamza-syndica commented on code on Jun 30, 2026 08:49 UTC
    Code Review
    shared/runtime/program/lib.zig:1
    @@ -56,19 +55,28 @@ const Program = struct {
     };
     
     // zig fmt: off
    -pub const NATIVE = sig.utils.pht(Program, &.{
    +const native_entries = [_]struct { sig.core.Pubkey, Program }{

    @yewman could't configure pht for this updated map, it was failing if I kept using pht for this. Any suggestion on this?

    codecov[bot] codecov[bot] commented on Jun 30, 2026 09:13 UTC
    Bot

    Codecov Report


    :white_check_mark: All modified and coverable lines are covered by tests.
    <details><summary> :rocket: New features to boost your workflow: </summary>

  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

  • </details>

    hamza-syndica hamza-syndica commented on code on Jun 30, 2026 11:30 UTC
    Code Review
    shared/runtime/program/lib.zig:1
    @@ -56,19 +55,28 @@ const Program = struct {
     };
     
     // zig fmt: off
    -pub const NATIVE = sig.utils.pht(Program, &.{
    +const native_entries = [_]struct { sig.core.Pubkey, Program }{
    dnut dnut commented on code on Jul 01, 2026 18:56 UTC
    Code Review
    shared/runtime/program/config/lib.zig:1
    @@ -2,6 +2,5 @@ const sig = @import("../../../lib.zig");
     const Pubkey = sig.core.Pubkey;
     
     pub const ID: Pubkey = .parse("Config1111111111111111111111111111111111111");
    -pub const SOURCE_ID: Pubkey = .parse("BuafH9fBv62u6XjzrzS4ZjAE8963ejqF5rt1f8Uga4Q3");
     
     pub const COMPUTE_UNITS = 450;

    This can be removed

    dnut dnut commented on code on Jul 01, 2026 18:57 UTC
    Code Review
    shared/utils/pht.zig:1
    @@ -58,9 +58,17 @@ pub fn pht(V: type, entries: []const struct { Pubkey, V }) type {
                 }
             };
     
    -        fn hash(x: *const Pubkey, key: u8) Hash {
    +        fn hash(x: *const Pubkey, key: u32) Hash {
                 const int: u32 = @bitCast(x.data[unique..][0..window].*);
    -            const result = @as(u64, key) *% int;
    +            // SplitMix64 finalizer over (key, int) — `key *% int` alone has
    +            // too little mixing to reliably produce a perfect hash for
    +            // small entry sets.

    we don't need comments to refer to the old implementation.

    dnut dnut commented on code on Jul 01, 2026 19:00 UTC
    Code Review
    shared/runtime/program/address_lookup_table/lib.zig:1
    @@ -20,9 +19,6 @@ pub const ProgramState = state.ProgramState;
     const Pubkey = sig.core.Pubkey;
     
     pub const ID: Pubkey = .parse("AddressLookupTab1e1111111111111111111111111");
    -pub const SOURCE_ID: Pubkey = .parse("AhXWrD9BBUYcKjtpA3zuiiZG4ysbo6C6wjHo1QhERk6A");
    -
    -pub const execute = @import("execute.zig").execute;
     
     // https://github.com/anza-xyz/agave/blob/8116c10021f09c806159852f65d37ffe6d5a118e/programs/address-lookup-table/src/processor.rs#L23
     pub const COMPUTE_UNITS = 750;

    this can be removed

    dnut dnut requested changes on Jul 01, 2026 19:02 UTC
    Changes Requested Reviewer

    Requested changes.

    yewman yewman requested changes on Jul 02, 2026 11:39 UTC
    Changes Requested Reviewer

    A few missed opportunities for dead-code removal.

    Stake (shared/runtime/program/stake/state.zig):

  • Meta.setLockup (L36-58) — reachable only from the deleted executor; drops last instruction.LockupArgs use inside state.zig.

  • Stake.split (L66-82) — dangling program.StakeError ref, no external callers.

  • Stake.deactivate (L85-90) — dangling program.StakeError return type, no external callers.

  • Authorized.authorize (L138-178) + Authorized.check (L120-134) — third program.StakeError site; check only called by authorize.

  • Authorized.equals (L180-183) and Lockup.equals (L208-212) — zero callers (all .equals( hits elsewhere are Pubkey.equals).

  • StakeFlags.combine (L109-111) — zero callers (StakeFlags.EMPTY stays, used by parse_stake.zig).

  • Follow-up: after the above, const instruction = @import("instruction.zig") at state.zig:L10 becomes unused and can go, and all three dangling program.StakeError references disappear without needing to add back a StakeError stub.
  • ALT (shared/runtime/program/address_lookup_table/):

  • pub const program = @import("lib.zig") (lib.zig:L10) — bogus self-import, zero refs (same shape as the pub const state = @import("stake/lib.zig") this PR already removed from program/lib.zig).

  • pub const instruction = @import("instruction.zig") (lib.zig:L12) — module alias, zero refs; Instruction is already re-exported directly on L14. (The parallel pub const state = @import("state.zig") at L11 must stay — live via address_lookup_table.state.LOOKUP_TABLE_META_SIZE.)

  • pub const COMPUTE_UNITS = 750 (lib.zig:L24) — zero internal or external refs; parallel to the SOURCE_IDs this PR did remove.

  • LookupTableMeta.new (state.zig:L60-64) — zero callers; LookupTableMeta is always built via struct-literal init.

  • AccountIndex scaffolding in instruction.zig — private AccountIndexWithPayer/AccountIndexNoPayer enums (L52-61) and the five pub const AccountIndex = ... decls on the variant structs (L76, L80, L87, L91, L95). The variant structs themselves stay (bincode payloads), but .AccountIndex on them is never referenced anywhere post-executor.
  • Also worth updating the PR body — it still says "Replace PHT with linear scan for NATIVE", but the final commit (applied pht fix from Harold) kept the PHT and instead swapped in a SplitMix64 finalizer.

    hamza-syndica hamza-syndica commented on code on Jul 06, 2026 06:00 UTC
    Code Review
    shared/utils/pht.zig:1
    @@ -58,9 +58,17 @@ pub fn pht(V: type, entries: []const struct { Pubkey, V }) type {
                 }
             };
     
    -        fn hash(x: *const Pubkey, key: u8) Hash {
    +        fn hash(x: *const Pubkey, key: u32) Hash {
                 const int: u32 = @bitCast(x.data[unique..][0..window].*);
    -            const result = @as(u64, key) *% int;
    +            // SplitMix64 finalizer over (key, int) — `key *% int` alone has
    +            // too little mixing to reliably produce a perfect hash for
    +            // small entry sets.
    hamza-syndica hamza-syndica commented on code on Jul 06, 2026 06:01 UTC
    Code Review
    shared/runtime/program/address_lookup_table/lib.zig:1
    @@ -20,9 +19,6 @@ pub const ProgramState = state.ProgramState;
     const Pubkey = sig.core.Pubkey;
     
     pub const ID: Pubkey = .parse("AddressLookupTab1e1111111111111111111111111");
    -pub const SOURCE_ID: Pubkey = .parse("AhXWrD9BBUYcKjtpA3zuiiZG4ysbo6C6wjHo1QhERk6A");
    -
    -pub const execute = @import("execute.zig").execute;
     
     // https://github.com/anza-xyz/agave/blob/8116c10021f09c806159852f65d37ffe6d5a118e/programs/address-lookup-table/src/processor.rs#L23
     pub const COMPUTE_UNITS = 750;
    hamza-syndica hamza-syndica commented on code on Jul 06, 2026 06:05 UTC
    Code Review
    shared/runtime/program/config/lib.zig:1
    @@ -2,6 +2,5 @@ const sig = @import("../../../lib.zig");
     const Pubkey = sig.core.Pubkey;
     
     pub const ID: Pubkey = .parse("Config1111111111111111111111111111111111111");
    -pub const SOURCE_ID: Pubkey = .parse("BuafH9fBv62u6XjzrzS4ZjAE8963ejqF5rt1f8Uga4Q3");
     
     pub const COMPUTE_UNITS = 450;
    yewman yewman commented on code on Jul 06, 2026 06:40 UTC
    Code Review
    shared/runtime/program/address_lookup_table/instruction.zig:1
    @@ -72,25 +61,15 @@ pub const CreateLookupTable = struct {
         /// addresses using the funding address, recent blockhash, and
         /// the user-passed `bump_seed`.
         bump_seed: u8,
    -
    -    pub const AccountIndex = AccountIndexWithPayer;
     };
     
    -pub const FreezeLookupTable = struct {
    -    pub const AccountIndex = AccountIndexNoPayer;
    -};
    +pub const FreezeLookupTable = struct {};
     
     // https://github.com/anza-xyz/agave/blob/7e8a1ddf86fa84b0ca4b64360af89399afd9de44/sdk/program/src/address_lookup_table/instruction.rs#L51
     pub const ExtendLookupTable = struct {
         new_addresses: []const Pubkey,
    -
    -    pub const AccountIndex = AccountIndexWithPayer;
     };
     
    -pub const DeactivateLookupTable = struct {
    -    pub const AccountIndex = AccountIndexNoPayer;
    -};
    +pub const DeactivateLookupTable = struct {};

    We should remove these empty structs, no need for the instruction variants to carry an named empty struct

    yewman yewman commented on Jul 06, 2026 06:47 UTC
    Reviewer

    We should remove the empty structs. Additionally I think the address_lookup_table, and stake modules could be defined just within a lib.zig similar to the config program. Ultimately I think we should separate the native program interfaces from their validator implementations however that can be left for a follow up PR.

    hamza-syndica hamza-syndica commented on code on Jul 06, 2026 07:21 UTC
    Code Review
    shared/runtime/program/address_lookup_table/instruction.zig:1
    @@ -72,25 +61,15 @@ pub const CreateLookupTable = struct {
         /// addresses using the funding address, recent blockhash, and
         /// the user-passed `bump_seed`.
         bump_seed: u8,
    -
    -    pub const AccountIndex = AccountIndexWithPayer;
     };
     
    -pub const FreezeLookupTable = struct {
    -    pub const AccountIndex = AccountIndexNoPayer;
    -};
    +pub const FreezeLookupTable = struct {};
     
     // https://github.com/anza-xyz/agave/blob/7e8a1ddf86fa84b0ca4b64360af89399afd9de44/sdk/program/src/address_lookup_table/instruction.rs#L51
     pub const ExtendLookupTable = struct {
         new_addresses: []const Pubkey,
    -
    -    pub const AccountIndex = AccountIndexWithPayer;
     };
     
    -pub const DeactivateLookupTable = struct {
    -    pub const AccountIndex = AccountIndexNoPayer;
    -};
    +pub const DeactivateLookupTable = struct {};
    hamza-syndica hamza-syndica commented on code on Jul 08, 2026 08:57 UTC
    Code Review
    shared/runtime/program/address_lookup_table/instruction.zig:1
    @@ -72,25 +61,15 @@ pub const CreateLookupTable = struct {
         /// addresses using the funding address, recent blockhash, and
         /// the user-passed `bump_seed`.
         bump_seed: u8,
    -
    -    pub const AccountIndex = AccountIndexWithPayer;
     };
     
    -pub const FreezeLookupTable = struct {
    -    pub const AccountIndex = AccountIndexNoPayer;
    -};
    +pub const FreezeLookupTable = struct {};
     
     // https://github.com/anza-xyz/agave/blob/7e8a1ddf86fa84b0ca4b64360af89399afd9de44/sdk/program/src/address_lookup_table/instruction.rs#L51
     pub const ExtendLookupTable = struct {
         new_addresses: []const Pubkey,
    -
    -    pub const AccountIndex = AccountIndexWithPayer;
     };
     
    -pub const DeactivateLookupTable = struct {
    -    pub const AccountIndex = AccountIndexNoPayer;
    -};
    +pub const DeactivateLookupTable = struct {};
    yewman yewman approved these changes on Jul 08, 2026 13:08 UTC
    Approved Reviewer

    Approved these changes.

    dnut dnut approved these changes on Jul 09, 2026 00:54 UTC
    Approved Reviewer

    Approved these changes.

    Reviewers
    Assignees
    hamza-syndica hamza-syndica
    Labels
    risk: low confidence: 68.3% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 59.1% (MEDIUM) · Higher = larger blast radius
    59.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 68.3% · Lower = rushed or shallow review
    68.3%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 18.7% · Safe to merge
    18.7%
    Repository