Skip to content

feat: improved fee payer protection #99

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dev-jodee
Copy link
Contributor

No description provided.

@dev-jodee dev-jodee requested a review from amilz July 16, 2025 19:45
@dev-jodee dev-jodee self-assigned this Jul 16, 2025
@dev-jodee dev-jodee changed the title Feature/improved fee payer protection feat: improved fee payer protection Jul 16, 2025
@dev-jodee
Copy link
Contributor Author

Draft until integration tests are merged into main, as this branch was checked out off of the fix-integration-tests-local branch.

@dev-jodee dev-jodee requested a review from pkxro July 16, 2025 20:20
Base automatically changed from dev-jodee/fix-integration-tests-local to main July 17, 2025 14:40
@dev-jodee dev-jodee force-pushed the feature/improved-fee-payer-protection branch from 8eafeb4 to ff0098a Compare July 17, 2025 17:20
@dev-jodee dev-jodee marked this pull request as ready for review July 17, 2025 17:21
Copy link
Contributor

@amilz amilz left a comment

Choose a reason for hiding this comment

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

This is awesome. See comments below.
I feel like it is probably worth doing this for all system/token program instructions tbh--particularly burn/close/approve.

Comment on lines +27 to +30
allow_sol_transfers: true,
allow_spl_transfers: true,
allow_token2022_transfers: true,
allow_assign: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

I understand that we'd want to have this backward compatible, but if we don't think there's any real application why any node operator would want to do this--I think it'd make sense to default false and include a warning of the change on install (in case an existing operator upgrades).

Comment on lines +197 to +202
system_instruction::SystemInstruction::Transfer { .. }
| system_instruction::SystemInstruction::TransferWithSeed { .. } => {
if !self.fee_payer_policy.allow_sol_transfers {
// For transfer instruction, first account is source
return account_keys[ix.accounts[0] as usize]
== self.fee_payer_pubkey;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think TransferWithSeed signer is actually position 1. I think position 0 here is the derived account.

Also need to add a test case with test_fee_payer_policy_assign

    /// Transfer lamports from a derived address
    ///
    /// # Account references
    ///   0. `[WRITE]` Funding account
    ///   1. `[SIGNER]` Base for funding account
    ///   2. `[WRITE]` Recipient account
    TransferWithSeed {
        /// Amount to transfer
        lamports: u64,

        /// Seed to use to derive the funding account address
        from_seed: String,

        /// Owner to use to derive the funding account address
        from_owner: Pubkey,
    },

== self.fee_payer_pubkey;
}
}
system_instruction::SystemInstruction::Assign { .. } => {
Copy link
Contributor

Choose a reason for hiding this comment

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

TIL -- there's an AssignWithSeed that we might want to include.

@@ -739,6 +809,268 @@ mod tests {
assert!(validated_amount > amount, "Interest should be added to the amount");
}

#[test]
fn test_fee_payer_policy_sol_transfers() {
Copy link
Contributor

Choose a reason for hiding this comment

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

add check for transfer_checked

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.

2 participants