forked from privacy-scaling-explorations/zkevm-specs
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
spec for write protection error (privacy-scaling-explorations#365)
* hackmd for write protection error * fix typo ready --> read * Update specs/error_state/error_write_protection.md Co-authored-by: adria0.eth <[email protected]> --------- Co-authored-by: adria0.eth <[email protected]>
- Loading branch information
1 parent
31201a2
commit 29f1c2d
Showing
1 changed file
with
25 additions
and
0 deletions.
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,25 @@ | ||
# ErrorWriteProtection state | ||
|
||
## Procedure | ||
there are some op codes which modify state. there are `[SSTORE, CREATE, CREATE2, | ||
CALL, SELFDESTRUCT, LOG0, LOG1, LOG2, LOG3, LOG4]` | ||
when execution call context is read only (static call), these op codes running will encounter | ||
write protection error. See [EIP-214](https://eips.ethereum.org/EIPS/eip-214) | ||
### EVM behavior | ||
in above op codes which modify state, `CALL` is somewhat special. for non call op codes(SSTORE, CREATE, etc) | ||
first check if running in read only call context, if yes, throw write protection error. | ||
for `CALL` op code, it will also check `value` is not zero. only both non zero value & read only call context, then | ||
throw write protection error. | ||
|
||
### Constraints | ||
1. constrain this error happens in one of op codes `[SSTORE, CREATE, CREATE2, | ||
CALL, SELFDESTRUCT, LOG0, LOG1, LOG2, LOG3, LOG4]` | ||
2. current call context must be readonly & internal call(since requires at least one `staticcall` earlier). | ||
3. for `CALL` op code, do stack read & check `value` is not zero. | ||
4. common error steps constraints: | ||
- current call must be failed. | ||
- rw_counter_end_of_reversion constraint | ||
- it restores caller's context by reading to `rw_table`, then does step state transition to it. | ||
|
||
## Code | ||
TODO: after circuit merge! |