Skip to content
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

Add EIP: TXINDEX opcode #8981

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 2 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
48 changes: 48 additions & 0 deletions EIPS/eip-txindex-opcode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
Marchhill marked this conversation as resolved.
Show resolved Hide resolved
title: TXINDEX opcode
description: Opcode to get index of transaction within block
author: Marc Harvey-Hill (@Marchhill), Ahmad Bitar (@smartprogrammer93)
discussions-to: <URL>
Marchhill marked this conversation as resolved.
Show resolved Hide resolved
status: Draft
type: Standards Track
category: Core
created: 2024-10-17
---

## Abstract

This EIP proposes to add a new opcode that returns the index of the transaction being executed within the current block.

## Motivation

The new opcode 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

The instruction `TXINDEX` is introduced at `TBD`. The opcode pushes the transaction index as 4 byte uint in big endian encoding to the top of the stack.

Following the yellow paper spec, it should be considered part of `W_base` for gas pricing.

## Rationale

<!-- TODO -->
TBD

## Backwards Compatibility

No backward compatibility issues found.

## Test Cases

N/A

## Security Considerations

<!-- TODO -->
Needs discussion.

## Copyright

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