Skip to content

Commit 0dc4cd5

Browse files
fix: pow challenge solution (#1363)
1 parent dd19dcf commit 0dc4cd5

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## v0.12.2 (TBD)
4+
5+
### Fixes
6+
7+
- Fixed `PoW` challenge solving in `miden-network-monitor` binary ([#1363](https://github.com/0xMiden/miden-node/pull/1363)).
8+
39
## v0.12.1 (2025-11-08)
410

511
- Added support for network transaction service in `miden-network-monitor` binary ([#1295](https://github.com/0xMiden/miden-node/pull/1295)).

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/network-monitor/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ workspace = true
1818
anyhow = { workspace = true }
1919
axum = { version = "0.8" }
2020
clap = { features = ["env"], workspace = true }
21+
hex = { version = "0.4" }
2122
humantime = { workspace = true }
2223
miden-lib = { workspace = true }
2324
miden-node-proto = { workspace = true }

bin/network-monitor/src/faucet.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use std::time::Duration;
77

88
use anyhow::Context;
9+
use hex;
910
use miden_objects::account::AccountId;
1011
use miden_objects::testing::account_id::ACCOUNT_ID_SENDER;
1112
use reqwest::Client;
@@ -162,7 +163,11 @@ async fn perform_faucet_test(
162163

163164
// Step 1: Request PoW challenge
164165
let pow_url = faucet_url.join("/pow")?;
165-
let response = client.get(pow_url).query(&[("account_id", &account_id)]).send().await?;
166+
let response = client
167+
.get(pow_url)
168+
.query(&[("account_id", &account_id), ("amount", &MINT_AMOUNT.to_string())])
169+
.send()
170+
.await?;
166171

167172
let response_text = response.text().await?;
168173
debug!("Faucet PoW response: {}", response_text);
@@ -216,17 +221,14 @@ async fn perform_faucet_test(
216221
///
217222
/// The nonce that solves the challenge, or an error if no solution is found within reasonable
218223
/// bounds.
224+
#[instrument(target = COMPONENT, name = "solve-pow-challenge", skip_all, ret(level = "debug"))]
219225
fn solve_pow_challenge(challenge: &str, target: u64) -> anyhow::Result<u64> {
220-
debug!(
221-
"Solving PoW challenge: challenge={}, target={} (~{} bits)",
222-
challenge,
223-
target,
224-
target.leading_zeros(),
225-
);
226+
let challenge_bytes = hex::decode(challenge).context("Failed to decode challenge from hex")?;
227+
226228
// Try up to 100 million nonces.
227229
for nonce in 0..MAX_CHALLENGE_ATTEMPTS {
228230
let mut hasher = Sha256::new();
229-
hasher.update(challenge.as_bytes());
231+
hasher.update(&challenge_bytes);
230232
hasher.update(nonce.to_be_bytes());
231233
let hash_result = hasher.finalize();
232234

0 commit comments

Comments
 (0)