Typed Transaction Envelope
EIP-2718 proposes a new transaction format that allows for multiple transaction types to be included in a single transaction. This is achieved by introducing a new envelope structure that wraps around the existing transaction data. The envelope includes a type field that specifies the type of transaction being included, as well as any additional data required by that transaction type. This allows for more flexibility in the types of transactions that can be included in a block, as well as enabling new features such as atomic swaps and cross-chain transactions. The proposal also includes changes to the transaction validation process to ensure that only valid transaction types are included in a block. Overall, EIP-2718 aims to improve the efficiency and functionality of the Ethereum network by introducing a more flexible and extensible transaction format.
Videos
Peep an EIP #11: EIP-2718 with Micah Zoltu
Original
Abstract
TransactionType || TransactionPayload
is a valid transaction and TransactionType || ReceiptPayload
is a valid transaction receipt where TransactionType
identifies the format of the transaction and *Payload
is the transaction/receipt contents, which are defined in future EIPs.
Motivation
In the past, when we have wanted to add new transaction types we have had to ensure they were backward compatible with all other transactions, meaning that you could differentiate them based only on the encoded payload, and it was not possible to have a transaction that matched both types.
This was seen in EIP-155 where the new value was bit-packed into one of the encoded fields.
There are multiple proposals in discussion that define new transaction types such as one that allows EOA accounts to execute code directly within their context, one that enables someone besides msg.sender
to pay for gas, and proposals related to layer 1 multi-sig transactions.
These all need to be defined in a way that is mutually compatible, which quickly becomes burdensome to EIP authors and to clients who now have to follow complex rules for differentiating transaction type.
By introducing an envelope transaction type, we only need to ensure backward compatibility with existing transactions and from then on we just need to solve the much simpler problem of ensuring there is no numbering conflict between TransactionType
s.
Specification
Definitions
||
is the byte/byte-array concatenation operator.
Transactions
As of FORK_BLOCK_NUMBER
, the transaction root in the block header MUST be the root hash of patriciaTrie(rlp(Index) => Transaction)
where:
Index
is the index in the block of this transactionTransaction
is eitherTransactionType || TransactionPayload
orLegacyTransaction
TransactionType
is a positive unsigned 8-bit number between0
and0x7f
that represents the type of the transactionTransactionPayload
is an opaque byte array whose interpretation is dependent on theTransactionType
and defined in future EIPsLegacyTransaction
isrlp([nonce, gasPrice, gasLimit, to, value, data, v, r, s])
All signatures for future transaction types SHOULD include the TransactionType
as the first byte of the signed data.
This makes it so we do not have to worry about signatures for one transaction type being used as signatures for a different transaction type.
Receipts
As of FORK_BLOCK_NUMBER
, the receipt root in the block header MUST be the root hash of patriciaTrie(rlp(Index) => Receipt)
where:
Index
is the index in the block of the transaction this receipt is forReceipt
is eitherTransactionType || ReceiptPayload
orLegacyReceipt
TransactionType
is a positive unsigned 8-bit number between0
and0x7f
that represents the type of the transactionReceiptPayload
is an opaque byte array whose interpretation is dependent on theTransactionType
and defined in future EIPsLegacyReceipt
isrlp([status, cumulativeGasUsed, logsBloom, logs])
The TransactionType
of the receipt MUST match the TransactionType
of the transaction with a matching Index
.
Rationale
TransactionType only goes up to 0x7f
For the forseable future, 0x7f is plenty and it leaves open a number of options for extending the range such as using the high bit as a continuation bit.
This also prevents us from colliding with legacy transaction types, which always start with a byte >= 0xc0
.
SHOULD instead of MUST for the TransactionType being first byte of signed data
While it is strongly recommended that all future transactions sign the first byte to ensure that there is no problem with signature reuse, the authors acknowledge that this may not always make sense or be possible. One example where this isn't possible is wrapped legacy transactions that are signature compatible with the legacy signing scheme. Another potential situation is one where transactions don't have a signature in the traditional sense and instead have some other mechanism for determining validity.
TransactionType selection algorithm
There was discussion about defining the TransactionType
identifier assignment/selection algorithm in this standard.
While it would be nice to have a standardized mechanism for assignment, at the time of writing of this standard there is not a strong need for it so it was deemed out of scope.
A future EIP may introduce a standard for TransactionType identifier assignment if it is deemed necessary.
Opaque byte array rather than an RLP array
By having the second byte on be opaque bytes, rather than an RLP (or other encoding) list, we can support different encoding formats for the transaction payload in the future such as SSZ, LEB128, or a fixed width format.
ORIGIN and CALLER
There was discussion about having ORIGIN and CALLER opcodes become dependent on the transaction type, so that each transaction type could define what those opcodes returned.
However, there is a desire to make transaction type opaque to the contracts to discourage contracts treating different types of transactions differently.
There also were concerns over backward compatibility with existing contracts which make assumptions about ORIGIN and CALLER opcodes.
Going forward, we will assume that all transaction types will have an address that reasonably represents a CALLER
of the first EVM frame and ORIGIN
will be the same address in all cases.
If a transaction type needs to supply additional information to contracts, they will need a new opcode.
Backwards Compatibility
Clients can differentiate between the legacy transactions and typed transactions by looking at the first byte.
If it starts with a value in the range [0, 0x7f]
then it is a new transaction type, if it starts with a value in the range [0xc0, 0xfe]
then it is a legacy transaction type.
0xff
is not realistic for an RLP encoded transaction, so it is reserved for future use as an extension sentinel value.
Security Considerations
When designing a new 2718 transaction type, it is STRONGLY recommended to include the transaction type as the first byte of the signed payload. If you fail to do this, it is possible that your transaction may be signature compatible with transactions of another type which can introduce security vulnerabilities for users.
Copyright
Copyright and related rights waived via CC0.
Adopted by projects
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