diff --git a/api/src/instruction.rs b/api/src/instruction.rs index fdf0469..7d46f32 100644 --- a/api/src/instruction.rs +++ b/api/src/instruction.rs @@ -89,6 +89,10 @@ pub enum OreInstruction { #[account(6, name = "mint_v1", desc = "Ore v1 token mint account", writable)] #[account(7, name = "token_program", desc = "SPL token program")] Upgrade = 7, + + #[account(0, name = "ore_program", desc = "Ore program")] + #[account(1, name = "proof", desc = "Ore proof account")] + DeclareProof = 8, #[account(0, name = "ore_program", desc = "Ore program")] #[account(1, name = "signer", desc = "Admin signer", signer)] diff --git a/program/src/declare_proof.rs b/program/src/declare_proof.rs new file mode 100644 index 0000000..3786155 --- /dev/null +++ b/program/src/declare_proof.rs @@ -0,0 +1,34 @@ +use solana_program::{ + account_info::AccountInfo, + entrypoint::ProgramResult, + program_error::ProgramError, + pubkey::Pubkey, +}; + + +/// DeclareProof is used by other instructions in the same transaction. +/// - Other instructions will use transaction introspection to ensure they +/// only process the declared proof. +/// - Other instructions that need to validate the declared proof will only +/// look at the first and second instructions in the transaction +/// +/// Safety requirements: +/// - No safety requirements are required in this instruction to keep cu's as +/// low as possible. Other instructions that use the declared proof handle +/// validation via the loader. +pub fn process_declare_proof<'a, 'info>( + _program_id: &Pubkey, + accounts: &'a [AccountInfo<'info>], + _data: &[u8], +) -> ProgramResult { + // Ensure one account info is provided + // Validation of this proof is handled by the mine ix + let [_proof_info] = + accounts + else { + return Err(ProgramError::NotEnoughAccountKeys); + }; + + Ok(()) +} + diff --git a/program/src/lib.rs b/program/src/lib.rs index 909a87a..1846e63 100644 --- a/program/src/lib.rs +++ b/program/src/lib.rs @@ -1,6 +1,7 @@ mod claim; mod close; mod initialize; +mod declare_proof; mod mine; mod open; mod reset; @@ -11,6 +12,7 @@ mod upgrade; use claim::*; use close::*; use initialize::*; +use declare_proof::*; use mine::*; use open::*; use reset::*; @@ -45,6 +47,7 @@ pub fn process_instruction( match OreInstruction::try_from(*tag).or(Err(ProgramError::InvalidInstructionData))? { OreInstruction::Claim => process_claim(program_id, accounts, data)?, OreInstruction::Close => process_close(program_id, accounts, data)?, + OreInstruction::DeclareProof => process_declare_proof(program_id, accounts, data)?, OreInstruction::Mine => process_mine(program_id, accounts, data)?, OreInstruction::Open => process_open(program_id, accounts, data)?, OreInstruction::Reset => process_reset(program_id, accounts, data)?,