Skip to content

refactor(state): split the old state into state reader and state writer structs#3291

Open
MaksymMalicki wants to merge 9 commits intomainfrom
maksym/state-refactor-2-clean
Open

refactor(state): split the old state into state reader and state writer structs#3291
MaksymMalicki wants to merge 9 commits intomainfrom
maksym/state-refactor-2-clean

Conversation

@MaksymMalicki
Copy link
Contributor

@MaksymMalicki MaksymMalicki commented Nov 21, 2025

This PR introduces the following change. The current implementation of the State gets split into two structs:

  • StateReader - a structure, which sole purpose is reading the state. It's fed with db.KeyValueReader to enforce read-only mode for the state. Eventually we want to feed it only with the db.Snapshot. It is going to be mainly used during the RPC requests.
  • State - a structure which purpose is reading and writing. The StateReader is a part of it. It is used during the synchronisation and execution. Currently it runs using an IndexedBatch, but eventually we want to feed it with an IndexedBatch-like structure, which will contain a write layer and db.Snapshot for reads.

Base automatically changed from maksym/trie-refactor-1 to main November 25, 2025 16:25
@MaksymMalicki MaksymMalicki force-pushed the maksym/state-refactor-2-clean branch 2 times, most recently from 7141eaa to b9b068f Compare December 1, 2025 15:24
@codecov
Copy link

codecov bot commented Dec 4, 2025

Codecov Report

❌ Patch coverage is 72.98387% with 67 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.96%. Comparing base (27e3453) to head (1abc350).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
core/state_reader.go 80.62% 18 Missing and 13 partials ⚠️
core/state.go 54.00% 8 Missing and 15 partials ⚠️
core/trie/proof.go 0.00% 4 Missing and 3 partials ⚠️
core/pending_state.go 0.00% 2 Missing ⚠️
core/trie/trie.go 84.61% 0 Missing and 2 partials ⚠️
core/contract.go 88.88% 0 Missing and 1 partial ⚠️
rpc/v8/storage.go 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3291      +/-   ##
==========================================
- Coverage   75.98%   74.96%   -1.03%     
==========================================
  Files         377      378       +1     
  Lines       34614    34950     +336     
==========================================
- Hits        26301    26199     -102     
- Misses       6466     6719     +253     
- Partials     1847     2032     +185     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@MaksymMalicki MaksymMalicki force-pushed the maksym/state-refactor-2-clean branch from 0d38a9e to 8f413db Compare February 4, 2026 16:07
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.

2 participants