EIP-3534 · Stagnant · Core · 2021-04-20
EIP-3534: Restricted Chain Context Type Transactions
Proposed a typed transaction carrying a `chainContext` that limits where it is valid: only after a given ancestor block, only for (or never for) certain block producers, and only until a timestamp.
What problem does it solve?
A normal Ethereum transaction is valid in any block as long as its nonce, balance and signature check out. The sender cannot say:
- "only include me on the chain I'm looking at, after block X" (so it does not land on a competing fork or after a reorg changes history);
- "only let these miners include me", or "never these ones";
- "drop me if not mined by time T" (instead of waiting in the mempool indefinitely or paying to replace it).
EIP-3534 proposed letting a transaction state these conditions itself, enforced by consensus: a block containing a transaction whose conditions are not met would be invalid.
How it works
A new EIP-2718 transaction type 0x4 extends the EIP-2930 access-list format with one extra field:
0x04 || rlp([chainId, chainContext, nonce, gasPrice, gasLimit, to, value,
data, access_list, yParity, senderR, senderS])
chainContext is a one-byte bit-flag prefix followed by RLP-encoded values, in a fixed order:
| Flag | Subclass | Value | Rule |
|---|---|---|---|
1 |
ancestorId |
block number (big-endian, no leading zeros) + first 4 bytes of its hash | block must have this ancestor |
2 |
eligibleMinerList |
up to 3 addresses | beneficiary must be in the list |
4 |
ineligibleMinerList |
up to 3 addresses | beneficiary must not be in the list |
8 |
expiry |
unsigned integer timestamp | limits the block timestamp |
The prefix is the sum of the flags used, like Unix file permissions: 9 = ancestor + expiry. Allow and deny lists cannot be combined, so 6 and 15 are invalid.
ancestorId acts like a finer-grained EIP-155 chainId: it ties a transaction to one segment of one chain. chainId is kept anyway because the field is optional and chains that split share early history.
Sample code
Building an ancestorId and a chainContext (Python; values from the spec's test vectors):
import rlp # pyrlp
def ancestor_id(number: int, block_hash: bytes) -> bytes:
num = number.to_bytes((number.bit_length() + 7) // 8, "big") # b"" for genesis
return num + block_hash[:4]
h = bytes.fromhex("e78b1ec31bcb535548ce4b6ef384deccad1e7dc599817b65ab5124eeaaee3e58")
assert ancestor_id(15_000_000, h).hex() == "e4e1c0e78b1ec3"
assert ancestor_id(1, h).hex() == "01e78b1ec3"
ANCESTOR, ELIGIBLE, INELIGIBLE, EXPIRY = 1, 2, 4, 8
# "valid only after block 15,000,000 (e78b1ec3...) and before timestamp T"
prefix = ANCESTOR | EXPIRY # 9
chain_context = bytes([prefix]) + rlp.encode([ancestor_id(15_000_000, h), 1_700_000_000])
Things to know
- Status is Stagnant; it was never scheduled and
FORK_BLOCK_NUMBERis TBD. - Type
0x04has since been taken by EIP-7702 set-code transactions, so this draft's type number is no longer available. - The spec is inconsistent about
expiry: the definition calls it the maximum valid block timestamp, while one example describes it as a minimum. Any revival would need to settle this. - Only 4 bytes of the ancestor hash are used to save space. The spec estimates the collision chance as very low in normal conditions; on a collision the transaction is simply valid on both branches, as today.
- A miner on a deny list can dodge it by using a fresh beneficiary address. The new fields carry no gas cost, so nodes would rely on dropping unwanted transactions from their pool.
- The design predates the Merge and talks about miners; under proof-of-stake the equivalent would be the block's fee recipient.