You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: steel/README.md
+27-9
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ In the realm of Ethereum and smart contracts, obtaining data directly from the b
10
10
Traditionally, these operations, especially when it comes to proving and verifying off-chain computations, involve a degree of complexity: either via proof of storage mechanisms requiring detailed knowledge of slot indexes, or via query-specific circuit development.
11
11
12
12
In contrast, this library abstracts away these complexities, allowing developers to query Ethereum's state by just defining the Solidity method they wish to call.
13
-
To demonstrate a simple instance of using the view call library, let's consider possibly the most common view call: querying the balance of an ERC-20 token for a specific address.
13
+
To demonstrate a simple instance of using this library, let's consider possibly the most common view call: querying the balance of an ERC-20 token for a specific address.
14
14
You can find the full example [here](../examples/erc20/README.md).
15
15
16
16
## Guest code
@@ -114,19 +114,37 @@ let journal = Journal {
114
114
env::commit_slice(&journal.abi_encode());
115
115
```
116
116
117
-
We also provide an example, [erc20-counter], showcasing such integration.
117
+
We provide several examples showcasing such integration, including [erc20-counter] and [token-stats].
118
118
119
-
### Block hash validation
119
+
### Block commitment validation
120
120
121
-
Since internally the `blockhash` opcode is used for validation, the commitment must not be older than 256 blocks.
122
-
Given a block time of 12 seconds, this allows just over 50 minutes to create the proof and ensure that the validating transaction is included in a block.
123
-
In many cases, this will work just fine: even very large computations such as proving an entire Ethereum block can be done in well under 50 minutes with sufficient resources.
121
+
Validating the block committed by a Steel proof is essential to ensure that the proof accurately reflects the correct blockchain state.
122
+
Steel supports two methods for block validation (see the `validateCommitment` function in [Steel.sol](../contracts/src/steel/Steel.sol)).
124
123
125
-
For scenarios needing a verified block hash older than 256 blocks:
124
+
#### 1. Block hash Commitment
126
125
127
-
* Save the required block hash to the contract state if known in advance (e.g., when initiating a governance proposal).
128
-
* Use RISC Zero to prove the hash chain from the queried block up to a block within the most recent 256.
126
+
This method uses the `blockhash` opcode to commit to a block hash that is no more than 256 blocks old.
127
+
With Ethereum's 12-second block time, this provides a window of about 50 minutes to generate the proof and ensure that the validating transaction is contained in a block.
128
+
This approach is ideal for most scenarios, including complex computations, as it typically provides sufficient time to generate the proof.
129
+
130
+
#### 2. Beacon Block Root Commitment
131
+
132
+
The second method allows validation using the [EIP-4788] beacon roots contract.
133
+
This technique extends the time window in which the proof can be validated on-chain to just over a day, making it suitable for scenarios requiring more extensive computation.
134
+
It requires access to a beacon API endpoint and can be enabled by calling `EvmEnv::into_beacon_input`.
135
+
However, this approach is specific to Ethereum Steel proofs and depends on the implementation of EIP-4788.
136
+
137
+
Note that EIP-4788 only provides access to the parent beacon root, requiring iterative queries in Solidity to retrieve the target beacon root for validation.
138
+
This iterative process can result in slightly higher gas costs compared to using the `blockhash` opcode. Overall, it is suitable for environments where longer proof generation times are required.
139
+
140
+
#### Bookmarking
141
+
142
+
A *bookmarking* validation technique can also be built on top of either block commitment approach.
143
+
The idea is to store the target block commitment in the contract state before generating a Steel proof that targets that specific block.
144
+
Once the block hash (or beacon root) has been bookmarked, it can be used later for validation, ensuring that the proof corresponds to the correct blockchain state.
0 commit comments