-
Notifications
You must be signed in to change notification settings - Fork 204
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
TrieRecreate refactor #6018
TrieRecreate refactor #6018
Conversation
…factor # Conflicts: # integrationTests/benchmarks/loadFromTrie_test.go # integrationTests/state/stateTrie/stateTrie_test.go # process/peer/process.go # state/accountsDB_test.go # state/interface.go # state/storagePruningManager/storagePruningManager_test.go
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## rc/v1.7.next1 #6018 +/- ##
=================================================
- Coverage 78.83% 78.74% -0.10%
=================================================
Files 752 752
Lines 98254 97976 -278
=================================================
- Hits 77461 77153 -308
- Misses 15559 15584 +25
- Partials 5234 5239 +5 ☔ View full report in Codecov by Sentry. |
@@ -39,7 +48,7 @@ func (holder *rootHashHolder) GetEpoch() core.OptionalUint32 { | |||
|
|||
// String returns rootHashesHolder as a string | |||
func (holder *rootHashHolder) String() string { | |||
return fmt.Sprintf("root hash %s, epoch %v, has value %v", holder.rootHash, holder.epoch.Value, holder.epoch.HasValue) | |||
return fmt.Sprintf("root hash %s, epoch %v, has value %v", hex.EncodeToString(holder.rootHash), holder.epoch.Value, holder.epoch.HasValue) |
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.
👍
@@ -258,15 +258,13 @@ func (service *SCQueryService) recreateTrie(blockRootHash []byte, blockHeader da | |||
|
|||
accountsAdapter := service.blockChainHook.GetAccountsAdapter() | |||
|
|||
rootHashHolder := holders.NewDefaultRootHashesHolder(blockRootHash) |
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.
👍 👍 👍
RecreateTrieCalled: func(options common.RootHashHolder) error { | ||
if options.GetEpoch().HasValue { | ||
recreateTrieWasCalled = false | ||
recreateTrieFromEpochWasCalled = true |
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.
After the refactor, a slightly better name would be recreateTrieWasCalledWithEpoch
.
|
||
// RecreateTrieFromEpoch won't do anything as write operations are disabled on this component | ||
func (r *simulationAccountsDB) RecreateTrieFromEpoch(_ common.RootHashHolder) error { | ||
func (r *simulationAccountsDB) RecreateTrie(_ common.RootHashHolder) error { |
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.
In the future, we can enable this for transaction simulation, as well (historical simulations).
wasCalled = true | ||
return nil | ||
}, | ||
}, createBlockInfoProviderStub(dummyRootHash)) | ||
|
||
err := accountsApi.RecreateTrie(nil) | ||
err := accountsApi.RecreateTrie(holders.NewDefaultRootHashesHolder([]byte{})) |
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.
is there any difference between nil and empty root hash when recreating the trie?
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.
No, we check len(rootHash)
which is 0 for both nil and empty
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.
Tested via Rosetta checker on shard 0, mainnet.
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.
Normal allin test: v1.6.15-dev-config-eb2e06c06d -> recreate-trie-refactor-de374b55f2
--- Specific errors ---
block hash does not match 1688
wrong nonce in block 893
miniblocks does not match 0
num miniblocks does not match 0
miniblock hash does not match 0
block bodies does not match 0
receipts hash missmatch 0
/------/
--- Statistics ---
Nr. of all ERRORS: 1
Nr. of all WARNS: 261
Nr. of new ERRORS: 1
Nr. of new WARNS: 0
Nr. of PANICS: 0
/------/
--- ERRORS ---
/------/
--- WARNINGS ---
/------/
The base branch was changed.
Reasoning behind the pull request
Proposed changes
Testing procedure
Pre-requisites
Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:
feat
branch created?feat
branch merging, do all satellite projects have a proper tag insidego.mod
?