From 858270505e2b16d9918946c8281296abff9ac81d Mon Sep 17 00:00:00 2001 From: Hardhat Chad Date: Sun, 10 Mar 2024 19:22:32 +0000 Subject: [PATCH] update pubkeys for mainet --- src/consts.rs | 27 +++++++++++++++----------- src/instruction.rs | 10 ++++------ src/lib.rs | 3 +-- src/processor/initialize.rs | 12 ++++++++---- tests/test_initialize.rs | 1 - tests/test_reset.rs | 38 ++++++++++++++++++------------------- 6 files changed, 48 insertions(+), 43 deletions(-) diff --git a/src/consts.rs b/src/consts.rs index cb2e9e7..232f08f 100644 --- a/src/consts.rs +++ b/src/consts.rs @@ -5,24 +5,24 @@ pub const START_AT: i64 = 0; /// The addresses of the bus accounts. pub const BUS_ADDRESSES: [Pubkey; BUS_COUNT] = [ - pubkey!("85JC7qU7pkjYdvvXewfzgjCBZvugtrnPKYE9mzPD2ajJ"), - pubkey!("FXCPt8PPwNQF8NVFDvdnHRENpkWexGMr5t8EnSoBsbns"), - pubkey!("HbbFBD9y6mqhwsgu3hDEtFwJAtUtCFrRPRP8MNJoFkpV"), - pubkey!("D65o7LLrZ8YoE7r7TaUSN434ZctNhYc7dEsfQrMXD7DS"), - pubkey!("EJBBRJih5WFsZPwhmWTHrxSbBRhqtXjMJfMtjgtYGpzA"), - pubkey!("BbecQomM3tCYHHDjKXybK8McthdyuuNJkmVaVXWyayyZ"), - pubkey!("7RyV6ZZmkadFjT8rMmZXsbEzHFbHe2ZHcJqUuk7H5ibP"), - pubkey!("72GSzz967ePb6mDrZYzmwyFFrfNUgH2PUwwocfeyjxLB"), + pubkey!("BipsVd7bXrsWTD7MSR7vEE6wCi812xree9MdMQHNpGve"), + pubkey!("4UywqKWK1hFk2FVn2i8dHGRL28wTmwv2pveBV4QhApsy"), + pubkey!("6q971fxeEjwQWXL3PTEWBpSAs55HvKkb4yVeP85qrycY"), + pubkey!("BWa6yzTg3Mrs6tH2rstKQrobSVEBkfQUzE4iZUJz54AP"), + pubkey!("AXdpmjuVJYk7re8TcDX33ZoLyYpbBopesRWaNYnDHe8L"), + pubkey!("FXikoBAemf48cZswLnnUtXZhD7Pr6knYPNq6cjb76ubh"), + pubkey!("9BqvaWJ9bmkPYNqaZPaHoonAR5bh1dHRymZV4nrae3sC"), + pubkey!("8T4ngp27XKn3fAJnHgZ9pDXwzMbHnxhCPuvBWMa5m3ro"), ]; /// The address of the Ore mint metadata account. -pub const METADATA_ADDRESS: Pubkey = pubkey!("4nbf4yufkBjJbZjZrz5D6L4nRyRbiw9rvKLTesCVpqnB"); +pub const METADATA_ADDRESS: Pubkey = pubkey!("wyJ7XtZQDox5XoPG3uw7u7XnpNXaqTDeAwKpuJqHLi4"); /// The address of the Ore mint account. -pub const MINT_ADDRESS: Pubkey = pubkey!("tmResQt9qPVRhAh74fMxginQqHBG74Ls3Nou1rkvCg7"); +pub const MINT_ADDRESS: Pubkey = pubkey!("oreoBXz6dRgETAVLre1Umgp6Hs4UdLRwJiYj5FkfzYh"); /// The address of the treasury account. -pub const TREASURY_ADDRESS: Pubkey = pubkey!("nLCGcWmqqLC2UVBb3neVQWhzzJd8GAJshvasczmVm94"); +pub const TREASURY_ADDRESS: Pubkey = pubkey!("CHTwJ2GLmz9KDEpPuLu5iYFF85pSzx4xzJSwm81ojN3Q"); /// The initial reward rate to payout in the first epoch. pub const INITIAL_REWARD_RATE: u64 = 10u64.pow(3u32); @@ -66,6 +66,11 @@ static_assertions::const_assert!( (MAX_EPOCH_REWARDS / BUS_COUNT as u64) * BUS_COUNT as u64 == MAX_EPOCH_REWARDS ); +/// Noise for deriving the mint pda +pub const MINT_NOISE: [u8; 16] = [ + 64, 193, 214, 243, 206, 254, 96, 138, 148, 27, 250, 15, 126, 55, 231, 93, +]; + /// The seed of the bus account PDA. pub const BUS: &[u8] = b"bus"; diff --git a/src/instruction.rs b/src/instruction.rs index c5cc038..43a70c5 100644 --- a/src/instruction.rs +++ b/src/instruction.rs @@ -9,7 +9,7 @@ use solana_program::{ use crate::{ impl_instruction_from_bytes, impl_to_bytes, state::Hash, BUS, METADATA, MINT, MINT_ADDRESS, - PROOF, TREASURY, TREASURY_ADDRESS, + MINT_NOISE, PROOF, TREASURY, TREASURY_ADDRESS, }; #[repr(u8)] @@ -155,10 +155,6 @@ impl_instruction_from_bytes!(UpdateDifficultyArgs); /// Builds an initialize instruction. pub fn initialize(signer: Pubkey) -> Instruction { - let treasury_tokens = spl_associated_token_account::get_associated_token_address( - &TREASURY_ADDRESS, - &MINT_ADDRESS, - ); let bus_pdas = [ Pubkey::find_program_address(&[BUS, &[0]], &crate::id()), Pubkey::find_program_address(&[BUS, &[1]], &crate::id()), @@ -169,8 +165,10 @@ pub fn initialize(signer: Pubkey) -> Instruction { Pubkey::find_program_address(&[BUS, &[6]], &crate::id()), Pubkey::find_program_address(&[BUS, &[7]], &crate::id()), ]; - let mint_pda = Pubkey::find_program_address(&[MINT], &crate::id()); + let mint_pda = Pubkey::find_program_address(&[MINT, MINT_NOISE.as_slice()], &crate::id()); let treasury_pda = Pubkey::find_program_address(&[TREASURY], &crate::id()); + let treasury_tokens = + spl_associated_token_account::get_associated_token_address(&treasury_pda.0, &mint_pda.0); let metadata_pda = Pubkey::find_program_address( &[ METADATA, diff --git a/src/lib.rs b/src/lib.rs index d9757d1..d5ef2c0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -15,9 +15,8 @@ use solana_program::{ }; // TODO Set START_AT before launch. -// TODO Set pubkey consts for derived mainnet pdas before lanch. -declare_id!("oreoDL2qcXyBdaYTEfd7F5MFLY5PAqqDooPLZv1XdBP"); +declare_id!("mineS8xKxv3GurPq4RAssdZa6kNSXuuxJCEVtQwPZX4"); #[cfg(not(feature = "no-entrypoint"))] solana_program::entrypoint!(process_instruction); diff --git a/src/processor/initialize.rs b/src/processor/initialize.rs index aa4faf4..32f9476 100644 --- a/src/processor/initialize.rs +++ b/src/processor/initialize.rs @@ -18,7 +18,7 @@ use crate::{ utils::AccountDeserialize, utils::Discriminator, BUS, BUS_ADDRESSES, BUS_COUNT, INITIAL_DIFFICULTY, INITIAL_REWARD_RATE, METADATA, - METADATA_ADDRESS, METADATA_NAME, METADATA_SYMBOL, METADATA_URI, MINT, MINT_ADDRESS, + METADATA_ADDRESS, METADATA_NAME, METADATA_SYMBOL, METADATA_URI, MINT, MINT_ADDRESS, MINT_NOISE, TOKEN_DECIMALS, TREASURY, TREASURY_ADDRESS, }; @@ -73,7 +73,11 @@ pub fn process_initialize<'a, 'info>( ], &mpl_token_metadata::ID, )?; - load_uninitialized_pda(mint_info, &[MINT, &[args.mint_bump]], &crate::id())?; + load_uninitialized_pda( + mint_info, + &[MINT, MINT_NOISE.as_slice(), &[args.mint_bump]], + &crate::id(), + )?; load_uninitialized_pda( treasury_info, &[TREASURY, &[args.treasury_bump]], @@ -156,7 +160,7 @@ pub fn process_initialize<'a, 'info>( mint_info, &spl_token::id(), Mint::LEN, - &[MINT, &[args.mint_bump]], + &[MINT, MINT_NOISE.as_slice(), &[args.mint_bump]], system_program, signer, )?; @@ -174,7 +178,7 @@ pub fn process_initialize<'a, 'info>( treasury_info.clone(), rent_sysvar.clone(), ], - &[&[MINT, &[args.mint_bump]]], + &[&[MINT, MINT_NOISE.as_slice(), &[args.mint_bump]]], )?; // Initialize mint metadata diff --git a/tests/test_initialize.rs b/tests/test_initialize.rs index 6817ee7..8143654 100644 --- a/tests/test_initialize.rs +++ b/tests/test_initialize.rs @@ -79,7 +79,6 @@ async fn test_initialize() { assert_eq!(metadata.creators, None); assert_eq!(metadata.primary_sale_happened, false); assert_eq!(metadata.is_mutable, true); - assert_eq!(metadata.edition_nonce, Some(u8::MAX)); assert_eq!(metadata.token_standard, Some(TokenStandard::Fungible)); assert_eq!(metadata.collection, None); assert_eq!(metadata.uses, None); diff --git a/tests/test_reset.rs b/tests/test_reset.rs index d20c66d..8a5e1a9 100644 --- a/tests/test_reset.rs +++ b/tests/test_reset.rs @@ -5,7 +5,7 @@ use ore::{ state::{Bus, Treasury}, utils::{AccountDeserialize, Discriminator}, BUS, BUS_ADDRESSES, BUS_COUNT, BUS_EPOCH_REWARDS, INITIAL_DIFFICULTY, INITIAL_REWARD_RATE, - MAX_EPOCH_REWARDS, MINT, MINT_ADDRESS, TOKEN_DECIMALS, TREASURY, TREASURY_ADDRESS, + MAX_EPOCH_REWARDS, MINT_ADDRESS, TOKEN_DECIMALS, TREASURY, TREASURY_ADDRESS, }; use rand::seq::SliceRandom; use solana_program::{ @@ -41,10 +41,11 @@ async fn test_reset() { Pubkey::find_program_address(&[BUS, &[6]], &ore::id()), Pubkey::find_program_address(&[BUS, &[7]], &ore::id()), ]; - let mint_pda = Pubkey::find_program_address(&[MINT], &ore::id()); - let treasury_pda = Pubkey::find_program_address(&[TREASURY], &ore::id()); - let treasury_tokens_address = - spl_associated_token_account::get_associated_token_address(&treasury_pda.0, &mint_pda.0); + // let mint_pda = Pubkey::find_program_address(&[MINT], &ore::id()); + let treasury_tokens_address = spl_associated_token_account::get_associated_token_address( + &TREASURY_ADDRESS, + &MINT_ADDRESS, + ); // Submit tx let ix = ore::instruction::reset(payer.pubkey()); @@ -62,10 +63,9 @@ async fn test_reset() { } // Test treasury state - let treasury_account = banks.get_account(treasury_pda.0).await.unwrap().unwrap(); + let treasury_account = banks.get_account(TREASURY_ADDRESS).await.unwrap().unwrap(); assert_eq!(treasury_account.owner, ore::id()); let treasury = Treasury::try_from_bytes(&treasury_account.data).unwrap(); - assert_eq!(treasury.bump as u8, treasury_pda.1); assert_eq!( treasury.admin, Pubkey::from_str("AeNqnoLwFanMd3ig9WoMxQZVwQHtCtqKMMBsT1sTrvz6").unwrap() @@ -76,10 +76,10 @@ async fn test_reset() { assert_eq!(treasury.total_claimed_rewards as u8, 0); // Test mint state - let mint_account = banks.get_account(mint_pda.0).await.unwrap().unwrap(); + let mint_account = banks.get_account(MINT_ADDRESS).await.unwrap().unwrap(); assert_eq!(mint_account.owner, spl_token::id()); let mint = Mint::unpack(&mint_account.data).unwrap(); - assert_eq!(mint.mint_authority, COption::Some(treasury_pda.0)); + assert_eq!(mint.mint_authority, COption::Some(TREASURY_ADDRESS)); assert_eq!(mint.supply, MAX_EPOCH_REWARDS); assert_eq!(mint.decimals, ore::TOKEN_DECIMALS); assert_eq!(mint.is_initialized, true); @@ -93,8 +93,8 @@ async fn test_reset() { .unwrap(); assert_eq!(treasury_tokens_account.owner, spl_token::id()); let treasury_tokens = spl_token::state::Account::unpack(&treasury_tokens_account.data).unwrap(); - assert_eq!(treasury_tokens.mint, mint_pda.0); - assert_eq!(treasury_tokens.owner, treasury_pda.0); + assert_eq!(treasury_tokens.mint, MINT_ADDRESS); + assert_eq!(treasury_tokens.owner, TREASURY_ADDRESS); assert_eq!(treasury_tokens.amount, MAX_EPOCH_REWARDS); assert_eq!(treasury_tokens.delegate, COption::None); assert_eq!(treasury_tokens.state, AccountState::Initialized); @@ -120,10 +120,10 @@ async fn test_reset_busses_out_of_order() { Pubkey::find_program_address(&[BUS, &[1]], &ore::id()), Pubkey::find_program_address(&[BUS, &[4]], &ore::id()), ]; - let mint_pda = Pubkey::find_program_address(&[MINT], &ore::id()); - let treasury_pda = Pubkey::find_program_address(&[TREASURY], &ore::id()); - let treasury_tokens = - spl_associated_token_account::get_associated_token_address(&treasury_pda.0, &mint_pda.0); + let treasury_tokens = spl_associated_token_account::get_associated_token_address( + &TREASURY_ADDRESS, + &MINT_ADDRESS, + ); // Submit tx let ix = Instruction { @@ -176,10 +176,10 @@ async fn test_reset_shuffle_error() { Pubkey::find_program_address(&[BUS, &[1]], &ore::id()), Pubkey::find_program_address(&[BUS, &[4]], &ore::id()), ]; - let mint_pda = Pubkey::find_program_address(&[MINT], &ore::id()); - let treasury_pda = Pubkey::find_program_address(&[TREASURY], &ore::id()); - let treasury_tokens = - spl_associated_token_account::get_associated_token_address(&treasury_pda.0, &mint_pda.0); + let treasury_tokens = spl_associated_token_account::get_associated_token_address( + &TREASURY_ADDRESS, + &MINT_ADDRESS, + ); // Fuzz test shuffled accounts. // Note some shuffles may still be valid if signer and non-bus accounts are all in correct positions.