ERC-7796 Conditional transaction submission RPC (Conditional send transaction RPC)
Review · Other · created 2024-04-16
Defines a JSON-RPC method that lets a sender attach a precondition, saying 'only include this in a block if this condition holds,' alongside the transaction. This lets block builders determine inclusion without running expensive simulations.
Why it is needed
With today's private block builder APIs (e.g., the Flashbots API), builders must simulate transactions one by one to figure out whether they can be included in a block. This is CPU-intensive and inefficient. The existing API also has no way to tell the builder about dependencies between different transactions. As a result, the only way to guarantee freedom from interference by other transactions is to place your transaction in the first slot of the block, which makes that slot disproportionately popular and expensive. Conversely, no guarantees can be made for the remaining slots, so they must be priced low. Because dependencies are hard to determine, finding the optimal transaction ordering itself becomes a computationally expensive task. Attaching inclusion conditions directly to transactions can reduce this burden.
In depth
Method structure: two parameters, transaction and options
The new JSON-RPC method eth_sendRawTransactionConditional takes two parameters. The first, transaction, is the signed raw transaction data, the same as in eth_sendRawTransaction. The second, options, is an object containing the conditions for the transaction to be included, and may have the members knownAccounts, blockNumberMin, blockNumberMax, timestampMin, timestampMax, and paysCoinbase, all of which are optional. paysCoinbase is a value the caller declares as the minimum amount this transaction pays to the coinbase, combining the gas fee and any direct transfer.
knownAccounts: specifying account state as a condition
knownAccounts is a mapping keyed by account address. If the value is a hex string, it represents that account's known storage root hash. If the value is an object, it is a mapping of the form "slot": "value", specifying in hex the exact value each slot must hold. Special keys can also be used inside the object. balance is the expected balance, nonce is the expected nonce, and code is the expected code. Using "" for code means the address must have no code, and using the "0xef0100" prefix means a specific EIP-7702 delegation is expected.
Builder validation procedure and rejection rules
Before accepting a request, the block builder or sequencer SHOULD check the following. If a block range is specified, verify the block number falls within that range; if a timestamp range is specified, verify the block timestamp falls within that range. For every address with a specified storage root hash, verify the current root is unchanged, and for every address with a specified slot-value mapping, verify those slots hold exactly the specified values. If any of these is not satisfied, the sequencer SHOULD REJECT the request.
Return value and error codes
If the conditions pass and the transaction is accepted, the hash of the newly submitted transaction is returned, just as with eth_sendRawTransaction. If condition validation fails immediately, an error describing the cause of failure must be returned; the error code is "-32003 transaction rejected" along with a description of the cause, such as a storage error or an exceeded block/time range. If failures recur, or if the knownAccounts mapping is too large for the builder to process, a "-32005 limit exceeded" code and description must be returned. Even if the transaction enters the builder's internal mempool without error, block inclusion is not guaranteed, so the caller MUST NOT assume inclusion and must keep watching the blockchain. A block reorganization could still cause the transaction to be dropped or fail.
Rationale for allowing only exact values
knownAccounts can only specify exact values for storage slots. Allowing a range such as minValue or maxValue on a slot would be useful in some cases, but it would greatly increase the API's complexity. It is also not easy for the transaction sender to compute the valid range of a slot's value in the first place. If a more complex condition is needed, it can be expressed by specifying the paysCoinbase parameter and triggering a transfer to the coinbase address under specific conditions.
Compatibility and proposal status
Since this proposal adds a new API method, no backward compatibility issues are expected. However, existing non-standard implementations of eth_sendRawTransactionConditional may need modification to be compatible with this standard. This proposal's current status is Review, meaning it is still under review and its content may change.
Things to watch out for
- Denial-of-service attacks via mass submission of requests destined to fail: Maliciously submitting a large volume of requests that are certain to fail can cause a denial of service against the block builder. Builders must protect themselves against API abuse.
- Per-sender rate limiting (throttling): Builders should impose a maximum RPC call rate allowed per sender. The allowance increases when transactions are successfully included and decreases when rejections recur.
- Time-based storage validation: Run storage validation not only against the current block but also against the state history of the past N seconds. This prevents the API from being abused for MEV while still allowing it to be used for ERC-4337 account validation.
- UserOperation validation: A sequencer serving ERC-4337 use cases can reduce abuse by checking whether the submitted UserOperation exists in the public mempool and rejecting the transaction if it does not.