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

Dynamic gas data trie loads #4804

Merged
merged 30 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
59c6359
add dynamic gas cost for data trie load
BeniaminDrasovean Dec 13, 2022
2c855ff
Merge remote-tracking branch 'origin/rc/v1.5.0' into dynamic-gas-data…
BeniaminDrasovean Dec 13, 2022
79072f0
update EnableEpochHandler stubs
BeniaminDrasovean Dec 13, 2022
d85888a
fix failing test
BeniaminDrasovean Dec 14, 2022
20a5646
add MinimumGasCost to dynamicStorageLoad in gasSchedule
BeniaminDrasovean Jan 9, 2023
74cbbb8
Merge remote-tracking branch 'origin/rc/v1.5.0' into dynamic-gas-data…
BeniaminDrasovean Jan 9, 2023
770e23a
update go mod
BeniaminDrasovean Jan 9, 2023
aeede82
update all versions of the gasSchedule
BeniaminDrasovean Jan 17, 2023
4747049
Merge remote-tracking branch 'origin/rc/v1.5.0' into dynamic-gas-data…
BeniaminDrasovean Jan 18, 2023
21ba9e3
Merge remote-tracking branch 'origin/rc/v1.5.0' into dynamic-gas-data…
BeniaminDrasovean Feb 1, 2023
4ce0fcc
fix after merge
BeniaminDrasovean Feb 3, 2023
82abe4b
fix after review
BeniaminDrasovean Feb 27, 2023
2250981
Merge remote-tracking branch 'origin/rc/v1.6.0' into dynamic-gas-data…
BeniaminDrasovean Feb 27, 2023
894f87e
update go mod and fix after merge
BeniaminDrasovean Feb 27, 2023
9f8d485
fix linter issue
BeniaminDrasovean Feb 27, 2023
ed89cf5
do not run test with race flag
BeniaminDrasovean Feb 27, 2023
3788c7d
fix after review
BeniaminDrasovean Feb 28, 2023
6e04a25
fix linter issue
BeniaminDrasovean Feb 28, 2023
30f3dcf
fix after review
BeniaminDrasovean Mar 1, 2023
ac26233
Merge branch 'rc/v1.6.0' into dynamic-gas-data-trie-loads
BeniaminDrasovean Mar 1, 2023
38f6051
Merge branch 'rc/v1.6.0' into dynamic-gas-data-trie-loads
BeniaminDrasovean Mar 1, 2023
4c959a3
Merge remote-tracking branch 'origin/rc/v1.6.0' into dynamic-gas-data…
BeniaminDrasovean Jun 28, 2023
5c516f2
fix after merge
BeniaminDrasovean Jun 30, 2023
e1e2c83
Merge branch 'rc/v1.6.0' into dynamic-gas-data-trie-loads
ssd04 Jul 10, 2023
4c76bac
Merge remote-tracking branch 'origin/rc/v1.6.0' into dynamic-gas-data…
BeniaminDrasovean Aug 14, 2023
8b5e396
fix after merge
BeniaminDrasovean Aug 14, 2023
2a6908a
update go mod
BeniaminDrasovean Aug 16, 2023
9166ce4
Merge remote-tracking branch 'origin/rc/v1.6.0' into dynamic-gas-data…
BeniaminDrasovean Aug 18, 2023
0156022
go mod update
BeniaminDrasovean Aug 18, 2023
12a225a
update go mod with proper releases
BeniaminDrasovean Aug 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions cmd/node/config/enableEpochs.toml
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@
# FixDelegationChangeOwnerOnAccountEnableEpoch represents the epoch when the fix for the delegation system smart contract is enabled
FixDelegationChangeOwnerOnAccountEnableEpoch = 3

# DynamicGasCostForDataTrieStorageLoadEnableEpoch represents the epoch when dynamic gas cost for data trie storage load will be enabled
DynamicGasCostForDataTrieStorageLoadEnableEpoch = 3

