EIP-1681 · Stagnant · Core · 2019-01-08
EIP-1681: Temporal Replay Protection
Proposed a `valid-until` timestamp on transactions, so a transaction that has not been included by a chosen time can never be mined or replayed later.
What problem does it solve?
An Ethereum transaction, once signed, stays valid until its nonce is used. That creates several headaches:
- During busy events (the spec mentions ICOs) a transaction can sit in the mempool for days and then execute long after the user stopped wanting it, still costing gas.
- Nodes have no shared rule for when to drop stale pending transactions.
- Some state-cleanup ideas, such as clearing empty "dust" accounts, would reset nonces and let old transactions be replayed. Preventing that by changing nonce rules is invasive.
EIP-1681 adds a simple expiry: the signer says "only valid before time T".
How it works
The rollout has two phases:
- Hard fork X: transactions gain an optional
valid-untilfield, auint64likenonce. If present, the transaction can only be included in a block whosetimestamp < valid-until. - Soft fork Y:
valid-untilbecomes mandatory; transactions without it are invalid.
Why wall-clock time instead of a block number (as an earlier proposal used):
- the signer always knows the current UTC time, even on an offline machine,
- the block number to time mapping drifts (hashrate, difficulty bomb), and is meaningless on testnets,
- "valid for two hours" is easier for people to choose than "valid for 514 blocks".
There is no maximum, so a user can still sign a transaction valid far into the future.
Sample code
Pseudocode for the inclusion check and the extended legacy RLP:
# legacy transaction with the optional extra field
tx = rlp.encode([
nonce, gas_price, gas_limit, to, value, data,
valid_until, # uint64 unix timestamp, new
v, r, s,
])
def can_include(tx, block):
if tx.valid_until is None:
return block.number < FORK_Y # mandatory after phase Y
return block.timestamp < tx.valid_until
A wallet would set it like this:
const validUntil = Math.floor(Date.now() / 1000) + 2 * 60 * 60; // two hours from now
Things to know
- Status is Stagnant. Ethereum transactions still have no protocol-level expiry; tools rely on nonce replacement to cancel stuck transactions.
- The field placement in the RLP above is illustrative; the spec does not fix the encoding. Since EIP-2718 typed transactions, any such field would more naturally live in a new transaction type. EIP-2711 (withdrawn) proposed one with an expiry.
- Phase Y would break pre-signed transactions kept on paper backups or gift cards, which is the main security trade-off the spec calls out.
- Many smart contracts implement their own deadline parameter (for example DEX swaps) to get the same effect at the application level.