Skip to content

Commit

Permalink
Merge pull request #5821 from multiversx/feat/esdt-improvements
Browse files Browse the repository at this point in the history
Feat/esdt improvements
  • Loading branch information
sasurobert committed Apr 11, 2024
2 parents 347ff4e + c3383ee commit d2ae491
Show file tree
Hide file tree
Showing 34 changed files with 1,472 additions and 59 deletions.
3 changes: 3 additions & 0 deletions cmd/node/config/enableEpochs.toml
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@
# AlwaysMergeContextsInEEIEnableEpoch represents the epoch in which the EEI will always merge the contexts
AlwaysMergeContextsInEEIEnableEpoch = 4

# DynamicESDTEnableEpoch represents the epoch when dynamic NFT feature is enabled
DynamicESDTEnableEpoch = 4

# BLSMultiSignerEnableEpoch represents the activation epoch for different types of BLS multi-signers
BLSMultiSignerEnableEpoch = [
{ EnableEpoch = 0, Type = "no-KOSK" },
Expand Down
5 changes: 5 additions & 0 deletions cmd/node/config/gasSchedules/gasScheduleV1.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
ESDTNFTAddUri = 500000
ESDTNFTUpdateAttributes = 500000
ESDTNFTMultiTransfer = 1000000
ESDTModifyRoyalties = 500000
ESDTModifyCreator = 500000
ESDTNFTRecreate = 1000000
ESDTNFTUpdate = 1000000
ESDTNFTSetNewURIs = 500000
SetGuardian = 250000
GuardAccount = 250000
UnGuardAccount = 250000
Expand Down
5 changes: 5 additions & 0 deletions cmd/node/config/gasSchedules/gasScheduleV2.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
ESDTNFTAddUri = 500000
ESDTNFTUpdateAttributes = 500000
ESDTNFTMultiTransfer = 1000000
ESDTModifyRoyalties = 500000
ESDTModifyCreator = 500000
ESDTNFTRecreate = 1000000
ESDTNFTUpdate = 1000000
ESDTNFTSetNewURIs = 500000
SetGuardian = 250000
GuardAccount = 250000
UnGuardAccount = 250000
Expand Down
5 changes: 5 additions & 0 deletions cmd/node/config/gasSchedules/gasScheduleV3.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
ESDTNFTAddUri = 500000
ESDTNFTUpdateAttributes = 500000
ESDTNFTMultiTransfer = 1000000
ESDTModifyRoyalties = 500000
ESDTModifyCreator = 500000
ESDTNFTRecreate = 1000000
ESDTNFTUpdate = 1000000
ESDTNFTSetNewURIs = 500000
SetGuardian = 250000
GuardAccount = 250000
UnGuardAccount = 250000
Expand Down
5 changes: 5 additions & 0 deletions cmd/node/config/gasSchedules/gasScheduleV4.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
ESDTNFTAddUri = 50000
ESDTNFTUpdateAttributes = 50000
ESDTNFTMultiTransfer = 200000
ESDTModifyRoyalties = 500000
ESDTModifyCreator = 500000
ESDTNFTRecreate = 1000000
ESDTNFTUpdate = 1000000
ESDTNFTSetNewURIs = 500000
SetGuardian = 250000
GuardAccount = 250000
UnGuardAccount = 250000
Expand Down
5 changes: 5 additions & 0 deletions cmd/node/config/gasSchedules/gasScheduleV5.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
ESDTNFTAddUri = 50000
ESDTNFTUpdateAttributes = 50000
ESDTNFTMultiTransfer = 200000
ESDTModifyRoyalties = 500000
ESDTModifyCreator = 500000
ESDTNFTRecreate = 1000000
ESDTNFTUpdate = 1000000
ESDTNFTSetNewURIs = 500000
SetGuardian = 250000
GuardAccount = 250000
UnGuardAccount = 250000
Expand Down
5 changes: 5 additions & 0 deletions cmd/node/config/gasSchedules/gasScheduleV6.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
ESDTNFTAddUri = 50000
ESDTNFTUpdateAttributes = 50000
ESDTNFTMultiTransfer = 200000
ESDTModifyRoyalties = 500000
ESDTModifyCreator = 500000
ESDTNFTRecreate = 1000000
ESDTNFTUpdate = 1000000
ESDTNFTSetNewURIs = 500000
SetGuardian = 250000
GuardAccount = 250000
UnGuardAccount = 250000
Expand Down
5 changes: 5 additions & 0 deletions cmd/node/config/gasSchedules/gasScheduleV7.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
ESDTNFTUpdateAttributes = 50000
ESDTNFTMultiTransfer = 200000
MultiESDTNFTTransfer = 200000 # should be the same value with the ESDTNFTMultiTransfer
ESDTModifyRoyalties = 500000
ESDTModifyCreator = 500000
ESDTNFTRecreate = 1000000
ESDTNFTUpdate = 1000000
ESDTNFTSetNewURIs = 500000
SetGuardian = 250000
GuardAccount = 250000
UnGuardAccount = 250000
Expand Down
1 change: 1 addition & 0 deletions common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -1011,5 +1011,6 @@ const (
StakingQueueFlag core.EnableEpochFlag = "StakingQueueFlag"
StakingV4StartedFlag core.EnableEpochFlag = "StakingV4StartedFlag"
AlwaysMergeContextsInEEIFlag core.EnableEpochFlag = "AlwaysMergeContextsInEEIFlag"
DynamicESDTFlag core.EnableEpochFlag = "DynamicEsdtFlag"
// all new flags must be added to createAllFlagsMap method, as part of enableEpochsHandler allFlagsDefined
)
6 changes: 6 additions & 0 deletions common/enablers/enableEpochsHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,12 @@ func (handler *enableEpochsHandler) createAllFlagsMap() {
},
activationEpoch: handler.enableEpochsConfig.AlwaysMergeContextsInEEIEnableEpoch,
},
common.DynamicESDTFlag: {
isActiveInEpoch: func(epoch uint32) bool {
return epoch >= handler.enableEpochsConfig.DynamicESDTEnableEpoch
},
activationEpoch: handler.enableEpochsConfig.DynamicESDTEnableEpoch,
},
}
}

