HomeEIPsNewsletter
EIPsEIP-7793
EIP-7793

TXINDEX precompile

Precompile to get index of transaction within block
DraftStandards Track: Core
Created: 2024-10-17
Marc Harvey-Hill (@Marchhill), Ahmad Bitar (@smartprogrammer93)
Discussions ForumOriginal Proposal LinkEdit
1 min read
Anyone may contribute to propose contents.
Go propose
Video
Anyone may contribute to propose contents.
Go propose
Original

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.

ZK-VM proving

The TXINDEX precompile should not increase the complexity of proving EVM execution, as it is similar to existing opcodes such as GAS. If a whole block is proven then no additional inputs to the circuit are required to prove transaction indices, as they can be inferred from the transaction ordering. If a transaction is proved individually then the index must be provided as an input to the circuit, along with the remaining gas for GAS, and more for other introspective opcodes.

Backwards Compatibility

No backward compatibility issues found.

Test Cases

N/A

Security Considerations

None.

Copyright and related rights waived via CC0.

Further reading
Anyone may contribute to propose contents.
Go propose

Not miss a beat of EIPs' update?

Subscribe EIPs Fun to receive the latest updates of EIPs Good for Buidlers to follow up.

View all
Serve Ethereum Builders, Scale the Community.
Resources
GitHub
Supported by