Skip to content
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

Update EIP-2935: Move to Draft #8166

Merged
merged 20 commits into from
Apr 20, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions EIPS/eip-2935.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
---
eip: 2935
title: Save historical block hashes in state
author: Vitalik Buterin (@vbuterin), Tomasz Stanczak (@tkstanczak)
author: Vitalik Buterin (@vbuterin), Tomasz Stanczak (@tkstanczak), Guillaume Ballet (@gballet), Gajinder Singh (@g11tech), Tanishq Jasoria (@tanishqjasoria)

Check failure on line 4 in EIPS/eip-2935.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

preamble header `author` is out of order

error[preamble-order]: preamble header `author` is out of order --> EIPS/eip-2935.md | 4 | author: Vitalik Buterin (@vbuterin), Tomasz Stanczak (@tkstanczak), Guillaume Ballet (@gballet), Gajinder Singh (@g11tech), Tanishq Jasoria (@tanishqjasoria) | = help: `author` should come after `description` = help: see https://ethereum.github.io/eipw/preamble-order/
description: store previous block hashes as storage slots of a system contract to allow for stateless execution
gballet marked this conversation as resolved.
Show resolved Hide resolved
discussions-to: https://ethereum-magicians.org/t/eip-2935-save-historical-block-hashes-in-state/4565
status: Stagnant
status: Draft
type: Standards Track
category: Core
created: 2020-09-03
---

Check failure on line 12 in EIPS/eip-2935.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

body is missing section(s): `Abstract`

error[markdown-req-section]: body is missing section(s): `Abstract` --> EIPS/eip-2935.md | | = help: must be at the second level (`## Heading`) = help: see https://ethereum.github.io/eipw/markdown-req-section/
## Simple Summary

Check failure on line 13 in EIPS/eip-2935.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

body has extra section(s)

error[markdown-order-section]: body has extra section(s) --> EIPS/eip-2935.md | 13 | ## Simple Summary | ::: EIPS/eip-2935.md | 63 | ## Implementation | = help: see https://ethereum.github.io/eipw/markdown-order-section/

Store historical block hashes in a contract, and modify the `BLOCKHASH (0x40)` opcode to read this contract.

Expand All @@ -26,22 +27,31 @@

| Parameter | Value |
| - | - |
| `FORK_BLKNUM` | TBD |
| `FORK_TIMESTAMP` | TBD |
| `HISTORY_STORAGE_ADDRESS` | `0xfffffffffffffffffffffffffffffffffffffffe`|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This conflicts with the system address from EIP-4788.

| `HISTORY_SERVE_WINDOW` | `256` |

At the start of processing any block where `block.number > FORK_BLKNUM` (ie. before processing any transactions), run `sstore(HISTORY_STORAGE_ADDRESS, block.number - 1, block.prevhash)`.
At the start of processing any block where `block.timestamp > FORK_TIMESTAMP` (ie. before processing any transactions),
* run `sstore(HISTORY_STORAGE_ADDRESS, block.number - 1, block.prevhash)`.

Check failure on line 35 in EIPS/eip-2935.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Lists should be surrounded by blank lines [Context: "* run `sstore(HISTORY_STORAGE_..."]

EIPS/eip-2935.md:35 MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "* run `sstore(HISTORY_STORAGE_..."]
* **additionally** if this is the first block of the fork, then store last `min(HISTORY_SERVE_WINDOW-1, block.number-1)` **blocks' prevhash** into their corresponding slots i.e persist the entire `HISTORY_SERVE_WINDOW` block hashes (up until the genesis) that can be accessed in the block.
* change the logic of the `BLOCKHASH` opcode as follows: return `sload(HISTORY_STORAGE_ADDRESS, arg)`.
gballet marked this conversation as resolved.
Show resolved Hide resolved

