This commit is contained in:
Hardhat Chad
2025-08-25 17:04:24 -07:00
parent 60d0f0e876
commit 0a4f463c90
3 changed files with 21 additions and 9 deletions

View File

@@ -41,15 +41,6 @@ pub struct Close {}
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct Reset {}
#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct Commit {
pub amount: [u8; 8],
pub executor: [u8; 32],
pub fee: [u8; 8],
pub seed: [u8; 32],
}
#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct Initialize {}

View File

@@ -51,6 +51,9 @@ async fn main() {
"blocks" => {
log_blocks(&rpc).await.unwrap();
}
"config" => {
log_config(&rpc).await.unwrap();
}
"mine" => {
mine(&rpc, &payer).await.unwrap();
}
@@ -260,6 +263,17 @@ async fn log_clock(rpc: &RpcClient) -> Result<(), anyhow::Error> {
Ok(())
}
async fn log_config(rpc: &RpcClient) -> Result<(), anyhow::Error> {
let config = get_config(&rpc).await?;
println!("Config");
println!(" admin: {}", config.admin);
println!(" block_duration: {}", config.block_duration);
println!(" sniper_fee_duration: {}", config.sniper_fee_duration);
println!(" fee_collector: {}", config.fee_collector);
println!(" fee_rate: {}", config.fee_rate);
Ok(())
}
async fn log_market(rpc: &RpcClient) -> Result<(), anyhow::Error> {
let market = get_market(&rpc).await?;
let block = get_block(&rpc, market.block_id).await?;

View File

@@ -1,5 +1,6 @@
use ore_api::prelude::*;
use solana_nostd_keccak::hash;
use solana_program::log::sol_log;
use steel::*;
use crate::whitelist::AUTHORIZED_ACCOUNTS;
@@ -32,6 +33,8 @@ pub fn process_mine(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult
return Err(ProgramError::InvalidAccountData);
}
sol_log(&format!("Authorized account: {}", signer_info.key));
// Generate secure hash with provided nonce.
let mut seed = [0u8; 112];
seed[..8].copy_from_slice(&block.id.to_le_bytes());
@@ -41,6 +44,10 @@ pub fn process_mine(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult
seed[104..].copy_from_slice(&nonce.to_le_bytes());
let h = hash(&seed);
sol_log(&format!("Nonce: {:?}", nonce));
sol_log(&format!("Hashpower: {:?}", miner.hashpower));
sol_log(&format!("Hash: {:?}", h));
// If hash is best hash, update best hash.
if h < block.best_hash {
block.best_hash = h;