use neptune_consensus::block::pow::{Pow, PowMastPaths};
use tasm_lib::triton_vm::prelude::*;
fn digest(seed: u64) -> Digest {
Digest::new(std::array::from_fn(|i| {
BFieldElement::new(seed.wrapping_add(i as u64))
}))
}
fn main() {
assert!(Pow::<29>::default().lustration_status().is_ok());
let maximum = Digest::new([BFieldElement::new(BFieldElement::P - 1); 5]);
let pow = Pow::<29>::guess(
&PowMastPaths::default(),
Digest::default(),
maximum,
None,
Some(BFieldElement::new(7)),
)
.unwrap();
assert_eq!(pow.path_a[26].values()[4].value(), 7);
let l = neptune_consensus::block::pow::LustrationStatus {
counter:
neptune_consensus::type_scripts::native_currency_amount::NativeCurrencyAmount::coins(3),
max_lustrating_aocl_leaf_index: 0x123456789abcdef0,
};
eprintln!(
"lustration JSON={} codec={:?}",
serde_json::to_string(&l).unwrap(),
l.encode().iter().map(|v| v.value()).collect::<Vec<_>>()
);
println!("// Generated by tools/neptune-policy-oracle/examples/mining_pow.rs\n// Neptune 0.15.1, commit 9869b5e35b659dc520fad51ba5a9c812fed46db0.");
println!("pub const HASHES: [[u64; 5]; 3] = [");
for seed in [0, 1000, BFieldElement::P - 400] {
let pow = Pow::<29> {
root: digest(seed),
nonce: digest(seed + 5),
path_a: std::array::from_fn(i digest(seed + 10 + i as u64 * 5)),
path_b: std::array::from_fn(i digest(seed + 155 + i as u64 * 5)),
};
let mast = PowMastPaths {
pow: std::array::from_fn(i digest(seed + 300 + i as u64 * 5)),
header: std::array::from_fn(i digest(seed + 315 + i as u64 * 5)),
kernel: [digest(seed + 325)],
};
let expected: Vec<_> = (5..10)
.chain(155..300)
.chain(10..155)
.chain(0..5)
.map(i BFieldElement::new(seed + i))
.collect();
assert_eq!(pow.encode(), expected, "native codec layout");
println!(
" {:?},",
mast.fast_mast_hash(pow).values().map(x x.value())
);
}
println!("];");
}