When `block.number > FORK_BLKNUM + 256`, change the logic of the `BLOCKHASH` opcode as follows: if `FORK_BLKNUM <= arg < block.number`, return `sload(HISTORY_STORAGE_ADDRESS, arg)`. Otherwise return 0.
Edge cases:
* For verkle 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`.

Check failure on line 40 in EIPS/eip-2935.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Lists should be surrounded by blank lines [Context: "* For verkle at genesis, no hi..."]

EIPS/eip-2935.md:40 MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "* For verkle at genesis, no hi..."]
* for verkle activated at block `1`, only genesis hash will be written at slot `0` as no additional history needs to be persisted.
* for verkle activated 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.
gballet marked this conversation as resolved.
Show resolved Hide resolved

## Rationale

Very similar ideas were proposed before in EIP-98 and EIP-210. This EIP is a simplification, removing two sources of needless complexity:

Check failure on line 46 in EIPS/eip-2935.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

the first match of the given pattern must be a link

error[markdown-link-first]: the first match of the given pattern must be a link --> EIPS/eip-2935.md | 46 | Very similar ideas were proposed before in EIP-98 and EIP-210. This EIP is a simplification, removing two sources of needless complexity: | = info: the pattern in question: `(?i)(?:eip|erc)-[0-9]+` = help: see https://ethereum.github.io/eipw/markdown-link-first/

Check failure on line 46 in EIPS/eip-2935.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

the first match of the given pattern must be a link

error[markdown-link-first]: the first match of the given pattern must be a link --> EIPS/eip-2935.md | 46 | Very similar ideas were proposed before in EIP-98 and EIP-210. This EIP is a simplification, removing two sources of needless complexity: | = info: the pattern in question: `(?i)(?:eip|erc)-[0-9]+`

Check failure on line 46 in EIPS/eip-2935.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

unable to read file `eip-98.md`: Io: JsValue(Error: ENOENT: no such file or directory, open 'EIPS/eip-98.md' Error: ENOENT: no such file or directory, open 'EIPS/eip-98.md')

error[markdown-refs]: unable to read file `eip-98.md`: Io: JsValue(Error: ENOENT: no such file or directory, open 'EIPS/eip-98.md' Error: ENOENT: no such file or directory, open 'EIPS/eip-98.md') --> EIPS/eip-2935.md | 46 | Very similar ideas were proposed before in EIP-98 and EIP-210. This EIP is a simplification, removing two sources of needless complexity: | = help: see https://ethereum.github.io/eipw/markdown-refs/

1. Having a tree-like structure with multiple layers as opposed to a single list
2. Writing the EIP in EVM code

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.

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.

## Backwards Compatibility

The range of `BLOCKHASH` is increased by this opcode, but behavior within the previous 256-block range remains unchanged.
Expand All @@ -52,11 +62,12 @@

## Implementation

TBD
* PR 28878 of go-ethereum
* Active on verkle-gen-devet-3 for its verkle implementation

## Security Considerations

Adding ~2.5 million storage slots per year bloats the state somewhat (but not much relative to the hundreds of millions of existing state objects). However, this EIP is not intended to be permanent; when eth1 is merged into eth2, the BLOCKHASH opcode would likely be repurposed to use eth2's built-in history accumulator structure (see [phase 0 spec](https://github.com/ethereum/annotated-spec/blob/master/phase0/beacon-chain.md#slots_per_historical_root)).

Check failure on line 70 in EIPS/eip-2935.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

non-relative link or image

error[markdown-rel-links]: non-relative link or image --> EIPS/eip-2935.md | 70 | Adding ~2.5 million storage slots per year bloats the state somewhat (but not much relative to the hundreds of millions of existing state objects). However, this EIP is not intended to be permanent; when eth1 is merged into eth2, the BLOCKHASH opcode would likely be repurposed to use eth2's built-in history accumulator structure (see [phase 0 spec](https://github.com/ethereum/annotated-spec/blob/master/phase0/beacon-chain.md#slots_per_historical_root)). | = help: see https://ethereum.github.io/eipw/markdown-rel-links/

## Copyright

Expand Down
Loading