Skip to content
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

Merged
merged 7 commits into from
Apr 16, 2024
Merged

Conversation

BeniaminDrasovean
Copy link
Contributor

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:

  • was the PR targeted to the correct branch?
  • if this is a larger feature that probably needs more than one PR, is there a feat branch created?
  • if this is a feat branch merging, do all satellite projects have a proper tag inside go.mod?

…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
@BeniaminDrasovean BeniaminDrasovean changed the title merge RecreateTrie and RecreateTrieFromEpoch TrieRecreate refactor Mar 6, 2024
Copy link

codecov bot commented Mar 6, 2024

Codecov Report

Attention: Patch coverage is 68.18182% with 14 lines in your changes are missing coverage. Please review.

Project coverage is 78.74%. Comparing base (c3383ee) to head (de374b5).
Report is 61 commits behind head on rc/v1.7.next1.

❗ Current head de374b5 differs from pull request most recent head f9ee246. Consider uploading reports for the commit f9ee246 to get more accurate results

Files Patch % Lines
common/holders/rootHashHolder.go 20.00% 4 Missing ⚠️
genesis/process/metaGenesisBlockCreator.go 0.00% 2 Missing ⚠️
genesis/process/shardGenesisBlockCreator.go 0.00% 2 Missing ⚠️
process/peer/process.go 0.00% 2 Missing ⚠️
state/accountsDB.go 84.61% 2 Missing ⚠️
state/syncer/baseAccountsSyncer.go 0.00% 2 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

iulianpascalau
iulianpascalau previously approved these changes Mar 6, 2024
@@ -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)
Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 👍 👍

andreibancioiu
andreibancioiu previously approved these changes Mar 6, 2024
RecreateTrieCalled: func(options common.RootHashHolder) error {
if options.GetEpoch().HasValue {
recreateTrieWasCalled = false
recreateTrieFromEpochWasCalled = true
Copy link
Collaborator

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 {
Copy link
Collaborator

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

AdoAdoAdo
AdoAdoAdo previously approved these changes Mar 6, 2024
wasCalled = true
return nil
},
}, createBlockInfoProviderStub(dummyRootHash))

err := accountsApi.RecreateTrie(nil)
err := accountsApi.RecreateTrie(holders.NewDefaultRootHashesHolder([]byte{}))
Copy link
Contributor

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?

Copy link
Contributor Author

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

@BeniaminDrasovean BeniaminDrasovean marked this pull request as ready for review March 28, 2024 11:55
danidrasovean
danidrasovean previously approved these changes Mar 28, 2024
Copy link
Collaborator

@danidrasovean danidrasovean left a 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.

gabi-vuls
gabi-vuls previously approved these changes Apr 2, 2024
Copy link
Contributor

@gabi-vuls gabi-vuls left a 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 ---

/------/

@BeniaminDrasovean BeniaminDrasovean changed the base branch from rc/v1.7.0 to rc/v1.7.next1 April 2, 2024 08:12
@BeniaminDrasovean BeniaminDrasovean dismissed stale reviews from gabi-vuls, danidrasovean, iulianpascalau, AdoAdoAdo, and andreibancioiu April 2, 2024 08:12

The base branch was changed.

@BeniaminDrasovean BeniaminDrasovean merged commit 8ddbfc8 into rc/v1.7.next1 Apr 16, 2024
8 checks passed
@BeniaminDrasovean BeniaminDrasovean deleted the recreate-trie-refactor branch April 16, 2024 08:40
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.

6 participants