mirror of
https://github.com/hinto-janai/cuprate.git
synced 2024-12-23 03:59:37 +00:00
Compare commits
2 commits
7cd3254477
...
065dd03ea7
Author | SHA1 | Date | |
---|---|---|---|
|
065dd03ea7 | ||
|
8acb166639 |
8 changed files with 73 additions and 27 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -3319,7 +3319,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tests-monero-serai"
|
name = "tests-monero-serai"
|
||||||
version = "0.1.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures",
|
"futures",
|
||||||
"hex",
|
"hex",
|
||||||
|
@ -3333,7 +3333,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tests-pow"
|
name = "tests-pow"
|
||||||
version = "0.1.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cuprate-consensus-rules",
|
"cuprate-consensus-rules",
|
||||||
"cuprate-cryptonight",
|
"cuprate-cryptonight",
|
||||||
|
|
|
@ -163,6 +163,7 @@ pretty_assertions = { version = "1" }
|
||||||
proptest = { version = "1" }
|
proptest = { version = "1" }
|
||||||
proptest-derive = { version = "0.5" }
|
proptest-derive = { version = "0.5" }
|
||||||
tokio-test = { version = "0.4" }
|
tokio-test = { version = "0.4" }
|
||||||
|
reqwest = { version = "0.12" }
|
||||||
|
|
||||||
## TODO:
|
## TODO:
|
||||||
## Potential dependencies.
|
## Potential dependencies.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "tests-monero-serai"
|
name = "tests-monero-serai"
|
||||||
version = "0.1.0"
|
version = "0.0.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -9,7 +9,7 @@ hex = { workspace = true, features = ["serde", "std"] }
|
||||||
serde = { workspace = true, features = ["derive"] }
|
serde = { workspace = true, features = ["derive"] }
|
||||||
serde_json = { workspace = true, features = ["std"] }
|
serde_json = { workspace = true, features = ["std"] }
|
||||||
tokio = { workspace = true, features = ["full"] }
|
tokio = { workspace = true, features = ["full"] }
|
||||||
reqwest = { version = "0.12", features = ["json"] }
|
reqwest = { workspace = true, features = ["json"] }
|
||||||
rayon = { workspace = true }
|
rayon = { workspace = true }
|
||||||
futures = { workspace = true, features = ["std"] }
|
futures = { workspace = true, features = ["std"] }
|
||||||
|
|
||||||
|
|
|
@ -13,14 +13,29 @@ async fn main() {
|
||||||
let now = Instant::now();
|
let now = Instant::now();
|
||||||
|
|
||||||
let rpc_url = if let Ok(url) = std::env::var("RPC_URL") {
|
let rpc_url = if let Ok(url) = std::env::var("RPC_URL") {
|
||||||
|
println!("RPC_URL (found): {url}");
|
||||||
url
|
url
|
||||||
} else {
|
} else {
|
||||||
"http://127.0.0.1:18081".to_string()
|
let rpc_url = "http://127.0.0.1:18081".to_string();
|
||||||
|
println!("RPC_URL (off, using default): {rpc_url}");
|
||||||
|
rpc_url
|
||||||
};
|
};
|
||||||
println!("rpc_url: {rpc_url}");
|
if std::env::var("VERBOSE").is_ok() {
|
||||||
|
println!("VERBOSE: true");
|
||||||
|
} else {
|
||||||
|
println!("VERBOSE: false");
|
||||||
|
}
|
||||||
|
|
||||||
let client = rpc::RpcClient::new(rpc_url).await;
|
let mut client = rpc::RpcClient::new(rpc_url).await;
|
||||||
let top_height = client.top_height;
|
|
||||||
|
let top_height = if let Ok(Ok(h)) = std::env::var("TOP_HEIGHT").map(|s| s.parse()) {
|
||||||
|
client.top_height = h;
|
||||||
|
println!("TOP_HEIGHT (found): {h}");
|
||||||
|
h
|
||||||
|
} else {
|
||||||
|
println!("TOP_HEIGHT (off, using latest): {}", client.top_height);
|
||||||
|
client.top_height
|
||||||
|
};
|
||||||
|
|
||||||
let ranges = (0..top_height)
|
let ranges = (0..top_height)
|
||||||
.collect::<Vec<usize>>()
|
.collect::<Vec<usize>>()
|
||||||
|
@ -28,11 +43,17 @@ async fn main() {
|
||||||
.map(<[usize]>::to_vec)
|
.map(<[usize]>::to_vec)
|
||||||
.collect::<Vec<Vec<usize>>>();
|
.collect::<Vec<Vec<usize>>>();
|
||||||
|
|
||||||
println!("ranges: ");
|
println!("ranges: [");
|
||||||
for range in &ranges {
|
for range in &ranges {
|
||||||
println!("[{}..{}]", range.first().unwrap(), range.last().unwrap());
|
println!(
|
||||||
|
" ({}..{}),",
|
||||||
|
range.first().unwrap(),
|
||||||
|
range.last().unwrap()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
println!("]\n");
|
||||||
|
|
||||||
let iter = ranges.into_iter().map(move |range| {
|
let iter = ranges.into_iter().map(move |range| {
|
||||||
let c = client.clone();
|
let c = client.clone();
|
||||||
async move {
|
async move {
|
||||||
|
|
|
@ -81,7 +81,6 @@ impl RpcClient {
|
||||||
.block_header
|
.block_header
|
||||||
.height;
|
.height;
|
||||||
|
|
||||||
println!("top_height: {top_height}");
|
|
||||||
assert!(top_height > 3301441, "node is behind");
|
assert!(top_height > 3301441, "node is behind");
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
|
@ -256,12 +255,17 @@ impl RpcClient {
|
||||||
assert_eq!(reward, block_reward, "{info}");
|
assert_eq!(reward, block_reward, "{info}");
|
||||||
assert_eq!(timestamp, block.header.timestamp, "{info}");
|
assert_eq!(timestamp, block.header.timestamp, "{info}");
|
||||||
|
|
||||||
let block_count = TESTED_BLOCK_COUNT.fetch_add(1, Ordering::Release) + 1;
|
let progress = TESTED_BLOCK_COUNT.fetch_add(1, Ordering::Release) + 1;
|
||||||
let tx_count = TESTED_TX_COUNT.fetch_add(num_txes, Ordering::Release) + 1;
|
let tx_count = TESTED_TX_COUNT.fetch_add(num_txes, Ordering::Release) + 1;
|
||||||
let percent = (block_count as f64 / top_height as f64) * 100.0;
|
|
||||||
|
if std::env::var("VERBOSE").is_err() && progress % 1000 != 0 {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let percent = (progress as f64 / top_height as f64) * 100.0;
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
"block_count | {block_count}/{top_height} ({percent:.2}%)
|
"progress | {progress}/{top_height} ({percent:.2}%)
|
||||||
tx_count | {tx_count}
|
tx_count | {tx_count}
|
||||||
hash | {}
|
hash | {}
|
||||||
miner_tx_hash | {}
|
miner_tx_hash | {}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "tests-pow"
|
name = "tests-pow"
|
||||||
version = "0.1.0"
|
version = "0.0.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -14,7 +14,7 @@ hex = { workspace = true, features = ["serde", "std"] }
|
||||||
serde = { workspace = true, features = ["derive"] }
|
serde = { workspace = true, features = ["derive"] }
|
||||||
serde_json = { workspace = true, features = ["std"] }
|
serde_json = { workspace = true, features = ["std"] }
|
||||||
tokio = { workspace = true, features = ["full"] }
|
tokio = { workspace = true, features = ["full"] }
|
||||||
reqwest = { version = "0.12", features = ["json"] }
|
reqwest = { workspace = true, features = ["json"] }
|
||||||
rayon = { workspace = true }
|
rayon = { workspace = true }
|
||||||
randomx-rs = { workspace = true }
|
randomx-rs = { workspace = true }
|
||||||
|
|
||||||
|
|
|
@ -12,14 +12,31 @@ async fn main() {
|
||||||
let now = Instant::now();
|
let now = Instant::now();
|
||||||
|
|
||||||
let rpc_url = if let Ok(url) = std::env::var("RPC_URL") {
|
let rpc_url = if let Ok(url) = std::env::var("RPC_URL") {
|
||||||
|
println!("RPC_URL (found): {url}");
|
||||||
url
|
url
|
||||||
} else {
|
} else {
|
||||||
"http://127.0.0.1:18081".to_string()
|
let rpc_url = "http://127.0.0.1:18081".to_string();
|
||||||
|
println!("RPC_URL (off, using default): {rpc_url}");
|
||||||
|
rpc_url
|
||||||
};
|
};
|
||||||
println!("rpc_url: {rpc_url}");
|
if std::env::var("VERBOSE").is_ok() {
|
||||||
|
println!("VERBOSE: true");
|
||||||
|
} else {
|
||||||
|
println!("VERBOSE: false");
|
||||||
|
}
|
||||||
|
|
||||||
let client = rpc::RpcClient::new(rpc_url).await;
|
let mut client = rpc::RpcClient::new(rpc_url).await;
|
||||||
let top_height = client.top_height;
|
|
||||||
|
let top_height = if let Ok(Ok(h)) = std::env::var("TOP_HEIGHT").map(|s| s.parse()) {
|
||||||
|
client.top_height = h;
|
||||||
|
println!("TOP_HEIGHT (found): {h}");
|
||||||
|
h
|
||||||
|
} else {
|
||||||
|
println!("TOP_HEIGHT (off, using latest): {}", client.top_height);
|
||||||
|
client.top_height
|
||||||
|
};
|
||||||
|
|
||||||
|
println!();
|
||||||
|
|
||||||
tokio::join!(
|
tokio::join!(
|
||||||
client.cryptonight_v0(),
|
client.cryptonight_v0(),
|
||||||
|
|
|
@ -66,7 +66,7 @@ impl RpcClient {
|
||||||
});
|
});
|
||||||
|
|
||||||
let top_height = client
|
let top_height = client
|
||||||
.get(&rpc_url)
|
.get(format!("{rpc_url}/json_rpc"))
|
||||||
.json(&request)
|
.json(&request)
|
||||||
.send()
|
.send()
|
||||||
.await
|
.await
|
||||||
|
@ -85,7 +85,6 @@ impl RpcClient {
|
||||||
.try_into()
|
.try_into()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
println!("top_height: {top_height}");
|
|
||||||
assert!(top_height > 3301441, "node is behind");
|
assert!(top_height > 3301441, "node is behind");
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
|
@ -103,7 +102,9 @@ impl RpcClient {
|
||||||
"params": {"height": height, "fill_pow_hash": true}
|
"params": {"height": height, "fill_pow_hash": true}
|
||||||
});
|
});
|
||||||
|
|
||||||
tokio::task::spawn(self.client.get(&self.rpc_url).json(&request).send())
|
let rpc_url = format!("{}/json_rpc", self.rpc_url);
|
||||||
|
|
||||||
|
tokio::task::spawn(self.client.get(rpc_url).json(&request).send())
|
||||||
.await
|
.await
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -169,16 +170,18 @@ impl RpcClient {
|
||||||
|
|
||||||
let count = TESTED_BLOCK_COUNT.fetch_add(1, Ordering::Release) + 1;
|
let count = TESTED_BLOCK_COUNT.fetch_add(1, Ordering::Release) + 1;
|
||||||
|
|
||||||
let hex_header = hex::encode(header.pow_hash);
|
if std::env::var("VERBOSE").is_err() && count % 500 != 0 {
|
||||||
let hex_hash = hex::encode(pow_hash);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let hash = hex::encode(pow_hash);
|
||||||
let percent = (count as f64 / top_height as f64) * 100.0;
|
let percent = (count as f64 / top_height as f64) * 100.0;
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
"progress | {count}/{top_height} ({percent:.2}%)
|
"progress | {count}/{top_height} ({percent:.2}%)
|
||||||
height | {height}
|
height | {height}
|
||||||
algo | {name}
|
algo | {name}
|
||||||
header | {hex_header}
|
hash | {hash}\n"
|
||||||
hash | {hex_hash}\n"
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue