1

So this is just something I've been thinking about. Hypothetically, if I had a PDA where anybody can call similar to the basic example below..

#[program]
mod hello_anchor {
    use super::*;
    pub fn set_data(ctx: Context<SetData>, data: u64) -> Result<()> {
        ctx.accounts.my_account.data = data;
        Ok(())
    }
}

#[account]
#[derive(Default)]
pub struct MyAccount {
    data: u64
}

#[derive(Accounts)]
pub struct SetData<'info> {
    #[account(mut)]
    pub my_account: Account<'info, MyAccount>
}

and there is no signer, would the PDA be susceptible to some type of "flood attack", where any body can just trigger it over and over and cause the app to crash or slow down other legitimate updates to the PDA?

My apologies if I'm way off on my thinking here, just trying to understand a broader picture of what would happen in this case.

1 Answer 1

3

It would work just like any other transaction. If there's a write lock on the account, the transaction scheduler needs to execute all transactions referencing the account serially, and that account would be able to use at most 12 million compute units in a block.

This means that your program would be throttled by the runtime due to the write locks. There's no impact on whether it's a signing PDA or not, it's entirely based on the write lock and the compute usage on the account.

2
  • So does this mean it would disrupt all activity for the entire program (updates and reads) not just for this the one function?
    – ZeroNine
    Commented Jan 31 at 19:35
  • 1
    If that PDA account is required for the other functions, yes
    – Jon C
    Commented Jan 31 at 22:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.