erigontech / erigontech/erigon

IBS 2-Cache Phase 5: Remove stateObject

Open
#19,704 1 comment 0 reactions 0 assignees View on GitHub
performance tech debt reduction
Dominant language
Go
Stars
3.6k
Forks
1.5k
Avg merge
1d 16h
Merged PRs (30d)
455

Description

Part of #19623 — Rationalize IntraBlockState to a 2-Cache Model.
Depends on #19703 (Phase 4).

## Goal

`IntraBlockState` holds no `stateObjects` map. All reads go through `versionMap`/storage reader; all writes go directly to `VersionedWrites`. The 4-cache architecture is reduced to 2: `VersionedIO`/`VersionMap` (intra-block MVCC) + `SharedDomains` (inter-block committed state).

## Changes

- Add to `IntraBlockState`:
- `codeCache map[Address][]byte` — replaces `stateObject.code` read-cache role
- `committedStorage map[Address]map[StorageKey]uint256.Int` — replaces `stateObject.originStorage`/`blockOriginStorage` for EIP-1283 original value tracking
- `GetCommittedState(addr, key)`: reads from `committedStorage` if cached; otherwise reads `versionMap` at `txIndex-1` (pre-tx value); populates `committedStorage` on first access.
- `GetCode(addr)`: reads from `codeCache`; populates from storage reader on miss.
- Remove from `IntraBlockState`: `stateObjects`, `stateObjectsDirty`, `nilAccounts`.
- Remove from `state_object.go`: `dirtyStorage`, `originStorage`, `blockOriginStorage`, all write-buffer fields (`data.Balance`, `data.Nonce`, `selfdestructed`, `dirtyCode`).
- Remove `state_object.go` entirely (or reduce to an empty file if still imported elsewhere during the transition cycle).

## New feature tests

- **`TestGetCommittedStateNoStateObject`** — assert EIP-1283 original values are correct when reading through `committedStorage`/`versionMap`, not `stateObject.originStorage`.
- **`TestCreatedContractFlagFromVersionedWrites`** — assert `newlyCreated` is correctly derived from presence of `IncarnationPath` write in current tx (no `stateObject` field).
- **`TestSSTOREGasCalcNoStateObject`** — end-to-end SSTORE gas calculation for cold/warm/original value cases (EIP-2200, EIP-2929), with no `stateObject`.
- **`TestCodeCacheHitMiss`** — verify `codeCache` is populated on first access and returned on subsequent reads, with no repeated storage reader calls.

## Regression tests

- **`TestSnapshotRandom`** (existing) — must still pass with the stateObject-free IBS.
- **`TestSnapshotRandomWithVersionMapExtended`** (Phase 4) — must still pass.
- **`TestJournalRevertWithVersionMap`** (Phase 4) — must still pass.
- Run **full `TestExecutionSpecBlockchain`** — all EEST blockchain test fixtures must pass.
- Run **`TestDeleteRecreateSlots`**, **`TestDeleteCreateRevert`** — existing chain-level regression tests.
- Run **`go test -race ./execution/state/... ./execution/stagedsync/...`** — no data races.
- Run **`make test-all`** — full test suite must pass.

## Files affected

- `execution/state/intra_block_state.go` — major rewrite (remove stateObjects, add codeCache/committedStorage)
- `execution/state/state_object.go` — removed
- `execution/state/journal.go` — any remaining stateObject references cleaned up

## Acceptance criteria

- `state_object.go` is deleted
- `stateObjects` map is removed from `IntraBlockState`
- Full EEST fixture suite passes
- `make test-all` passes
- `-race` test run is clean

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.