Skip to content

docs(tip-1040): epoch-scoped temporary storage precompile#3879

Open
decofe wants to merge 3 commits into
mainfrom
tip/1040-reopen
Open

docs(tip-1040): epoch-scoped temporary storage precompile#3879
decofe wants to merge 3 commits into
mainfrom
tip/1040-reopen

Conversation

@decofe
Copy link
Copy Markdown
Member

@decofe decofe commented May 10, 2026

Reopened from #3366 for renewed discussion.

TIP-1040: Epoch-Scoped Temporary Storage

Approach: Epoch-based expiring storage. Values written in epoch E are readable in epochs E and E+1, then automatically expire.

Key design points

  • Epochs are 2^16 blocks (~18 hours at 1s blocks). Current + previous epoch storage are live; older epochs prunable.
  • Storage slot = keccak256(sender || key) in a per-epoch account — sender-isolated, no collisions.
  • temporaryStore: 40k gas for new slots, SSTORE-equivalent for overwrites.
  • temporaryLoad: EIP-2929 cold/warm model (2,100 / 100 gas), falls back to previous epoch.
  • Pruning: drop entire epoch account in one operation — no slot scanning.

Tradeoffs vs TIP-1048 (MEV-based)

  • ✅ Simpler — no cleanup transactions needed, automatic expiry
  • ✅ Bounded state — at most 2 epoch accounts at any time
  • ❌ Cannot support arbitrary expiry times (fixed ~18h–36h window)
  • ❌ More involved Reth changes (per-epoch account management)

See thread discussion: https://tempoxyz.slack.com/archives/C0A761BDJ6P/p1774624334588709

cc @klkvr @dankrad

Reopened from #3366. Epoch-based expiring storage with automatic pruning.
Values live for 2^16 to 2^17 blocks, scoped per epoch account.

Amp-Thread-ID: https://ampcode.com/threads/T-019e12a5-b71d-72db-afef-0fcd16f065d5
Key changes from original:
- temporaryStore now takes numEpochs (1-512) for configurable lifetime
- Tiered gas pricing: 20k (1 epoch) -> 250k (181-512 epochs)
- temporaryLoad scans backwards from current epoch to find live entries
- New temporaryLoadExpiry returns value + remaining lifetime
- MAX_EXPIRY_EPOCHS=512 covers ~1 year at 1s blocks
- Pruning remains deterministic: epoch account E droppable when
  current_epoch > E + MAX_EXPIRY_EPOCHS

Motivated by MPP session duration flexibility.

Amp-Thread-ID: https://ampcode.com/threads/T-019e12a5-b71d-72db-afef-0fcd16f065d5
… (day/week/month/year)

Replaces the variable numEpochs + backward-scanning design with four
fixed epoch tiers. Each tier uses the original simple 2-epoch model
(current + previous), eliminating:
- Backward scan across up to 512 epoch accounts on load
- Per-entry metadata slot for individual expiry tracking
- Unpredictable load gas costs

Tiers: day (~18h, 20k gas), week (~6d, 80k), month (~24d, 160k),
year (~388d, 250k). At most 8 live epoch accounts total (2 per tier).

Amp-Thread-ID: https://ampcode.com/threads/T-019e2218-8522-7664-9b02-c1f731c33f19
@decofe decofe force-pushed the tip/1040-reopen branch from 034c0b9 to c6e3624 Compare May 13, 2026 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant