Skip to content

Commit 02c9517

Browse files
authored
Merge 1676c94 into 6354028
2 parents 6354028 + 1676c94 commit 02c9517

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

EIPS/eip-7814.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
eip: 7814
3+
title: Introspection precompiles
4+
description: Introspection precompiles that expose the current block context to the EVM
5+
author: Brecht Devos (@Brechtpd)
6+
discussions-to: https://ethereum-magicians.org/t/eip-7814-introspection-precompiles/21872
7+
status: Draft
8+
type: Standards Track
9+
category: Core
10+
created: 2024-11-09
11+
---
12+
13+
## Abstract
14+
15+
This EIP proposes to add two precompiles that enable introspection of the chain state at arbitrary points within a block in the EVM. Currently, the EVM only has access to the state of previous blocks. No block data is currently exposed to the EVM for the block it's executing in.
16+
17+
## Motivation
18+
19+
The new precompiles aim to enhance introspection capabilities within the EVM, enabling the calculation of the latest chain state offchain at any point in an Ethereum block. This is important to allow general and efficient synchronous composability with L1. Otherwise, to ensure having the latest L1 state, the state would have to be read on L1 and passed in as a separate input. This is expensive and there may be limitations on who can read the state without something like [EIP-2330](https://eips.ethereum.org/EIPS/eip-2330).
20+
21+
This proposal allows computing the latest state from the state root of the previous block and the transactions that are in the current block. This data can then be passed into any system requiring the latest chain state where the partial block can be re-executed to compute the latest state in a provable way.
22+
23+
## Specification
24+
25+
If `block.number >= TBD` two new precompiled contracts shall be created:
26+
- `TXTRIEROOT` at address `TBD`: This precompile returns the transaction trie root of all transactions in the current block, up to and including the transaction that is currently executing. The tx trie is already calculated for the block header. This EIP just enforces that the trie is constructed incrementally per transaction and exposes the root to the EVM.
27+
- `OPCODECOUNTER` at address `TBD`: This precompile returns a 4 byte uint in big endian encoding representing the total number of opcodes that have been executed for the current transaction up till (and excluding) the call to this precompile.
28+
29+
### Gas Cost
30+
31+
The gas cost for `TXTRIEROOT` and `OPCODECOUNTER` is a fixed fee of `2`.
32+
33+
## Rationale
34+
35+
Simple and efficient access to the latest state of a chain is critical for composability. For synchronous composability, we need to be able to immediately prove all offchain work inside the same block. This makes it impossible to delay the proving to a later block where more information about the current block is available.
36+
37+
### Gas Price
38+
39+
The precompiles are priced to match similar opcodes in the `W_base` set.
40+
41+
### Precompile
42+
43+
Implementing this feature via precompiles instead of opcodes gives L2s flexibility to decide whether to implement it.
44+
45+
## Backwards Compatibility
46+
47+
Further discussion required.
48+
49+
## Test Cases
50+
51+
N/A
52+
53+
## Security Considerations
54+
55+
Needs discussion.
56+
57+
## Copyright
58+
59+
Copyright and related rights waived via [CC0](../LICENSE.md).

0 commit comments

Comments
 (0)