risc0 / risc0-ethereum

Integration of the RISC Zero verifiable compute platform with Ethereum and EVM chains.
https://risczero.com
Apache License 2.0
60 stars 15 forks source link

feat: Add hash chain support for older commitments #167

Closed Wollac closed 2 months ago

Wollac commented 2 months ago

Previously, EvmEnv::block_commitment() returned the commitment with respect to the block holding the EVM state. This can cause problems during on-chain verification if that block is older than 256 blocks. To address this issue, this PR adds functionality to use EvmEnv::into_input_with_chain(self, block_number) to prepare a hash chain from the state block to the more recent block with block_number. This makes it possible to generate Steel proofs for blocks older than 256 blocks.

// Create a view call environment from an RPC endpoint and a block number in the past.
let mut env = EthViewCallEnv::from_rpc(&args.rpc_url, Some(old_block_number))?;

// Preflight the call to construct the input with respect to a more recent block.
let mut contract = Contract::preflight(CONTRACT, &mut env);
let returns = contract.call_builder(&CALL).from(CALLER).call()?;
let input = env.into_input_with_chain(latest_block_number)?;
Wollac commented 2 months ago

Superseded by #170