-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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
|
||
|
||
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: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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). |
There was a problem hiding this comment.
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