EIP-7793 Conditional Transactions
No call decision · Security & privacy · EIP status Stagnant · created 2024-10-17
Introduces a new transaction type that is only valid at a specific slot and index within a block, along with a TXINDEX opcode that lets contracts read that index.
Why it is needed
An encrypted mempool is a structure that accepts transactions with their contents encrypted and determines their inclusion order before the contents are revealed. Once the order is set, the decrypted transactions are included at the front of the block. The problem is that the builder assembling the block is not guaranteed to respect this order. If a builder sees the contents of a decrypted transaction and inserts its own transaction ahead of it, this enables frontrunning, profiting by cutting in front of someone else's trade. This proposal introduces conditional transactions that declare in advance that they are valid only at a specific position within a specific slot. If a decrypted transaction is not included at its promised index, the transaction itself becomes invalid, making it impossible for a builder to violate the ordering.
What changes
Today
- There is no way to force builders to respect the inclusion order set by an encrypted mempool.
- Builders can frontrun by inserting other transactions ahead of a decrypted transaction.
- There is no way to pin down in advance which position within a block a transaction must occupy.
After EIP-7793
- A transaction can specify in advance the slot and in-block index at which it is valid.
- A conditional transaction not included at its designated position becomes invalid, making reordering impossible.
- The TXINDEX opcode lets a contract read the index value of a conditional transaction from within the contract.
Who is affected
- Users: Protection from builder frontrunning when using an encrypted mempool.
- Wallet & app developers: Support must be added for creating and signing the new transaction type (0x05).
- Client teams: Validation of the new transaction format and the TXINDEX opcode must be implemented.
- Builders / block producers: Conditional transactions must be placed at their designated slot and index; violating this invalidates the transaction.
In depth
New transaction type and field structure
Defines a new transaction with TransactionType COND_TX_TYPE (0x05) under the EIP-2718 scheme. The TransactionPayload is the RLP serialization of [chain_id, nonce, max_priority_fee_per_gas, max_fee_per_gas, gas_limit, to, value, data, access_list, max_fee_per_blob_gas, blob_versioned_hashes, conditional_slot, conditional_tx_index, y_parity, r, s]. chain_id through max_fee_per_blob_gas carry the same meaning as in EIP-4844. blob_versioned_hashes is also the same as in EIP-4844, except that an empty list is allowed for conditional transactions.
conditional_slot and conditional_tx_index
Both fields are uint64 and specify the slot and transaction index at which this transaction is valid, respectively. Validating conditional_slot requires the slot number to be present in the block header, so EIP-7843, which adds the slot number to the header, is listed as a dependency (requires). Both fields use -1 as a sentinel value; when a field is -1, the corresponding slot or index check is skipped. This means it is possible to specify only the slot or only the index.
Signature scheme
The signature values y_parity, r, and s are computed as a secp256k1 signature over the digest keccak256(COND_TX_TYPE || rlp([chain_id, nonce, max_priority_fee_per_gas, max_fee_per_gas, gas_limit, to, value, data, access_list, max_fee_per_blob_gas, blob_versioned_hashes, conditional_slot, conditional_tx_index])). Because conditional_slot and conditional_tx_index are included in what gets signed, no one can alter the conditions after signing.
TXINDEX opcode
Adds a new opcode, TXINDEX, at TXINDEX_OPCODE_BYTE (0x4c). When executed, it pushes a single TransactionIndex onto the stack. TransactionIndex is a big-endian-encoded uint64 that equals conditional_tx_index if the current transaction is a conditional transaction, and -1 otherwise. The gas cost is the fixed TXINDEX_OPCODE_GAS (2), priced to match similar opcodes in the W_base set.
Why a new transaction type
An alternative would be to skip creating a new type and simply add an opcode that returns the current transaction index. However, that would let contracts dynamically change their behavior based on the returned index value, creating complex constraints that make block building harder. A new transaction type forces the expected index to be statically declared in advance, avoiding this problem. This is the reason the new type was chosen.
Current status
This proposal's status is Stagnant; discussion has stalled and it is not a finalized specification. Its content may change or be abandoned. The original text states that no backwards compatibility issues have been found. The Test Cases and Security Considerations sections are empty, marked N/A and None respectively. There is no record of a decision to include it in a fork from core dev calls.