-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e34137f
add op-steel readme
Wollac 34dc356
Merge branch 'main' into chore/op-steel-readme
Wollac 64b0e66
Merge branch 'main' into chore/op-steel-readme
Wollac 8888c5d
add OP examples to README.md
Wollac dafa04e
Merge branch 'main' into chore/op-steel-readme
Wollac eaa7d05
address review comment
Wollac ffd2f1b
Merge branch 'main' into chore/op-steel-readme
Wollac File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# 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 and any OP Stack-compatible chains. Steel provides a generic tool to interact with EVM-compatible chains, enabling offchain execution of EVM apps while preserving onchain security through execution proofs. | ||
|
||
While you can use Steel directly to query and verify on the same chain (including OP chains), OP-Steel makes this process more convenient by including pre-configured OP network settings. The main advantage of OP-Steel, however, is its ability to perform **cross-chain queries** between Optimism and Ethereum, a feature not available in Steel alone. | ||
|
||
## 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 | ||
- **Cross-Chain Queries**: | ||
- Perform cross-chain queries between Optimism and Ethereum | ||
- Seamlessly verify OP contract execution on Ethereum L1 | ||
- **Dispute Game Integration**: | ||
- Find and validate dispute games | ||
- Support for latest, finalized, and specific game indices | ||
- Automatic verification against the L1 `OptimismPortal` contract | ||
- **OP Stack Compatibility**: | ||
- Use OP-Steel with OP-Mainnet and any OP Stack-compatible chains | ||
|
||
## 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. | ||
|
||
### Querying and Verifying on the Same Chain | ||
|
||
If you only need to query and verify on the same chain (e.g., OP-Mainnet), you can use Steel directly. However, OP-Steel simplifies this process by providing pre-configured OP network settings. | ||
|
||
```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?; | ||
``` | ||
|
||
### Cross-Chain Queries (OP to Ethereum) | ||
|
||
OP-Steel enables cross-chain queries, such as verifying OP contract execution on Ethereum L1. This is a key feature that Steel alone does not provide. | ||
|
||
```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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.