-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor state and contract modules #2224
base: main
Are you sure you want to change the base?
Conversation
a9715c7
to
7670cbc
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2224 +/- ##
==========================================
- Coverage 75.63% 75.35% -0.28%
==========================================
Files 104 103 -1
Lines 11102 11168 +66
==========================================
+ Hits 8397 8416 +19
- Misses 2073 2104 +31
- Partials 632 648 +16 ☔ View full report in Codecov by Sentry. |
7670cbc
to
6a76c92
Compare
commit f5dc02c Author: Kirill <paltsev.kir@gmail.com> Date: Thu Oct 17 11:15:15 2024 +0400 Small restructure of plugin logic (#2221) commit b43c46f Author: Rian Hughes <rian.hughes@physics.ox.ac.uk> Date: Wed Oct 16 15:42:07 2024 +0300 Support plugins (#2051) Co-authored-by: rian <rian@physics.ox.ac.uk> Co-authored-by: LordGhostX <solomonghost9@gmail.com> commit ca006de Author: Kirill <paltsev.kir@gmail.com> Date: Wed Oct 16 16:14:16 2024 +0400 Replace UnmarshalJSON() with UnmarshalText() for transaction statuses (#2220) * Replace UnmarshalJSON() with UnmarshalText() for transaction statuses UnmarshalText avoids issues with forgetting quotes in JSON, making it simpler for parsing plain text values. fix merge conflicts
25465ba
to
c466cca
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
state.go
was hard to review I guess because of the method re-ordering and diff looks weird.
Only some minor comments
} | ||
|
||
if oldValue != nil { | ||
if err = cb(&key, oldValue); err != nil { | ||
if oldVal != nil && logChanges { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checks the 2nd cond only if we care of logging
if oldVal != nil && logChanges { | |
if logChanges && oldVal != nil { |
@@ -1,134 +0,0 @@ | |||
package core |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have the functionality to read contract's historical data now?
I saw we log old values but can we read?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Ok they're implemented in state,go
assert.Equal(t, replacedVal, nonce) | ||
|
||
require.NoError(t, state.Revert(2, nonceStateUpdate)) | ||
nonce, sErr = state.ContractNonce(new(felt.Felt).Set(&su1FirstDeployedAddress)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need to pass a cloned value instead of the original (su1FirstDeployedAddress
)
It's a bit hard to read 🤔
Also new(felt.Felt).SetUint64(n)
👇 bellow
Description
This PR has 2 major changes:
Combine
ContractNonce
,ContractClassHash
, andContractDeploymentHeight
into a single bucket calledContract
.Separation of the contract fields in different buckets creates data duplication. Instead, we can encode them into a single object and store them in a single bucket. The slight performance degradation of encoding/decoding is insignificant as the fields are small.
Migration codes are added along with the unit tests.
Refactor
State.Update
,State.Revert
and the removal ofhistory
.In the previous implementation, after applying each state diff (i.e. nonce, class hash, storage), the contract commitment is recalculated. This indicates that the higher the number of individual state diffs, the more times we need to recalculate the contract commitment.
In this new implementation, a contract's commitment is calculated only once after all state diffs are applied to a contract object. Now, the number of contract commitment calculations depends on the number of contracts updated.
Benchmark Results