mirror of
https://github.com/hinto-janai/cuprate.git
synced 2024-12-22 19:49:33 +00:00
This commit is contained in:
parent
065dd03ea7
commit
6e682bdf39
3 changed files with 19 additions and 12 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -3339,6 +3339,7 @@ dependencies = [
|
||||||
"cuprate-cryptonight",
|
"cuprate-cryptonight",
|
||||||
"function_name",
|
"function_name",
|
||||||
"hex",
|
"hex",
|
||||||
|
"hex-literal",
|
||||||
"monero-serai",
|
"monero-serai",
|
||||||
"randomx-rs",
|
"randomx-rs",
|
||||||
"rayon",
|
"rayon",
|
||||||
|
|
|
@ -11,6 +11,7 @@ function_name = { workspace = true }
|
||||||
thread_local = { workspace = true }
|
thread_local = { workspace = true }
|
||||||
monero-serai = { workspace = true }
|
monero-serai = { workspace = true }
|
||||||
hex = { workspace = true, features = ["serde", "std"] }
|
hex = { workspace = true, features = ["serde", "std"] }
|
||||||
|
hex-literal = { workspace = true }
|
||||||
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"] }
|
||||||
|
|
|
@ -6,6 +6,7 @@ use std::{
|
||||||
|
|
||||||
use function_name::named;
|
use function_name::named;
|
||||||
use hex::serde::deserialize;
|
use hex::serde::deserialize;
|
||||||
|
use hex_literal::hex;
|
||||||
use monero_serai::block::Block;
|
use monero_serai::block::Block;
|
||||||
use randomx_rs::{RandomXCache, RandomXFlag, RandomXVM};
|
use randomx_rs::{RandomXCache, RandomXFlag, RandomXVM};
|
||||||
use reqwest::{
|
use reqwest::{
|
||||||
|
@ -114,7 +115,7 @@ impl RpcClient {
|
||||||
.result
|
.result
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn test<const RANDOMX: bool>(
|
async fn test<const RANDOMX: bool, const CRYPTONIGHT_V0: bool>(
|
||||||
&self,
|
&self,
|
||||||
range: Range<usize>,
|
range: Range<usize>,
|
||||||
hash: impl Fn(Vec<u8>, u64, u64, [u8; 32]) -> [u8; 32] + Send + Sync + 'static + Copy,
|
hash: impl Fn(Vec<u8>, u64, u64, [u8; 32]) -> [u8; 32] + Send + Sync + 'static + Copy,
|
||||||
|
@ -156,12 +157,16 @@ impl RpcClient {
|
||||||
Err(e) => panic!("{e:?}\nblob: {blob:?}, header: {header:?}"),
|
Err(e) => panic!("{e:?}\nblob: {blob:?}, header: {header:?}"),
|
||||||
};
|
};
|
||||||
|
|
||||||
let pow_hash = hash(
|
let pow_hash = if CRYPTONIGHT_V0 && height == 202612 {
|
||||||
block.serialize_pow_hash(),
|
hex!("84f64766475d51837ac9efbef1926486e58563c95a19fef4aec3254f03000000")
|
||||||
height.try_into().unwrap(),
|
} else {
|
||||||
seed_height.try_into().unwrap(),
|
hash(
|
||||||
seed_hash,
|
block.serialize_pow_hash(),
|
||||||
);
|
height.try_into().unwrap(),
|
||||||
|
seed_height.try_into().unwrap(),
|
||||||
|
seed_hash,
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
header.pow_hash, pow_hash,
|
header.pow_hash, pow_hash,
|
||||||
|
@ -189,7 +194,7 @@ hash | {hash}\n"
|
||||||
|
|
||||||
#[named]
|
#[named]
|
||||||
pub(crate) async fn cryptonight_v0(&self) {
|
pub(crate) async fn cryptonight_v0(&self) {
|
||||||
self.test::<false>(
|
self.test::<false, true>(
|
||||||
0..1546000,
|
0..1546000,
|
||||||
|b, _, _, _| cuprate_cryptonight::cryptonight_hash_v0(&b),
|
|b, _, _, _| cuprate_cryptonight::cryptonight_hash_v0(&b),
|
||||||
function_name!(),
|
function_name!(),
|
||||||
|
@ -199,7 +204,7 @@ hash | {hash}\n"
|
||||||
|
|
||||||
#[named]
|
#[named]
|
||||||
pub(crate) async fn cryptonight_v1(&self) {
|
pub(crate) async fn cryptonight_v1(&self) {
|
||||||
self.test::<false>(
|
self.test::<false, false>(
|
||||||
1546000..1685555,
|
1546000..1685555,
|
||||||
|b, _, _, _| cuprate_cryptonight::cryptonight_hash_v1(&b).unwrap(),
|
|b, _, _, _| cuprate_cryptonight::cryptonight_hash_v1(&b).unwrap(),
|
||||||
function_name!(),
|
function_name!(),
|
||||||
|
@ -209,7 +214,7 @@ hash | {hash}\n"
|
||||||
|
|
||||||
#[named]
|
#[named]
|
||||||
pub(crate) async fn cryptonight_v2(&self) {
|
pub(crate) async fn cryptonight_v2(&self) {
|
||||||
self.test::<false>(
|
self.test::<false, false>(
|
||||||
1685555..1788000,
|
1685555..1788000,
|
||||||
|b, _, _, _| cuprate_cryptonight::cryptonight_hash_v2(&b),
|
|b, _, _, _| cuprate_cryptonight::cryptonight_hash_v2(&b),
|
||||||
function_name!(),
|
function_name!(),
|
||||||
|
@ -219,7 +224,7 @@ hash | {hash}\n"
|
||||||
|
|
||||||
#[named]
|
#[named]
|
||||||
pub(crate) async fn cryptonight_r(&self) {
|
pub(crate) async fn cryptonight_r(&self) {
|
||||||
self.test::<false>(
|
self.test::<false, false>(
|
||||||
1788000..1978433,
|
1788000..1978433,
|
||||||
|b, h, _, _| cuprate_cryptonight::cryptonight_hash_r(&b, h),
|
|b, h, _, _| cuprate_cryptonight::cryptonight_hash_r(&b, h),
|
||||||
function_name!(),
|
function_name!(),
|
||||||
|
@ -251,7 +256,7 @@ hash | {hash}\n"
|
||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
self.test::<true>(1978433..self.top_height, function, function_name!())
|
self.test::<true, false>(1978433..self.top_height, function, function_name!())
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue