Skip to content

Commit

Permalink
Merge pull request #6498 from multiversx/merge-1-7-next-into-esdt-pre…
Browse files Browse the repository at this point in the history
…fix-25-sept

Merge 1 7 next into esdt prefix 25 sept
  • Loading branch information
axenteoctavian authored Sep 25, 2024
2 parents e6160f7 + bf14142 commit 6dc2dda
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
build:
strategy:
matrix:
runs-on: [ubuntu-latest, macos-13, macos-13-xlarge]
runs-on: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.runs-on }}
name: Build
steps:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
build:
strategy:
matrix:
runs-on: [ubuntu-latest, macos-13, macos-13-xlarge]
runs-on: [ubuntu-latest]
runs-on: ${{ matrix.runs-on }}
name: Build
steps:
Expand Down Expand Up @@ -129,7 +129,7 @@ jobs:
zip -r -j ${ARCHIVE} ${BUILD_DIR}
- name: Save artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARCHIVE }}
path: ${{ env.ARCHIVE }}
Expand All @@ -145,7 +145,7 @@ jobs:
# https://docs.github.com/en/free-pro-team@latest/actions/guides/storing-workflow-data-as-artifacts#downloading-or-deleting-artifacts
# A directory for each artifact is created using its name
- name: Download all workflow run artifacts
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
path: assets

Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ require (
github.com/multiversx/mx-chain-communication-go v1.1.0
github.com/multiversx/mx-chain-core-go v1.2.22
github.com/multiversx/mx-chain-crypto-go v1.2.12
github.com/multiversx/mx-chain-es-indexer-go v1.7.9-0.20240912110120-3287bbe713da
github.com/multiversx/mx-chain-es-indexer-go v1.7.9
github.com/multiversx/mx-chain-logger-go v1.0.15
github.com/multiversx/mx-chain-scenario-go v1.4.4
github.com/multiversx/mx-chain-storage-go v1.0.16
github.com/multiversx/mx-chain-vm-common-go v1.5.16-0.20240924142433-ea6ae5029de8
github.com/multiversx/mx-chain-vm-go v1.5.33-0.20240912115217-e4a93d0c7fa2
github.com/multiversx/mx-chain-vm-common-go v1.5.16-0.20240925102527-33ed01923a3c
github.com/multiversx/mx-chain-vm-go v1.5.36-0.20240923134141-bdba60bb6bcd
github.com/multiversx/mx-chain-vm-v1_2-go v1.2.68
github.com/multiversx/mx-chain-vm-v1_3-go v1.3.69
github.com/multiversx/mx-chain-vm-v1_4-go v1.4.98
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -391,18 +391,18 @@ github.com/multiversx/mx-chain-core-go v1.2.22 h1:yDYrvoQOBbsDerEp7L3+de5AfMy3pT
github.com/multiversx/mx-chain-core-go v1.2.22/go.mod h1:B5zU4MFyJezmEzCsAHE9YNULmGCm2zbPHvl9hazNxmE=
github.com/multiversx/mx-chain-crypto-go v1.2.12 h1:zWip7rpUS4CGthJxfKn5MZfMfYPjVjIiCID6uX5BSOk=
github.com/multiversx/mx-chain-crypto-go v1.2.12/go.mod h1:HzcPpCm1zanNct/6h2rIh+MFrlXbjA5C8+uMyXj3LI4=
github.com/multiversx/mx-chain-es-indexer-go v1.7.9-0.20240912110120-3287bbe713da h1:Dk0UXrr4rwMblSnsXWERKiqi1Jwa+bWIrLn7J03ixZU=
github.com/multiversx/mx-chain-es-indexer-go v1.7.9-0.20240912110120-3287bbe713da/go.mod h1:oGcRK2E3Syv6vRTszWrrb/TqD8akq0yeoMr1wPPiTO4=
github.com/multiversx/mx-chain-es-indexer-go v1.7.9 h1:rWq9phJu8GG6TtoJ5cL+MmhyReWCEyqBE5ymXUvudCg=
github.com/multiversx/mx-chain-es-indexer-go v1.7.9/go.mod h1:oGcRK2E3Syv6vRTszWrrb/TqD8akq0yeoMr1wPPiTO4=
github.com/multiversx/mx-chain-logger-go v1.0.15 h1:HlNdK8etyJyL9NQ+6mIXyKPEBo+wRqOwi3n+m2QIHXc=
github.com/multiversx/mx-chain-logger-go v1.0.15/go.mod h1:t3PRKaWB1M+i6gUfD27KXgzLJJC+mAQiN+FLlL1yoGQ=
github.com/multiversx/mx-chain-scenario-go v1.4.4 h1:DVE2V+FPeyD/yWoC+KEfPK3jsFzHeruelESfpTlf460=
github.com/multiversx/mx-chain-scenario-go v1.4.4/go.mod h1:kI+TWR3oIEgUkbwkHCPo2CQ3VjIge+ezGTibiSGwMxo=
github.com/multiversx/mx-chain-storage-go v1.0.16 h1:l2lJq+EAN3YwLbjJrnoKfFd1/1Xmo9DcAUECND2obLs=
github.com/multiversx/mx-chain-storage-go v1.0.16/go.mod h1:uM/z7YyqTOD3wgyH8TfapyEl5sb+7x/Jaxne4cfG4HI=
github.com/multiversx/mx-chain-vm-common-go v1.5.16-0.20240924142433-ea6ae5029de8 h1:5VEo2wTw/XYYi1hPOO/nyHu22Q/HAfm9gRTeZaOcdCo=
github.com/multiversx/mx-chain-vm-common-go v1.5.16-0.20240924142433-ea6ae5029de8/go.mod h1:1rSkXreUZNXyPTTdhj47M+Fy62yjxbu3aAsXEtKN3UY=
github.com/multiversx/mx-chain-vm-go v1.5.33-0.20240912115217-e4a93d0c7fa2 h1:p8pHfq+VhdKUp4oSP0QEjUkjAVLpXlCXnM4eS1vsGoo=
github.com/multiversx/mx-chain-vm-go v1.5.33-0.20240912115217-e4a93d0c7fa2/go.mod h1:3LmdbQOb+Fy3UqF9DtQ9j/RITetee9CHbEm+PV+JrC4=
github.com/multiversx/mx-chain-vm-common-go v1.5.16-0.20240925102527-33ed01923a3c h1:vPovEuMUXYYXO29ZAkjyYm8o9W1Tc3d71tsePQxkjiI=
github.com/multiversx/mx-chain-vm-common-go v1.5.16-0.20240925102527-33ed01923a3c/go.mod h1:1rSkXreUZNXyPTTdhj47M+Fy62yjxbu3aAsXEtKN3UY=
github.com/multiversx/mx-chain-vm-go v1.5.36-0.20240923134141-bdba60bb6bcd h1:2vJk299/KQbtTE/dUmwFW8dkn0RTru0F7EqFqSyMneQ=
github.com/multiversx/mx-chain-vm-go v1.5.36-0.20240923134141-bdba60bb6bcd/go.mod h1:EJF+vOF/9ZhACjcKhIeCUzr4CL31rWaeC9ReV8EJqfw=
github.com/multiversx/mx-chain-vm-v1_2-go v1.2.68 h1:L3GoAVFtLLzr9ya0rVv1YdTUzS3MyM7kQNBSAjCNO2g=
github.com/multiversx/mx-chain-vm-v1_2-go v1.2.68/go.mod h1:ixxwib+1pXwSDHG5Wa34v0SRScF+BwFzH4wFWY31saI=
github.com/multiversx/mx-chain-vm-v1_3-go v1.3.69 h1:G/PLsyfQV4bMLs2amGRvaLKZoW1DC7M+7ecVaLuaCNc=
Expand Down
116 changes: 114 additions & 2 deletions integrationTests/chainSimulator/vm/esdtImprovements_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4017,7 +4017,7 @@ func TestChainSimulator_metaESDT_mergeMetaDataFromMultipleUpdates(t *testing.T)
checkReservedField(t, cs, core.SystemAccountAddress, tokenID, 1, []byte{1})

retrievedMetaData := getMetaDataFromAcc(t, cs, core.SystemAccountAddress, tokenID, 2)
require.Equal(t, uint64(0), retrievedMetaData.Nonce)
require.Equal(t, uint64(1), retrievedMetaData.Nonce)
require.Equal(t, 0, len(retrievedMetaData.Name))
require.Equal(t, addrs[2].Bytes, retrievedMetaData.Creator)
require.Equal(t, newMetaData2.Royalties, []byte(hex.EncodeToString(big.NewInt(int64(retrievedMetaData.Royalties)).Bytes())))
Expand Down Expand Up @@ -4330,7 +4330,6 @@ func TestChainSimulator_dynamicNFT_mergeMetaDataFromMultipleUpdates(t *testing.T
checkMetaDataNotInAcc(t, cs, core.SystemAccountAddress, tokenID, 0)
checkMetaDataNotInAcc(t, cs, core.SystemAccountAddress, tokenID, 1)
checkMetaData(t, cs, addrs[0].Bytes, tokenID, 0, metaData)
newMetaData.Nonce = []byte{}
newMetaData.Attributes = []byte{}
checkMetaData(t, cs, addrs[1].Bytes, tokenID, 1, newMetaData)

Expand Down Expand Up @@ -4384,3 +4383,116 @@ func TestChainSimulator_dynamicNFT_mergeMetaDataFromMultipleUpdates(t *testing.T
checkMetaDataNotInAcc(t, cs, addrs[1].Bytes, tokenID, 1)
checkMetaData(t, cs, addrs[2].Bytes, tokenID, 2, mergedMetaData)
}

func TestChainSimulator_dynamicNFT_changeMetaDataForOneNFTShouldNotChangeOtherNonces(t *testing.T) {
t.Parallel()

baseIssuingCost := "1000"
cs, _ := getTestChainSimulatorWithDynamicNFTEnabled(t, baseIssuingCost)
defer cs.Close()

addrs := createAddresses(t, cs, true)

log.Info("Register dynamic NFT token")

ticker := []byte("NFTTICKER")
tokenName := []byte("tokenName")

txDataField := bytes.Join(
[][]byte{
[]byte("registerDynamic"),
[]byte(hex.EncodeToString(tokenName)),
[]byte(hex.EncodeToString(ticker)),
[]byte(hex.EncodeToString([]byte("NFT"))),
},
[]byte("@"),
)

callValue, _ := big.NewInt(0).SetString(baseIssuingCost, 10)

shard0Nonce := uint64(0)
tx := &transaction.Transaction{
Nonce: shard0Nonce,
SndAddr: addrs[0].Bytes,
RcvAddr: vm.ESDTSCAddress,
GasLimit: 100_000_000,
GasPrice: minGasPrice,
Signature: []byte("dummySig"),
Data: txDataField,
Value: callValue,
ChainID: []byte(configs.ChainID),
Version: 1,
}
shard0Nonce++

txResult, err := cs.SendTxAndGenerateBlockTilTxIsExecuted(tx, maxNumOfBlockToGenerateWhenExecutingTx)
require.Nil(t, err)
require.NotNil(t, txResult)

require.Equal(t, "success", txResult.Status.String())

tokenID := txResult.Logs.Events[0].Topics[0]
roles := [][]byte{
[]byte(core.ESDTRoleNFTCreate),
[]byte(core.ESDTRoleTransfer),
[]byte(core.ESDTRoleNFTUpdate),
}
setAddressEsdtRoles(t, cs, shard0Nonce, addrs[0], tokenID, roles)
shard0Nonce++

err = cs.GenerateBlocks(10)
require.Nil(t, err)

metaData := txsFee.GetDefaultMetaData()
metaData.Nonce = []byte(hex.EncodeToString(big.NewInt(1).Bytes()))

tx = esdtNftCreateTx(shard0Nonce, addrs[0].Bytes, tokenID, metaData, 1)
shard0Nonce++
txResult, err = cs.SendTxAndGenerateBlockTilTxIsExecuted(tx, maxNumOfBlockToGenerateWhenExecutingTx)
require.Nil(t, err)
require.NotNil(t, txResult)
require.Equal(t, "success", txResult.Status.String())

metaData.Nonce = []byte(hex.EncodeToString(big.NewInt(2).Bytes()))
tx = esdtNftCreateTx(shard0Nonce, addrs[0].Bytes, tokenID, metaData, 1)
shard0Nonce++
txResult, err = cs.SendTxAndGenerateBlockTilTxIsExecuted(tx, maxNumOfBlockToGenerateWhenExecutingTx)
require.Nil(t, err)
require.NotNil(t, txResult)
require.Equal(t, "success", txResult.Status.String())

err = cs.GenerateBlocks(10)
require.Nil(t, err)

log.Info("give update role to another account and update metaData for nonce 2")

shard0Nonce = transferSpecialRoleToAddr(t, cs, shard0Nonce, tokenID, addrs[0].Bytes, addrs[1].Bytes, []byte(core.ESDTRoleNFTUpdate))

newMetaData := &txsFee.MetaData{}
newMetaData.Nonce = []byte(hex.EncodeToString(big.NewInt(2).Bytes()))
newMetaData.Name = []byte(hex.EncodeToString([]byte("name2")))
newMetaData.Hash = []byte(hex.EncodeToString([]byte("hash2")))
newMetaData.Royalties = []byte(hex.EncodeToString(big.NewInt(15).Bytes()))

tx = esdtMetaDataUpdateTx(tokenID, newMetaData, 0, addrs[1].Bytes)
txResult, err = cs.SendTxAndGenerateBlockTilTxIsExecuted(tx, maxNumOfBlockToGenerateWhenExecutingTx)
require.Nil(t, err)
require.NotNil(t, txResult)
require.Equal(t, "success", txResult.Status.String())

log.Info("transfer nft with nonce 1 - should not merge metaData")

tx = esdtNFTTransferTx(shard0Nonce, addrs[0].Bytes, addrs[1].Bytes, tokenID)
txResult, err = cs.SendTxAndGenerateBlockTilTxIsExecuted(tx, maxNumOfBlockToGenerateWhenExecutingTx)
require.Nil(t, err)
require.NotNil(t, txResult)
require.Equal(t, "success", txResult.Status.String())

err = cs.GenerateBlocks(10)
require.Nil(t, err)

checkMetaDataNotInAcc(t, cs, core.SystemAccountAddress, tokenID, 0)
checkMetaDataNotInAcc(t, cs, core.SystemAccountAddress, tokenID, 1)
metaData.Nonce = []byte(hex.EncodeToString(big.NewInt(1).Bytes()))
checkMetaData(t, cs, addrs[1].Bytes, tokenID, 1, metaData)
}

0 comments on commit 6dc2dda

Please sign in to comment.