Skip to content

Add EIP: Introspection precompiles #9028

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all 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
59 changes: 59 additions & 0 deletions EIPS/eip-7814.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
eip: 7814
title: Introspection precompiles
description: Introspection precompiles that expose the current block context to the EVM
author: Brecht Devos (@Brechtpd)
discussions-to: https://ethereum-magicians.org/t/eip-7814-introspection-precompiles/21872
status: Draft
type: Standards Track
category: Core
created: 2024-11-09
---

## Abstract

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.

## Motivation

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).

Check failure on line 19 in EIPS/eip-7814.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-7814.md | 19 | The new precompiles aim to enhance introspection capabilities within the EVM, enabling the calculation of the latest chain state off... | = help: use `./eip-2330.md` instead = help: see https://ethereum.github.io/eipw/markdown-rel-links/
Copy link
Contributor

Choose a reason for hiding this comment

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

kindly address the bot failures


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.

## Specification

If `block.number >= TBD` two new precompiled contracts shall be created:
Copy link
Contributor

Choose a reason for hiding this comment

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

we now don't add hardfork number/timestamp information in the EIPs

- `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.

Check failure on line 26 in EIPS/eip-7814.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Lists should be surrounded by blank lines [Context: "- `TXTRIEROOT` at address `TBD..."]

EIPS/eip-7814.md:26 MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "- `TXTRIEROOT` at address `TBD..."]
Copy link
Contributor

@g11tech g11tech Jan 28, 2025

Choose a reason for hiding this comment

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

add a html <-- TODO --> tag to be autoflagged at the review PR stage whereever there is TBD in the EIP

Copy link
Contributor

Choose a reason for hiding this comment

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

seems that it would be technically feasible to only compute stateroot till previous tx. kinky confirm that what you wrote is what you intend to propose

- `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.

### Gas Cost

The gas cost for `TXTRIEROOT` and `OPCODECOUNTER` is a fixed fee of `2`.

## Rationale

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.
Copy link
Contributor

Choose a reason for hiding this comment

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

needs some examples where this proposal would be beneficial. rationale is a bit light imo and needs more support and reasoning.


### Gas Price

The precompiles are priced to match similar opcodes in the `W_base` set.

### Precompile

Implementing this feature via precompiles instead of opcodes gives L2s flexibility to decide whether to implement it.
Copy link
Contributor

Choose a reason for hiding this comment

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

do you mean precompiles vs system contracts? precomplies are sort of an opcode implementation


## Backwards Compatibility

Further discussion required.

## Test Cases

N/A

## Security Considerations

Needs discussion.
Copy link
Contributor

Choose a reason for hiding this comment

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

add html <-- TODO --> tag here and else where (discussion pending) to be autoflagged at review status update stage


## Copyright

Copyright and related rights waived via [CC0](../LICENSE.md).
Loading