← Back to Pull requests

test: Token-2022 fee-payer drain property coverage #653

Closed
VedantMadane closed this pull request without merging on Sep 23, 2026 11:10 UTC
View on GitHub
VedantMadane VedantMadane commented on Aug 24, 2026 14:29 UTC
Author

## Summary

test: Token-2022 fee-payer drain property coverage

Changes

  • fee_payer_policy_props/token_2022.rs: DrainRole coverage for Token-2022 fee-payer flags

  • includes Pause/Resume mapped to freeze/thaw flags and extension authority roles

  • WithdrawExcessLamports in ROLES with destination != owner so excess does not collapse back to the fee payer

  • proptest cases bumped to 512

  • token2022_security.rs: WithdrawExcessLamports is policy-gated (allow_withdraw_excess_lamports), not RejectIfFeePayerPresent (parity with SPL Token so the flag is reachable)

  • mod.rs: declare token_2022 module
  • Fixes #643

    Test plan

  • cargo test -p kora-lib --lib fee_payer_policy_props — 6 passed
  • AI disclosure

  • AI tooling was used

  • - Tool and extent: coding agent assisted implementing review fixes (WithdrawExcessLamports instruction arm, destination/owner separation, security-policy parity, rebase/sign)

    Diff: 180 lines (+178 / -2) across 3 files Reviewer: dev-jodee Review duration: 43000m
    All Vouch review confidence checks passed
    Residual risk 0.09 = Change Risk (0.60) × (1 − Review Confidence (0.85)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.60 · 180 lines diff across 3 files
    0.60
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.74 · 5 substantive comment(s)
    0.74
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    84%
    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.311
    Sensitive Paths sensitive_paths
    0.060
    Real PR Conversation Timeline
    20 items
    greptile-apps[bot] greptile-apps[bot] commented on Aug 24, 2026 14:32 UTC
    Bot

    <!-- greptile_summary -->

    <h2><a href="https://app.greptile.com/api/retrigger?id=56262470"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img alt="Retrigger" src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2" align="right"></picture></a>Confidence Score: 5/5</h2>

    The PR appears safe to merge; the prior compilation and unreachable-policy findings are resolved and no new actionable defects remain.

    <h2>Findings</h2>

    1. <img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top">&nbsp;Withdraw role lacks instruction arm <a href="https://github.com/solana-foundation/kora/pull/653#discussion_r4036997806">▶</a>

    <h3>Summary</h3>

    Adds Token-2022 fee-payer drain property coverage and aligns WithdrawExcessLamports with its configured policy gate.

  • Registers the Token-2022 property-test module and covers standard, pause/resume, and extension-authority roles.

  • Adds a complete WithdrawExcessLamports test instruction with a destination distinct from the authority.

  • Removes the instruction from the unconditional unsupported-extension rejection path so its dedicated policy flag is reachable.
  • <!-- greptile_confidence_score:5 -->

    <sub>Reviews (6) · Last reviewed commit: "test: Token-2022 fee-payer drain propert..."</sub>

    greptile-apps[bot] greptile-apps[bot] commented on code on Aug 24, 2026 14:32 UTC
    Code Review
    crates/lib/src/validator/transaction_validator/fee_payer_policy_props/token_2022.rs:1
    @@ -0,0 +1,173 @@
    +use super::{assert_role_gated_iff_flag_off, role_and_flags, DrainRole};
    +use crate::config::FeePayerPolicy;
    +use proptest::prelude::*;
    +use solana_sdk::{instruction::Instruction, pubkey::Pubkey};
    +use spl_token_2022_interface::{
    +    extension::{
    +        metadata_pointer::instruction as metadata_pointer_ix,
    +        pausable::instruction as pausable_ix,
    +        transfer_fee::instruction as transfer_fee_ix,
    +    },
    +    id as token_2022_program_id,
    +    instruction::{
    +        approve, burn, close_account, freeze_account, initialize_account3, initialize_mint2,
    +        initialize_multisig2, mint_to, revoke, set_authority, thaw_account, transfer_checked,
    +        AuthorityType,
    +    },
    +};
    +
    +#[derive(Debug, Clone, Copy)]
    +enum Token2022Role {
    +    Transfer,
    +    Burn,
    +    CloseAccount,
    +    Approve,
    +    Revoke,
    +    SetAuthority,
    +    MintTo,
    +    InitializeMint,
    +    InitializeAccount,
    +    InitializeMultisig,
    +    FreezeAccount,
    +    ThawAccount,
    +    Pause,
    +    Resume,
    +    InitializeExtensionAuthorityMetadataPointer,
    +    InitializeExtensionAuthorityTransferFee,
    +    UpdateExtensionAuthorityMetadataPointer,
    +}
    +
    +impl DrainRole for Token2022Role {
    +    const ROLES: &'static [Self] = &[
    +        Self::Transfer,
    +        Self::Burn,
    +        Self::CloseAccount,
    +        Self::Approve,
    +        Self::Revoke,
    +        Self::SetAuthority,
    +        Self::MintTo,
    +        Self::InitializeMint,
    +        Self::InitializeAccount,
    +        Self::InitializeMultisig,
    +        Self::FreezeAccount,
    +        Self::ThawAccount,
    +        Self::Pause,
    +        Self::Resume,
    +        Self::InitializeExtensionAuthorityMetadataPointer,
    +        Self::InitializeExtensionAuthorityTransferFee,
    +        Self::UpdateExtensionAuthorityMetadataPointer,

    <a href="#"><img alt="P2" src="https://greptile-static-assets.s3.amazonaws.com/badges/p2.svg?v=9" align="top"></a> Withdraw role lacks property coverage

    Token2022Role::ROLES omits the reachable WithdrawExcessLamports policy role, so this property suite never exercises allow_withdraw_excess_lamports and regressions in that gate can pass CI.

    Knowledge Base Used:

  • Transaction validation policy

  • Fees and paymaster controls
  • dev-jodee dev-jodee requested changes on Aug 26, 2026 13:43 UTC
    Changes Requested Reviewer

    greptile's comments

    VedantMadane VedantMadane commented on Aug 27, 2026 00:05 UTC
    Author

    Addressed the Greptile review feedback:

  • Withdraw role lacks property coverage — Token2022Role now includes WithdrawExcessLamports, wired to token_2022.allow_withdraw_excess_lamports and building a real withdraw_excess_lamports instruction (same shape as the SPL Token props).
  • Commit: d19a9bd

    VedantMadane VedantMadane commented on code on Aug 27, 2026 00:05 UTC
    Code Review
    crates/lib/src/validator/transaction_validator/fee_payer_policy_props/token_2022.rs:1
    @@ -0,0 +1,173 @@
    +use super::{assert_role_gated_iff_flag_off, role_and_flags, DrainRole};
    +use crate::config::FeePayerPolicy;
    +use proptest::prelude::*;
    +use solana_sdk::{instruction::Instruction, pubkey::Pubkey};
    +use spl_token_2022_interface::{
    +    extension::{
    +        metadata_pointer::instruction as metadata_pointer_ix,
    +        pausable::instruction as pausable_ix,
    +        transfer_fee::instruction as transfer_fee_ix,
    +    },
    +    id as token_2022_program_id,
    +    instruction::{
    +        approve, burn, close_account, freeze_account, initialize_account3, initialize_mint2,
    +        initialize_multisig2, mint_to, revoke, set_authority, thaw_account, transfer_checked,
    +        AuthorityType,
    +    },
    +};
    +
    +#[derive(Debug, Clone, Copy)]
    +enum Token2022Role {
    +    Transfer,
    +    Burn,
    +    CloseAccount,
    +    Approve,
    +    Revoke,
    +    SetAuthority,
    +    MintTo,
    +    InitializeMint,
    +    InitializeAccount,
    +    InitializeMultisig,
    +    FreezeAccount,
    +    ThawAccount,
    +    Pause,
    +    Resume,
    +    InitializeExtensionAuthorityMetadataPointer,
    +    InitializeExtensionAuthorityTransferFee,
    +    UpdateExtensionAuthorityMetadataPointer,
    +}
    +
    +impl DrainRole for Token2022Role {
    +    const ROLES: &'static [Self] = &[
    +        Self::Transfer,
    +        Self::Burn,
    +        Self::CloseAccount,
    +        Self::Approve,
    +        Self::Revoke,
    +        Self::SetAuthority,
    +        Self::MintTo,
    +        Self::InitializeMint,
    +        Self::InitializeAccount,
    +        Self::InitializeMultisig,
    +        Self::FreezeAccount,
    +        Self::ThawAccount,
    +        Self::Pause,
    +        Self::Resume,
    +        Self::InitializeExtensionAuthorityMetadataPointer,
    +        Self::InitializeExtensionAuthorityTransferFee,
    +        Self::UpdateExtensionAuthorityMetadataPointer,

    Fixed in d19a9bd — added WithdrawExcessLamports to Token2022Role (enum, ROLES, flag → allow_withdraw_excess_lamports, and instruction via withdraw_excess_lamports), matching the existing SPL Token property coverage so the suite exercises that gate.

    VedantMadane VedantMadane commented on code on Aug 27, 2026 00:05 UTC
    Code Review
    crates/lib/src/validator/transaction_validator/fee_payer_policy_props/token_2022.rs:1
    @@ -0,0 +1,173 @@
    +use super::{assert_role_gated_iff_flag_off, role_and_flags, DrainRole};
    +use crate::config::FeePayerPolicy;
    +use proptest::prelude::*;
    +use solana_sdk::{instruction::Instruction, pubkey::Pubkey};
    +use spl_token_2022_interface::{
    +    extension::{
    +        metadata_pointer::instruction as metadata_pointer_ix,
    +        pausable::instruction as pausable_ix,
    +        transfer_fee::instruction as transfer_fee_ix,
    +    },
    +    id as token_2022_program_id,
    +    instruction::{
    +        approve, burn, close_account, freeze_account, initialize_account3, initialize_mint2,
    +        initialize_multisig2, mint_to, revoke, set_authority, thaw_account, transfer_checked,
    +        AuthorityType,
    +    },
    +};
    +
    +#[derive(Debug, Clone, Copy)]
    +enum Token2022Role {
    +    Transfer,
    +    Burn,
    +    CloseAccount,
    +    Approve,
    +    Revoke,
    +    SetAuthority,
    +    MintTo,
    +    InitializeMint,
    +    InitializeAccount,
    +    InitializeMultisig,
    +    FreezeAccount,
    +    ThawAccount,
    +    Pause,
    +    Resume,
    +    InitializeExtensionAuthorityMetadataPointer,
    +    InitializeExtensionAuthorityTransferFee,
    +    UpdateExtensionAuthorityMetadataPointer,
    +}
    +
    +impl DrainRole for Token2022Role {
    +    const ROLES: &'static [Self] = &[
    +        Self::Transfer,
    +        Self::Burn,
    +        Self::CloseAccount,
    +        Self::Approve,
    +        Self::Revoke,
    +        Self::SetAuthority,
    +        Self::MintTo,
    +        Self::InitializeMint,
    +        Self::InitializeAccount,
    +        Self::InitializeMultisig,
    +        Self::FreezeAccount,
    +        Self::ThawAccount,
    +        Self::Pause,
    +        Self::Resume,
    +        Self::InitializeExtensionAuthorityMetadataPointer,
    +        Self::InitializeExtensionAuthorityTransferFee,
    +        Self::UpdateExtensionAuthorityMetadataPointer,

    Fixed in d19a9bd — added WithdrawExcessLamports to Token2022Role (enum, ROLES, flag → allow_withdraw_excess_lamports, instruction via withdraw_excess_lamports), matching SPL Token property coverage.

    greptile-apps[bot] greptile-apps[bot] commented on code on Aug 27, 2026 00:08 UTC
    Code Review
    crates/lib/src/validator/transaction_validator/fee_payer_policy_props/token_2022.rs:1
    @@ -0,0 +1,186 @@
    +use super::{assert_role_gated_iff_flag_off, role_and_flags, DrainRole};
    +use crate::config::FeePayerPolicy;
    +use proptest::prelude::*;
    +use solana_sdk::{instruction::Instruction, pubkey::Pubkey};
    +use spl_token_2022_interface::{
    +    extension::{
    +        metadata_pointer::instruction as metadata_pointer_ix,
    +        pausable::instruction as pausable_ix,
    +        transfer_fee::instruction as transfer_fee_ix,
    +    },
    +    id as token_2022_program_id,
    +    instruction::{
    +        approve, burn, close_account, freeze_account, initialize_account3, initialize_mint2,
    +        initialize_multisig2, mint_to, revoke, set_authority, thaw_account, transfer_checked,
    +        withdraw_excess_lamports, AuthorityType,
    +    },
    +};
    +
    +#[derive(Debug, Clone, Copy)]
    +enum Token2022Role {
    +    Transfer,
    +    Burn,
    +    CloseAccount,
    +    Approve,
    +    Revoke,
    +    SetAuthority,
    +    MintTo,
    +    InitializeMint,
    +    InitializeAccount,
    +    InitializeMultisig,
    +    FreezeAccount,
    +    ThawAccount,
    +    Pause,
    +    Resume,
    +    WithdrawExcessLamports,
    +    InitializeExtensionAuthorityMetadataPointer,
    +    InitializeExtensionAuthorityTransferFee,
    +    UpdateExtensionAuthorityMetadataPointer,
    +}
    +
    +impl DrainRole for Token2022Role {
    +    const ROLES: &'static [Self] = &[
    +        Self::Transfer,
    +        Self::Burn,
    +        Self::CloseAccount,
    +        Self::Approve,
    +        Self::Revoke,
    +        Self::SetAuthority,
    +        Self::MintTo,
    +        Self::InitializeMint,
    +        Self::InitializeAccount,
    +        Self::InitializeMultisig,
    +        Self::FreezeAccount,
    +        Self::ThawAccount,
    +        Self::Pause,
    +        Self::Resume,
    +        Self::WithdrawExcessLamports,

    <a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> Withdrawal property always rejects

    When the property selects WithdrawExcessLamports with the actor as fee payer and allow_withdraw_excess_lamports enabled, the normal flag gate passes but the subsequent Token-2022 RejectIfFeePayerPresent check rejects the authority account unconditionally, causing the property's enabled-flag assertion to fail instead of covering the configured gate.

    Knowledge Base Used:

  • Transaction validation policy

  • Fees and paymaster controls
  • VedantMadane VedantMadane commented on Sep 10, 2026 05:56 UTC
    Author

    Rebased on upstream/main and updated Token-2022 property test:

  • Fixed Token2022Role roles to cover all valid configurable fee-payer policy flags for Token-2022 (allow_transfer, allow_burn, allow_close_account, allow_approve, allow_revoke, allow_set_authority, allow_mint_to, allow_initialize_mint, allow_initialize_account, allow_initialize_multisig, allow_freeze_account / Pause, allow_thaw_account / Resume, allow_initialize_extension_authority, and allow_update_extension_authority).

  • Excluded unconfigurable unconditional rejection operations per issue guidelines (WithdrawExcessLamports in Token-2022 is rejected unconditionally by the security parser as an unsupported fee-payer extension instruction).

  • Fixed initialize_multisig2 parameter slice type.

  • Cleanly registered mod token_2022; in fee_payer_policy_props/mod.rs.
  • Mutation Proof


    Temporarily mapped Token2022Role::Transfer to policy.token_2022.allow_burn:
    ---- validator::transaction_validator::fee_payer_policy_props::token_2022::fee_payer_role_gated_iff_flag_off stdout ----
    thread 'validator::transaction_validator::fee_payer_policy_props::token_2022::fee_payer_role_gated_iff_flag_off' panicked at crates\lib\src\validator\transaction_validator\fee_payer_policy_props\token_2022.rs:164:1:
    Test failed: Transfer by fee payer must pass when its flag is on, got Err(InvalidTransaction("Fee payer cannot be used for 'Token2022 Token Transfer'"))
    

    Reverted back to allow_transfer. All 6 property test suites pass:
    running 6 tests
    test validator::transaction_validator::fee_payer_policy_props::token_2022::fee_payer_role_gated_iff_flag_off ... ok
    test validator::transaction_validator::fee_payer_policy_props::spl_token::fee_payer_role_gated_iff_flag_off ... ok
    test validator::transaction_validator::fee_payer_policy_props::system::fee_payer_role_gated_iff_flag_off ... ok
    test validator::transaction_validator::fee_payer_policy_props::loader_v4::fee_payer_role_gated_iff_flag_off ... ok
    test validator::transaction_validator::fee_payer_policy_props::alt::fee_payer_role_gated_iff_flag_off ... ok
    test validator::transaction_validator::fee_payer_policy_props::bpf_loader_upgradeable::fee_payer_role_gated_iff_flag_off ... ok
    
    test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 962 filtered out; finished in 0.10s
    

    dev-jodee dev-jodee commented on Sep 15, 2026 17:21 UTC
    Contributor

    @VedantMadane you need to sign your commit

    dev-jodee dev-jodee commented on Sep 15, 2026 17:23 UTC
    Contributor

    @VedantMadane and you need to fix the ci :) (prob rebase + fix the enum)

    dev-jodee dev-jodee commented on code on Sep 15, 2026 19:33 UTC
    Code Review
    crates/lib/src/validator/transaction_validator/fee_payer_policy_props/token_2022.rs:1
    @@ -0,0 +1,173 @@
    +use super::{assert_role_gated_iff_flag_off, role_and_flags, DrainRole};
    +use crate::config::FeePayerPolicy;
    +use proptest::prelude::*;
    +use solana_sdk::{instruction::Instruction, pubkey::Pubkey};
    +use spl_token_2022_interface::{
    +    extension::{
    +        metadata_pointer::instruction as metadata_pointer_ix,
    +        pausable::instruction as pausable_ix,
    +        transfer_fee::instruction as transfer_fee_ix,
    +    },
    +    id as token_2022_program_id,
    +    instruction::{
    +        approve, burn, close_account, freeze_account, initialize_account3, initialize_mint2,
    +        initialize_multisig2, mint_to, revoke, set_authority, thaw_account, transfer_checked,
    +        AuthorityType,
    +    },
    +};
    +
    +#[derive(Debug, Clone, Copy)]
    +enum Token2022Role {
    +    Transfer,
    +    Burn,
    +    CloseAccount,
    +    Approve,
    +    Revoke,
    +    SetAuthority,
    +    MintTo,
    +    InitializeMint,
    +    InitializeAccount,
    +    InitializeMultisig,
    +    FreezeAccount,
    +    ThawAccount,
    +    Pause,
    +    Resume,
    +    InitializeExtensionAuthorityMetadataPointer,
    +    InitializeExtensionAuthorityTransferFee,
    +    UpdateExtensionAuthorityMetadataPointer,
    +}
    +
    +impl DrainRole for Token2022Role {
    +    const ROLES: &'static [Self] = &[
    +        Self::Transfer,
    +        Self::Burn,
    +        Self::CloseAccount,
    +        Self::Approve,
    +        Self::Revoke,
    +        Self::SetAuthority,
    +        Self::MintTo,
    +        Self::InitializeMint,
    +        Self::InitializeAccount,
    +        Self::InitializeMultisig,
    +        Self::FreezeAccount,
    +        Self::ThawAccount,
    +        Self::Pause,
    +        Self::Resume,
    +        Self::InitializeExtensionAuthorityMetadataPointer,
    +        Self::InitializeExtensionAuthorityTransferFee,
    +        Self::UpdateExtensionAuthorityMetadataPointer,

    WithdrawExcessLamports still isn't in ROLES

    dev-jodee dev-jodee commented on code on Sep 15, 2026 19:33 UTC
    Code Review
    crates/lib/src/validator/transaction_validator/fee_payer_policy_props/token_2022.rs:1
    @@ -0,0 +1,173 @@
    +use super::{assert_role_gated_iff_flag_off, role_and_flags, DrainRole};
    +use crate::config::FeePayerPolicy;
    +use proptest::prelude::*;
    +use solana_sdk::{instruction::Instruction, pubkey::Pubkey};
    +use spl_token_2022_interface::{
    +    extension::{
    +        metadata_pointer::instruction as metadata_pointer_ix,
    +        pausable::instruction as pausable_ix,
    +        transfer_fee::instruction as transfer_fee_ix,
    +    },
    +    id as token_2022_program_id,
    +    instruction::{
    +        approve, burn, close_account, freeze_account, initialize_account3, initialize_mint2,
    +        initialize_multisig2, mint_to, revoke, set_authority, thaw_account, transfer_checked,
    +        AuthorityType,
    +    },
    +};
    +
    +#[derive(Debug, Clone, Copy)]
    +enum Token2022Role {
    +    Transfer,
    +    Burn,
    +    CloseAccount,
    +    Approve,
    +    Revoke,
    +    SetAuthority,
    +    MintTo,
    +    InitializeMint,
    +    InitializeAccount,
    +    InitializeMultisig,
    +    FreezeAccount,
    +    ThawAccount,
    +    Pause,
    +    Resume,
    +    InitializeExtensionAuthorityMetadataPointer,
    +    InitializeExtensionAuthorityTransferFee,
    +    UpdateExtensionAuthorityMetadataPointer,
    +}
    +
    +impl DrainRole for Token2022Role {
    +    const ROLES: &'static [Self] = &[
    +        Self::Transfer,
    +        Self::Burn,
    +        Self::CloseAccount,
    +        Self::Approve,
    +        Self::Revoke,
    +        Self::SetAuthority,
    +        Self::MintTo,
    +        Self::InitializeMint,
    +        Self::InitializeAccount,
    +        Self::InitializeMultisig,
    +        Self::FreezeAccount,
    +        Self::ThawAccount,
    +        Self::Pause,
    +        Self::Resume,
    +        Self::InitializeExtensionAuthorityMetadataPointer,
    +        Self::InitializeExtensionAuthorityTransferFee,
    +        Self::UpdateExtensionAuthorityMetadataPointer,
    +    ];
    +
    +    fn allowed_programs() -> Vec<String> {
    +        vec![token_2022_program_id().to_string()]
    +    }
    +
    +    fn flag(self, policy: &mut FeePayerPolicy) -> &mut bool {
    +        match self {
    +            Self::Transfer => &mut policy.token_2022.allow_transfer,
    +            Self::Burn => &mut policy.token_2022.allow_burn,
    +            Self::CloseAccount => &mut policy.token_2022.allow_close_account,
    +            Self::Approve => &mut policy.token_2022.allow_approve,
    +            Self::Revoke => &mut policy.token_2022.allow_revoke,
    +            Self::SetAuthority => &mut policy.token_2022.allow_set_authority,
    +            Self::MintTo => &mut policy.token_2022.allow_mint_to,
    +            Self::InitializeMint => &mut policy.token_2022.allow_initialize_mint,
    +            Self::InitializeAccount => &mut policy.token_2022.allow_initialize_account,
    +            Self::InitializeMultisig => &mut policy.token_2022.allow_initialize_multisig,
    +            Self::FreezeAccount | Self::Pause => &mut policy.token_2022.allow_freeze_account,
    +            Self::ThawAccount | Self::Resume => &mut policy.token_2022.allow_thaw_account,
    +            Self::InitializeExtensionAuthorityMetadataPointer
    +            | Self::InitializeExtensionAuthorityTransferFee => {
    +                &mut policy.token_2022.allow_initialize_extension_authority
    +            }
    +            Self::UpdateExtensionAuthorityMetadataPointer => {
    +                &mut policy.token_2022.allow_update_extension_authority
    +            }
    +        }
    +    }
    +
    +    fn instruction(self, actor: &Pubkey) -> Instruction {
    +        let program_id = token_2022_program_id();
    +        let mint = Pubkey::new_unique();
    +        let account = Pubkey::new_unique();
    +        let other = Pubkey::new_unique();
    +        match self {
    +            Self::Transfer => transfer_checked(
    +                &program_id,
    +                &account,
    +                &mint,
    +                &other,
    +                actor,
    +                &[],
    +                1,
    +                6,
    +            )
    +            .expect("transfer_checked"),
    +            Self::Burn => burn(&program_id, &account, &mint, actor, &[], 1).expect("burn"),
    +            Self::CloseAccount => {
    +                close_account(&program_id, &account, actor, actor, &[]).expect("close_account")
    +            }
    +            Self::Approve => {
    +                approve(&program_id, &account, &other, actor, &[], 1).expect("approve")
    +            }
    +            Self::Revoke => revoke(&program_id, &account, actor, &[]).expect("revoke"),
    +            Self::SetAuthority => set_authority(
    +                &program_id,
    +                &account,
    +                Some(&other),
    +                AuthorityType::AccountOwner,
    +                actor,
    +                &[],
    +            )
    +            .expect("set_authority"),
    +            Self::MintTo => mint_to(&program_id, &mint, &account, actor, &[], 1).expect("mint_to"),
    +            Self::InitializeMint => {
    +                initialize_mint2(&program_id, &mint, actor, None, 6).expect("initialize_mint2")
    +            }
    +            Self::InitializeAccount => {
    +                initialize_account3(&program_id, &account, &mint, actor).expect("initialize_account3")
    +            }
    +            Self::InitializeMultisig => {
    +                initialize_multisig2(&program_id, &account, &[actor], 1).expect("initialize_multisig2")
    +            }
    +            Self::FreezeAccount => {
    +                freeze_account(&program_id, &account, &mint, actor, &[]).expect("freeze_account")
    +            }
    +            Self::ThawAccount => {
    +                thaw_account(&program_id, &account, &mint, actor, &[]).expect("thaw_account")
    +            }
    +            Self::Pause => pausable_ix::pause(&program_id, &mint, actor, &[]).expect("pause"),
    +            Self::Resume => pausable_ix::resume(&program_id, &mint, actor, &[]).expect("resume"),
    +            Self::InitializeExtensionAuthorityMetadataPointer => {
    +                metadata_pointer_ix::initialize(&program_id, &mint, Some(*actor), Some(other))
    +                    .expect("metadata_pointer initialize")
    +            }
    +            Self::InitializeExtensionAuthorityTransferFee => {
    +                transfer_fee_ix::initialize_transfer_fee_config(
    +                    &program_id,
    +                    &mint,
    +                    Some(actor),
    +                    Some(&other),
    +                    100,
    +                    1_000,
    +                )
    +                .expect("transfer_fee initialize")
    +            }
    +            Self::UpdateExtensionAuthorityMetadataPointer => {
    +                metadata_pointer_ix::update(&program_id, &mint, actor, &[], Some(other))
    +                    .expect("metadata_pointer update")
    +            }
    +        }
    +    }
    +}
    +
    +proptest! {
    +    #![proptest_config(ProptestConfig::with_cases(256))]

    bump to 512

    dev-jodee dev-jodee commented on code on Sep 15, 2026 19:34 UTC
    Code Review
    crates/lib/src/validator/transaction_validator/fee_payer_policy_props/token_2022.rs:1
    @@ -0,0 +1,173 @@
    +use super::{assert_role_gated_iff_flag_off, role_and_flags, DrainRole};
    +use crate::config::FeePayerPolicy;
    +use proptest::prelude::*;
    +use solana_sdk::{instruction::Instruction, pubkey::Pubkey};
    +use spl_token_2022_interface::{
    +    extension::{
    +        metadata_pointer::instruction as metadata_pointer_ix,
    +        pausable::instruction as pausable_ix,
    +        transfer_fee::instruction as transfer_fee_ix,
    +    },
    +    id as token_2022_program_id,
    +    instruction::{
    +        approve, burn, close_account, freeze_account, initialize_account3, initialize_mint2,
    +        initialize_multisig2, mint_to, revoke, set_authority, thaw_account, transfer_checked,
    +        AuthorityType,
    +    },
    +};
    +
    +#[derive(Debug, Clone, Copy)]
    +enum Token2022Role {
    +    Transfer,
    +    Burn,
    +    CloseAccount,
    +    Approve,
    +    Revoke,
    +    SetAuthority,
    +    MintTo,
    +    InitializeMint,
    +    InitializeAccount,
    +    InitializeMultisig,
    +    FreezeAccount,
    +    ThawAccount,
    +    Pause,
    +    Resume,
    +    InitializeExtensionAuthorityMetadataPointer,
    +    InitializeExtensionAuthorityTransferFee,
    +    UpdateExtensionAuthorityMetadataPointer,
    +}
    +
    +impl DrainRole for Token2022Role {
    +    const ROLES: &'static [Self] = &[
    +        Self::Transfer,
    +        Self::Burn,
    +        Self::CloseAccount,
    +        Self::Approve,
    +        Self::Revoke,
    +        Self::SetAuthority,
    +        Self::MintTo,
    +        Self::InitializeMint,
    +        Self::InitializeAccount,
    +        Self::InitializeMultisig,
    +        Self::FreezeAccount,
    +        Self::ThawAccount,
    +        Self::Pause,
    +        Self::Resume,
    +        Self::InitializeExtensionAuthorityMetadataPointer,
    +        Self::InitializeExtensionAuthorityTransferFee,
    +        Self::UpdateExtensionAuthorityMetadataPointer,
    +    ];
    +
    +    fn allowed_programs() -> Vec<String> {
    +        vec![token_2022_program_id().to_string()]
    +    }
    +
    +    fn flag(self, policy: &mut FeePayerPolicy) -> &mut bool {
    +        match self {
    +            Self::Transfer => &mut policy.token_2022.allow_transfer,
    +            Self::Burn => &mut policy.token_2022.allow_burn,
    +            Self::CloseAccount => &mut policy.token_2022.allow_close_account,
    +            Self::Approve => &mut policy.token_2022.allow_approve,
    +            Self::Revoke => &mut policy.token_2022.allow_revoke,
    +            Self::SetAuthority => &mut policy.token_2022.allow_set_authority,
    +            Self::MintTo => &mut policy.token_2022.allow_mint_to,
    +            Self::InitializeMint => &mut policy.token_2022.allow_initialize_mint,
    +            Self::InitializeAccount => &mut policy.token_2022.allow_initialize_account,
    +            Self::InitializeMultisig => &mut policy.token_2022.allow_initialize_multisig,
    +            Self::FreezeAccount | Self::Pause => &mut policy.token_2022.allow_freeze_account,
    +            Self::ThawAccount | Self::Resume => &mut policy.token_2022.allow_thaw_account,
    +            Self::InitializeExtensionAuthorityMetadataPointer
    +            | Self::InitializeExtensionAuthorityTransferFee => {
    +                &mut policy.token_2022.allow_initialize_extension_authority
    +            }
    +            Self::UpdateExtensionAuthorityMetadataPointer => {
    +                &mut policy.token_2022.allow_update_extension_authority
    +            }
    +        }
    +    }
    +
    +    fn instruction(self, actor: &Pubkey) -> Instruction {
    +        let program_id = token_2022_program_id();
    +        let mint = Pubkey::new_unique();
    +        let account = Pubkey::new_unique();
    +        let other = Pubkey::new_unique();
    +        match self {
    +            Self::Transfer => transfer_checked(
    +                &program_id,
    +                &account,
    +                &mint,
    +                &other,
    +                actor,
    +                &[],
    +                1,
    +                6,
    +            )
    +            .expect("transfer_checked"),
    +            Self::Burn => burn(&program_id, &account, &mint, actor, &[], 1).expect("burn"),
    +            Self::CloseAccount => {
    +                close_account(&program_id, &account, actor, actor, &[]).expect("close_account")

    passes actor as both destination and owner, so rent returns to fee payer, doesn't test the actual fee drain

    dev-jodee dev-jodee requested changes on Sep 15, 2026 19:34 UTC
    Changes Requested Reviewer

    Requested changes.

    greptile-apps[bot] greptile-apps[bot] commented on code on Sep 17, 2026 12:50 UTC
    Code Review
    crates/lib/src/validator/transaction_validator/fee_payer_policy_props/token_2022.rs:1
    @@ -0,0 +1,169 @@
    +use super::{assert_role_gated_iff_flag_off, role_and_flags, DrainRole};
    +use crate::config::FeePayerPolicy;
    +use proptest::prelude::*;
    +use solana_sdk::{instruction::Instruction, pubkey::Pubkey};
    +use spl_token_2022_interface::{
    +    extension::{
    +        metadata_pointer::instruction as metadata_pointer_ix, pausable::instruction as pausable_ix,
    +        transfer_fee::instruction as transfer_fee_ix,
    +    },
    +    id as token_2022_program_id,
    +    instruction::{
    +        approve, burn, close_account, freeze_account, initialize_account3, initialize_mint2,
    +        initialize_multisig2, mint_to, revoke, set_authority, thaw_account, transfer_checked,
    +        withdraw_excess_lamports,
    +        AuthorityType,
    +    },
    +};
    +
    +#[derive(Debug, Clone, Copy)]
    +enum Token2022Role {
    +    Transfer,
    +    Burn,
    +    CloseAccount,
    +    WithdrawExcessLamports,
    +    Approve,
    +    Revoke,
    +    SetAuthority,
    +    MintTo,
    +    InitializeMint,
    +    InitializeAccount,
    +    InitializeMultisig,
    +    FreezeAccount,
    +    ThawAccount,
    +    Pause,
    +    Resume,
    +    InitializeExtensionAuthorityMetadataPointer,
    +    InitializeExtensionAuthorityTransferFee,
    +    UpdateExtensionAuthorityMetadataPointer,
    +}
    +
    +impl DrainRole for Token2022Role {
    +    const ROLES: &'static [Self] = &[
    +        Self::Transfer,
    +        Self::Burn,
    +        Self::CloseAccount,
    +        Self::WithdrawExcessLamports,
    +        Self::Approve,
    +        Self::Revoke,
    +        Self::SetAuthority,
    +        Self::MintTo,
    +        Self::InitializeMint,
    +        Self::InitializeAccount,
    +        Self::InitializeMultisig,
    +        Self::FreezeAccount,
    +        Self::ThawAccount,
    +        Self::Pause,
    +        Self::Resume,
    +        Self::InitializeExtensionAuthorityMetadataPointer,
    +        Self::InitializeExtensionAuthorityTransferFee,
    +        Self::UpdateExtensionAuthorityMetadataPointer,
    +    ];
    +
    +    fn allowed_programs() -> Vec<String> {
    +        vec![token_2022_program_id().to_string()]
    +    }
    +
    +    fn flag(self, policy: &mut FeePayerPolicy) -> &mut bool {
    +        match self {
    +            Self::Transfer => &mut policy.token_2022.allow_transfer,
    +            Self::Burn => &mut policy.token_2022.allow_burn,
    +            Self::CloseAccount => &mut policy.token_2022.allow_close_account,
    +            Self::WithdrawExcessLamports => &mut policy.token_2022.allow_withdraw_excess_lamports,
    +            Self::Approve => &mut policy.token_2022.allow_approve,
    +            Self::Revoke => &mut policy.token_2022.allow_revoke,
    +            Self::SetAuthority => &mut policy.token_2022.allow_set_authority,
    +            Self::MintTo => &mut policy.token_2022.allow_mint_to,
    +            Self::InitializeMint => &mut policy.token_2022.allow_initialize_mint,
    +            Self::InitializeAccount => &mut policy.token_2022.allow_initialize_account,
    +            Self::InitializeMultisig => &mut policy.token_2022.allow_initialize_multisig,
    +            Self::FreezeAccount | Self::Pause => &mut policy.token_2022.allow_freeze_account,
    +            Self::ThawAccount | Self::Resume => &mut policy.token_2022.allow_thaw_account,
    +            Self::InitializeExtensionAuthorityMetadataPointer
    +            | Self::InitializeExtensionAuthorityTransferFee => {
    +                &mut policy.token_2022.allow_initialize_extension_authority
    +            }
    +            Self::UpdateExtensionAuthorityMetadataPointer => {
    +                &mut policy.token_2022.allow_update_extension_authority
    +            }
    +        }
    +    }
    +
    +    fn instruction(self, actor: &Pubkey) -> Instruction {
    +        let program_id = token_2022_program_id();
    +        let mint = Pubkey::new_unique();
    +        let account = Pubkey::new_unique();
    +        let other = Pubkey::new_unique();
    +        match self {

    <a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> Withdraw role lacks instruction arm

    When the library tests compile, instruction() does not handle the newly added WithdrawExcessLamports variant and has no wildcard arm, causing a non-exhaustive-match compilation error before the property test can run.

    VedantMadane VedantMadane commented on Sep 23, 2026 11:07 UTC
    Author

    Addressed the blocking review items on d70d767:

    1. WithdrawExcessLamports in ROLES — enum + ROLES + flag + instruction() arm (destination=other, authority=actor).
    2. proptest cases = 512
    3. CloseAccount / Withdraw destination != owner — rent/excess does not collapse back to the fee payer.
    4. CI compile — non-exhaustive match fixed; rebased onto main.
    5. Policy reachability — Token-2022 WithdrawExcessLamports was under RejectIfFeePayerPresent as an "unsupported extension", which made allow_withdraw_excess_lamports unreachable. Removed from that list so the policy flag gates it (parity with SPL Token). Property suite green locally: cargo test -p kora-lib --lib fee_payer_policy_props -> 6 passed.

    Remaining (needs maintainer / account setup):

  • Commits signed (GitHub verified): commit is GPG-signed with key E1FE8F465F1B0E23, author 6527493+VedantMadane@users.noreply.github.com. GitHub reports bad_email because the key on the account does not yet include the noreply UID (local key was updated; re-upload of the public key needs admin:gpg_key scope).

  • Accepted issue linked: #643 has labels enhancement, help wanted, good first issue but not accepted. The hygiene check requires the accepted label.
  • VedantMadane VedantMadane commented on Sep 23, 2026 11:08 UTC
    Author

    Addressed all inline CR: WithdrawExcessLamports in ROLES + instruction arm (and removed incorrect Token-2022 RejectIfFeePayerPresent listing so the allow flag is reachable); proptest 512; close/withdraw destination uses other so rent does not return to fee payer. Rebased on main. fee_payer_policy_props tests 6/6 pass. Ready for re-review. Note: commit is GPG-signed; GitHub may still show bad_email until the noreply UID is on the uploaded key. Issue #643 may need the accepted label for hygiene.

    github-actions[bot] github-actions[bot] requested changes on Sep 23, 2026 11:10 UTC
    Changes Requested Reviewer

    <!-- signed-commits:76c5d14b0564 -->
    Every commit in a Solana Foundation repository needs signature verification, and these are unverified:

  • d70d767 test: Token-2022 fee-payer drain property coverage
  • Set up signing, then sign the existing commits (git rebase --exec 'git commit --amend --no-edit -S' main) and force-push. This review is dismissed automatically once every commit verifies.

    github-actions[bot] github-actions[bot] commented on Sep 23, 2026 11:10 UTC
    Bot

    <!-- needs-issue -->
    Hi @VedantMadane,

    Thanks for the pull request. We ask that every change references an issue a maintainer has accepted, and there isn't one linked here.

    Kora signs transactions with a funded fee payer, so a change landing in the wrong shape is expensive to undo. Agreeing on the approach in an issue first means nobody writes code that can't be merged. See CONTRIBUTING.md for the full workflow.

    Please open an issue describing the change, or comment on the existing one. Once a maintainer has labelled it accepted, put Fixes #<issue> in this description and reopen this pull request; the check runs again and clears itself. Typos, broken links and comment-only fixes are exempt: write Linked issue: trivial instead.

    Reviewers
    Assignees
    VedantMadane VedantMadane
    Labels
    risk: low confidence: 84.6% reviewed sensitive_module
    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: 60.2% (MEDIUM) · Higher = larger blast radius
    60.2%
    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: 84.6% · Lower = rushed or shallow review
    84.6%
    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: 9.2% · Safe to merge
    9.2%