mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-14 15:10:13 +00:00
remove all admin functions
This commit is contained in:
@@ -138,7 +138,6 @@ pub fn process_initialize<'a, 'info>(
|
||||
config.admin = *signer.key;
|
||||
config.base_reward_rate = INITIAL_BASE_REWARD_RATE;
|
||||
config.last_reset_at = 0;
|
||||
config.paused = 1;
|
||||
|
||||
// Initialize treasury
|
||||
create_pda(
|
||||
|
||||
@@ -66,14 +66,9 @@ pub fn process_mine<'a, 'info>(
|
||||
return Err(OreError::TransactionInvalid.into());
|
||||
}
|
||||
|
||||
// Validate mining is not paused
|
||||
// Validate epoch is active
|
||||
let config_data = config_info.data.borrow();
|
||||
let config = Config::try_from_bytes(&config_data)?;
|
||||
if config.paused.ne(&0) {
|
||||
return Err(OreError::IsPaused.into());
|
||||
}
|
||||
|
||||
// Validate epoch is active
|
||||
let clock = Clock::get().or(Err(ProgramError::InvalidAccountData))?;
|
||||
if config
|
||||
.last_reset_at
|
||||
|
||||
@@ -2,20 +2,16 @@ mod claim;
|
||||
mod deregister;
|
||||
mod initialize;
|
||||
mod mine;
|
||||
mod pause;
|
||||
mod register;
|
||||
mod reset;
|
||||
mod stake;
|
||||
mod update_admin;
|
||||
mod upgrade;
|
||||
|
||||
pub use claim::*;
|
||||
pub use deregister::*;
|
||||
pub use initialize::*;
|
||||
pub use mine::*;
|
||||
pub use pause::*;
|
||||
pub use register::*;
|
||||
pub use reset::*;
|
||||
pub use stake::*;
|
||||
pub use update_admin::*;
|
||||
pub use upgrade::*;
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
use solana_program::{
|
||||
account_info::AccountInfo, entrypoint::ProgramResult, program_error::ProgramError,
|
||||
pubkey::Pubkey,
|
||||
};
|
||||
|
||||
use crate::{instruction::PauseArgs, loaders::*, state::Config, utils::AccountDeserialize};
|
||||
|
||||
/// Pause updates the program's pause flag. Its responsibilities include:
|
||||
/// 1. Update the pause flag.
|
||||
///
|
||||
/// Safety requirements:
|
||||
/// - Can only succeed if the signer is the program admin.
|
||||
/// - Can only succeed if the provided config is valid.
|
||||
///
|
||||
/// Discussion:
|
||||
/// - This should only be used to address critical contract risks and force migration to a new
|
||||
/// verison (hardfork).
|
||||
pub fn process_pause<'a, 'info>(
|
||||
_program_id: &Pubkey,
|
||||
accounts: &'a [AccountInfo<'info>],
|
||||
data: &[u8],
|
||||
) -> ProgramResult {
|
||||
// Parse args
|
||||
let args = PauseArgs::try_from_bytes(data)?;
|
||||
|
||||
// Load accounts
|
||||
let [signer, config_info] = accounts else {
|
||||
return Err(ProgramError::NotEnoughAccountKeys);
|
||||
};
|
||||
load_signer(signer)?;
|
||||
load_config(config_info, true)?;
|
||||
|
||||
// Validate signer is admin
|
||||
let mut config_data = config_info.data.borrow_mut();
|
||||
let config = Config::try_from_bytes_mut(&mut config_data)?;
|
||||
if config.admin.ne(&signer.key) {
|
||||
return Err(ProgramError::MissingRequiredSignature);
|
||||
}
|
||||
|
||||
// Update paused
|
||||
config.paused = args.paused as u64;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -70,14 +70,9 @@ pub fn process_reset<'a, 'info>(
|
||||
bus_7_info,
|
||||
];
|
||||
|
||||
// Validate mining is not paused
|
||||
// Validate enough time has passed since last reset
|
||||
let mut config_data = config_info.data.borrow_mut();
|
||||
let config = Config::try_from_bytes_mut(&mut config_data)?;
|
||||
if config.paused.ne(&0) {
|
||||
return Err(OreError::IsPaused.into());
|
||||
}
|
||||
|
||||
// Validate enough time has passed since last reset
|
||||
let clock = Clock::get().or(Err(ProgramError::InvalidAccountData))?;
|
||||
if config
|
||||
.last_reset_at
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
use solana_program::{
|
||||
account_info::AccountInfo, entrypoint::ProgramResult, program_error::ProgramError,
|
||||
pubkey::Pubkey,
|
||||
};
|
||||
|
||||
use crate::{instruction::UpdateAdminArgs, loaders::*, state::Config, utils::AccountDeserialize};
|
||||
|
||||
/// UpdateAdmin updates the program's admin account. Its responsibilities include:
|
||||
/// 1. Update the treasury admin address.
|
||||
///
|
||||
/// Safety requirements:
|
||||
/// - Can only succeed if the signer is the program admin.
|
||||
/// - Can only succeed if the provided treasury is valid.
|
||||
///
|
||||
/// Discussion:
|
||||
/// - The admin authority has one lever of power: the ability to adjust the global
|
||||
/// mining difficulty. If the difficulty is too easy, miners will find hashes very quickly
|
||||
/// and the bottleneck for mining will shift from local compute to Solana bandwidth. In essence,
|
||||
/// if the Ore token has value and difficulty is low, mining becomes an incentivized stress
|
||||
/// test for the Solana network.
|
||||
/// - At the same time, if difficulty is too hard, miners will have to wait a very long period
|
||||
/// of time between finding valid hashes. This will bias rewards to well-resourced miners
|
||||
/// with large compute operations. Keeping a low difficulty ensures casual miners can
|
||||
/// consistently earn rewards and undercuts some of the advantage of larger players.
|
||||
/// - Ultimately admin authority should be delegated to a governance mechanism – either
|
||||
/// democratic or futarchic – to ensure difficulty is kept at a value that represents the
|
||||
/// values and interests of the ecosystem.
|
||||
pub fn process_update_admin<'a, 'info>(
|
||||
_program_id: &Pubkey,
|
||||
accounts: &'a [AccountInfo<'info>],
|
||||
data: &[u8],
|
||||
) -> ProgramResult {
|
||||
// Parse args
|
||||
let args = UpdateAdminArgs::try_from_bytes(data)?;
|
||||
|
||||
// Load accounts
|
||||
let [signer, config_info] = accounts else {
|
||||
return Err(ProgramError::NotEnoughAccountKeys);
|
||||
};
|
||||
load_signer(signer)?;
|
||||
load_config(config_info, true)?;
|
||||
|
||||
// Validate signer is admin
|
||||
let mut config_data = config_info.data.borrow_mut();
|
||||
let config = Config::try_from_bytes_mut(&mut config_data)?;
|
||||
if config.admin.ne(&signer.key) {
|
||||
return Err(ProgramError::MissingRequiredSignature);
|
||||
}
|
||||
|
||||
// Update admin
|
||||
config.admin = args.new_admin;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user