-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WEB3-329: chore: Add op-steel readme #425
Changes from 5 commits
e34137f
34dc356
64b0e66
8888c5d
dafa04e
eaa7d05
ffd2f1b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# op-steel | ||
|
||
A Rust library for integrating Optimism's Layer 2 blockchain with Steel, RISC Zero's production-ready smart contract execution prover. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to say "OP Stack Later 2 blockchain", or is that not accurate? "Optimism's" might make people think its only for OP Mainnet. But maybe this is not a real concern. |
||
|
||
## Overview | ||
|
||
op-steel extends [Steel](https://github.com/risc0/risc0-ethereum/tree/main/crates/steel) to work with Optimism's Layer 2 blockchain. Steel enables EVM apps to run offchain while preserving onchain security through execution proofs. op-steel brings these capabilities to the Optimism ecosystem. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If someone wants to query an OP chain can verify on the same chain, they can use base Steel, ya? Do we want to clarify that this is primarily for cross-chain queries? Or do you need op-steel to query an OP stack chain in the first place. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should it be op-steel, |
||
|
||
The library provides tools and utilities for: | ||
- Interacting with Optimism's Layer 2 blockchain | ||
- Validating block headers and state | ||
- Working with Optimism dispute games | ||
- Building and verifying proofs for L2 blocks using Steel's proving system | ||
|
||
## Features | ||
|
||
- **Steel Integration**: | ||
- Leverage Steel's execution proving system for Optimism L2 operations | ||
- Generate verifiable proofs of correct smart contract execution | ||
- Maintain onchain security while performing computation offchain | ||
- **Dispute Game Integration**: | ||
- Find and validate dispute games | ||
- Support for latest, finalized, and specific game indices | ||
- Automatic verification against L1 OptimismPortal contract | ||
|
||
## Usage | ||
|
||
Usage of op-steel is very similar to Steel. | ||
See the [Steel README](https://github.com/risc0/risc0-ethereum/tree/main/crates/steel#readme) for more details. | ||
|
||
### Basic Example | ||
|
||
```rust | ||
// Create an OP environment | ||
let env = OpEvmEnv::builder() | ||
.rpc(Url::parse("https://optimism-rpc.publicnode.com")?) | ||
.build() | ||
.await? | ||
// Apply chain configuration | ||
.with_chain_spec(&OP_MAINNET_CHAIN_SPEC); | ||
|
||
// Implement steel functionality | ||
let contract = Contract::new(CONTRACT, &env); | ||
contract.call_builder(&CALL).from(CALLER).call(); | ||
|
||
// Convert to input format for the guest | ||
let input = env.into_input().await?; | ||
``` | ||
|
||
### Working with Dispute Games | ||
|
||
By relying on the existing dispute game functionality it is seamlessly possible to verify OP contract execution on L1. | ||
|
||
```rust | ||
// Create an OP environment referencing a dispute game | ||
let env = OpEvmEnv::builder() | ||
.dispute_game_from_rpc( | ||
portal_address, | ||
"https://ethereum-rpc.publicnode.com".parse()? | ||
) | ||
.rpc("https://optimism-rpc.publicnode.com".parse()?) | ||
.game_index(DisputeGameIndex::Latest) | ||
.build() | ||
.await?; | ||
|
||
// Implement steel functionality | ||
let contract = Contract::new(CONTRACT, &env); | ||
contract.call_builder(&CALL).from(CALLER).call(); | ||
|
||
// Convert to input format for the guest | ||
let input = env.into_input().await?; | ||
``` | ||
|
||
## Learn More | ||
|
||
- [Steel Documentation](https://github.com/risc0/risc0-ethereum/tree/main/crates/steel#readme) - Learn about the core Steel system | ||
- [RISC Zero Developer Docs](https://dev.risczero.com/api/) - Detailed documentation about the underlying zkVM | ||
- [Optimism Documentation](https://community.optimism.io/) - Learn about Optimism's L2 system |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,45 @@ | ||
# Examples | ||
This directory includes three example uses of Steel. Each example demonstrates a different concept of Steel. | ||
|
||
## [ERC20 Balance Query](./erc20/README.md) | ||
This directory includes three example uses of Steel. Each example demonstrates a different concept of Steel. | ||
|
||
This introductory example illustrates how to use [Steel] to directly query the `balanceOf` function of any ERC20 token contract, providing a verifiable proof of a user's token balance. | ||
### [ERC20 Balance Query](./erc20/README.md) | ||
|
||
## [ERC20 Counter with Off-Chain Proofs](./erc20-counter/README.md) | ||
This introductory example illustrates how to use [Steel] to directly query the `balanceOf` function of any ERC20 token | ||
contract, providing a verifiable proof of a user's token balance. | ||
|
||
### [ERC20 Counter with Off-Chain Proofs](./erc20-counter/README.md) | ||
|
||
Explore a more advanced interaction between [Steel] and a custom Ethereum smart contract. This counter contract utilizes | ||
off-chain [Steel] proofs to: | ||
|
||
Explore a more advanced interaction between [Steel] and a custom Ethereum smart contract. This counter contract utilizes off-chain [Steel] proofs to: | ||
- Increment a counter based on user-submitted proofs. | ||
- Verify ERC20 token ownership (minimum 1 token required) before incrementing. | ||
- Leverage RISC Zero as a [coprocessor] for efficient proof generation and verification. | ||
|
||
## [Compound Token Stats (APR Proof)](./token-stats/README.md) | ||
### [Compound Token Stats (APR Proof)](./token-stats/README.md) | ||
|
||
This example shows how the [Steel] library can be used to call multiple view functions of a contract. | ||
This example generates a proof of a [Compound] cToken's APR (Annual Percentage Rate), showcasing the potential for on-chain verification of complex financial metrics. | ||
This example generates a proof of a [Compound] cToken's APR (Annual Percentage Rate), showcasing the potential for | ||
on-chain verification of complex financial metrics. | ||
|
||
## ERC20 Balance Query using [op-steel] | ||
|
||
### [L2 Execution - L2 Verification](./op/l2) | ||
|
||
This example shows how to use [op-steel] to query the `balanceOf` function of an ERC20 token on OP, providing a proof | ||
that can be verified on OP. | ||
|
||
### [L1 Execution - L2 Verification](./op/l1-to-l2) | ||
|
||
This example shows how to use [op-steel] to query the `balanceOf` function of an ERC20 token on Ethereum and how the | ||
generated proof can be verified on OP. | ||
|
||
### [L2 Execution - L1 Verification](./op/l2-to-l1) | ||
|
||
This example shows how to use [op-steel] to query the `balanceOf` function of an ERC20 token on OP and how the generated | ||
proof can be verified on Ethereum. | ||
|
||
[coprocessor]: https://risczero.com/blog/a-guide-to-zk-coprocessors-for-scalability | ||
[Steel]: ../crates/steel | ||
[Compound]: https://compound.finance/ | ||
[op-steel]: ../crates/op-steel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This README does a good job of discussing mechanics. It may not be immediately clear to the reader they can use this for cross-chain Steel queries / cross-chain communication. It might be good to highlight that, as I think its the most common use case for this work.