-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a6e506a
commit a973671
Showing
16 changed files
with
558 additions
and
675 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use std::num::{NonZeroU64, NonZeroUsize}; | ||
|
||
use clap::Parser; | ||
|
||
/// `cuprate` <-> `monerod` compatability tester. | ||
#[derive(Parser, Debug)] | ||
#[command(about, long_about = None)] | ||
pub struct Args { | ||
/// Name of the person to greet | ||
#[arg(short, long, default_value_t = String::from("http://127.0.0.1:18081"))] | ||
pub rpc_url: String, | ||
|
||
/// Amount of verifying threads to spawn. | ||
#[arg(short, long, default_value_t = std::thread::available_parallelism().unwrap())] | ||
pub threads: NonZeroUsize, | ||
|
||
/// Print an update every `update` amount of blocks. | ||
#[arg(short, long, default_value_t = NonZeroU64::new(500).unwrap())] | ||
pub update: NonZeroU64, | ||
} | ||
|
||
impl Args { | ||
pub fn get() -> Self { | ||
let this = Self::parse(); | ||
|
||
println!("{this:#?}"); | ||
|
||
this | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use std::sync::atomic::{AtomicU64, AtomicUsize}; | ||
|
||
/// Height at which RandomX activated. | ||
pub const RANDOMX_START_HEIGHT: u64 = 1978433; | ||
|
||
/// Total amount of blocks tested, used as a global counter. | ||
pub static TESTED_BLOCK_COUNT: AtomicU64 = AtomicU64::new(0); | ||
|
||
/// Total amount of transactions tested, used as a global counter. | ||
pub static TESTED_TX_COUNT: AtomicUsize = AtomicUsize::new(0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#![allow( | ||
clippy::doc_markdown, | ||
reason = "TODO: add exception to doc clippy for `RandomX`" | ||
)] | ||
#![allow(unreachable_pub, reason = "This is a binary, everything `pub` is ok")] | ||
|
||
mod cli; | ||
mod constants; | ||
mod cryptonight; | ||
mod randomx; | ||
mod rpc; | ||
mod types; | ||
mod verify; | ||
|
||
use std::{ | ||
sync::atomic::Ordering, | ||
time::{Duration, Instant}, | ||
}; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
let now = Instant::now(); | ||
|
||
// Parse CLI args. | ||
let cli::Args { | ||
rpc_url, | ||
update, | ||
threads, | ||
} = cli::Args::get(); | ||
|
||
// Set-up RPC client. | ||
let client = rpc::RpcClient::new(rpc_url).await; | ||
let top_height = client.top_height; | ||
println!("top_height: {top_height}"); | ||
println!(); | ||
|
||
// Test. | ||
let (tx, rx) = crossbeam::channel::unbounded(); | ||
verify::spawn_verify_pool(threads, update, top_height, rx); | ||
client.test(top_height, tx).await; | ||
|
||
// Wait for other threads to finish. | ||
loop { | ||
let count = constants::TESTED_BLOCK_COUNT.load(Ordering::Acquire); | ||
|
||
if top_height == count { | ||
println!("finished, took {}s", now.elapsed().as_secs()); | ||
std::process::exit(0); | ||
} | ||
|
||
std::thread::sleep(Duration::from_secs(1)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.