diff --git a/README.md b/README.md index 251a27b..f4f1a9f 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,10 @@ nonces, verifies each proof of work independently, and receives 33 matching pool ACCEPT responses. The 33rd job also exercises the chain reset before hardware work ID reuse. This is host-only evidence, not a stock-firmware boot or a production board adapter. +The same strict pool fixture reconstructs one BM1362 job with an empty +extranonce2 and independently verifies its captured share before returning +ACCEPT. This extends the host pool path to a second chip family; physical +chain initialization and stock firmware remain unverified. Its cycle helper reads one pool event, drains up to 256 ASIC reports, and sends verified shares when present. A share reply unanswered for 30 seconds closes the connection so a caller can reconnect instead of filling the pending diff --git a/examples/simulator_pool_replay_probe.rs b/examples/simulator_pool_replay_probe.rs index bd69050..07e07f5 100644 --- a/examples/simulator_pool_replay_probe.rs +++ b/examples/simulator_pool_replay_probe.rs @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -//! Bounded host-only check: captured BM1366 report through HAL to a strict pool. +//! Bounded host-only check: captured BM13xx report through HAL to a strict pool. use alkane_os::hal_wire::HalClient; use alkane_os::miner::Bm1366Miner; @@ -17,6 +17,21 @@ const CAPTURED_HEADER: [u8; 80] = [ 0x2c, 0x5b, 0x4c, 0x74, 0xc1, 0x01, 0x2e, 0x6a, 0x8f, 0x06, 0x02, 0x17, 0x00, 0x00, 0x00, 0x00, ]; +const BM1362_HEADER_HEX: &str = concat!( + "00000020fc3ab8d43021f45eb662389d0f791f657dbf75a5cb93670b57b6c22503", + "b4213a0503969b7384e1215aace8cfc65dae22d8493ad48fec0b7ac3b0ad7b4e7", + "fb0c5c0012e6a8f06021700000000" +); + +fn bm1362_header() -> Result<[u8; 80], io::Error> { + let mut header = [0_u8; 80]; + for (index, pair) in BM1362_HEADER_HEX.as_bytes().chunks_exact(2).enumerate() { + let digits = std::str::from_utf8(pair).map_err(io::Error::other)?; + header[index] = u8::from_str_radix(digits, 16).map_err(io::Error::other)?; + } + Ok(header) +} + fn failure(message: impl Into) -> io::Error { io::Error::other(message.into()) } @@ -24,7 +39,7 @@ fn failure(message: impl Into) -> io::Error { fn main() -> Result<(), Box> { let mut args = std::env::args().skip(1); let socket = args.next().ok_or_else(|| { - failure("usage: simulator_pool_replay_probe HAL_SOCKET POOL_ADDRESS [SHARES]") + failure("usage: simulator_pool_replay_probe HAL_SOCKET POOL_ADDRESS [SHARES] [CHIP]") })?; let address: SocketAddr = args .next() @@ -34,6 +49,13 @@ fn main() -> Result<(), Box> { if !(1..=64).contains(&expected_accepts) { return Err(failure("SHARES must be between 1 and 64").into()); } + let chip = args.next().unwrap_or_else(|| "BM1366".to_owned()); + let first_header = match chip.as_str() { + "BM1366" => CAPTURED_HEADER, + "BM1362" if expected_accepts == 1 => bm1362_header()?, + "BM1362" => return Err(failure("BM1362 has one captured header").into()), + _ => return Err(failure("unsupported captured chip").into()), + }; if args.next().is_some() { return Err(failure("unexpected argument").into()); } @@ -68,7 +90,7 @@ fn main() -> Result<(), Box> { .count(); match event { PoolEvent::Work(work) => { - if issued == 0 && work.header != CAPTURED_HEADER { + if issued == 0 && work.header != first_header { return Err(failure("pool job differs from real-silicon capture").into()); } issued += 1; @@ -81,7 +103,7 @@ fn main() -> Result<(), Box> { if accepted == expected_accepts { miner.stop()?; println!( - "BM1366 real captured nonce accepted by strict loopback pool ({accepted} shares)" + "{chip} real captured nonce accepted by strict loopback pool ({accepted} shares)" ); return Ok(()); }