diff --git a/api/src/state/miner.rs b/api/src/state/miner.rs index 86532e1..8d504fb 100644 --- a/api/src/state/miner.rs +++ b/api/src/state/miner.rs @@ -14,7 +14,7 @@ pub struct Miner { pub deployed: [u64; 25], /// Unused buffer. - #[deprecated(note = "Use automation executor instead")] + #[deprecated(note = "No longer used")] pub buffer: [u8; 24], /// Whether this miner is associated with a Solana Seeker. diff --git a/program/src/automate.rs b/program/src/automate.rs index 587835f..044a715 100644 --- a/program/src/automate.rs +++ b/program/src/automate.rs @@ -1,8 +1,6 @@ use ore_api::prelude::*; use steel::*; -use crate::whitelist::AUTHORIZED_ACCOUNTS; - /// Sets the executor. pub fn process_automate(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult { // Parse data. @@ -27,10 +25,10 @@ pub fn process_automate(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramRes )?; system_program.is_program(&system_program::ID)?; - // Check whitelist - if !AUTHORIZED_ACCOUNTS.contains(&signer_info.key) { - return Err(trace("Not authorized", OreError::NotAuthorized.into())); - } + // // Check whitelist + // if !AUTHORIZED_ACCOUNTS.contains(&signer_info.key) { + // return Err(trace("Not authorized", OreError::NotAuthorized.into())); + // } // Close account if executor is Pubkey::default(). if *executor_info.key == Pubkey::default() { diff --git a/program/src/claim_seeker.rs b/program/src/claim_seeker.rs index f61f855..9b2c640 100644 --- a/program/src/claim_seeker.rs +++ b/program/src/claim_seeker.rs @@ -23,14 +23,41 @@ pub fn process_claim_seeker(accounts: &[AccountInfo<'_>], _data: &[u8]) -> Progr signer_info.is_signer()?; miner_info.is_writable()?; mint_info.has_owner(&spl_token_2022::ID)?; - seeker_info.is_writable()?.is_empty()?; + seeker_info + .is_writable()? + .has_seeds(&[SEEKER, &mint_info.key.to_bytes()], &ore_api::ID)?; token_account_info .as_associated_token_account(signer_info.key, mint_info.key)? .assert(|t| t.amount() == 1)?; system_program.is_program(&system_program::ID)?; + // Load mint. + let mint_data = mint_info.try_borrow_data()?; + let mint = PodStateWithExtensions::::unpack(&mint_data)?; + + // Check mint authority. + assert!( + mint.base.mint_authority + == PodCOption::some(pubkey!("GT2zuHVaZQYZSyQMgJPLzvkmyztfyXg2NJunqFp4p3A4")), + "mint authority mismatch" + ); + + // Check metadata pointer. + let ext = mint.get_extension::()?; + assert!( + ext.authority.0 == pubkey!("GT2zuHVaZQYZSyQMgJPLzvkmyztfyXg2NJunqFp4p3A4"), + "metadata authority mismatch" + ); + assert!( + ext.metadata_address.0 == pubkey!("GT22s89nU4iWFkNXj1Bw6uYhJJWDRPpShHt4Bk8f99Te"), + "metadata address mismatch" + ); + // Open seeker account. // Each genesis token can only be claimed once. + if !seeker_info.data_is_empty() { + return Ok(()); + } create_program_account::( seeker_info, system_program, @@ -68,28 +95,6 @@ pub fn process_claim_seeker(accounts: &[AccountInfo<'_>], _data: &[u8]) -> Progr .assert_mut(|m| m.is_seeker == 0)? }; - // Load mint. - let mint_data = mint_info.try_borrow_data()?; - let mint = PodStateWithExtensions::::unpack(&mint_data)?; - - // Check mint authority. - assert!( - mint.base.mint_authority - == PodCOption::some(pubkey!("GT2zuHVaZQYZSyQMgJPLzvkmyztfyXg2NJunqFp4p3A4")), - "mint authority mismatch" - ); - - // Check metadata pointer. - let ext = mint.get_extension::()?; - assert!( - ext.authority.0 == pubkey!("GT2zuHVaZQYZSyQMgJPLzvkmyztfyXg2NJunqFp4p3A4"), - "metadata authority mismatch" - ); - assert!( - ext.metadata_address.0 == pubkey!("GT22s89nU4iWFkNXj1Bw6uYhJJWDRPpShHt4Bk8f99Te"), - "metadata address mismatch" - ); - // Flag the miner as a Seeker. miner.is_seeker = 1; diff --git a/program/src/deploy.rs b/program/src/deploy.rs index c2e9eb7..dcfae99 100644 --- a/program/src/deploy.rs +++ b/program/src/deploy.rs @@ -2,8 +2,6 @@ use ore_api::prelude::*; use solana_program::{keccak::hashv, log::sol_log, native_token::lamports_to_sol}; use steel::*; -use crate::whitelist::AUTHORIZED_ACCOUNTS; - /// Deploys capital to prospect on a square. pub fn process_deploy(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult { // Parse data. @@ -32,10 +30,10 @@ pub fn process_deploy(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResul let square = square_info.as_account_mut::(&ore_api::ID)?; system_program.is_program(&system_program::ID)?; - // Check whitelist - if !AUTHORIZED_ACCOUNTS.contains(&signer_info.key) { - return Err(trace("Not authorized", OreError::NotAuthorized.into())); - } + // // Check whitelist + // if !AUTHORIZED_ACCOUNTS.contains(&signer_info.key) { + // return Err(trace("Not authorized", OreError::NotAuthorized.into())); + // } // Check if signer is the automation executor. let automation = if !automation_info.data_is_empty() { diff --git a/program/src/lib.rs b/program/src/lib.rs index ec82380..d8e9767 100644 --- a/program/src/lib.rs +++ b/program/src/lib.rs @@ -11,7 +11,6 @@ mod migrate_miner; mod reset; mod set_admin; mod set_fee_collector; -mod whitelist; mod wrap; use automate::*; @@ -59,7 +58,6 @@ pub fn process_instruction( // Seeker OreInstruction::ClaimSeeker => process_claim_seeker(accounts, data)?, OreInstruction::MigrateMiner => process_migrate_miner(accounts, data)?, - // _ => return Err(ProgramError::InvalidInstructionData), } Ok(()) diff --git a/program/src/reset.rs b/program/src/reset.rs index 3e3a591..5e9317d 100644 --- a/program/src/reset.rs +++ b/program/src/reset.rs @@ -1,5 +1,5 @@ use ore_api::prelude::*; -use solana_program::slot_hashes::SlotHashes; +use solana_program::{log::sol_log, slot_hashes::SlotHashes}; use steel::*; /// Pays out the winners and block reward. @@ -298,7 +298,13 @@ fn get_winning_square(r: u64) -> usize { fn is_motherlode_activated(r: u64) -> bool { // Returns true if the motherlode was activated with 1/625 chance. let r = r.reverse_bits(); - (r % 625) == 0 + let x = r % 625; + if x == 0 { + sol_log("Motherlode was activated"); + } else { + sol_log(&format!("Motherlode missed by {}", x).as_str()); + } + x == 0 } /// Randomly selects a winning miner based on their proportional deposits. diff --git a/program/src/whitelist.rs b/program/src/whitelist.rs index e3ff4ce..875ccde 100644 --- a/program/src/whitelist.rs +++ b/program/src/whitelist.rs @@ -1,6 +1,7 @@ use solana_program::pubkey; use steel::*; +#[deprecated(note = "No longer used")] pub const AUTHORIZED_ACCOUNTS: [Pubkey; 280] = [ pubkey!("pqspJ298ryBjazPAr95J9sULCVpZe3HbZTWkbC1zrkS"), pubkey!("HNWhK5f8RMWBqcA7mXJPaxdTPGrha3rrqUrri7HSKb3T"),