-
Notifications
You must be signed in to change notification settings - Fork 195
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
base: main
Are you sure you want to change the base?
Conversation
Draft until integration tests are merged into main, as this branch was checked out off of the fix-integration-tests-local branch. |
8eafeb4
to
ff0098a
Compare
There was a problem hiding this 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.
allow_sol_transfers: true, | ||
allow_spl_transfers: true, | ||
allow_token2022_transfers: true, | ||
allow_assign: true, |
There was a problem hiding this comment.
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).
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; |
There was a problem hiding this comment.
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 { .. } => { |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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
No description provided.