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

Feat/balance data tries #4636

Merged
merged 143 commits into from May 30, 2023
Merged

Feat/balance data tries #4636

merged 143 commits into from May 30, 2023

Conversation

BeniaminDrasovean
Copy link
Contributor

@BeniaminDrasovean BeniaminDrasovean commented Oct 24, 2022

Reasoning behind the pull request

  • The keys at which values are saved in a data trie are not random. Because of this, the data tries are not balanced, thus resulting in more intermediary nodes.

Proposed changes

  • When saving some data in the data trie, do not save at key but rather at hash(key). This way, the keys will be random, resulting in balanced data tries.
  • In order for this change to be backwards compatible, add Version field to trie nodes. Nodes that are accessed will be automatically migrated to the new version (where the storage key is hash(key))
  • Add a built in function that will migrate data trie nodes when it is called
  • Add a new API endpoint which will return true if the data trie of a specified account is fully migrated.

Testing procedure

  • Deploy a contract with some data before the activation of this feature. After the activation, access all the keys and check that they are automatically migrated.
  • Deploy a contract with some data before the activation of this feature. Use the built in function to migrate the data trie after the feature is active.
  • Check that the data that is added after the feature is active is saved in the trie by using the new version.

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?

BeniaminDrasovean and others added 30 commits October 24, 2022 14:51
…ata-trie

Add hasher to trackable data trie
…ie-tracker

Add marshaller to data trie tracker
….4.0-to-feat/balance-data-tries

# Conflicts:
#	integrationTests/testInitializer.go
#	integrationTests/vm/testInitializer.go
#	state/trackableDataTrie_test.go
…eat/balance-data-tries

28.10 merge rc/1.4.0 to feat/balance data tries
…data-trie

Enable epochs handler to data trie
# Conflicts:
#	epochStart/metachain/systemSCs.go
#	integrationTests/testProcessorNode.go
#	node/node.go
#	node/trieIterators/delegatedListProcessor.go
#	node/trieIterators/directStakedListProcessor.go
#	node/trieIterators/stakeValuesProcessor.go
remove key size from total leaf size computation
BeniaminDrasovean and others added 8 commits May 23, 2023 10:25
…in-feat/balance-data-tries-23may

# Conflicts:
#	api/errors/errors.go
#	api/mock/facadeStub.go
#	common/enablers/enableEpochsHandler.go
#	common/enablers/enableEpochsHandler_test.go
#	common/enablers/epochFlags.go
#	common/interface.go
#	config/epochConfig.go
#	errors/errors.go
#	facade/initial/initialNodeFacade_test.go
#	facade/mock/nodeStub.go
#	factory/processing/processComponents.go
#	factory/statusCore/statusCoreComponents_test.go
#	go.mod
#	go.sum
#	integrationTests/interface.go
#	outport/factory/notifierFactory_test.go
#	outport/notifier/eventNotifier_test.go
#	sharding/mock/enableEpochsHandlerMock.go
#	testscommon/components/default.go
#	testscommon/enableEpochsHandlerMock/enableEpochsHandlerStub.go
#	trie/trieStorageManager_test.go
#	vm/systemSmartContracts/governance_test.go
#	vm/systemSmartContracts/validator_test.go
…nce-data-tries-23may

Merge rc/v1.6.0 in feat/balance data tries 23may
…in-feat/balance-data-tries-24may

# Conflicts:
#	dataRetriever/factory/storageRequestersContainer/baseRequestersContainerFactory.go
#	dataRetriever/factory/storageRequestersContainer/metaRequestersContainerFactory.go
#	dataRetriever/factory/storageRequestersContainer/shardRequestersContainerFactory.go
#	epochStart/metachain/baseRewards_test.go
#	epochStart/metachain/systemSCs_test.go
#	errors/errors.go
#	factory/processing/blockProcessorCreator_test.go
#	factory/state/stateComponents.go
#	genesis/process/genesisBlockCreator.go
#	genesis/process/genesisBlockCreator_test.go
#	go.mod
#	go.sum
#	integrationTests/benchmarks/loadFromTrie_test.go
#	integrationTests/state/stateTrieClose/stateTrieClose_test.go
#	integrationTests/testProcessorNode.go
#	integrationTests/vm/testInitializer.go
#	state/accountsDB.go
#	state/syncer/errors.go
#	testscommon/components/components.go
#	trie/branchNode.go
#	trie/branchNode_test.go
#	trie/doubleListSync_test.go
#	trie/errors.go
#	trie/extensionNode.go
#	trie/extensionNode_test.go
#	trie/factory/trieCreator.go
#	trie/factory/trieCreator_test.go
#	trie/interface.go
#	trie/leafNode.go
#	trie/patriciaMerkleTrie.go
#	trie/patriciaMerkleTrie_test.go
#	trie/trieStorageManager_test.go
#	update/genesis/import.go
…in-feat/balance-data-tries-24may

# Conflicts:
#	go.mod
#	go.sum
…nce-data-tries-24may

Merge rc/v1.6.0 in feat/balance data tries 24may
BeniaminDrasovean and others added 9 commits May 25, 2023 14:09
…poch

change epoch in which autoBalanceDataTries is enabled
…nce-data-tries-29may

# Conflicts:
#	common/enablers/enableEpochsHandler.go
#	common/enablers/epochFlags.go
#	common/interface.go
#	go.mod
#	go.sum
#	sharding/mock/enableEpochsHandlerMock.go
#	testscommon/enableEpochsHandlerMock/enableEpochsHandlerStub.go
…es-29may

Update feat/balance data tries 29may
@BeniaminDrasovean BeniaminDrasovean marked this pull request as ready for review May 30, 2023 09:36
Copy link
Collaborator

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

System test passed

@BeniaminDrasovean BeniaminDrasovean merged commit 37f967b into rc/v1.6.0 May 30, 2023
6 checks passed
@BeniaminDrasovean BeniaminDrasovean deleted the feat/balance-data-tries branch May 30, 2023 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants