Skip to content

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.

return fmt.Errorf("get contract nonce: %v", err)
}
p.stateDiff.Nonces[*contractAddress] = currentNonce.Add(&currentNonce, feltOne)
p.stateDiff.Nonces[*contractAddress] = currentNonce.Add(&currentNonce, &felt.One)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're unsure if the felt is eventually modified, we should consider copying it.

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
Comment on lines +28 to +29
*felt.NewFromUint64[felt.Felt](1): {},
*felt.NewFromUint64[felt.Felt](2): {},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
*felt.NewFromUint64[felt.Felt](1): {},
*felt.NewFromUint64[felt.Felt](2): {},
felt.FromUint64[felt.Felt](1): {},
felt.FromUint64[felt.Felt](2): {},

@codecov
Copy link

codecov bot commented Dec 4, 2025

Codecov Report

❌ Patch coverage is 77.55102% with 55 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.26%. Comparing base (2a873f5) to head (0d38a9e).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
core/state_reader.go 78.34% 19 Missing and 15 partials ⚠️
core/state.go 66.10% 15 Missing and 5 partials ⚠️
core/pending_state.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3291      +/-   ##
==========================================
+ Coverage   76.14%   76.26%   +0.12%     
==========================================
  Files         349      350       +1     
  Lines       32937    33117     +180     
==========================================
+ Hits        25079    25256     +177     
+ Misses       6067     6055      -12     
- Partials     1791     1806      +15     

☔ 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.

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.

3 participants