Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions crank-counter/anchor/programs/crank-counter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ pub mod anchor_counter {
Ok(())
}

// This example intentionally keeps `increment` permissionless. A privileged scheduled
// instruction must authenticate the preceding Hydra `Trigger` through the instructions
// sysvar. Scheduled instructions run top-level and do not inherit a Hydra PDA signature.
/// Increment the counter.
pub fn increment(ctx: Context<Increment>) -> Result<()> {
let counter = &mut ctx.accounts.counter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ pub mod delegation_actions {
Ok(())
}

// This example intentionally keeps `increment` permissionless. A privileged
// post-delegation action should require an action signer that was validated and recorded
// when the account was delegated, or check an authority stored in program state.
pub fn increment(ctx: Context<Increment>) -> Result<()> {
let counter = &mut ctx.accounts.counter;
counter.count += 1;
Expand Down
4 changes: 4 additions & 0 deletions magic-actions/anchor/programs/magic-actions/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ pub struct Increment<'info> {
pub counter: Account<'info, Counter>,
}

// `#[action]` adds the action accounts but does not authenticate the caller.
// This example intentionally leaves `update_leaderboard` public. A privileged handler
// must constrain `escrow_auth` to an expected authority and require the derived `escrow`
// PDA as a signer, or require an authority stored in program state.
#[action]
#[derive(Accounts)]
pub struct UpdateLeaderboard<'info> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ pub fn process_callback_roll_dice(
return Err(ProgramError::InvalidSeeds);
}

// The scoped identity address is public. Its signer privilege proves that the
// VRF program invoked this callback.
if !program_identity.is_signer() {
return Err(ProgramError::MissingRequiredSignature);
}

let rnd_u8 = random_u8_with_range(&randomness, 1, 6);
pinocchio_log::log!("Consuming random number: {}", rnd_u8);
pinocchio_log::log!("client_seed={}", client_seed);
Expand Down
6 changes: 6 additions & 0 deletions roll-dice/pinocchio/programs/roll-dice/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ pub fn process_callback_roll_dice(
return Err(ProgramError::InvalidSeeds);
}

// The scoped identity address is public. Its signer privilege proves that the
// VRF program invoked this callback.
if !program_identity.is_signer() {
return Err(ProgramError::MissingRequiredSignature);
}

let rnd_u8 = random_u8_with_range(&randomness, 1, 6);
pinocchio_log::log!("Consuming random number: {}", rnd_u8);
pinocchio_log::log!("client_seed={}", client_seed);
Expand Down
Loading