diff --git a/proving/igneum-prove/fin/src/fold.rs b/proving/igneum-prove/fin/src/fold.rs index dd55c3b7f..d690b3446 100644 --- a/proving/igneum-prove/fin/src/fold.rs +++ b/proving/igneum-prove/fin/src/fold.rs @@ -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) } diff --git a/proving/igneum-prove/fin/tests/harness.rs b/proving/igneum-prove/fin/tests/harness.rs index 9a320fe9d..c560dbecb 100644 --- a/proving/igneum-prove/fin/tests/harness.rs +++ b/proving/igneum-prove/fin/tests/harness.rs @@ -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