From 6e682bdf39a8c1a5fd732d0861ca0487a7fe9c4b Mon Sep 17 00:00:00 2001 From: "hinto.janai" Date: Fri, 13 Dec 2024 08:53:02 -0500 Subject: [PATCH] handle 202612 pow hash --- Cargo.lock | 1 + tests/pow/Cargo.toml | 1 + tests/pow/src/rpc.rs | 29 +++++++++++++++++------------ 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 40394be..be524f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3339,6 +3339,7 @@ dependencies = [ "cuprate-cryptonight", "function_name", "hex", + "hex-literal", "monero-serai", "randomx-rs", "rayon", diff --git a/tests/pow/Cargo.toml b/tests/pow/Cargo.toml index 74a5f3a..bb17694 100644 --- a/tests/pow/Cargo.toml +++ b/tests/pow/Cargo.toml @@ -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"] } diff --git a/tests/pow/src/rpc.rs b/tests/pow/src/rpc.rs index 557d0ef..129cee6 100644 --- a/tests/pow/src/rpc.rs +++ b/tests/pow/src/rpc.rs @@ -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( + async fn test( &self, range: Range, hash: impl Fn(Vec, 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( - block.serialize_pow_hash(), - height.try_into().unwrap(), - seed_height.try_into().unwrap(), - seed_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::( + self.test::( 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::( + self.test::( 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::( + self.test::( 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::( + self.test::( 1788000..1978433, |b, h, _, _| cuprate_cryptonight::cryptonight_hash_r(&b, h), function_name!(), @@ -251,7 +256,7 @@ hash | {hash}\n" .unwrap() }; - self.test::(1978433..self.top_height, function, function_name!()) + self.test::(1978433..self.top_height, function, function_name!()) .await; } }