mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-13 15:09:57 +00:00
localnet
This commit is contained in:
3388
Cargo.lock
generated
3388
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
[workspace]
|
||||
resolver = "2"
|
||||
members = ["api", "program"]
|
||||
members = ["api", "program", "cli"]
|
||||
|
||||
[workspace.package]
|
||||
version = "3.7.0"
|
||||
|
||||
@@ -3,22 +3,8 @@ use steel::*;
|
||||
#[derive(Debug, Error, Clone, Copy, PartialEq, Eq, IntoPrimitive)]
|
||||
#[repr(u32)]
|
||||
pub enum OreError {
|
||||
#[error("The epoch has ended and needs reset")]
|
||||
NeedsReset = 0,
|
||||
#[error("The provided hash is invalid")]
|
||||
HashInvalid = 1,
|
||||
#[error("The provided hash did not satisfy the minimum required difficulty")]
|
||||
HashTooEasy = 2,
|
||||
#[error("The claim amount cannot be greater than the claimable rewards")]
|
||||
ClaimTooLarge = 3,
|
||||
#[error("The clock time is invalid")]
|
||||
ClockInvalid = 4,
|
||||
#[error("You are trying to submit too soon")]
|
||||
Spam = 5,
|
||||
#[error("The maximum supply has been reached")]
|
||||
MaxSupply = 6,
|
||||
#[error("The proof does not match the expected account")]
|
||||
AuthFailed = 7,
|
||||
#[error("Placeholder error")]
|
||||
Dummy = 0,
|
||||
}
|
||||
|
||||
error!(OreError);
|
||||
|
||||
@@ -86,12 +86,12 @@ pub fn close(signer: Pubkey, wager: Pubkey) -> Instruction {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn initialize(signer: Pubkey, mint: Pubkey, ore_mint: Pubkey) -> Instruction {
|
||||
pub fn initialize(signer: Pubkey) -> Instruction {
|
||||
let block = block_pda().0;
|
||||
let block_bets =
|
||||
spl_associated_token_account::get_associated_token_address(&signer, &native_mint::ID);
|
||||
spl_associated_token_account::get_associated_token_address(&block, &native_mint::ID);
|
||||
let block_ore =
|
||||
spl_associated_token_account::get_associated_token_address(&signer, &MINT_ADDRESS);
|
||||
spl_associated_token_account::get_associated_token_address(&block, &MINT_ADDRESS);
|
||||
Instruction {
|
||||
program_id: crate::ID,
|
||||
accounts: vec![
|
||||
@@ -99,8 +99,8 @@ pub fn initialize(signer: Pubkey, mint: Pubkey, ore_mint: Pubkey) -> Instruction
|
||||
AccountMeta::new(block, false),
|
||||
AccountMeta::new(block_bets, false),
|
||||
AccountMeta::new(block_ore, false),
|
||||
AccountMeta::new(mint, false),
|
||||
AccountMeta::new(ore_mint, false),
|
||||
AccountMeta::new_readonly(MINT_ADDRESS, false),
|
||||
AccountMeta::new_readonly(native_mint::ID, false),
|
||||
AccountMeta::new_readonly(system_program::ID, false),
|
||||
AccountMeta::new_readonly(spl_token::ID, false),
|
||||
AccountMeta::new_readonly(spl_associated_token_account::ID, false),
|
||||
|
||||
@@ -5,12 +5,12 @@ use super::OreAccount;
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
|
||||
pub struct Block {
|
||||
/// The current round.
|
||||
pub current_round: u64,
|
||||
|
||||
/// The number of bets made in the current round.
|
||||
pub bet_count: u64,
|
||||
|
||||
/// The current round.
|
||||
pub current_round: u64,
|
||||
|
||||
/// The slot at which the current round ends.
|
||||
pub ends_at: u64,
|
||||
|
||||
|
||||
26
cli/Cargo.toml
Normal file
26
cli/Cargo.toml
Normal file
@@ -0,0 +1,26 @@
|
||||
[package]
|
||||
name = "ore-cli"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
homepage.workspace = true
|
||||
documentation.workspace = true
|
||||
repository.workspace = true
|
||||
keywords.workspace = true
|
||||
publish = false
|
||||
|
||||
[features]
|
||||
no-entrypoint = []
|
||||
default = []
|
||||
|
||||
[dependencies]
|
||||
base64 = "0.22.1"
|
||||
bincode = "1.3.3"
|
||||
bytemuck = { workspace = true }
|
||||
ore-api = { path = "../api" }
|
||||
serde_json = "1.0.140"
|
||||
solana-client = { workspace = true }
|
||||
solana-sdk = { workspace = true }
|
||||
solana-program = { workspace = true }
|
||||
spl-associated-token-account.workspace = true
|
||||
tokio = { workspace = true }
|
||||
39
cli/src/main.rs
Normal file
39
cli/src/main.rs
Normal file
@@ -0,0 +1,39 @@
|
||||
use solana_client::nonblocking::rpc_client::RpcClient;
|
||||
use solana_sdk::{
|
||||
compute_budget::ComputeBudgetInstruction,
|
||||
signature::{read_keypair_file, Signer},
|
||||
transaction::Transaction,
|
||||
};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
// Read keypair from file
|
||||
let payer =
|
||||
read_keypair_file(&std::env::var("KEYPAIR").expect("Missing KEYPAIR env var")).unwrap();
|
||||
|
||||
// Build transaction
|
||||
let rpc = RpcClient::new(std::env::var("RPC").expect("Missing RPC env var"));
|
||||
let cu_budget_ix = ComputeBudgetInstruction::set_compute_unit_limit(1_400_000);
|
||||
let ix = match std::env::var("COMMAND")
|
||||
.expect("Missing COMMAND env var")
|
||||
.as_str()
|
||||
{
|
||||
"initialize" => ore_api::sdk::initialize(payer.pubkey()),
|
||||
// "payout" => ore_api::sdk::payout(payer.pubkey()),
|
||||
// "reset" => ore_api::sdk::reset(payer.pubkey()),
|
||||
_ => panic!("Invalid command"),
|
||||
};
|
||||
let blockhash = rpc.get_latest_blockhash().await.unwrap();
|
||||
let transaction = Transaction::new_signed_with_payer(
|
||||
&[cu_budget_ix, ix],
|
||||
Some(&payer.pubkey()),
|
||||
&[&payer],
|
||||
blockhash,
|
||||
);
|
||||
|
||||
// Send transaction
|
||||
match rpc.send_and_confirm_transaction(&transaction).await {
|
||||
Ok(signature) => println!("Transaction succeeded! Signature: {}", signature),
|
||||
Err(err) => println!("Transaction failed: {}", err),
|
||||
}
|
||||
}
|
||||
25
localnet copy.sh
Executable file
25
localnet copy.sh
Executable file
@@ -0,0 +1,25 @@
|
||||
solana-test-validator \
|
||||
-r \
|
||||
--bpf-program oreV2ZymfyeXgNgBdqMkumTqqAprVqgBWQfoYkrtKWQ target/deploy/ore.so \ # ORE program
|
||||
--url https://api.mainnet-beta.solana.com \ # Set copy of mainnet
|
||||
--clone-upgradeable-program BoostzzkNfCA9D1qNuN5xZxB5ErbK4zQuBeTHGDpXT1 \ # Boost program
|
||||
--clone-upgradeable-program Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB \ # Meteora pools program
|
||||
--clone-upgradeable-program 24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi \ # Meteora vault program
|
||||
--clone 2G3WKgP9Eemzgbzk5B4w2JSAizjWfEmEwa4JMfzLyXzM \ # ORE config
|
||||
--clone Dh5ZkjGD8EVujR7C8mxMyYaE2LRVarJ9W6bMofTgNJFP \ # Treasury
|
||||
--clone HqPcY2CUB4FL5EAGWN1yZkS6DHYUoMsnjoSpdGqV8wPC \ # Treasury tokens
|
||||
--clone oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp \ # ORE mint
|
||||
--clone DvYP7L1dH6vK4CbEKtQehP9cSZC5qXFP53NQi5THt5U5 \ # Boost proof
|
||||
--clone FQpx4mmybtZSwv8G5QwfyXWYjRt9nkqiw3sAsKGiUpCG \ # Boost config
|
||||
--clone GgaDTFbqdgjoZz3FP7zrtofGwnRS4E6MCzmmD5Ni1Mxj \ # ORE-SOL pool
|
||||
--clone 3s6ki6dQSM8FuqWiPsnGkgVsAEo8BTAfUR1Vvt1TPiJN \ # A vault
|
||||
--clone FERjPVNEa7Udq8CEv68h6tPL46Tq7ieE49HrE2wea3XT \ # B vault
|
||||
--clone BtJuiRG44vew5nYBVeUhuBawPTZLyYYxdzTYzerkfnto \ # A token vault
|
||||
--clone HZeLxbZ9uHtSpwZC3LBr4Nubd14iHwz7bRSghRZf5VCG \ # B token vault
|
||||
--clone 6Av9sdKvnjwoDHVnhEiz6JEq8e6SGzmhCsCncT2WJ7nN \ # A vault LP mint
|
||||
--clone FZN7QZ8ZUUAxMPfxYEYkH3cXUASzH8EqA6B4tyCL8f1j \ # B vault LP mint
|
||||
--clone 2k7V1NtM1krwh1sdt5wWqBRcvNQ5jzxj3J2rV78zdTsL \ # A vault LP
|
||||
--clone CFATQFgkKXJyU3MdCNvQqN79qorNSMJFF8jrF66a7r6i \ # B vault LP
|
||||
--clone 3WYz5TC8X4FLvwWQ2QvSfXuZHXjqvsdymKwmMFkgCgVs \ # Protocol token fee A
|
||||
--clone 6kzYo2LMo2q2bkLAD8ienoG5NC1MkNXNTfm8sdyHuX3h # Protocol token fee B
|
||||
|
||||
38
localnet.sh
Normal file → Executable file
38
localnet.sh
Normal file → Executable file
@@ -1,14 +1,24 @@
|
||||
solana-test-validator -r \
|
||||
# TODO Copy accounts and programs from mainnet
|
||||
# Config
|
||||
# Treasury
|
||||
# Treasury tokens
|
||||
# ORE mint
|
||||
# Boost proof
|
||||
# Boost program
|
||||
# Boost config
|
||||
# Meteora program
|
||||
# Meteora pool and vaults
|
||||
|
||||
|
||||
# TODO Deploy ore program
|
||||
solana-test-validator \
|
||||
-r \
|
||||
--bpf-program oreV2ZymfyeXgNgBdqMkumTqqAprVqgBWQfoYkrtKWQ target/deploy/ore.so \
|
||||
--url https://api.mainnet-beta.solana.com \
|
||||
--clone-upgradeable-program BoostzzkNfCA9D1qNuN5xZxB5ErbK4zQuBeTHGDpXT1 \
|
||||
--clone-upgradeable-program Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB \
|
||||
--clone-upgradeable-program 24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi \
|
||||
--clone 2G3WKgP9Eemzgbzk5B4w2JSAizjWfEmEwa4JMfzLyXzM \
|
||||
--clone Dh5ZkjGD8EVujR7C8mxMyYaE2LRVarJ9W6bMofTgNJFP \
|
||||
--clone HqPcY2CUB4FL5EAGWN1yZkS6DHYUoMsnjoSpdGqV8wPC \
|
||||
--clone oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp \
|
||||
--clone DvYP7L1dH6vK4CbEKtQehP9cSZC5qXFP53NQi5THt5U5 \
|
||||
--clone FQpx4mmybtZSwv8G5QwfyXWYjRt9nkqiw3sAsKGiUpCG \
|
||||
--clone GgaDTFbqdgjoZz3FP7zrtofGwnRS4E6MCzmmD5Ni1Mxj \
|
||||
--clone 3s6ki6dQSM8FuqWiPsnGkgVsAEo8BTAfUR1Vvt1TPiJN \
|
||||
--clone FERjPVNEa7Udq8CEv68h6tPL46Tq7ieE49HrE2wea3XT \
|
||||
--clone BtJuiRG44vew5nYBVeUhuBawPTZLyYYxdzTYzerkfnto \
|
||||
--clone HZeLxbZ9uHtSpwZC3LBr4Nubd14iHwz7bRSghRZf5VCG \
|
||||
--clone 6Av9sdKvnjwoDHVnhEiz6JEq8e6SGzmhCsCncT2WJ7nN \
|
||||
--clone FZN7QZ8ZUUAxMPfxYEYkH3cXUASzH8EqA6B4tyCL8f1j \
|
||||
--clone 2k7V1NtM1krwh1sdt5wWqBRcvNQ5jzxj3J2rV78zdTsL \
|
||||
--clone CFATQFgkKXJyU3MdCNvQqN79qorNSMJFF8jrF66a7r6i \
|
||||
--clone 3WYz5TC8X4FLvwWQ2QvSfXuZHXjqvsdymKwmMFkgCgVs \
|
||||
--clone 6kzYo2LMo2q2bkLAD8ienoG5NC1MkNXNTfm8sdyHuX3h
|
||||
|
||||
@@ -9,17 +9,15 @@ pub fn process_initialize(accounts: &[AccountInfo<'_>], _data: &[u8]) -> Program
|
||||
else {
|
||||
return Err(ProgramError::NotEnoughAccountKeys);
|
||||
};
|
||||
signer_info.is_signer()?.has_address(&INITIALIZER_ADDRESS)?;
|
||||
signer_info.is_signer()?; // .has_address(&INITIALIZER_ADDRESS)?;
|
||||
block_info
|
||||
.is_empty()?
|
||||
.is_writable()?
|
||||
.has_seeds(&[BLOCK], &ore_api::ID)?;
|
||||
block_bets_info.is_empty()?.is_writable()?;
|
||||
block_ore_info.is_empty()?.is_writable()?;
|
||||
ore_mint_info.has_address(&MINT_ADDRESS)?.as_mint()?;
|
||||
sol_mint_info
|
||||
.has_address(&spl_token::native_mint::ID)?
|
||||
.as_mint()?;
|
||||
ore_mint_info.has_address(&MINT_ADDRESS)?;
|
||||
sol_mint_info.has_address(&spl_token::native_mint::ID)?;
|
||||
system_program.is_program(&system_program::ID)?;
|
||||
token_program.is_program(&spl_token::ID)?;
|
||||
associated_token_program.is_program(&spl_associated_token_account::ID)?;
|
||||
@@ -53,15 +51,15 @@ pub fn process_initialize(accounts: &[AccountInfo<'_>], _data: &[u8]) -> Program
|
||||
token_program,
|
||||
associated_token_program,
|
||||
)?;
|
||||
create_associated_token_account(
|
||||
signer_info,
|
||||
block_info,
|
||||
block_ore_info,
|
||||
ore_mint_info,
|
||||
system_program,
|
||||
token_program,
|
||||
associated_token_program,
|
||||
)?;
|
||||
// create_associated_token_account(
|
||||
// signer_info,
|
||||
// block_info,
|
||||
// block_ore_info,
|
||||
// ore_mint_info,
|
||||
// system_program,
|
||||
// token_program,
|
||||
// associated_token_program,
|
||||
// )?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[toolchain]
|
||||
channel = "1.81.0"
|
||||
channel = "1.82.0"
|
||||
components = [ "rustfmt", "rust-analyzer" ]
|
||||
targets = [ "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "aarch64-apple-darwin"]
|
||||
profile = "minimal"
|
||||
|
||||
Reference in New Issue
Block a user