Title: VDS Consensus Execution Contracts Cost Description Post by: lilialfahas94 on April 24, 2020, 03:36:29 AM From a certain perspective, the essence of smart contracts is bytecode. It is through these bytecodes that functions such as logical jumps, calculations, and storage are realized. Taking the creation of the 3rd-generation VDS group as an example, the compiled bytecode is 42,697 bytes, which does not include the initial settings such as group name, group rules, and group announcements. The most expensive part of the cost is to create contracts (GasPrice multiplied by GasLimit is the effective part of the cost, as in the Ethereum network)
These 42,697 bytes contain logic, calculations, and data types of the 3rd-generation VDS group, which cannot be further reduced. Excluding network fluctuations, it will consume 5,600,000*0.0000004=2.24 Vollar to make the data on-chain. Additional data such as group name, group rules, and group announcements should also be converted into code and calculated. That is to say, in order to ensure the successful execution of contracts, you have to pay a sufficient amount of Gas to support its consumption process. 0.0000004 Vollar is set as the lower limit of GasPrice while the rest is adjustable according to GasLimit. There’s also a cap on GasLimit, which means we cannot add so much content into the smart contracts and execute them. Infinite loops such as the Mobius Strip can never be executed in the smart contracts since it has exceeded the upper limit of 50,000,000 Vollar. The amount of Gas required to execute a smart contract also varies, depending on how the smart contract is executed, its complexity, and the amount of data to be modified and stored. Even if we adopt minimal execution (aka “Empty Function”), it would cost 21,000 GasLimit, converted to a handling fee of 0.0000004*21,000=0.0084 Vollar. The creation of OTC contracts costs 260,000*0.0000004 = 1.04 Vollar, execution costs 45,000*0.0000004=0.018 Vollar. The cost accuracy of OTC contracts is around 0.001 Vollar. It should be noted that we cannot simply use a unified method to calculate the value of bytecode, but should take into consideration the logic complexity of calculation and the influence of special cases such as network fluctuations. About External Contract Call The current group interfaces include setting group name, group announcement, group rules, group entry fee, trading mode (trading pair, which can be modified by group admin and not affect the actual transaction. Like an agreement), whether you need admin approval to enter the group, admin rejects group application, admin removes group members, bulk permission of group entry, increasing the upper limit of group members, individual application for group entry, individual application cancel, group member leaves the group, additional margin from the admin, admin withdraw group deposit. A contract fee is required for all of the above-mentioned interfaces while some of the query type don’t. Take setting the group name as an example. Name the group “Me*100”, record this operation as “A”. The generated code size is 841 bytes, and the Gas cost is 271,338 (Gas is the calculation method of cost, which is specially used to calculate the cost of contracts. The minimum unit of Vollar is shatoshi, 0.000004 represents 40 shatoshi, 271,338 meaning 271,338 units of 40 shatoshi are spent. The handling fee is 271,338*0. 0000004=0.1085352 Vollar. On the basis of A, change the group name to “Me” and record this operation as “B”. The size of the generated code is 201 bytes and the Gas cost 41,915, handling fee 41,915*0.0000004 = 0.0016766 Vollar. On the basis of B, rename the group as “Me” and record operation as C. Gas cost is 33,260, handling fee 33,260*0.0000004 = 0.0013304 Vollar. It can be concluded that handling fee would become higher if there’s a large variation in content; handling fee becomes lower if there’s no big difference. Conclusion The principle of VDS smart contracts is the same as that of Ethereum. Ethereum cannot guarantee as well the accurate cost of each executed contract. Both VDS and ETH adopt prior estimation, which is usually higher than the actual cost. The current cost of group creation is around 2 Vollar. To further downsizing it requires removing certain interfaces that change single storage only, such as removing multiplexing interfaces like group name settings, group rule and group announcements for optimization. The creation of OTC contracts can hardly be optimized. What can be optimized is the interface of contract calls such as confirming receipts, which can be accurately calculated at a cost of about 0.02 Vollar per time. |