From 0e1460e2a43323534e9188160d21cc7d1f18340e Mon Sep 17 00:00:00 2001 From: Hardhat Chad <155858888+HardhatChad@users.noreply.github.com> Date: Fri, 1 Nov 2024 16:08:02 -0500 Subject: [PATCH] Deprecate upgrade (#101) * deprecate upgrade function * bump versions * move flag --- Cargo.lock | 4 +-- Cargo.toml | 2 +- README.md | 1 - api/src/instruction.rs | 2 ++ api/src/sdk.rs | 4 ++- program/src/lib.rs | 2 +- program/src/upgrade.rs | 65 ++---------------------------------------- 7 files changed, 11 insertions(+), 69 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e99d408..619ea7a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1287,7 +1287,7 @@ checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "ore-api" -version = "2.5.0" +version = "2.6.0" dependencies = [ "array-const-fn-init", "bytemuck", @@ -1323,7 +1323,7 @@ dependencies = [ [[package]] name = "ore-program" -version = "2.5.0" +version = "2.6.0" dependencies = [ "drillx", "mpl-token-metadata", diff --git a/Cargo.toml b/Cargo.toml index 983efd3..a0ef435 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ resolver = "2" members = ["api", "program"] [workspace.package] -version = "2.5.0" +version = "2.6.0" edition = "2021" license = "Apache-2.0" homepage = "https://ore.supply" diff --git a/README.md b/README.md index 8c09602..96274cd 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,6 @@ - [`Mine`](program/src/mine.rs) – Verifies a hash and increments a miner's claimable balance. - [`Reset`](program/src/reset.rs) – Resets the program for a new epoch. - [`Update`](program/src/update.rs) – Updates a proof account's miner authority. -- [`Upgrade`](program/src/upgrade.rs) – Migrates ORE v1 tokens to ORE v2, one-for-one. - [`Initialize`](program/src/initialize.rs) – Initializes the program and creates the global accounts. ## State diff --git a/api/src/instruction.rs b/api/src/instruction.rs index 4427d88..9b422af 100644 --- a/api/src/instruction.rs +++ b/api/src/instruction.rs @@ -12,6 +12,7 @@ pub enum OreInstruction { #[deprecated(since = "2.4.0", note = "Please stake with the boost program")] Stake = 5, Update = 6, + #[deprecated(since = "2.6.0", note = "v1 tokens are no longer eligable to upgrade")] Upgrade = 7, // Admin @@ -57,6 +58,7 @@ pub struct Stake { #[derive(Clone, Copy, Debug, Pod, Zeroable)] pub struct Update {} +#[deprecated(since = "2.6.0", note = "v1 tokens are no longer eligable to upgrade")] #[repr(C)] #[derive(Clone, Copy, Debug, Pod, Zeroable)] pub struct Upgrade { diff --git a/api/src/sdk.rs b/api/src/sdk.rs index ee8d38b..fc9a85d 100644 --- a/api/src/sdk.rs +++ b/api/src/sdk.rs @@ -125,10 +125,10 @@ pub fn reset(signer: Pubkey) -> Instruction { } /// Build a stake instruction. +#[allow(deprecated)] #[deprecated(since = "2.4.0", note = "Please stake with the boost program")] pub fn stake(signer: Pubkey, sender: Pubkey, amount: u64) -> Instruction { let proof = proof_pda(signer).0; - #[allow(deprecated)] Instruction { program_id: crate::ID, accounts: vec![ @@ -160,6 +160,8 @@ pub fn update(signer: Pubkey, miner: Pubkey) -> Instruction { } // Build an upgrade instruction. +#[allow(deprecated)] +#[deprecated(since = "2.6.0", note = "v1 tokens are no longer eligable to upgrade")] pub fn upgrade(signer: Pubkey, beneficiary: Pubkey, sender: Pubkey, amount: u64) -> Instruction { Instruction { program_id: crate::ID, diff --git a/program/src/lib.rs b/program/src/lib.rs index 798b9f2..13984d8 100644 --- a/program/src/lib.rs +++ b/program/src/lib.rs @@ -21,6 +21,7 @@ use upgrade::*; use ore_api::instruction::*; use steel::*; +#[allow(deprecated)] pub fn process_instruction( program_id: &Pubkey, accounts: &[AccountInfo], @@ -34,7 +35,6 @@ pub fn process_instruction( OreInstruction::Mine => process_mine(accounts, data)?, OreInstruction::Open => process_open(accounts, data)?, OreInstruction::Reset => process_reset(accounts, data)?, - #[allow(deprecated)] OreInstruction::Stake => process_stake(accounts, data)?, OreInstruction::Update => process_update(accounts, data)?, OreInstruction::Upgrade => process_upgrade(accounts, data)?, diff --git a/program/src/upgrade.rs b/program/src/upgrade.rs index f7d692d..8e0786d 100644 --- a/program/src/upgrade.rs +++ b/program/src/upgrade.rs @@ -1,67 +1,6 @@ -use ore_api::prelude::*; use steel::*; /// Upgrade allows a user to migrate a v1 token to a v2 token at a 1:1 exchange rate. -pub fn process_upgrade(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult { - // Parse args - let args = Upgrade::try_from_bytes(data)?; - let amount = u64::from_le_bytes(args.amount); - - // Load accounts - let [signer_info, beneficiary_info, mint_info, mint_v1_info, sender_info, treasury_info, token_program] = - accounts - else { - return Err(ProgramError::NotEnoughAccountKeys); - }; - signer_info.is_signer()?; - beneficiary_info - .is_writable()? - .as_token_account()? - .assert(|t| t.owner == *signer_info.key)? - .assert(|t| t.mint == MINT_ADDRESS)?; - let mint = mint_info - .is_writable()? - .has_address(&MINT_ADDRESS)? - .as_mint()?; - mint_v1_info - .is_writable()? - .has_address(&MINT_V1_ADDRESS)? - .as_mint()?; - sender_info - .is_writable()? - .as_token_account()? - .assert(|t| t.owner == *signer_info.key)? - .assert(|t| t.mint == MINT_V1_ADDRESS)?; - treasury_info.is_treasury()?; - token_program.is_program(&spl_token::ID)?; - - // Burn v1 tokens - burn( - sender_info, - mint_v1_info, - signer_info, - token_program, - amount, - )?; - - // Account for decimals change. - // v1 token has 9 decimals. v2 token has 11. - let amount_to_mint = amount.saturating_mul(100); - - // Cap at max supply. - if mint.supply.saturating_add(amount_to_mint).gt(&MAX_SUPPLY) { - return Err(OreError::MaxSupply.into()); - } - - // Mint to the beneficiary account - mint_to_signed( - mint_info, - beneficiary_info, - treasury_info, - token_program, - amount_to_mint, - &[TREASURY], - )?; - - Ok(()) +pub fn process_upgrade(_accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResult { + panic!("This instruction has been deprecated. v1 tokens are no longer eligable to upgrade."); }