From 581d31953cbd81e1a5e4ad0e397c0a1269ae384e Mon Sep 17 00:00:00 2001 From: Marc Harvey-Hill Date: Thu, 17 Oct 2024 17:00:51 +0100 Subject: [PATCH 1/4] intial commit --- EIPS/eip-txindex-opcode.md | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 EIPS/eip-txindex-opcode.md diff --git a/EIPS/eip-txindex-opcode.md b/EIPS/eip-txindex-opcode.md new file mode 100644 index 00000000000000..8013c4de9b9080 --- /dev/null +++ b/EIPS/eip-txindex-opcode.md @@ -0,0 +1,48 @@ +--- +title: TXINDEX opcode +description: Opcode to get index of transaction within block +author: Marc Harvey-Hill (@Marchhill), Ahmad Bitar (@smartprogrammer93) +discussions-to: +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 better support encrypted mempools in the protocol. In order to be secure, the validity of a transaction sent to an encrypted mempool should be tied to its correct inclusion by a proposer. This means that the transaction should only be valid if it is included at the correct slot, and the correct index within a block according to the encrypted mempool's ordering rules. This can be enforced in two ways: +- Enshrinement: a block will not be valid if it does not include encrypted mempool transactions in the correct order. +- Smart contract: encrypted mempool transactions invoke a smart contract that enforces inclusion in the correct order. If a single transaction is not included correctly, then all encrypted mempool transactions are invalidated. + +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 smart contract solutions could be used for experimentation until a design appropriate for enshrinement in protocol 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 + +TBD + +## Backwards Compatibility + +No backward compatibility issues found. + +## Test Cases + +TBD + +## Security Considerations + +TBD + +## Copyright + +Copyright and related rights waived via [CC0](../LICENSE.md). From 9fd19ed07e858ab81a4e138bbdd4ac34a195344a Mon Sep 17 00:00:00 2001 From: Marc Harvey-Hill Date: Mon, 21 Oct 2024 10:44:42 +0100 Subject: [PATCH 2/4] make motivation more concise --- EIPS/eip-txindex-opcode.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/EIPS/eip-txindex-opcode.md b/EIPS/eip-txindex-opcode.md index 8013c4de9b9080..c7f8de3da1a50f 100644 --- a/EIPS/eip-txindex-opcode.md +++ b/EIPS/eip-txindex-opcode.md @@ -15,11 +15,9 @@ This EIP proposes to add a new opcode that returns the index of the transaction ## Motivation -The new opcode aims to better support encrypted mempools in the protocol. In order to be secure, the validity of a transaction sent to an encrypted mempool should be tied to its correct inclusion by a proposer. This means that the transaction should only be valid if it is included at the correct slot, and the correct index within a block according to the encrypted mempool's ordering rules. This can be enforced in two ways: -- Enshrinement: a block will not be valid if it does not include encrypted mempool transactions in the correct order. -- Smart contract: encrypted mempool transactions invoke a smart contract that enforces inclusion in the correct order. If a single transaction is not included correctly, then all encrypted mempool transactions are invalidated. +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 smart contract solutions could be used for experimentation until a design appropriate for enshrinement in protocol is agreed upon. +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 @@ -29,6 +27,7 @@ Following the yellow paper spec, it should be considered part of `W_base` for ga ## Rationale + TBD ## Backwards Compatibility @@ -37,11 +36,12 @@ No backward compatibility issues found. ## Test Cases -TBD +N/A ## Security Considerations -TBD + +Needs discussion. ## Copyright From 2a069f97c5af7914070fd0237adb7fdfeca08804 Mon Sep 17 00:00:00 2001 From: Marc Harvey-Hill Date: Wed, 30 Oct 2024 23:45:57 +0000 Subject: [PATCH 3/4] EIP number and discussion thread --- EIPS/{eip-txindex-opcode.md => eip-7793.md} | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) rename EIPS/{eip-txindex-opcode.md => eip-7793.md} (94%) diff --git a/EIPS/eip-txindex-opcode.md b/EIPS/eip-7793.md similarity index 94% rename from EIPS/eip-txindex-opcode.md rename to EIPS/eip-7793.md index c7f8de3da1a50f..e84a691a98c36a 100644 --- a/EIPS/eip-txindex-opcode.md +++ b/EIPS/eip-7793.md @@ -1,8 +1,9 @@ --- +eip: 7793 title: TXINDEX opcode description: Opcode to get index of transaction within block author: Marc Harvey-Hill (@Marchhill), Ahmad Bitar (@smartprogrammer93) -discussions-to: +discussions-to: https://ethereum-magicians.org/t/eip-7793-txindex-opcode/21513 status: Draft type: Standards Track category: Core From 5f61797e260fa327c56bd7bde2187b9b46fa41a9 Mon Sep 17 00:00:00 2001 From: Ahmad Bitar <33181301+smartprogrammer93@users.noreply.github.com> Date: Thu, 31 Oct 2024 18:16:33 +0300 Subject: [PATCH 4/4] Update eip-7793.md --- EIPS/eip-7793.md | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/EIPS/eip-7793.md b/EIPS/eip-7793.md index e84a691a98c36a..f6b198efd18ea7 100644 --- a/EIPS/eip-7793.md +++ b/EIPS/eip-7793.md @@ -22,14 +22,29 @@ This proposal enables smart contract solutions to check their own transaction in ## 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. +### `TXINDEX` (`TBD`) -Following the yellow paper spec, it should be considered part of `W_base` for gas pricing. +A new opcode `TXINDEX` shall be created at `TBD`. It shall return one stack element. + +#### Output + +##### Stack + +| Stack | Value | +| ---------- | -------------| +| `top - 0` | `Index` | + +`Index` is a 4 byte uint in big endian encoding. + +#### Gas Cost + +The gas cost for `TXINDEX` is a fixed fee of `2` ## Rationale - -TBD +### Gas Price + +Similar opcodes are considered part of the `W_base` set. ## Backwards Compatibility