Simultaneous transactions could cause race conditions on a Solana program? For instance if we have the following counter example:
#[account]
pub struct Counter {
pub number: u8,
}
#[derive(Accounts)]
pub struct UpdateCounter<'info> {
pub payer: Signer<'info>,
#[account(mut)]
pub counter: Account<'info, Counter>,
}
pub fn update_counter(ctx: Context<UpdateCounter>) -> Result<()> {
let counter = &mut ctx.accounts.counter;
counter.number = counter.number + 1;
Ok(())
}
And many users call update_counter()
at the same time which would be the outcome? would it cause some transactions to fail? would the last transaction overwrite the number written by the previous user? Or would it work normally (No race conditions)?