# BLSMultiSignerEnableEpoch represents the activation epoch for different types of BLS multi-signers
BLSMultiSignerEnableEpoch = [
{ EnableEpoch = 0, Type = "no-KOSK" },
Expand Down
13 changes: 13 additions & 0 deletions cmd/node/config/gasSchedules/gasScheduleV1.toml
Original file line number Diff line number Diff line change
Expand Up @@ -812,3 +812,16 @@
MaxBuiltInCallsPerTx = 100
MaxNumberOfTransfersPerTx = 250
MaxNumberOfTrieReadsPerTx = 1500

# Quadratic, Linear and Constant are the coefficients for a quadratic func. Separate variables are used for the
# sign of each coefficient, 0 meaning positive and 1 meaning negative
# The current values for the coefficients were computed based on benchmarking.
# For the given coefficients, the minimum of the function must not be lower than MinimumGasCost
[DynamicStorageLoad]
QuadraticCoefficient = 688
SignOfQuadratic = 0
LinearCoefficient = 31858
SignOfLinear = 0
ConstantCoefficient = 15287
SignOfConstant = 0
MinimumGasCost = 10000
13 changes: 13 additions & 0 deletions cmd/node/config/gasSchedules/gasScheduleV2.toml
Original file line number Diff line number Diff line change
Expand Up @@ -812,3 +812,16 @@
MaxBuiltInCallsPerTx = 100
MaxNumberOfTransfersPerTx = 250
MaxNumberOfTrieReadsPerTx = 1500

# Quadratic, Linear and Constant are the coefficients for a quadratic func. Separate variables are used for the
# sign of each coefficient, 0 meaning positive and 1 meaning negative
# The current values for the coefficients were computed based on benchmarking.
# For the given coefficients, the minimum of the function must not be lower than MinimumGasCost
[DynamicStorageLoad]
QuadraticCoefficient = 688
SignOfQuadratic = 0
LinearCoefficient = 31858
SignOfLinear = 0
ConstantCoefficient = 15287
SignOfConstant = 0
MinimumGasCost = 10000
13 changes: 13 additions & 0 deletions cmd/node/config/gasSchedules/gasScheduleV3.toml
Original file line number Diff line number Diff line change
Expand Up @@ -812,3 +812,16 @@
MaxBuiltInCallsPerTx = 100
MaxNumberOfTransfersPerTx = 250
MaxNumberOfTrieReadsPerTx = 1500

# Quadratic, Linear and Constant are the coefficients for a quadratic func. Separate variables are used for the
# sign of each coefficient, 0 meaning positive and 1 meaning negative
# The current values for the coefficients were computed based on benchmarking.
# For the given coefficients, the minimum of the function must not be lower than MinimumGasCost
[DynamicStorageLoad]
QuadraticCoefficient = 688
SignOfQuadratic = 0
LinearCoefficient = 31858
SignOfLinear = 0
ConstantCoefficient = 15287
SignOfConstant = 0
MinimumGasCost = 10000
13 changes: 13 additions & 0 deletions cmd/node/config/gasSchedules/gasScheduleV4.toml
Original file line number Diff line number Diff line change
Expand Up @@ -812,3 +812,16 @@
MaxBuiltInCallsPerTx = 100
MaxNumberOfTransfersPerTx = 250
MaxNumberOfTrieReadsPerTx = 1500

# Quadratic, Linear and Constant are the coefficients for a quadratic func. Separate variables are used for the
# sign of each coefficient, 0 meaning positive and 1 meaning negative
# The current values for the coefficients were computed based on benchmarking.
# For the given coefficients, the minimum of the function must not be lower than MinimumGasCost
[DynamicStorageLoad]
QuadraticCoefficient = 688
SignOfQuadratic = 0
LinearCoefficient = 31858
SignOfLinear = 0
ConstantCoefficient = 15287
SignOfConstant = 0
MinimumGasCost = 10000
13 changes: 13 additions & 0 deletions cmd/node/config/gasSchedules/gasScheduleV5.toml
Original file line number Diff line number Diff line change
Expand Up @@ -812,3 +812,16 @@
MaxBuiltInCallsPerTx = 100
MaxNumberOfTransfersPerTx = 250
MaxNumberOfTrieReadsPerTx = 1500

# Quadratic, Linear and Constant are the coefficients for a quadratic func. Separate variables are used for the
# sign of each coefficient, 0 meaning positive and 1 meaning negative
# The current values for the coefficients were computed based on benchmarking.
# For the given coefficients, the minimum of the function must not be lower than MinimumGasCost
[DynamicStorageLoad]
QuadraticCoefficient = 688
SignOfQuadratic = 0
LinearCoefficient = 31858
SignOfLinear = 0
ConstantCoefficient = 15287
SignOfConstant = 0
MinimumGasCost = 10000
13 changes: 13 additions & 0 deletions cmd/node/config/gasSchedules/gasScheduleV6.toml
Original file line number Diff line number Diff line change
Expand Up @@ -812,3 +812,16 @@
MaxBuiltInCallsPerTx = 100
MaxNumberOfTransfersPerTx = 250
MaxNumberOfTrieReadsPerTx = 1500

# Quadratic, Linear and Constant are the coefficients for a quadratic func. Separate variables are used for the
# sign of each coefficient, 0 meaning positive and 1 meaning negative
# The current values for the coefficients were computed based on benchmarking.
# For the given coefficients, the minimum of the function must not be lower than MinimumGasCost
[DynamicStorageLoad]
QuadraticCoefficient = 688
SignOfQuadratic = 0
LinearCoefficient = 31858
SignOfLinear = 0
ConstantCoefficient = 15287
SignOfConstant = 0
MinimumGasCost = 10000
13 changes: 13 additions & 0 deletions cmd/node/config/gasSchedules/gasScheduleV7.toml
Original file line number Diff line number Diff line change
Expand Up @@ -813,3 +813,16 @@
MaxBuiltInCallsPerTx = 100
MaxNumberOfTransfersPerTx = 250
MaxNumberOfTrieReadsPerTx = 1500

# Quadratic, Linear and Constant are the coefficients for a quadratic func. Separate variables are used for the
# sign of each coefficient, 0 meaning positive and 1 meaning negative
# The current values for the coefficients were computed based on benchmarking.
# For the given coefficients, the minimum of the function must not be lower than MinimumGasCost
[DynamicStorageLoad]
QuadraticCoefficient = 688
SignOfQuadratic = 0
LinearCoefficient = 31858
SignOfLinear = 0
ConstantCoefficient = 15287
SignOfConstant = 0
MinimumGasCost = 10000
1 change: 1 addition & 0 deletions common/enablers/enableEpochsHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ func (handler *enableEpochsHandler) EpochConfirmed(epoch uint32, _ uint64) {
handler.setFlagValue(epoch >= handler.enableEpochsConfig.AutoBalanceDataTriesEnableEpoch, handler.autoBalanceDataTriesFlag, "autoBalanceDataTriesFlag", epoch, handler.enableEpochsConfig.AutoBalanceDataTriesEnableEpoch)
handler.setFlagValue(epoch >= handler.enableEpochsConfig.FixDelegationChangeOwnerOnAccountEnableEpoch, handler.fixDelegationChangeOwnerOnAccountFlag, "fixDelegationChangeOwnerOnAccountFlag", epoch, handler.enableEpochsConfig.FixDelegationChangeOwnerOnAccountEnableEpoch)
handler.setFlagValue(epoch >= handler.enableEpochsConfig.SCProcessorV2EnableEpoch, handler.scProcessorV2Flag, "scProcessorV2Flag", epoch, handler.enableEpochsConfig.SCProcessorV2EnableEpoch)
handler.setFlagValue(epoch >= handler.enableEpochsConfig.DynamicGasCostForDataTrieStorageLoadEnableEpoch, handler.dynamicGasCostForDataTrieStorageLoadFlag, "dynamicGasCostForDataTrieStorageLoadFlag", epoch, handler.enableEpochsConfig.DynamicGasCostForDataTrieStorageLoadEnableEpoch)
}

func (handler *enableEpochsHandler) setFlagValue(value bool, flag *atomic.Flag, flagName string, epoch uint32, flagEpoch uint32) {
Expand Down
7 changes: 7 additions & 0 deletions common/enablers/epochFlags.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ type epochFlagsHolder struct {
consistentTokensValuesCheckFlag *atomic.Flag
autoBalanceDataTriesFlag *atomic.Flag
fixDelegationChangeOwnerOnAccountFlag *atomic.Flag
dynamicGasCostForDataTrieStorageLoadFlag *atomic.Flag
}

func newEpochFlagsHolder() *epochFlagsHolder {
Expand Down Expand Up @@ -199,6 +200,7 @@ func newEpochFlagsHolder() *epochFlagsHolder {
changeUsernameFlag: &atomic.Flag{},
autoBalanceDataTriesFlag: &atomic.Flag{},
fixDelegationChangeOwnerOnAccountFlag: &atomic.Flag{},
dynamicGasCostForDataTrieStorageLoadFlag: &atomic.Flag{},
}
}

Expand Down Expand Up @@ -729,3 +731,8 @@ func (holder *epochFlagsHolder) IsAutoBalanceDataTriesEnabled() bool {
func (holder *epochFlagsHolder) FixDelegationChangeOwnerOnAccountEnabled() bool {
return holder.fixDelegationChangeOwnerOnAccountFlag.IsSet()
}

// IsDynamicGasCostForDataTrieStorageLoadEnabled returns true if dynamicGasCostForDataTrieStorageLoadFlag is enabled
func (holder *epochFlagsHolder) IsDynamicGasCostForDataTrieStorageLoadEnabled() bool {
return holder.dynamicGasCostForDataTrieStorageLoadFlag.IsSet()
}
1 change: 1 addition & 0 deletions common/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ type EnableEpochsHandler interface {
IsChangeUsernameEnabled() bool
IsConsistentTokensValuesLengthCheckEnabled() bool
IsAutoBalanceDataTriesEnabled() bool
IsDynamicGasCostForDataTrieStorageLoadEnabled() bool
FixDelegationChangeOwnerOnAccountEnabled() bool

IsInterfaceNil() bool
Expand Down
1 change: 1 addition & 0 deletions config/epochConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ type EnableEpochs struct {
AutoBalanceDataTriesEnableEpoch uint32
ConsistentTokensValuesLengthCheckEnableEpoch uint32
FixDelegationChangeOwnerOnAccountEnableEpoch uint32
DynamicGasCostForDataTrieStorageLoadEnableEpoch uint32
Copy link
Contributor

Choose a reason for hiding this comment

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

also adapt tests in the tomlConfig_test.go ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

BLSMultiSignerEnableEpoch []MultiSignerConfig
}

Expand Down
97 changes: 51 additions & 46 deletions config/tomlConfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,9 @@ func TestEnableEpochConfig(t *testing.T) {
# DeterministicSortOnValidatorsInfoEnableEpoch represents the epoch when the deterministic sorting on validators info is enabled
DeterministicSortOnValidatorsInfoEnableEpoch = 66

# DynamicGasCostForDataTrieStorageLoadEnableEpoch represents the epoch when dynamic gas cost for data trie storage load will be enabled
DynamicGasCostForDataTrieStorageLoadEnableEpoch = 64

# MaxNodesChangeEnableEpoch holds configuration for changing the maximum number of nodes and the enabling epoch
MaxNodesChangeEnableEpoch = [
{ EpochEnable = 44, MaxNumNodes = 2169, NodesToShufflePerShard = 80 },
Expand Down Expand Up @@ -848,51 +851,53 @@ func TestEnableEpochConfig(t *testing.T) {
ReturnDataToLastTransferEnableEpoch: 15,
SenderInOutTransferEnableEpoch: 16,
StakeEnableEpoch: 17,
StakingV2EnableEpoch: 18,
DoubleKeyProtectionEnableEpoch: 19,
ESDTEnableEpoch: 20,
GovernanceEnableEpoch: 21,
DelegationManagerEnableEpoch: 22,
DelegationSmartContractEnableEpoch: 23,
CorrectLastUnjailedEnableEpoch: 24,
RelayedTransactionsV2EnableEpoch: 25,
UnbondTokensV2EnableEpoch: 26,
SaveJailedAlwaysEnableEpoch: 27,
ReDelegateBelowMinCheckEnableEpoch: 28,
ValidatorToDelegationEnableEpoch: 29,
WaitingListFixEnableEpoch: 30,
IncrementSCRNonceInMultiTransferEnableEpoch: 31,
ESDTMultiTransferEnableEpoch: 32,
GlobalMintBurnDisableEpoch: 33,
ESDTTransferRoleEnableEpoch: 34,
BuiltInFunctionOnMetaEnableEpoch: 35,
ComputeRewardCheckpointEnableEpoch: 36,
SCRSizeInvariantCheckEnableEpoch: 37,
BackwardCompSaveKeyValueEnableEpoch: 38,
ESDTNFTCreateOnMultiShardEnableEpoch: 39,
MetaESDTSetEnableEpoch: 40,
AddTokensToDelegationEnableEpoch: 41,
MultiESDTTransferFixOnCallBackOnEnableEpoch: 42,
OptimizeGasUsedInCrossMiniBlocksEnableEpoch: 43,
CorrectFirstQueuedEpoch: 44,
DeleteDelegatorAfterClaimRewardsEnableEpoch: 45,
FixOOGReturnCodeEnableEpoch: 46,
RemoveNonUpdatedStorageEnableEpoch: 47,
OptimizeNFTStoreEnableEpoch: 48,
CreateNFTThroughExecByCallerEnableEpoch: 49,
StopDecreasingValidatorRatingWhenStuckEnableEpoch: 50,
FrontRunningProtectionEnableEpoch: 51,
IsPayableBySCEnableEpoch: 52,
CleanUpInformativeSCRsEnableEpoch: 53,
StorageAPICostOptimizationEnableEpoch: 54,
TransformToMultiShardCreateEnableEpoch: 55,
StakingV2EnableEpoch: 18,

DoubleKeyProtectionEnableEpoch: 19,
ESDTEnableEpoch: 20,
GovernanceEnableEpoch: 21,
DelegationManagerEnableEpoch: 22,
DelegationSmartContractEnableEpoch: 23,
CorrectLastUnjailedEnableEpoch: 24,

RelayedTransactionsV2EnableEpoch: 25,
UnbondTokensV2EnableEpoch: 26,
SaveJailedAlwaysEnableEpoch: 27,
ReDelegateBelowMinCheckEnableEpoch: 28,ValidatorToDelegationEnableEpoch: 29,

WaitingListFixEnableEpoch: 30,
IncrementSCRNonceInMultiTransferEnableEpoch: 31,
ESDTMultiTransferEnableEpoch: 32,
GlobalMintBurnDisableEpoch: 33,
ESDTTransferRoleEnableEpoch: 34,
BuiltInFunctionOnMetaEnableEpoch: 35,
ComputeRewardCheckpointEnableEpoch: 36,
SCRSizeInvariantCheckEnableEpoch: 37,
BackwardCompSaveKeyValueEnableEpoch: 38,
ESDTNFTCreateOnMultiShardEnableEpoch: 39,
MetaESDTSetEnableEpoch: 40,
AddTokensToDelegationEnableEpoch: 41,
MultiESDTTransferFixOnCallBackOnEnableEpoch: 42,
OptimizeGasUsedInCrossMiniBlocksEnableEpoch: 43,
CorrectFirstQueuedEpoch: 44,
DeleteDelegatorAfterClaimRewardsEnableEpoch: 45,
FixOOGReturnCodeEnableEpoch: 46,
RemoveNonUpdatedStorageEnableEpoch: 47,
OptimizeNFTStoreEnableEpoch: 48,
CreateNFTThroughExecByCallerEnableEpoch: 49,
StopDecreasingValidatorRatingWhenStuckEnableEpoch: 50,
FrontRunningProtectionEnableEpoch: 51,
IsPayableBySCEnableEpoch: 52,
CleanUpInformativeSCRsEnableEpoch: 53,
StorageAPICostOptimizationEnableEpoch: 54,
TransformToMultiShardCreateEnableEpoch: 55,
ESDTRegisterAndSetAllRolesEnableEpoch: 56,
ScheduledMiniBlocksEnableEpoch: 57,
CorrectJailedNotUnstakedEmptyQueueEpoch: 58,
DoNotReturnOldBlockInBlockchainHookEnableEpoch: 59,
AddFailedRelayedTxToInvalidMBsDisableEpoch: 60,
SCRSizeInvariantOnBuiltInResultEnableEpoch: 61,
CheckCorrectTokenIDForTransferRoleEnableEpoch: 62,
ScheduledMiniBlocksEnableEpoch: 57,
CorrectJailedNotUnstakedEmptyQueueEpoch: 58,
DoNotReturnOldBlockInBlockchainHookEnableEpoch: 59,
AddFailedRelayedTxToInvalidMBsDisableEpoch: 60,
SCRSizeInvariantOnBuiltInResultEnableEpoch: 61,
CheckCorrectTokenIDForTransferRoleEnableEpoch: 62,
DisableExecByCallerEnableEpoch: 63,
RefactorContextEnableEpoch: 64,
FailExecutionOnEveryAPIErrorEnableEpoch: 65,
Expand All @@ -902,8 +907,7 @@ func TestEnableEpochConfig(t *testing.T) {
ESDTMetadataContinuousCleanupEnableEpoch: 69,
MiniBlockPartialExecutionEnableEpoch: 70,
FixAsyncCallBackArgsListEnableEpoch: 71,
FixOldTokenLiquidityEnableEpoch: 72,
RuntimeMemStoreLimitEnableEpoch: 73,
FixOldTokenLiquidityEnableEpoch: 72,RuntimeMemStoreLimitEnableEpoch: 73,
SetSenderInEeiOutputTransferEnableEpoch: 74,
RefactorPeersMiniBlocksEnableEpoch: 75,
MaxBlockchainHookCountersEnableEpoch: 76,
Expand Down Expand Up @@ -931,6 +935,7 @@ func TestEnableEpochConfig(t *testing.T) {
},
},
DeterministicSortOnValidatorsInfoEnableEpoch: 66,
DynamicGasCostForDataTrieStorageLoadEnableEpoch: 64,
BLSMultiSignerEnableEpoch: []MultiSignerConfig{
{
EnableEpoch: 0,
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ require (
github.com/multiversx/mx-chain-logger-go v1.0.13
github.com/multiversx/mx-chain-scenario-go v1.2.1
github.com/multiversx/mx-chain-storage-go v1.0.12
github.com/multiversx/mx-chain-vm-common-go v1.5.2
github.com/multiversx/mx-chain-vm-go v1.5.5
github.com/multiversx/mx-chain-vm-common-go v1.5.3
github.com/multiversx/mx-chain-vm-go v1.5.6
github.com/multiversx/mx-chain-vm-v1_2-go v1.2.60
github.com/multiversx/mx-chain-vm-v1_3-go v1.3.61
github.com/multiversx/mx-chain-vm-v1_4-go v1.4.87
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -390,10 +390,10 @@ github.com/multiversx/mx-chain-scenario-go v1.2.1 h1:9eC6VcOEAKRRKZ7EbSWPLzCdNIM
github.com/multiversx/mx-chain-scenario-go v1.2.1/go.mod h1:EuZY7DpNFHVNSxJR8dKE1z2I8gBYfEFFPSwNUOXptqE=
github.com/multiversx/mx-chain-storage-go v1.0.12 h1:FrkgHPV38BO8cwdK0GUYHxVkUyOhyBBIhPz0P1e72NA=
github.com/multiversx/mx-chain-storage-go v1.0.12/go.mod h1:/8VrMbO9CbIi0Ym3F1QPY6EENGcUq5DpEBPDt4evn9Q=
github.com/multiversx/mx-chain-vm-common-go v1.5.2 h1:iRWJNlogjkq9w+pJZIfkVkXQFmMoRxZr6pzCfg2/K68=
github.com/multiversx/mx-chain-vm-common-go v1.5.2/go.mod h1:sqkKMCnwkWl8DURdb9q7pctK8IANghdHY1KJLE0ox2c=
github.com/multiversx/mx-chain-vm-go v1.5.5 h1:/ROeFnd44/vRGtnzlfUJZMBX/g3bNwxPpLTXo52XLbY=
github.com/multiversx/mx-chain-vm-go v1.5.5/go.mod h1:5d5GC+Ibz8X27+W8TYqbsMXh8n4F/kHUbdr0bVz8o8Y=
github.com/multiversx/mx-chain-vm-common-go v1.5.3 h1:u4ttQc+1bj92SoGeRk3EYc8JvOMDPIGyrQuQGM+YYpU=
github.com/multiversx/mx-chain-vm-common-go v1.5.3/go.mod h1:sqkKMCnwkWl8DURdb9q7pctK8IANghdHY1KJLE0ox2c=
github.com/multiversx/mx-chain-vm-go v1.5.6 h1:IOwq/L4dBDBjXTIAR9hHCS/D4fn2xMkkINimHWsYiUQ=
github.com/multiversx/mx-chain-vm-go v1.5.6/go.mod h1:WCYCljlHi2UQWHQAlSw1LzDsiMlckoMzvHL2fA5VKU4=
github.com/multiversx/mx-chain-vm-v1_2-go v1.2.60 h1:YYElal1woAT3gwcVGe2JUEqBlzMXt963BSdQHuJpTMk=
github.com/multiversx/mx-chain-vm-v1_2-go v1.2.60/go.mod h1:3X3V/nj4G2ziTIijSEiucGn3r3S8v3CRIg5/szOtCLY=
github.com/multiversx/mx-chain-vm-v1_3-go v1.3.61 h1:z1LkUlVNwc6mfWqFu+VTpPorDd0/Pj7/SMNXmNDdkK4=
Expand Down
38 changes: 5 additions & 33 deletions integrationTests/benchmarks/loadFromTrie_test.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
package benchmarks

import (
"encoding/hex"
"fmt"
"math/rand"
"strings"
"testing"
"time"

"github.com/multiversx/mx-chain-core-go/hashing"
"github.com/multiversx/mx-chain-core-go/hashing/blake2b"
"github.com/multiversx/mx-chain-core-go/marshal"
"github.com/multiversx/mx-chain-go/common"
"github.com/multiversx/mx-chain-go/integrationTests"
"github.com/multiversx/mx-chain-go/storage"
"github.com/multiversx/mx-chain-go/storage/database"
"github.com/multiversx/mx-chain-go/storage/storageunit"
Expand All @@ -22,12 +20,6 @@ import (
"github.com/stretchr/testify/require"
)

var charsPool = []string{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E"}

const (
keyLength = 32
)

func TestTrieLoadTime(t *testing.T) {
t.Skip()

Expand Down Expand Up @@ -133,33 +125,13 @@ func insertKeysIntoTrie(t *testing.T, tr common.Trie, numTrieLevels int, numChil
}

func insertInTrie(tr common.Trie, numTrieLevels int, numChildrenPerBranch int) []byte {
var key []byte
hexKeyLength := keyLength * 2
if numTrieLevels == 1 {
hexKey := generateRandHexString(hexKeyLength)
key, _ = hex.DecodeString(hexKey)
keys := integrationTests.GenerateTrieKeysForMaxLevel(numTrieLevels, numChildrenPerBranch)
for _, key := range keys {
_ = tr.Update(key, key)
return key
}

for i := 0; i < numTrieLevels-1; i++ {
for j := 0; j < numChildrenPerBranch-1; j++ {
hexKey := generateRandHexString(hexKeyLength-numTrieLevels) + strings.Repeat(charsPool[j], numTrieLevels-i) + strings.Repeat("F", i)
key, _ = hex.DecodeString(hexKey)
_ = tr.Update(key, key)
}
}

return key
}

func generateRandHexString(size int) string {
buff := make([]string, size)
for i := 0; i < size; i++ {
buff[i] = charsPool[rand.Intn(len(charsPool))]
}

return strings.Join(buff, "")
lastKeyIndex := len(keys) - 1
return keys[lastKeyIndex]
}

func getTrieStorageManager(store storage.Storer, marshaller marshal.Marshalizer, hasher hashing.Hasher) common.StorageManager {
Expand Down