handle 202612 pow hash
Some checks failed
Deny / audit (push) Has been cancelled

This commit is contained in:
hinto.janai 2024-12-13 08:53:02 -05:00
parent 065dd03ea7
commit 6e682bdf39
No known key found for this signature in database
GPG key ID: D47CE05FA175A499
3 changed files with 19 additions and 12 deletions

1
Cargo.lock generated
View file

@ -3339,6 +3339,7 @@ dependencies = [
"cuprate-cryptonight",
"function_name",
"hex",
"hex-literal",
"monero-serai",
"randomx-rs",
"rayon",

View file

@ -11,6 +11,7 @@ function_name = { workspace = true }
thread_local = { workspace = true }
monero-serai = { workspace = true }
hex = { workspace = true, features = ["serde", "std"] }
hex-literal = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true, features = ["std"] }
tokio = { workspace = true, features = ["full"] }

View file

@ -6,6 +6,7 @@ use std::{
use function_name::named;
use hex::serde::deserialize;
use hex_literal::hex;
use monero_serai::block::Block;
use randomx_rs::{RandomXCache, RandomXFlag, RandomXVM};
use reqwest::{
@ -114,7 +115,7 @@ impl RpcClient {
.result
}
async fn test<const RANDOMX: bool>(
async fn test<const RANDOMX: bool, const CRYPTONIGHT_V0: bool>(
&self,
range: Range<usize>,
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:?}"),
};
let pow_hash = hash(
let pow_hash = if CRYPTONIGHT_V0 && height == 202612 {
hex!("84f64766475d51837ac9efbef1926486e58563c95a19fef4aec3254f03000000")
} else {
hash(
block.serialize_pow_hash(),
height.try_into().unwrap(),
seed_height.try_into().unwrap(),
seed_hash,
);
)
};
assert_eq!(
header.pow_hash, pow_hash,
@ -189,7 +194,7 @@ hash | {hash}\n"
#[named]
pub(crate) async fn cryptonight_v0(&self) {
self.test::<false>(
self.test::<false, true>(
0..1546000,
|b, _, _, _| cuprate_cryptonight::cryptonight_hash_v0(&b),
function_name!(),
@ -199,7 +204,7 @@ hash | {hash}\n"
#[named]
pub(crate) async fn cryptonight_v1(&self) {
self.test::<false>(
self.test::<false, false>(
1546000..1685555,
|b, _, _, _| cuprate_cryptonight::cryptonight_hash_v1(&b).unwrap(),
function_name!(),
@ -209,7 +214,7 @@ hash | {hash}\n"
#[named]
pub(crate) async fn cryptonight_v2(&self) {
self.test::<false>(
self.test::<false, false>(
1685555..1788000,
|b, _, _, _| cuprate_cryptonight::cryptonight_hash_v2(&b),
function_name!(),
@ -219,7 +224,7 @@ hash | {hash}\n"
#[named]
pub(crate) async fn cryptonight_r(&self) {
self.test::<false>(
self.test::<false, false>(
1788000..1978433,
|b, h, _, _| cuprate_cryptonight::cryptonight_hash_r(&b, h),
function_name!(),
@ -251,7 +256,7 @@ hash | {hash}\n"
.unwrap()
};
self.test::<true>(1978433..self.top_height, function, function_name!())
self.test::<true, false>(1978433..self.top_height, function, function_name!())
.await;
}
}