# EPF - Update 6 ## Progress Overview * Project Proposal is merged and it's [live](https://github.com/eth-protocol-fellows/cohort-six/blob/master/projects/grandine_beacon_zkVMs_snarkification.md) on EPF repo. * Read the grandine zkVM codebase and understood the integration of risc0. * Successfully ran existing risc0 test cases. ## Breakdown #### How risc0 implemenation works The system has two parts: a **host program** that manages data and coordinates execution, and a **guest program** that runs inside the zkVM to perform the actual state transition computation. #### Key Implementation Details **Reference Execution (Host Program):** ```rust let block_ssz = get_or_download(/*...*/)?; let state_ssz = get_or_download(/*...*/)?; let (expected_root, cache) = { let block = SignedBeaconBlock::<Mainnet>::from_ssz(&config, block_ssz.clone())?; let mut state = BeaconState::<Mainnet>::from_ssz(&config, state_ssz.clone())?; let cache = PubkeyCache::load(Database::in_memory()); // performing on the host to get the cache object that speed up the zkVM processing state_transition(&config, &cache, &mut state, &block)?; (state.hash_tree_root(), cache.to_ssz().unwrap()) }; //... let vm = Vm::new()?; let (output_bytes, proof) = vm.prove(state_ssz, block_ssz, cache)?; let state_root = H256(output_bytes.try_into().unwrap()); ``` We get `expected_root` when we run STF outside zkVM. We use this to compare with `state_root` which we get by running the STF inside risc0. **Guest Program Execution:** ```rust let env = ExecutorEnv::builder() .write_slice(&state_ssz) // Send beacon state to guest .write_slice(&block_ssz) // Send beacon block to guest .write_slice(&cache_ssz) // Send validator cache to guest .build()?; //.. let elf = RISC0_GRANDINE_STATE_TRANSITION_ELF; // Compiled guest program binary let prove_info = prover.prove(env, elf)?; // Execute guest inside zkVM let receipt = prove_info.receipt; // Get results and proof ``` The guest program runs the same state transition inside the provable environment. #### Test Cases Results You can see the test cases result [here](https://hackmd.io/@0xprivateChaos/SJDpxLQwex). ## Next Steps I have to do a similar integration with zisk zkVM. So will learn about zisk, which would be a challenging part because it doesn't have any technical in-depth documentation at present.