From e8ce6c1d95a6901505fcf2d4ada4245feb69ea7e Mon Sep 17 00:00:00 2001 From: Marc Date: Mon, 23 Dec 2024 12:43:08 +0000 Subject: [PATCH] Add EIP: TXINDEX precompile Merged by EIP-Bot. --- EIPS/eip-7793.md | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 EIPS/eip-7793.md diff --git a/EIPS/eip-7793.md b/EIPS/eip-7793.md new file mode 100644 index 00000000000000..640ba81f3824e0 --- /dev/null +++ b/EIPS/eip-7793.md @@ -0,0 +1,57 @@ +--- +eip: 7793 +title: TXINDEX precompile +description: Precompile to get index of transaction within block +author: Marc Harvey-Hill (@Marchhill), Ahmad Bitar (@smartprogrammer93) +discussions-to: https://ethereum-magicians.org/t/eip-7793-txindex-precompile/21513 +status: Draft +type: Standards Track +category: Core +created: 2024-10-17 +--- + +## Abstract + +This EIP proposes to add a new precompile that returns the index of the transaction being executed within the current block. + +## Motivation + +The new precompile aims to improve support for encrypted mempools. In order to be secure, the validity of encrypted mempool transactions should be tied to the inclusion of all transactions by a proposer in the correct slot, and following the ordering rules. If these rules are not enshrined as block validity conditions then they can be enforced by a smart contract. + +This proposal enables smart contract solutions to check their own transaction index, so they can enforce inclusion at the correct index. These out-of-protocol solutions could be used for experimentation until a design appropriate for enshrinement is agreed upon. + +## Specification + +If `block.timestamp >= TBD` a new precompiled contract `TXINDEX` shall be created at address `TBD`. + +`TXINDEX` returns as output the transaction index as a 4 byte uint in big endian encoding. + +### Gas Cost + +The gas cost for `TXINDEX` is a fixed fee of `2` + +## Rationale + +### Gas Price + +The precompile is priced to match similar opcodes in the `W_base` set. + +### Precompile + +Making the feature a precompile rather than an opcode gives L2s flexibility to decide whether to implement it. + +## Backwards Compatibility + +No backward compatibility issues found. + +## Test Cases + +N/A + +## Security Considerations + +None. + +## Copyright + +Copyright and related rights waived via [CC0](../LICENSE.md).