Expand Down
13 changes: 8 additions & 5 deletions common/enablers/enableEpochsHandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,12 @@ func createEnableEpochsConfig() config.EnableEpochs {
FixGasRemainingForSaveKeyValueBuiltinFunctionEnableEpoch: 93,
ChangeOwnerAddressCrossShardThroughSCEnableEpoch: 94,
CurrentRandomnessOnSortingEnableEpoch: 95,
StakeLimitsEnableEpoch: 95,
StakingV4Step1EnableEpoch: 96,
StakingV4Step2EnableEpoch: 97,
StakingV4Step3EnableEpoch: 98,
AlwaysMergeContextsInEEIEnableEpoch: 99,
StakeLimitsEnableEpoch: 96,
StakingV4Step1EnableEpoch: 97,
StakingV4Step2EnableEpoch: 98,
StakingV4Step3EnableEpoch: 99,
AlwaysMergeContextsInEEIEnableEpoch: 100,
DynamicESDTEnableEpoch: 101,
}
}

Expand Down Expand Up @@ -321,6 +322,7 @@ func TestEnableEpochsHandler_IsFlagEnabled(t *testing.T) {
require.False(t, handler.IsFlagEnabled(common.StakingQueueFlag))
require.True(t, handler.IsFlagEnabled(common.StakingV4StartedFlag))
require.True(t, handler.IsFlagEnabled(common.AlwaysMergeContextsInEEIFlag))
require.True(t, handler.IsFlagEnabled(common.DynamicESDTFlag))
}

