fin-proof: certificates are checked against the history before the block (witnesses are built before the fold)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
igneum-labs 2026-10-07 07:57:14 +00:00
parent 98bb67389f
commit df097420d9
2 changed files with 14 additions and 13 deletions

View file

@ -198,24 +198,25 @@ pub fn fold_block(state: &mut FinState, params: &FinParams, block: &ChainBlockWi
}
}
// 4. the block's own entry in the history, with the table after it
state.end_daa = block.daa;
state.end_number = block.number;
state.keys.retain(|k| !k.is_empty_at(block.daa));
let (_, total) = voters_at(&state.keys, block.daa, params.dust);
let leaf = HistoryLeaf { number: block.number, block_hash: block.block_hash, daa: block.daa, table_root: state.table_root(), keys_hash: state.keys_hash(), total };
mmr::append(&mut state.peaks, &mut state.leaves, leaf.hash());
// 4. the certificates that landed with this block, against the history as it stood before it (every witness
// builder, the tracker, the host and the harness, makes the table proofs before the fold)
for c in &witness.certificates {
verify_certificate(state, params, c, bls)?;
report.locks += 1;
}
// 5. staleness: a window without a lock (the frozen table never expires in the proof, design 4.4)
if state.lock.index > 0 && block.daa >= state.lock.daa.saturating_add(params.weight_window) {
state.stale = true;
}
// 6. the certificates that landed with this block
for c in &witness.certificates {
verify_certificate(state, params, c, bls)?;
report.locks += 1;
}
// 6. the block's own entry in the history, with the table after it
state.end_daa = block.daa;
state.end_number = block.number;
state.keys.retain(|k| !k.is_empty_at(block.daa));
let (_, total) = voters_at(&state.keys, block.daa, params.dust);
let leaf = HistoryLeaf { number: block.number, block_hash: block.block_hash, daa: block.daa, table_root: state.table_root(), keys_hash: state.keys_hash(), total };
mmr::append(&mut state.peaks, &mut state.leaves, leaf.hash());
Ok(report)
}

View file

@ -206,7 +206,7 @@ fn chain_past_the_gate(labels: &[&str]) -> Sim {
w.reveals = (0..labels.len()).map(|i| reveal(&sim.keys[i])).collect();
sim.mine(0, &[], w).unwrap();
for n in 1..260u64 {
let miner = [0, 0, 0, 0, 1, 1, 1, 2, 2, 3][(n % 10) as usize];
let miner = [0, 0, 0, 0, 1, 1, 1, 2, 2, 3][(n % 10) as usize] % labels.len();
sim.mine(miner, &[], FoldWitness::default()).unwrap();
}
sim