risc0 / risc0-ethereum

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

feat: Add hash chained input #170

Closed Wollac closed 1 month ago

Wollac commented 3 months ago

Previously, EvmEnv::block_commitment() returned the commitment with respect to the block holding the EVM state. This is not very flexible. To improve this, the PR adds the EvmChainInput that in addition to the EVM input also contains a chain of block headers to move this commitment to a later point.

// 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_chain_input(newer_block_number)?;