Steel: Bridging RISC Zero and Ethereum for Enhanced DApp Development
The success of the Ethereum network has driven the flourishing development of the DApp ecosystem. However, along with this success comes increasingly challenging scalability issues. Developers find themselves in a dilemma: either limit the functionality and data richness of their applications or bear the high gas fees and usage restrictions. But what if developers could find a way to bypass these limitations?
RISC Zero, one of the developers behind zkVM, has recently introduced a new technology called Steel. Steel is a view call proof library based on Alloy that completely changes the way developers interact with Ethereum L1 or other EVM-compatible chains. By leveraging zero-knowledge proofs and RISC Zero’s zkVM technology, Steel provides developers with a scalable, secure, and cost-effective method to execute view calls and verify Ethereum state reads and computations.
Harnessing the Power of ZK with the Convenience of Solidity
Steel bridges the gap between Ethereum application development and zero-knowledge proof technology, greatly facilitating the process of applying zero-knowledge proofs (ZK) in smart contracts. By integrating RISC Zero’s zkVM capabilities, Steel equips developers with tools to build more secure, scalable, and efficient applications on Ethereum L1 or any EVM-compatible chain.
With Steel, developers can achieve significant improvements in the following areas:
1. Direct execution of complex on-chain logic: Execute Solidity smart contracts directly on zkVM to support more complex on-chain logic.
2. Access to historical states: Access historical Ethereum states in zkVM, providing broader resources for data analysis and verification.
3. Overcome computational limitations: Use continuations for computations, unaffected by block size or transaction data size limitations.
4. Ensure security of off-chain computations: Guarantee the security of off-chain computations with the same reliability as on-chain execution.
5. Verified zkVM: Utilize the first zkVM rigorously tested and used in production environments by multiple partners.
6. Private computations: Perform private computations on Ethereum states, enhancing data protection.
7. Open-source flexibility: Implemented through an open-source codebase to ensure flexibility and freedom from vendor restrictions.
The introduction of Steel provides developers with powerful tools to integrate advanced zero-knowledge proof technology into existing blockchain solutions, further driving innovation in blockchain application development.
Seamless Integration and Cost Savings
With Steel, executing view calls is as simple as specifying the desired Solidity method. Whether retrieving ERC-20 token balances or accessing Ethereum states and more, Steel simplifies the process by seamlessly integrating with RISC Zero zkVM, ensuring security and efficiency. Tests have shown that Steel is capable of handling over 100K SLOAD operations in a single view call, saving thousands of dollars in gas fees on the mainnet. We can prove this using Bonsai in approximately 15 minutes, which would require at least 210M gas, exceeding block limits by 7 times.
Example: ERC20 balanceOf
The code snippet below demonstrates the process of proving the balance of a specific address deployed on Ethereum using Steel. This example showcases how developers can interact with Ethereum on-chain data within zkVM using Steel. The complete code can be viewed here.
Defining the view function signature
First, use the sol! macro to define the balanceOf function signature for ERC-20. This will parse the Solidity syntax to generate the corresponding Rust struct that implements the SolCall trait, allowing calling the balanceOf method, which takes an account address and returns the associated ERC-20 token balance.
[img]
Preparing the call
Next, set up the call by instantiating the balanceOfCall struct with the target account address. Also, define constants for the contract address and the caller’s address that you want to query.
[img]
Executing the call in Main
The main function executes within zkVM, generating the zero-knowledge proof. It first reads the input environment, then constructs a ViewCallEnv object to ensure the current state matches the expected state root. After submitting the relevant block hash and number, it executes the view call and prints the balance.
[img]
The Principle
Steel simplifies the process of executing Solidity code within RISC Zero zkVM by achieving proof generation through three clear steps:
1. Pre-flight phase: This phase is initiated by making view calls to Ethereum’s RPC nodes, caching the required storage slots and populating the EVM database based on the query requirements. All storage slots are automatically discovered and retrieved during the execution process of the view call.
2. Storage verification: This step involves checking the integrity of the storage, ensuring the data in the EVM database matches the state root of the blockchain, thus verifying the data’s legitimacy.
3. Solidity execution: Execute the specified Solidity function on the EVM inside RISC Zero zkVM, ensuring the code runs as expected.
Through these three steps, Steel provides an efficient and reliable method to prove and execute Solidity code within RISC Zero zkVM, greatly simplifying the entire process.
How is this different from storage proofs?
With traditional storage proofs, developers have to manually select the storage slots their smart contract uses and reimplement the smart contract logic. With Steel, all storage slots are automatically discovered and retrieved during the execution of the view call. This saves developers a significant amount of time, reduces the possibility of implementation errors, and minimizes the chance of security vulnerabilities.
Obtaining Verified Block Hashes
When verifying with the blockhash opcode in Ethereum smart contracts, the commitment being verified must reference block hashes that are no more than 256 blocks old. Considering the average block time of 12 seconds, this sets a narrow time window of approximately 50 minutes to generate proofs and confirm that the verification transaction has been included in a block.
When there is a need to obtain a verified block hash that is older than 256 blocks on-chain, there are several strategies that can be employed:
1. When the required block hash is known in advance (e.g., when initiating a governance proposal), it can be saved to the contract state.
2. Another approach is to use RISC Zero to prove a hash chain from the queried block to one of the last 256 blocks.
The Future of On-Chain Applications
Imagine a future where off-chain computations seamlessly integrate with on-chain verification. Steel empowers developers to reliably access and compute the complete history of Ethereum within zkVM, enabling the creation of next-generation, data-rich, and more powerful on-chain applications. Steel makes a significant contribution to realizing this vision.