From 62260b3e847ec03bcc92ae7fd1d049771c71e4ec Mon Sep 17 00:00:00 2001 From: Steven Gu Date: Wed, 22 Mar 2023 12:18:17 +0800 Subject: [PATCH] Add Markdown doc for `ErrorOutOfGasSHA3` state. --- specs/error_state/ErrorOutOfGasSHA3.md | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 specs/error_state/ErrorOutOfGasSHA3.md diff --git a/specs/error_state/ErrorOutOfGasSHA3.md b/specs/error_state/ErrorOutOfGasSHA3.md new file mode 100644 index 000000000..bec1b14b1 --- /dev/null +++ b/specs/error_state/ErrorOutOfGasSHA3.md @@ -0,0 +1,30 @@ +# ErrorOutOfGasSHA3 state for SHA3 OOG error + +## Procedure + +Handle the corresponding out of gas error for `SHA3`. + +### EVM behavior + +For `SHA3`, the out of gas error may occur in conditions: + +1. `memory_offset + memory_length > 0x1FFFFFFFE0 ((2^32 - 1) * 32)` if `memory_length` is non-zero. +2. Gas left is less than a constant gas cost of `30`. +3. Gas left is less than the sum of both constant and dynamic gas costs. The dynamic gas cost is calculated for memory expansion and copying (variable depending on the memory size copied to memory). + +### Constraints + +1. Constrain either `memory_offset + memory_length > 0x1FFFFFFFE0` or `gas_left < gas_cost` must be true. +2. Current call must fail. +3. If it's a root call, it transits to `EndTx`. +4. If it isn't a root call, it restores caller's context by reading to `rw_table`, then does step state transition to it. +5. Constrain `rw_counter_end_of_reversion = rw_counter_end_of_step + reversible_counter`. + +### Lookups + +`4` basic bus-mapping lookups: + +. `2` stack pop `offset` and `size`. +. `2` call context lookups for `is_success` and `rw_counter_end_of_reversion`. + +And restore context lookups for non-root call.