diff --git a/api/src/state/config.rs b/api/src/state/config.rs index 3f53eaf..ed6f338 100644 --- a/api/src/state/config.rs +++ b/api/src/state/config.rs @@ -1,6 +1,6 @@ use steel::*; -use crate::state::{config_pda, OreAccountOLD}; +use crate::state::config_pda; use super::OreAccount; @@ -23,26 +23,6 @@ pub struct Config { pub is_seeker_activation_enabled: u64, } -#[repr(C)] -#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)] -pub struct ConfigOLD { - /// The address that can update the config. - pub admin: Pubkey, - - /// The last boost timestamp. - pub last_boost: i64, - - /// Whether seeker activation is enabled. - pub is_seeker_activation_enabled: u64, - - /// The address that receives admin fees. - pub fee_collector: Pubkey, - - // The fee rate taken for each swap. - #[deprecated(since = "1.0.0", note = "Unused")] - pub fee_rate: u64, -} - impl Config { pub fn pda() -> (Pubkey, u8) { config_pda() @@ -50,4 +30,3 @@ impl Config { } account!(OreAccount, Config); -account!(OreAccountOLD, ConfigOLD); diff --git a/api/src/state/miner.rs b/api/src/state/miner.rs index 2489d87..eb37b77 100644 --- a/api/src/state/miner.rs +++ b/api/src/state/miner.rs @@ -1,6 +1,6 @@ use steel::*; -use crate::state::{miner_pda, OreAccountOLD, Treasury}; +use crate::state::{miner_pda, Treasury}; use super::OreAccount; @@ -50,40 +50,6 @@ pub struct Miner { pub lifetime_rewards_ore: u64, } -#[repr(C)] -#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)] -pub struct MinerOLD { - /// The authority of this miner account. - pub authority: Pubkey, - - /// The miner's prospects in the current round. - pub deployed: [u64; 25], - - /// The cumulative amount of SOL deployed on each square prior to this miner's move. - pub cumulative: [u64; 25], - - /// SOL witheld in reserve to pay for checkpointing. - pub checkpoint_fee: u64, - - /// The last round that this miner checkpointed. - pub checkpoint_id: u64, - - /// The amount of SOL this miner can claim. - pub rewards_sol: u64, - - /// The amount of ORE this miner can claim. - pub rewards_ore: u64, - - /// The ID of the round this miner last played in. - pub round_id: u64, - - /// The total amount of SOL this miner has mined across all blocks. - pub lifetime_rewards_sol: u64, - - /// The total amount of ORE this miner has mined across all blocks. - pub lifetime_rewards_ore: u64, -} - impl Miner { pub fn pda(&self) -> (Pubkey, u8) { miner_pda(self.authority) @@ -137,4 +103,3 @@ impl Miner { } account!(OreAccount, Miner); -account!(OreAccountOLD, MinerOLD); diff --git a/api/src/state/mod.rs b/api/src/state/mod.rs index 90d4b27..d8326c3 100644 --- a/api/src/state/mod.rs +++ b/api/src/state/mod.rs @@ -35,14 +35,6 @@ pub enum OreAccount { Round = 109, } -#[repr(u8)] -#[derive(Clone, Copy, Debug, Eq, PartialEq, IntoPrimitive, TryFromPrimitive)] -pub enum OreAccountOLD { - ConfigOLD = 101, - MinerOLD = 103, - TreasuryOLD = 104, -} - pub fn automation_pda(authority: Pubkey) -> (Pubkey, u8) { Pubkey::find_program_address(&[AUTOMATION, &authority.to_bytes()], &crate::ID) } diff --git a/api/src/state/treasury.rs b/api/src/state/treasury.rs index 3e7eafc..fa87790 100644 --- a/api/src/state/treasury.rs +++ b/api/src/state/treasury.rs @@ -1,7 +1,5 @@ use steel::*; -use crate::state::OreAccountOLD; - use super::OreAccount; /// Treasury is a singleton account which is the mint authority for the ORE token and the authority of @@ -31,27 +29,4 @@ pub struct Treasury { pub total_refined: u64, } -#[repr(C)] -#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)] -pub struct TreasuryOLD { - // The amount of SOL collected for buy-bury operations. - pub balance: u64, - - /// The amount of ORE in the motherlode rewards pool. - pub motherlode: u64, - - /// The cumulative ORE distributed to miners, divided by the total unclaimed ORE at the time of distribution. - pub miner_rewards_factor: Numeric, - - /// The cumulative ORE distributed to stakers, divided by the total stake at the time of distribution. - pub stake_rewards_factor: Numeric, - - /// The current total amount of ORE staking deposits. - pub total_staked: u64, - - /// The current total amount of unclaimed ORE mining rewards. - pub total_unclaimed: u64, -} - account!(OreAccount, Treasury); -account!(OreAccountOLD, TreasuryOLD); diff --git a/cli/src/main.rs b/cli/src/main.rs index 21814c7..23b9d1a 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -110,12 +110,6 @@ async fn main() { "participating_miners" => { participating_miners(&rpc).await.unwrap(); } - "migrate_miners" => { - migrate_miners(&rpc, &payer).await.unwrap(); - } - "migrate_treasury" => { - migrate_treasury(&rpc, &payer).await.unwrap(); - } "keys" => { keys().await.unwrap(); } @@ -123,45 +117,6 @@ async fn main() { }; } -async fn migrate_miners( - rpc: &RpcClient, - payer: &solana_sdk::signer::keypair::Keypair, -) -> Result<(), anyhow::Error> { - let miners = get_miners_old(rpc).await?; - let mut ixs = vec![]; - for (i, (address, miner)) in miners.iter().enumerate() { - println!( - "[{}/{}] Migrate miner: {}", - i + 1, - miners.len(), - miner.authority - ); - ixs.push(ore_api::sdk::migrate_miner(payer.pubkey(), *address)); - } - // submit_transaction(rpc, payer, &ixs).await?; - // let ix = ore_api::sdk::migrate_miner(payer.pubkey()); - // submit_transaction(rpc, payer, &[ix]).await?; - - // simulate_transaction_batches(rpc, payer, ixs, 10).await?; - submit_transaction_batches(rpc, payer, ixs, 10).await?; - - Ok(()) -} - -async fn get_miners_old(rpc: &RpcClient) -> Result, anyhow::Error> { - let miners = get_program_accounts(rpc, ore_api::ID, vec![]).await?; - Ok(miners) -} - -async fn migrate_treasury( - rpc: &RpcClient, - payer: &solana_sdk::signer::keypair::Keypair, -) -> Result<(), anyhow::Error> { - let ix = ore_api::sdk::migrate_treasury(payer.pubkey()); - submit_transaction(rpc, payer, &[ix]).await?; - Ok(()) -} - async fn participating_miners(rpc: &RpcClient) -> Result<(), anyhow::Error> { let round_id = std::env::var("ID").expect("Missing ID env var"); let round_id = u64::from_str(&round_id).expect("Invalid ID"); diff --git a/program/src/lib.rs b/program/src/lib.rs index ea5001b..869b860 100644 --- a/program/src/lib.rs +++ b/program/src/lib.rs @@ -10,8 +10,6 @@ mod close; mod deploy; mod deposit; mod log; -// mod migrate_miner; -mod migrate_treasury; mod reset; mod set_admin; mod set_fee_collector; @@ -31,8 +29,6 @@ use close::*; use deploy::*; use deposit::*; use log::*; -// use migrate_miner::*; -// use migrate_treasury::*; use reset::*; use set_admin::*; use set_fee_collector::*; diff --git a/program/src/migrate_miner.rs b/program/src/migrate_miner.rs deleted file mode 100644 index 8d7f48a..0000000 --- a/program/src/migrate_miner.rs +++ /dev/null @@ -1,60 +0,0 @@ -use ore_api::prelude::*; -use solana_program::rent::Rent; -use steel::*; - -/// Sets the admin. -pub fn process_migrate_miner(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult { - // Load accounts. - let [signer_info, config_info, miner_info, system_program] = accounts else { - return Err(ProgramError::NotEnoughAccountKeys); - }; - signer_info.is_signer()?; - let config = config_info - .as_account_mut::(&ore_api::ID)? - .assert_mut_err( - |c| c.admin == *signer_info.key, - OreError::NotAuthorized.into(), - )?; - let miner = miner_info.as_account_mut::(&ore_api::ID)?; - system_program.is_program(&system_program::ID)?; - - // Record old values. - let authority = miner.authority; - let deployed = miner.deployed; - let cumulative = miner.cumulative; - let checkpoint_fee = miner.checkpoint_fee; - let checkpoint_id = miner.checkpoint_id; - let rewards_sol = miner.rewards_sol; - let rewards_ore = miner.rewards_ore; - let round_id = miner.round_id; - let lifetime_rewards_sol = miner.lifetime_rewards_sol; - let lifetime_rewards_ore = miner.lifetime_rewards_ore; - - // Realloc miner. - let new_size = 8 + std::mem::size_of::(); - let old_size = 8 + std::mem::size_of::(); - let new_rent = Rent::get()?.minimum_balance(new_size); - let old_rent = Rent::get()?.minimum_balance(old_size); - let additional_rent = new_rent - old_rent; - miner_info.realloc(new_size, false)?; - miner_info.collect(additional_rent, &signer_info)?; - - // Update miner. - let miner = miner_info.as_account_mut::(&ore_api::ID)?; - miner.authority = authority; - miner.deployed = deployed; - miner.cumulative = cumulative; - miner.checkpoint_fee = checkpoint_fee; - miner.checkpoint_id = checkpoint_id; - miner.rewards_sol = rewards_sol; - miner.rewards_ore = rewards_ore; - miner.round_id = round_id; - miner.lifetime_rewards_sol = lifetime_rewards_sol; - miner.lifetime_rewards_ore = lifetime_rewards_ore; - miner.last_claim_ore_at = 0; - miner.last_claim_sol_at = 0; - miner.rewards_factor = Numeric::ZERO; - miner.refined_ore = 0; - - Ok(()) -} diff --git a/program/src/migrate_treasury.rs b/program/src/migrate_treasury.rs deleted file mode 100644 index 69360e3..0000000 --- a/program/src/migrate_treasury.rs +++ /dev/null @@ -1,46 +0,0 @@ -use ore_api::prelude::*; -use solana_program::{pubkey, rent::Rent}; -use steel::*; - -/// Sets the admin. -pub fn process_migrate_treasury(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult { - // Load accounts. - let [signer_info, config_info, system_program] = accounts else { - return Err(ProgramError::NotEnoughAccountKeys); - }; - signer_info.is_signer()?; - let config = config_info - .as_account_mut::(&ore_api::ID)? - .assert_mut_err( - |c| c.admin == *signer_info.key, - OreError::NotAuthorized.into(), - )?; - system_program.is_program(&system_program::ID)?; - - // Record old values. - let admin = config.admin; - let fee_collector = config.fee_collector; - let last_boost = config.last_boost; - let is_seeker_activation_enabled = config.is_seeker_activation_enabled; - - // Realloc treasury. - let new_size = 8 + std::mem::size_of::(); - let old_size = 8 + std::mem::size_of::(); - let new_rent = Rent::get()?.minimum_balance(new_size); - let old_rent = Rent::get()?.minimum_balance(old_size); - config_info.realloc(new_size, false)?; - if new_size > old_size { - let additional_rent = new_rent.saturating_sub(old_rent); - config_info.collect(additional_rent, &signer_info)?; - } - - // Update config. - let config = config_info.as_account_mut::(&ore_api::ID)?; - config.admin = admin; - config.fee_collector = fee_collector; - config.bury_authority = pubkey!("HNWhK5f8RMWBqcA7mXJPaxdTPGrha3rrqUrri7HSKb3T"); - config.last_boost = last_boost; - config.is_seeker_activation_enabled = is_seeker_activation_enabled; - - Ok(()) -}