func TestEnableEpochsHandler_GetActivationEpoch(t *testing.T) {
Expand Down Expand Up @@ -437,6 +439,7 @@ func TestEnableEpochsHandler_GetActivationEpoch(t *testing.T) {
require.Equal(t, cfg.StakingV4Step1EnableEpoch, handler.GetActivationEpoch(common.StakingQueueFlag))
require.Equal(t, cfg.StakingV4Step1EnableEpoch, handler.GetActivationEpoch(common.StakingV4StartedFlag))
require.Equal(t, cfg.AlwaysMergeContextsInEEIEnableEpoch, handler.GetActivationEpoch(common.AlwaysMergeContextsInEEIFlag))
require.Equal(t, cfg.DynamicESDTEnableEpoch, handler.GetActivationEpoch(common.DynamicESDTFlag))
}

func TestEnableEpochsHandler_IsInterfaceNil(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions config/epochConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ type EnableEpochs struct {
StakingV4Step2EnableEpoch uint32
StakingV4Step3EnableEpoch uint32
AlwaysMergeContextsInEEIEnableEpoch uint32
DynamicESDTEnableEpoch uint32
BLSMultiSignerEnableEpoch []MultiSignerConfig
}

Expand Down
4 changes: 4 additions & 0 deletions config/tomlConfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,9 @@ func TestEnableEpochConfig(t *testing.T) {
# AlwaysMergeContextsInEEIEnableEpoch represents the epoch in which the EEI will always merge the contexts
AlwaysMergeContextsInEEIEnableEpoch = 94
# DynamicESDTEnableEpoch represents the epoch when dynamic NFT feature is enabled
DynamicESDTEnableEpoch = 95
# 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 @@ -962,6 +965,7 @@ func TestEnableEpochConfig(t *testing.T) {
MigrateDataTrieEnableEpoch: 92,
CurrentRandomnessOnSortingEnableEpoch: 93,
AlwaysMergeContextsInEEIEnableEpoch: 94,
DynamicESDTEnableEpoch: 95,
MaxNodesChangeEnableEpoch: []MaxNodesChangeConfig{
{
EpochEnable: 44,
Expand Down
20 changes: 20 additions & 0 deletions factory/disabled/globalSettingsHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@ func NewDisabledGlobalSettingHandler() *disabledGlobalSettingsHandler {
return &disabledGlobalSettingsHandler{}
}

// IsBurnForAll returns false as this is a disabled component
func (d *disabledGlobalSettingsHandler) IsBurnForAll(_ []byte) bool {
return false
}

// IsSenderOrDestinationWithTransferRole returns false as this is a disabled component
func (d *disabledGlobalSettingsHandler) IsSenderOrDestinationWithTransferRole(_, _, _ []byte) bool {
return false
}

// GetTokenType returns 0 as this is a disabled component
func (d *disabledGlobalSettingsHandler) GetTokenType(_ []byte) (uint32, error) {
return 0, nil
}

// SetTokenType does nothing as this is a disabled component
func (d *disabledGlobalSettingsHandler) SetTokenType(_ []byte, _ uint32) error {
return nil
}

// IsPaused returns false as this is a disabled component
func (d *disabledGlobalSettingsHandler) IsPaused(_ []byte) bool {
return false
Expand Down
2 changes: 1 addition & 1 deletion genesis/process/disabled/disabled_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ func TestSimpleNFTStorage(t *testing.T) {
require.Equal(t, &esdt.ESDigitalToken{Value: big.NewInt(0)}, token)
require.True(t, ok)
require.Nil(t, err)
require.Nil(t, handler.SaveNFTMetaDataToSystemAccount(nil))
require.Nil(t, handler.SaveNFTMetaData(nil))
require.False(t, handler.IsInterfaceNil())
}

Expand Down
4 changes: 2 additions & 2 deletions genesis/process/disabled/simpleNFTStorageHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ func (s *SimpleNFTStorage) GetESDTNFTTokenOnDestination(_ vmcommon.UserAccountHa
return &esdt.ESDigitalToken{Value: big.NewInt(0)}, true, nil
}

// SaveNFTMetaDataToSystemAccount is disabled
func (s *SimpleNFTStorage) SaveNFTMetaDataToSystemAccount(_ data.TransactionHandler) error {
// SaveNFTMetaData is disabled
func (s *SimpleNFTStorage) SaveNFTMetaData(_ data.TransactionHandler) error {
return nil
}

Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ require (
github.com/klauspost/cpuid/v2 v2.2.5
github.com/mitchellh/mapstructure v1.5.0
github.com/multiversx/mx-chain-communication-go v1.0.13-0.20240321151517-2fffad77c605
github.com/multiversx/mx-chain-core-go v1.2.19-0.20240321150532-5960a8922b18
github.com/multiversx/mx-chain-core-go v1.2.20-0.20240328090024-e88291d59ace
github.com/multiversx/mx-chain-crypto-go v1.2.10-0.20231206065052-38843c1f1479
github.com/multiversx/mx-chain-es-indexer-go v1.4.20-0.20240228094052-28a36809b9b8
github.com/multiversx/mx-chain-logger-go v1.0.14-0.20240129144507-d00e967c890c
github.com/multiversx/mx-chain-scenario-go v1.4.3-0.20240212160120-cc32d1580157
github.com/multiversx/mx-chain-storage-go v1.0.15-0.20240321150623-3974ec1d6474
github.com/multiversx/mx-chain-vm-common-go v1.5.12-0.20240321152012-f18c2869d6b4
github.com/multiversx/mx-chain-vm-go v1.5.28-0.20240321153018-3e5a88ba7368
github.com/multiversx/mx-chain-vm-common-go v1.5.12-0.20240328091908-c46c76dac779
github.com/multiversx/mx-chain-vm-go v1.5.28-0.20240328092329-b5f2c7c059eb
github.com/multiversx/mx-chain-vm-v1_2-go v1.2.66-0.20240321152247-79521988c8e6
github.com/multiversx/mx-chain-vm-v1_3-go v1.3.67-0.20240321152532-45da5eabdc38
github.com/multiversx/mx-chain-vm-v1_4-go v1.4.96-0.20240321152756-16110ce9d968
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,8 @@ github.com/multiversx/concurrent-map v0.1.4 h1:hdnbM8VE4b0KYJaGY5yJS2aNIW9TFFsUY
github.com/multiversx/concurrent-map v0.1.4/go.mod h1:8cWFRJDOrWHOTNSqgYCUvwT7c7eFQ4U2vKMOp4A/9+o=
github.com/multiversx/mx-chain-communication-go v1.0.13-0.20240321151517-2fffad77c605 h1:WYPdDmxL5rk9O6wUYVW4Fpw/QtwkWiIzFHeH2F5Zap4=
github.com/multiversx/mx-chain-communication-go v1.0.13-0.20240321151517-2fffad77c605/go.mod h1:wUM/1NFfgeTjovQMaaXghynwXgOyoPchMquu2wnCHz8=
github.com/multiversx/mx-chain-core-go v1.2.19-0.20240321150532-5960a8922b18 h1:hytqre8g+NIHsq/Kxl/lwIykHna57Gv+E38tt4K5A9I=
github.com/multiversx/mx-chain-core-go v1.2.19-0.20240321150532-5960a8922b18/go.mod h1:B5zU4MFyJezmEzCsAHE9YNULmGCm2zbPHvl9hazNxmE=
github.com/multiversx/mx-chain-core-go v1.2.20-0.20240328090024-e88291d59ace h1:sCXg0IlWmi0k5mC3BmUVCKVrxatGRQKGmqVS/froLDw=
github.com/multiversx/mx-chain-core-go v1.2.20-0.20240328090024-e88291d59ace/go.mod h1:B5zU4MFyJezmEzCsAHE9YNULmGCm2zbPHvl9hazNxmE=
github.com/multiversx/mx-chain-crypto-go v1.2.10-0.20231206065052-38843c1f1479 h1:beVIhs5ysylwNplQ/bZ0h5DoDlqKNWgpWE/NMHHNmAw=
github.com/multiversx/mx-chain-crypto-go v1.2.10-0.20231206065052-38843c1f1479/go.mod h1:Ap6p7QZFtwPlb++OvCG+85BfuZ+bLP/JtQp6EwjWJsI=
github.com/multiversx/mx-chain-es-indexer-go v1.4.20-0.20240228094052-28a36809b9b8 h1:z9ePQGALhPCs9Fv7cQsnsScbEq8KuOJ9xrJEEEOiHyI=
Expand All @@ -399,10 +399,10 @@ github.com/multiversx/mx-chain-scenario-go v1.4.3-0.20240212160120-cc32d1580157
github.com/multiversx/mx-chain-scenario-go v1.4.3-0.20240212160120-cc32d1580157/go.mod h1:ndk45i9J9McuCJpTcgiaK4ocd0yhnBBCPrlFwO6GRcs=
github.com/multiversx/mx-chain-storage-go v1.0.15-0.20240321150623-3974ec1d6474 h1:x65Su8ojHwA+NICp9DrSVGLDDcAlW04DafkqCHY1QPE=
github.com/multiversx/mx-chain-storage-go v1.0.15-0.20240321150623-3974ec1d6474/go.mod h1:hnc6H4D5Ge1haRAQ6QHTXhyh+CT2DRiNJ0U0HQYI3DY=
github.com/multiversx/mx-chain-vm-common-go v1.5.12-0.20240321152012-f18c2869d6b4 h1:Xq8R5eRcZDTPYYK7boM2x71XRDifdtP+rgQQhvmJLbg=
github.com/multiversx/mx-chain-vm-common-go v1.5.12-0.20240321152012-f18c2869d6b4/go.mod h1:JqhuZPrx9bAKagTefUXq9y2fhLdCJstnppq2JKAUvFI=
github.com/multiversx/mx-chain-vm-go v1.5.28-0.20240321153018-3e5a88ba7368 h1:DP48O3jSAG6IgwJsCffORfFKPWRgbPRCzc0Xt00C/C0=
github.com/multiversx/mx-chain-vm-go v1.5.28-0.20240321153018-3e5a88ba7368/go.mod h1:BTnxVk/6RUSwUr6iFgDMPWHIibVQBe5wsFO1v+sEFig=
github.com/multiversx/mx-chain-vm-common-go v1.5.12-0.20240328091908-c46c76dac779 h1:FSgAtNcml8kWdIEn8MxCfPkZ8ZE/wIFNKI5TZLEfcT0=
github.com/multiversx/mx-chain-vm-common-go v1.5.12-0.20240328091908-c46c76dac779/go.mod h1:G6daPJC6bFsvAw45RPMCRi2rP+8LjFxa8G+3alHuJow=
github.com/multiversx/mx-chain-vm-go v1.5.28-0.20240328092329-b5f2c7c059eb h1:0WvWXqzliYS1yKW+6uTxZGMjQd08IQNPzlNNxxyNWHM=
github.com/multiversx/mx-chain-vm-go v1.5.28-0.20240328092329-b5f2c7c059eb/go.mod h1:mZNRILxq51LVqwqE9jMJyDHgmy9W3x7otOGuFjOm82Q=
github.com/multiversx/mx-chain-vm-v1_2-go v1.2.66-0.20240321152247-79521988c8e6 h1:7HqUo9YmpsfN/y9px6RmzREJm5O6ZzP9NqvFSrHTw24=
github.com/multiversx/mx-chain-vm-v1_2-go v1.2.66-0.20240321152247-79521988c8e6/go.mod h1:H2H/zoskiZC0lEokq9qMFVxRkB0RWVDPLjHbG/NrGUU=
github.com/multiversx/mx-chain-vm-v1_3-go v1.3.67-0.20240321152532-45da5eabdc38 h1:SAKjOByxXkZ5Sys5O4IkrrSGCKLoPvD+cCJJEvbev4w=
Expand Down
2 changes: 1 addition & 1 deletion integrationTests/vm/esdt/process/esdtProcess_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ func TestESDTIssueFromASmartContractSimulated(t *testing.T) {
interimProc, _ := metaNode.InterimProcContainer.Get(block.SmartContractResultBlock)
mapCreatedSCRs := interimProc.GetAllCurrentFinishedTxs()

require.Equal(t, len(mapCreatedSCRs), 2)
require.Equal(t, len(mapCreatedSCRs), 3)
foundTransfer := false
for _, addedSCR := range mapCreatedSCRs {
foundTransfer = foundTransfer || strings.Contains(string(addedSCR.GetData()), core.BuiltInFunctionESDTTransfer)
Expand Down

0 comments on commit d2ae491

Please sign in to comment.