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 from fa90bb4 to 7141eaa Compare December 1, 2025 14:52
@MaksymMalicki MaksymMalicki force-pushed the maksym/state-refactor-2-clean branch 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): {},

@MaksymMalicki MaksymMalicki force-pushed the maksym/state-refactor-2-clean branch from b9b068f to 2ad7d63 Compare December 4, 2025 09:48
@codecov
Copy link

codecov bot commented Dec 4, 2025

Codecov Report

❌ Patch coverage is 79.38596% with 47 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.26%. Comparing base (584e500) to head (0fcba84).

Files with missing lines Patch % Lines
core/state_reader.go 81.29% 15 Missing and 11 partials ⚠️
core/state.go 67.21% 15 Missing and 5 partials ⚠️
core/pending_state.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3291      +/-   ##
==========================================
+ Coverage   76.20%   76.26%   +0.06%     
==========================================
  Files         346      347       +1     
  Lines       32690    32722      +32     
==========================================
+ Hits        24912    24957      +45     
+ Misses       5987     5977      -10     
+ Partials     1791     1788       -3     

☔ 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