Skip to content

Commit 941d3be

Browse files
committed
update
1 parent a4c79a5 commit 941d3be

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

EIPS/eip-2935.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ Additional secondary motivations include:
2929
| - | - |
3030
| `FORK_TIMESTAMP` | TBD |
3131
| `HISTORY_STORAGE_ADDRESS` | `0xfffffffffffffffffffffffffffffffffffffffe`|
32-
| `HISTORY_SERVE_WINDOW` | `256` |
32+
| `MIN_HISTORY_SERVE_WINDOW` | `256` |
33+
| `MAX_HISTORY_SERVE_WINDOW` | `2**256` |
3334

3435
At the start of processing any block where `block.timestamp >= FORK_TIMESTAMP` (ie. before processing any transactions), update the history in the following way:
3536

@@ -41,7 +42,7 @@ def process_block_hash_history(block :Block, state: State):
4142
# If this is the first fork block, add the parent's direct 255 ancestors as well
4243
if block.parent.timestamp < FORK_TIMESTAMP:
4344
ancestor = block.parent
44-
for i in range(HISTORY_SERVE_WINDOW - 1):
45+
for i in range(MIN_HISTORY_SERVE_WINDOW - 1):
4546
# stop at genesis block
4647
if ancestor.number == 0:
4748
break
@@ -50,26 +51,27 @@ def process_block_hash_history(block :Block, state: State):
5051
state.insert_slot(HISTORY_STORAGE_ADDRESS, ancestor.number, ancestor.hash)
5152
```
5253

53-
Note that if this is the fork block, then it persists the additional requisite history that could be needed while resolving `BLOCKHASH` opcode for all of the `HISTORY_SERVE_WINDOW` ancestors (up until genesis).
54+
Note that if this is the fork block, then it persists the additional requisite history that could be needed while resolving `BLOCKHASH` opcode for all of the `MIN_HISTORY_SERVE_WINDOW` ancestors (up until genesis).
5455

5556
For resolving the `BLOCKHASH` opcode this fork onwards (`block.timestamp >= FORK_TIMESTAMP`), switch the logic to:
5657

5758
```python
5859
def resolve_blockhash(block: Block, state: State, arg: uint64):
5960
# check the wrap around range
60-
if arg >= block.number or arg < max(block.number - 2**256, 0)
61+
if arg >= block.number or arg < max(block.number - MAX_HISTORY_SERVE_WINDOW, 0)
6162
return 0
6263

6364
return state.load_slot(HISTORY_STORAGE_ADDRESS, arg)
6465
```
6566

66-
Note that the above logic allows access deeper than `HISTORY_SERVE_WINDOW` if it exists.
67+
Note that the above logic allows access deeper than `MIN_HISTORY_SERVE_WINDOW` if it exists all the way upto `MAX_HISTORY_SERVE_WINDOW`.
6768

6869
Edge cases:
6970

7071
* For the fork to be activated at genesis, no history is written to the genesis state, and at the start of block `1`, genesis hash will be written as a normal operation to slot `0`.
7172
* for activation at block `1`, only genesis hash will be written at slot `0` as there is no additional history that needs to be persisted.
7273
* for activation at block `32`, block `31`'s hash will be written to slot `31` and additonal history for `0..30`'s hashes will be persisted, so all in all `0..31`'s hashes.
74+
* for activation at block `1000`, block `744-999`'s hashes will be presisted in the slot and `BLOCKHASH` for `733` or less would resolve to `0` as only `MIN_HISTORY_SERVE_WINDOW` is persisted.
7375

7476
### [EIP-158](./eip-158.md) exception
7577

@@ -89,11 +91,11 @@ Very similar ideas were proposed before in [EIP-210](./eip-210.md) et al. This E
8991

9092
The former was intended to save space. Since then, however, storage usage has increased massively, to the point where even eg. 5 million new storage slots are fairly negligible compared to existing usage. The latter was intended as a first step toward "writing the Ethereum protocol in EVM" as much as possible, but this goal has since been de-facto abandoned.
9193

92-
Storing of all last `HISTORY_SERVE_WINDOW` block hashes alleviates the need to detect fork activation height to transition to the new logic as the entire required history will be available from the first block of the fork itself. The cost of doing so is marginal considering the `HISTORY_SERVE_WINDOW` being small.
94+
Storing of all last `MIN_HISTORY_SERVE_WINDOW` block hashes alleviates the need to detect fork activation height to transition to the new logic in backward compatible manner as the entire requisite history will be available from the first block of the fork itself. The cost of doing so is marginal considering the `MIN_HISTORY_SERVE_WINDOW` being small.
9395

9496
## Backwards Compatibility
9597

96-
The range of `BLOCKHASH` is increased by this opcode, but behavior within the previous 256-block range remains unchanged.
98+
The range of `BLOCKHASH` is increased by this opcode, but behavior within the previous `MIN_HISTORY_SERVE_WINDOW`-block range remains unchanged.
9799

98100
## Test Cases
99101

0 commit comments

Comments
 (0)