EIP-2733 Transaction package
No call decision · Account abstraction · EIP status Withdrawn · created 2020-06-16
An EIP that proposes bundling multiple transactions into a single new transaction type, executing them atomically in order, and passing results such as the success status and gas used of a preceding transaction to the next transaction.
Why it is needed
Bringing new users onto Ethereum required them to first obtain ether to pay gas fees, creating a barrier to entry. Meta-transactions, intended to solve this, were a fragile solution because they required recovering the signature inside the smart contract. In particular, the relay contracts that process meta-transactions had to forward only a partial amount of gas to subcalls in order to catch cases where an inner transaction reverted, a practice that has long been considered bad practice. This workflow also risked breaking outright if the gas schedule changed in the future. This EIP aims to build a more robust framework in which relayers can trustlessly pay for multiple users' transactions at once, by bundling multiple transactions into a package, executing them atomically, and allowing results to be passed between them.
What changes
Today
- Meta-transactions require the relay contract to manage nonces and recover signatures inside the contract
- Catching reverts requires forwarding only a partial amount of gas to subcalls
- Changes to the gas schedule risk breaking existing meta-transaction workflows
After EIP-2733
- A new transaction type (id=2) bundles multiple transactions into a package and executes them atomically in order
- The success status, gas used, and return value of a preceding transaction are passed to the next transaction via RETURNDATACOPY
- Each child transaction has its own nonce and signature, and can delegate the choice of gas price and limit to the package signer via max_gas_price
Who is affected
- Relayers and fee-sponsorship services: Multiple users' transactions can be bundled into a single package and processed trustlessly at once.
- Wallet & app developers: Conditional workflows that branch on the result of a previous transaction can be built without recovering signatures inside the contract.
- Client teams: New logic must be implemented in the mempool to validate packages as a unit and to track nonce invalidation among child transactions.
- Existing contracts: Contracts that use the pattern of checking whether ORIGIN equals CALLER and RETURNDATASIZE is 0 will always fail unless they are the first transaction in the package.
In depth
Transaction structure
A TransactionPackage consists of chain_id, children (a list of ChildPackage), nonce, gas_price, and the signature v, r, s. Each ChildPackage has type, nonce, transactions (a list of ChildTransaction), max_gas_price, and its own signature v, r, s. A ChildTransaction consists of the fields flags, to, value, data, extra, and gas_limit; in the current specification, flags and extra are always left empty (value 0, length 0). The hash of the entire package is keccak256(rlp([2, chain_id, children, nonce, gas_price, v, r, s])), and the hash to be signed, excluding v, r, s, is keccak256(rlp([2, chain_id, children, nonce, gas_price])).
Two types of child packages
The type field of a ChildPackage indicates whether the child signer delegates the choice of gas price and gas limit to the package signer. If type is 0x00, the signature hash includes max_gas_price and is signed as keccak256(rlp([0, nonce, transactions, max_gas_price])); if type is 0x01, it is signed using transactions_without_gas_limit, which excludes the gas limit, as keccak256(rlp([1, nonce, transactions_without_gas_limit])). This is intended for interactions with trusted relayers, allowing a user to sign a transaction and have the relayer choose the optimal gas price and limit before including it on-chain.
Validity check
The is_valid function checks the following: chain_id must match the config, children must not be empty, and the package signer's nonce must equal tx.nonce - 1. The sum of the gas_limit of all child transactions multiplied by gas_price, plus the package's own intrinsic_gas, must not exceed the package signer's balance. Each ChildPackage must match its own signer's nonce, its value must not exceed that signer's balance, and it is invalid if max_gas_price is lower than the package's gas_price. Each ChildTransaction must have flags equal to 0 and extra empty, and gas_limit must be at least intrinsic_gas.
Receipts and result passing
After each ChildTransaction executes, a ChildReceipt (status, cumulative_gas_used, logs_bloom, logs) is generated, and the overall Receipt is the list of these ChildReceipts. The result of the preceding transaction is computed as a Result structure (success, gas_used, cum_gas_used, return_size, return_value) and made available for reading via RETURNDATACOPY (0x3E) in the next transaction's first execution frame. Every field except the last is zero-padded on the left to 32 bytes.
Intrinsic gas cost
The package's intrinsic_gas is calculated as the sum of the data costs of all transactions belonging to all child packages, plus a fixed cost of 17000 and 8000 per child package. That is, intrinsic_gas = 17000 + 8000 * children.len() + data_gas. This value is used both to check the package signer's balance and to check the minimum gas_limit of each ChildTransaction.
Design choice: separate signatures per child
For the sake of simplicity, the author chose to have each child package carry its own separate signature, even when the child signer is the same person as the package signer. This choice minimizes client changes while providing maximum flexibility; even a single user acting alone only needs to accept the cost of one extra signature recovery. Allowing max_gas_price to specify a range rather than a fixed price is likewise a choice meant to give relayers the flexibility to find the optimal price on the user's behalf.
Backward compatibility and mempool security
Contracts that use the pattern of checking ORIGIN(0x32) == CALLER(0x33) and RETURNDATASIZE(0x3D) == 0 will always fail, since this condition becomes false unless the transaction is the first one in the package. The source states that it is unknown whether such contracts actually exist in practice. Meanwhile, to prevent the new transaction type from becoming a mempool DDoS vector, packages are designed so that the is_valid function can verify them in constant time, and the 10Mb limit of an RLPx frame can serve as a natural upper bound on package size, or clients can impose their own lower limit. Validated packages must continue to be monitored for internal nonce invalidation, and the author proposes implementing the mempool using a pointer structure in which each part of the package points to the others.
Status: Withdrawn
This EIP is in Withdrawn status. The author withdrew it, stating in the withdrawal-reason that EIP-3074 was chosen as the preferred solution over transaction packages. The specification described here was therefore never actually adopted or included in a fork.