From f580f7fd58f1e851744a7a3a3dfa171b6c951ab0 Mon Sep 17 00:00:00 2001 From: Hardhat Chad Date: Thu, 27 Jun 2024 12:36:14 +0000 Subject: [PATCH] cleanup ix names --- README.md | 9 ++--- src/instruction.rs | 42 +++++++++++------------ src/lib.rs | 6 ++-- src/processor/{deregister.rs => close.rs} | 4 +-- src/processor/mod.rs | 8 ++--- src/processor/{register.rs => open.rs} | 6 ++-- 6 files changed, 38 insertions(+), 37 deletions(-) rename src/processor/{deregister.rs => close.rs} (90%) rename src/processor/{register.rs => open.rs} (95%) diff --git a/README.md b/README.md index 0d95802..b0c8d93 100644 --- a/README.md +++ b/README.md @@ -19,13 +19,14 @@ cargo install ore-cli ## Instructions -- [`Initialize`](src/processor/initialize.rs) – Initializes the Ore program, creating the bus, mint, and treasury accounts. - [`Reset`](src/processor/reset.rs) – Resets the program for a new epoch. -- [`Register`](src/processor/register.rs) – Creates a new proof account for a prospective miner. +- [`Open`](src/processor/open.rs) – Creates a new proof account for a prospective miner. +- [`Close`](src/processor/close.rs) – Closes a new proof account returns the rent to the owner. - [`Mine`](src/processor/mine.rs) – Verifies a hash provided by a miner and issues claimable rewards. +- [`Stake`](src/processor/stake.rs) – Stakes ORE with a miner to increase their multiplier. - [`Claim`](src/processor/claim.rs) – Distributes claimable rewards as tokens from the treasury to a miner. -- [`UpdateAdmin`](src/processor/update_admin.rs) – Updates the admin authority. -- [`UpdateDifficulty`](src/processor/update_difficulty.rs) - Updates the hashing difficulty. +- [`Upgrade`](src/processor/upgrade.rs) – Migrates v1 ORE tokens to v2 ORE. +- [`Initialize`](src/processor/initialize.rs) – Initializes the Ore program, creating the bus, mint, and treasury accounts. ## State diff --git a/src/instruction.rs b/src/instruction.rs index 17212e6..631fed0 100644 --- a/src/instruction.rs +++ b/src/instruction.rs @@ -38,7 +38,13 @@ pub enum OreInstruction { #[account(1, name = "signer", desc = "Signer", signer)] #[account(2, name = "proof", desc = "Ore proof account", writable)] #[account(3, name = "system_program", desc = "Solana system program")] - Register = 1, + Open = 1, + + #[account(0, name = "ore_program", desc = "Ore program")] + #[account(1, name = "signer", desc = "Signer", signer)] + #[account(2, name = "proof", desc = "Ore proof account", writable)] + #[account(3, name = "system_program", desc = "Solana system program")] + Close = 2, #[account(0, name = "ore_program", desc = "Ore program")] #[account(1, name = "signer", desc = "Signer", signer)] @@ -47,7 +53,7 @@ pub enum OreInstruction { #[account(4, name = "noise", desc = "Ore noise account")] #[account(5, name = "proof", desc = "Ore proof account", writable)] #[account(6, name = "slot_hashes", desc = "Solana slot hashes sysvar")] - Mine = 2, + Mine = 3, #[account(0, name = "ore_program", desc = "Ore program")] #[account(1, name = "signer", desc = "Signer", signer)] @@ -56,7 +62,7 @@ pub enum OreInstruction { #[account(4, name = "treasury", desc = "Ore treasury account", writable)] #[account(5, name = "treasury_tokens", desc = "Ore treasury token account", writable)] #[account(6, name = "token_program", desc = "SPL token program")] - Claim = 3, + Claim = 4, #[account(0, name = "ore_program", desc = "Ore program")] #[account(1, name = "signer", desc = "Signer", signer)] @@ -64,7 +70,7 @@ pub enum OreInstruction { #[account(3, name = "sender", desc = "Signer token account", writable)] #[account(4, name = "treasury_tokens", desc = "Ore treasury token account", writable)] #[account(5, name = "token_program", desc = "SPL token program")] - Stake = 4, + Stake = 5, #[account(0, name = "ore_program", desc = "Ore program")] #[account(1, name = "signer", desc = "Signer", signer)] @@ -74,13 +80,7 @@ pub enum OreInstruction { #[account(5, name = "mint", desc = "Ore token mint account", writable)] #[account(6, name = "mint_v1", desc = "Ore v1 token mint account", writable)] #[account(7, name = "token_program", desc = "SPL token program")] - Upgrade = 5, - - #[account(0, name = "ore_program", desc = "Ore program")] - #[account(1, name = "signer", desc = "Signer", signer)] - #[account(2, name = "proof", desc = "Ore proof account", writable)] - #[account(3, name = "system_program", desc = "Solana system program")] - Deregister = 6, + Upgrade = 6, #[account(0, name = "ore_program", desc = "Ore program")] #[account(1, name = "signer", desc = "Admin signer", signer)] @@ -130,7 +130,7 @@ pub struct InitializeArgs { #[repr(C)] #[derive(Clone, Copy, Debug, Pod, Zeroable)] -pub struct RegisterArgs { +pub struct OpenArgs { pub bump: u8, } @@ -172,14 +172,14 @@ pub struct PauseArgs { } impl_to_bytes!(InitializeArgs); -impl_to_bytes!(RegisterArgs); +impl_to_bytes!(OpenArgs); impl_to_bytes!(MineArgs); impl_to_bytes!(ClaimArgs); impl_to_bytes!(StakeArgs); impl_to_bytes!(UpgradeArgs); impl_instruction_from_bytes!(InitializeArgs); -impl_instruction_from_bytes!(RegisterArgs); +impl_instruction_from_bytes!(OpenArgs); impl_instruction_from_bytes!(MineArgs); impl_instruction_from_bytes!(ClaimArgs); impl_instruction_from_bytes!(StakeArgs); @@ -213,8 +213,8 @@ pub fn reset(signer: Pubkey) -> Instruction { } } -/// Builds a register instruction. -pub fn register(signer: Pubkey) -> Instruction { +/// Builds an open instruction. +pub fn open(signer: Pubkey) -> Instruction { let proof_pda = Pubkey::find_program_address(&[PROOF, signer.as_ref()], &crate::id()); Instruction { program_id: crate::id(), @@ -225,15 +225,15 @@ pub fn register(signer: Pubkey) -> Instruction { AccountMeta::new_readonly(sysvar::slot_hashes::id(), false), ], data: [ - OreInstruction::Register.to_vec(), - RegisterArgs { bump: proof_pda.1 }.to_bytes().to_vec(), + OreInstruction::Open.to_vec(), + OpenArgs { bump: proof_pda.1 }.to_bytes().to_vec(), ] .concat(), } } -/// Builds a deregister instruction. -pub fn deregister(signer: Pubkey) -> Instruction { +/// Builds a close instruction. +pub fn close(signer: Pubkey) -> Instruction { let proof_pda = Pubkey::find_program_address(&[PROOF, signer.as_ref()], &crate::id()); Instruction { program_id: crate::id(), @@ -242,7 +242,7 @@ pub fn deregister(signer: Pubkey) -> Instruction { AccountMeta::new(proof_pda.0, false), AccountMeta::new_readonly(solana_program::system_program::id(), false), ], - data: OreInstruction::Deregister.to_vec(), + data: OreInstruction::Close.to_vec(), } } diff --git a/src/lib.rs b/src/lib.rs index e4d1e9e..a5d064d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -33,12 +33,12 @@ pub fn process_instruction( .ok_or(ProgramError::InvalidInstructionData)?; match OreInstruction::try_from(*tag).or(Err(ProgramError::InvalidInstructionData))? { - OreInstruction::Register => process_register(program_id, accounts, data)?, - OreInstruction::Deregister => process_deregister(program_id, accounts, data)?, - OreInstruction::Reset => process_reset(program_id, accounts, data)?, + OreInstruction::Open => process_open(program_id, accounts, data)?, + OreInstruction::Close => process_close(program_id, accounts, data)?, OreInstruction::Mine => process_mine(program_id, accounts, data)?, OreInstruction::Claim => process_claim(program_id, accounts, data)?, OreInstruction::Stake => process_stake(program_id, accounts, data)?, + OreInstruction::Reset => process_reset(program_id, accounts, data)?, OreInstruction::Upgrade => process_upgrade(program_id, accounts, data)?, OreInstruction::Initialize => process_initialize(program_id, accounts, data)?, } diff --git a/src/processor/deregister.rs b/src/processor/close.rs similarity index 90% rename from src/processor/deregister.rs rename to src/processor/close.rs index 00ba60e..0356341 100644 --- a/src/processor/deregister.rs +++ b/src/processor/close.rs @@ -5,7 +5,7 @@ use solana_program::{ use crate::{loaders::*, state::Proof, utils::AccountDeserialize}; -/// Deregister closes a proof account and returns the rent to the owner. Its responsibilities include: +/// Close closes a proof account and returns the rent to the owner. Its responsibilities include: /// 1. Realloc proof account size to 0. /// 2. Transfer lamports to the owner. /// @@ -13,7 +13,7 @@ use crate::{loaders::*, state::Proof, utils::AccountDeserialize}; /// - Deregister is a permissionless instruction and can be invoked by any singer. /// - Can only succeed if the provided proof acount PDA is valid (associated with the signer). /// - The provided system program must be valid. -pub fn process_deregister<'a, 'info>( +pub fn process_close<'a, 'info>( _program_id: &Pubkey, accounts: &'a [AccountInfo<'info>], _data: &[u8], diff --git a/src/processor/mod.rs b/src/processor/mod.rs index 3ea9e10..91b8fb4 100644 --- a/src/processor/mod.rs +++ b/src/processor/mod.rs @@ -1,17 +1,17 @@ mod claim; -mod deregister; +mod close; mod initialize; mod mine; -mod register; +mod open; mod reset; mod stake; mod upgrade; pub use claim::*; -pub use deregister::*; +pub use close::*; pub use initialize::*; pub use mine::*; -pub use register::*; +pub use open::*; pub use reset::*; pub use stake::*; pub use upgrade::*; diff --git a/src/processor/register.rs b/src/processor/open.rs similarity index 95% rename from src/processor/register.rs rename to src/processor/open.rs index 74fa0d7..8db78c7 100644 --- a/src/processor/register.rs +++ b/src/processor/open.rs @@ -13,7 +13,7 @@ use solana_program::{ }; use crate::{ - instruction::RegisterArgs, + instruction::OpenArgs, loaders::*, state::Proof, utils::AccountDeserialize, @@ -30,13 +30,13 @@ use crate::{ /// - Can only succeed if the provided proof acount PDA is valid (associated with the signer). /// - Can only succeed if the user does not already have a proof account. /// - The provided system program must be valid. -pub fn process_register<'a, 'info>( +pub fn process_open<'a, 'info>( _program_id: &Pubkey, accounts: &'a [AccountInfo<'info>], data: &[u8], ) -> ProgramResult { // Parse args - let args = RegisterArgs::try_from_bytes(data)?; + let args = OpenArgs::try_from_bytes(data)?; // Load accounts let [signer, proof_info, system_program, slot_hashes_info] = accounts else {