The main entry point of the header chain circuit.
(guest: &impl ZkvmGuest)
| 12 | |
| 13 | /// The main entry point of the header chain circuit. |
| 14 | pub fn header_chain_circuit(guest: &impl ZkvmGuest) { |
| 15 | let start = risc0_zkvm::guest::env::cycle_count(); |
| 16 | |
| 17 | let input: HeaderChainCircuitInput = guest.read_from_host(); |
| 18 | // println!("Detected network: {:?}", NETWORK_TYPE); |
| 19 | // println!("NETWORK_CONSTANTS: {:?}", NETWORK_CONSTANTS); |
| 20 | let mut chain_state = match input.prev_proof { |
| 21 | HeaderChainPrevProofType::GenesisBlock => ChainState::new(), |
| 22 | HeaderChainPrevProofType::PrevProof(prev_proof) => { |
| 23 | assert_eq!(prev_proof.method_id, input.method_id); |
| 24 | guest.verify(input.method_id, &prev_proof); |
| 25 | prev_proof.chain_state |
| 26 | } |
| 27 | }; |
| 28 | |
| 29 | chain_state.apply_blocks(input.block_headers); |
| 30 | |
| 31 | guest.commit(&BlockHeaderCircuitOutput { |
| 32 | method_id: input.method_id, |
| 33 | chain_state, |
| 34 | }); |
| 35 | let end = risc0_zkvm::guest::env::cycle_count(); |
| 36 | println!("Header chain circuit took {:?} cycles", end - start); |
| 37 | } |
no test coverage detected