difftreelog
Merge branch 'develop' into tests/generalization
in: master
30 files changed
pallets/evm-contract-helpers/src/stubs/ContractHelpers.rawdiffbeforeafterbothbinary blob — no preview
pallets/fungible/src/erc.rsdiffbeforeafterboth57 },57 },58}58}595960#[solidity_interface(name = ERC20, events(ERC20Events))]60#[solidity_interface(name = ERC20, events(ERC20Events), expect_selector = 0x942e8b22)]61impl<T: Config> FungibleHandle<T> {61impl<T: Config> FungibleHandle<T> {62 fn name(&self) -> Result<String> {62 fn name(&self) -> Result<String> {63 Ok(decode_utf16(self.name.iter().copied())63 Ok(decode_utf16(self.name.iter().copied())136 Ok(<Allowance<T>>::get((self.id, owner, spender)).into())136 Ok(<Allowance<T>>::get((self.id, owner, spender)).into())137 }137 }138139 /// @notice Returns collection helper contract address140 fn collection_helper_address(&self) -> Result<Address> {141 Ok(T::ContractAddress::get())142 }143}138}144139145#[solidity_interface(name = ERC20Mintable)]140#[solidity_interface(name = ERC20Mintable)]313 Ok(true)308 Ok(true)314 }309 }310311 /// @notice Returns collection helper contract address312 fn collection_helper_address(&self) -> Result<Address> {313 Ok(T::ContractAddress::get())314 }315}315}316316317#[solidity_interface(317#[solidity_interface(pallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth511 bytes value;511 bytes value;512}512}513513514/// @dev the ERC-165 identifier for this interface is 0x7dee5997514/// @dev the ERC-165 identifier for this interface is 0x65789571515contract ERC20UniqueExtensions is Dummy, ERC165 {515contract ERC20UniqueExtensions is Dummy, ERC165 {516 /// @notice A description for the collection.516 /// @notice A description for the collection.517 /// @dev EVM selector for this function is: 0x7284e416,517 /// @dev EVM selector for this function is: 0x7284e416,608 return false;608 return false;609 }609 }610611 /// @notice Returns collection helper contract address612 /// @dev EVM selector for this function is: 0x1896cce6,613 /// or in textual repr: collectionHelperAddress()614 function collectionHelperAddress() public view returns (address) {615 require(false, stub_error);616 dummy;617 return 0x0000000000000000000000000000000000000000;618 }610}619}611620612/// @dev anonymous struct621/// @dev anonymous struct637 event Approval(address indexed owner, address indexed spender, uint256 value);646 event Approval(address indexed owner, address indexed spender, uint256 value);638}647}639648640/// @dev the ERC-165 identifier for this interface is 0x8cb847c4649/// @dev the ERC-165 identifier for this interface is 0x942e8b22641contract ERC20 is Dummy, ERC165, ERC20Events {650contract ERC20 is Dummy, ERC165, ERC20Events {642 /// @dev EVM selector for this function is: 0x06fdde03,651 /// @dev EVM selector for this function is: 0x06fdde03,643 /// or in textual repr: name()652 /// or in textual repr: name()725 return 0;734 return 0;726 }735 }727728 /// @notice Returns collection helper contract address729 /// @dev EVM selector for this function is: 0x1896cce6,730 /// or in textual repr: collectionHelperAddress()731 function collectionHelperAddress() public view returns (address) {732 require(false, stub_error);733 dummy;734 return 0x0000000000000000000000000000000000000000;735 }736}736}737737738contract UniqueFungible is Dummy, ERC165, ERC20, ERC20Mintable, ERC20UniqueExtensions, Collection {}738contract UniqueFungible is Dummy, ERC165, ERC20, ERC20Mintable, ERC20UniqueExtensions, Collection {}pallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterbothbinary blob — no preview
pallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/refungible/src/stubs/UniqueRefungibleToken.rawdiffbeforeafterbothbinary blob — no preview
pallets/unique/src/eth/stubs/CollectionHelpers.rawdiffbeforeafterbothbinary blob — no preview
tests/src/benchmarks/mintFee/benchmark.tsdiffbeforeafterboth1import {EthUniqueHelper, usingEthPlaygrounds} from '../../eth/util';1import {EthUniqueHelper, usingEthPlaygrounds} from '../../eth/util';2import {readFile} from 'fs/promises';2import {readFile} from 'fs/promises';3import {ContractImports} from '../../eth/util/playgrounds/types';3import {ContractImports, TokenPermissionField} from '../../eth/util/playgrounds/types';4import {4import {5 ICrossAccountId,5 ICrossAccountId,6 ITokenPropertyPermission,6 ITokenPropertyPermission,58 substrateFee: number;58 substrateFee: number;59 ethFee: number;59 ethFee: number;60 ethBulkFee: number;60 ethBulkFee: number;61 ethMintCrossFee: number;61 evmProxyContractFee: number;62 evmProxyContractFee: number;62 evmProxyContractBulkFee: number;63 evmProxyContractBulkFee: number;63}64}6465interface IBenchmarkCollection {66 createFee: number,67 mintFee: number,68 transferFee: number,69}65const main = async () => {70const main = async () => {66 const benchmarks = [71 const benchmarks = [67 'substrateFee',72 'substrateFee',68 'ethFee',73 'ethFee',69 'ethBulkFee',74 'ethBulkFee',75 'ethMintCrossFee',70 'evmProxyContractFee',76 'evmProxyContractFee',71 'evmProxyContractBulkFee',77 'evmProxyContractBulkFee',72 ];78 ];82 });88 });838984 await usingEthPlaygrounds(async (helper, privateKey) => {90 await usingEthPlaygrounds(async (helper, privateKey) => {91 const NOMINAL = helper.balance.getOneTokenNominal();85 const CONTRACT_SOURCE = (92 const CONTRACT_SOURCE = (86 await readFile(`${__dirname}/proxyContract.sol`)93 await readFile(`${__dirname}/proxyContract.sol`)87 ).toString();94 ).toString();95 const ZEPPELIN_OBJECT = '0x' + (await readFile(`${__dirname}/openZeppelin/bin/ZeppelinContract.bin`)).toString();96 const ZEPPELIN_ABI = JSON.parse((await readFile(`${__dirname}/openZeppelin/bin/ZeppelinContract.abi`)).toString());889789 const donor = await privateKey('//Alice'); // Seed from account with balance on this network98 const donor = await privateKey('//Alice'); // Seed from account with balance on this network99 const [substrateReceiver] = await helper.arrange.createAccounts([10n], donor);10090 const ethSigner = await helper.eth.createAccountWithBalance(donor, 100n);101 const ethSigner = await helper.eth.createAccountWithBalance(donor, 100n);102 const ethReceiver = await helper.eth.createAccountWithBalance(donor, 5n);103 104 let susbtrateCollection: UniqueNFTCollection | null;105 const createCollectionSubstrateFee = convertToTokens(106 await helper.arrange.calculcateFee({Substrate: donor.address}, async () => {107 susbtrateCollection = await helper.nft.mintCollection(donor, {tokenPropertyPermissions: [108 {109 key: 'url',110 permission: {111 tokenOwner: true,112 collectionAdmin: true,113 mutable: true,114 },115 },116 ]});117 }),118 NOMINAL,119 );120121 const susbstrateMintFee = convertToTokens(122 await helper.arrange.calculcateFee(123 {Substrate: donor.address},124 () => susbtrateCollection!.mintToken(donor, {Substrate: substrateReceiver.address}, [{key: 'url', value: 'test'}]),125 ),126 NOMINAL,127 );128 const susbstrateTransferFee = convertToTokens(129 await helper.arrange.calculcateFee(130 {Substrate: substrateReceiver.address},131 () => susbtrateCollection!.transferToken(substrateReceiver, 1, {Substrate: donor.address}),132 ),133 NOMINAL,134 );135 const substrateFee: IBenchmarkCollection = {136 createFee: createCollectionSubstrateFee,137 mintFee: susbstrateMintFee,138 transferFee: susbstrateTransferFee,139 };140141 const helperContract = await helper.ethNativeContract.collectionHelpers(ethSigner);142143 let ethContract: Contract | null = null;144145 const createCollectionEthFee = convertToTokens(146 await helper.arrange.calculcateFee({Ethereum: ethSigner}, async () => {147 const result = await helperContract.methods.createNFTCollection('a', 'b', 'c').send({from: ethSigner, value: Number(2n * helper.balance.getOneTokenNominal())});148 ethContract = await helper.ethNativeContract.collection(helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId), 'nft', ethSigner);149 }),150 NOMINAL,151 );152153 await ethContract!.methods.setTokenPropertyPermissions([154 ['url', [155 [TokenPermissionField.Mutable, true],156 [TokenPermissionField.TokenOwner, true],157 [TokenPermissionField.CollectionAdmin, true]],158 ],159 ]).send({from: ethSigner});160161 const ethMintFee = convertToTokens(await helper.arrange.calculcateFee(162 {Ethereum: ethSigner},163 () => ethContract!.methods.mintCross(164 helper.ethCrossAccount.fromAddress(ethReceiver),165 [{key: 'url', value: Buffer.from('test')}],166 )167 .send({from: ethSigner}),168 ), NOMINAL);169170 const ethTransferFee = convertToTokens(await helper.arrange.calculcateFee(171 {Ethereum: ethReceiver},172 () => ethContract!.methods.transferFrom(ethReceiver, ethSigner, 1)173 .send({from: ethReceiver}),174 ), NOMINAL);175176 const ethFee: IBenchmarkCollection = {177 createFee: createCollectionEthFee,178 mintFee: ethMintFee,179 transferFee: ethTransferFee,180 };181182 let zeppelelinContract: Contract | null = null;183184 const zeppelinDeployFee = convertToTokens(185 await helper.arrange.calculcateFee({Ethereum: ethSigner}, async () => {186 zeppelelinContract = await helper.ethContract.deployByAbi(187 ethSigner,188 ZEPPELIN_ABI,189 ZEPPELIN_OBJECT,190 );191 }),192 NOMINAL,193 );194195 const zeppelinMintFee = convertToTokens(await helper.arrange.calculcateFee(196 {Ethereum: ethSigner},197 () => zeppelelinContract!.methods.safeMint(ethReceiver, 'test').send({from: ethSigner}),198 ), NOMINAL);199200201 const zeppelinTransferFee = convertToTokens(await helper.arrange.calculcateFee(202 {Ethereum: ethReceiver},203 () => zeppelelinContract!.methods.safeTransferFrom(ethReceiver, ethSigner, 0).send({from: ethReceiver}),204 ), NOMINAL);205206 const zeppelinFee: IBenchmarkCollection = {207 createFee: zeppelinDeployFee,208 mintFee: zeppelinMintFee,209 transferFee: zeppelinTransferFee,210 };211212 console.log('collection ops fees');213 const results = {substrate: substrateFee, eth: ethFee, zeppelin: zeppelinFee};214 console.table(results);9121592 const contract = await helper.ethContract.deployByCode(216 const contract = await helper.ethContract.deployByCode(93 ethSigner,217 ethSigner,366 },490 },367 );491 );492493 const ethMintCrossFee = await calculateFeeNftMintWithProperties(494 helper,495 privateKey,496 {Ethereum: ethSigner},497 ethSigner,498 proxyContract.options.address,499 async (collection) => {500 const evmContract = await helper.ethNativeContract.collection(501 helper.ethAddress.fromCollectionId(collection.collectionId),502 'nft',503 );504505 await evmContract.methods.mintCross(506 helper.ethCrossAccount.fromAddress(receiverEthAddress),507 PROPERTIES.slice(0, setup.propertiesNumber),508 )509 .send({from: ethSigner});510 },511 );368512369 const proxyContractFee = await calculateFeeNftMintWithProperties(513 const proxyContractFee = await calculateFeeNftMintWithProperties(370 helper,514 helper,405 substrateFee: convertToTokens(substrateFee, nominal),549 substrateFee: convertToTokens(substrateFee, nominal),406 ethFee: convertToTokens(ethFee, nominal),550 ethFee: convertToTokens(ethFee, nominal),407 ethBulkFee: convertToTokens(ethBulkFee, nominal),551 ethBulkFee: convertToTokens(ethBulkFee, nominal),552 ethMintCrossFee: convertToTokens(ethMintCrossFee, nominal),408 evmProxyContractFee: convertToTokens(proxyContractFee, nominal),553 evmProxyContractFee: convertToTokens(proxyContractFee, nominal),409 evmProxyContractBulkFee: convertToTokens(proxyContractBulkFee, nominal),554 evmProxyContractBulkFee: convertToTokens(proxyContractBulkFee, nominal),410 };555 };tests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/README.mddiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/access/Ownable.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/token/ERC721/ERC721.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/token/ERC721/IERC721.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/token/ERC721/IERC721Receiver.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/utils/Address.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/utils/Context.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/utils/Counters.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/utils/Strings.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/utils/introspection/ERC165.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/utils/introspection/IERC165.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/utils/math/Math.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ZeppelinContract.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/bin/ZeppelinContract.abidiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/bin/ZeppelinContract.bindiffbeforeafterbothno changes
tests/src/eth/api/UniqueFungible.soldiffbeforeafterboth353 bytes value;353 bytes value;354}354}355355356/// @dev the ERC-165 identifier for this interface is 0x7dee5997356/// @dev the ERC-165 identifier for this interface is 0x65789571357interface ERC20UniqueExtensions is Dummy, ERC165 {357interface ERC20UniqueExtensions is Dummy, ERC165 {358 /// @notice A description for the collection.358 /// @notice A description for the collection.359 /// @dev EVM selector for this function is: 0x7284e416,359 /// @dev EVM selector for this function is: 0x7284e416,404 uint256 amount404 uint256 amount405 ) external returns (bool);405 ) external returns (bool);406407 /// @notice Returns collection helper contract address408 /// @dev EVM selector for this function is: 0x1896cce6,409 /// or in textual repr: collectionHelperAddress()410 function collectionHelperAddress() external view returns (address);406}411}407412408/// @dev anonymous struct413/// @dev anonymous struct427 event Approval(address indexed owner, address indexed spender, uint256 value);432 event Approval(address indexed owner, address indexed spender, uint256 value);428}433}429434430/// @dev the ERC-165 identifier for this interface is 0x8cb847c4435/// @dev the ERC-165 identifier for this interface is 0x942e8b22431interface ERC20 is Dummy, ERC165, ERC20Events {436interface ERC20 is Dummy, ERC165, ERC20Events {432 /// @dev EVM selector for this function is: 0x06fdde03,437 /// @dev EVM selector for this function is: 0x06fdde03,433 /// or in textual repr: name()438 /// or in textual repr: name()469 /// or in textual repr: allowance(address,address)474 /// or in textual repr: allowance(address,address)470 function allowance(address owner, address spender) external view returns (uint256);475 function allowance(address owner, address spender) external view returns (uint256);471472 /// @notice Returns collection helper contract address473 /// @dev EVM selector for this function is: 0x1896cce6,474 /// or in textual repr: collectionHelperAddress()475 function collectionHelperAddress() external view returns (address);476}476}477477478interface UniqueFungible is Dummy, ERC165, ERC20, ERC20Mintable, ERC20UniqueExtensions, Collection {}478interface UniqueFungible is Dummy, ERC165, ERC20, ERC20Mintable, ERC20UniqueExtensions, Collection {}