current position:Home>Conflux advanced course - the main differences between CVM and EVM virtual machine layers of conflux
Conflux advanced course - the main differences between CVM and EVM virtual machine layers of conflux
2022-02-03 00:39:23 【Conflux Chinese community】
take EVM Bytecode migration to Conflux On
Copy code
Conflux The deposit mechanism is adopted . When executing smart contracts , If you pass SSTORE (0x55) When an instruction writes non-zero data to storage , You need to pay a deposit . When this data is cleared , The deposit will be returned to the payer .
The price of deposit is 1/1024 CFX/byte. Each storage unit counts 64 byte . besides , After the contract is created , The code also requires a storage deposit .
The difference between the deposit mechanism
Copy code
Conflux The deposit mechanism is adopted . When executing smart contracts , If you pass SSTORE (0x55) When an instruction writes non-zero data to storage , You need to pay a deposit . When this data is cleared , The deposit will be returned to the payer .
The price of deposit is 1/1024 CFX/byte. Each storage unit counts 64 byte . besides , After the contract is created , The code also requires a storage deposit .
The maximum storage domain of the transaction
Copy code
stay Conflux in , You need to fill in the upper limit of each transaction , Unit is byte . If the storage limit is too high , It exceeds the deposit that can be paid by the account balance , The deal will fail . If the storage limit is too low , As a result, the actual newly added storage at the end of transaction execution exceeds the storage limit , The deal will also fail .
One of the simplest solutions is , adopt Conflux RPC Estimate ( Please refer to the relevant sections ) The maximum amount of storage required for a transaction . perhaps , Can pass n*1024 Calculate the maximum supported storage limit of account balance according to the formula of .( among n Is the balance after paying the transaction fee and account transfer fee . For the sake of insurance , You can also fill in a smaller number , Such as n*1000 )
Write the fuel consumed by storage
That's enough . stay Conflux in , all SSTORE (0x55) The fuel consumed by the command is 5000 gas. Comparison , The logic of Ethereum here is very complicated . however , The average developer doesn't need to care about the specifics of each instruction gas pricing , Just go through RPC Just estimate the fuel consumption of the whole transaction .
Differences arising from consensus mechanisms
Block height and block hash related instructions
Copy code
In Ethereum , BLOCKHASH (0x40) Instructions (Solidity Medium block.blockhash(n) function ) Accept block number ( Block height ) n As input , Output the hash value corresponding to the block height . Where the parameter height is n The height difference from the block where the transaction is executed cannot exceed 256, Otherwise it will return to 0.
Conflux Tree graph structure is adopted , When blocks are sorted , Each block will generate a sort number , This sort number is different from the block height . Because after the tree structure is sorted , Two adjacent blocks may have no parent-child relationship , So the number is n-1 The block is not necessarily numbered n The father of the block .
Conflux in BLOCKHASH (0x40) Instructions (Solidity Medium block.blockhash(n) function ) Accept block sort number n As input . Corresponding , NUMBER (0x43) Instructions (Solidity Medium block.number Variable ) The result is also a sort number .
Besides , Ethereal BLOCKHASH (0x40) The order can ask the exchange in front of the block 256 Hash value of blocks , and Conflux The instruction can only query the hash value of the previous block . however ,Conflux The number of parameters is no different from Ethereum .
Block out speed
Copy code
Conflux The output speed of is per second 2 Block , Much faster than Ethereum . If the block speed is hard coded in the code logic of the smart contract , Changes need to be made accordingly .
Fill in the information in the transaction
Copy code
When a user initiates a transaction ,Conflux The information you need to fill in is different . But in general RPC and SDK Will do this for developers and users .
Storage Limit: Storage cap . See The maximum storage domain of the transaction Section .
Gas Limit: Fuel cap . For unused gas, Conflux At most... Will be returned Gas Limit Of 1/4, So before sending out the deal , Be sure to estimate a more accurate upper fuel limit .
Chain ID: Blockchain number . Specify the blockchain number that can execute this transaction , Avoid someone replaying the transactions of the test network on the main network . at present , Test network Chain ID yes 1, Main network Chain ID yes 2.
Epoch Height: When the transaction is executed ( About the )epoch. If the transaction is actually executed Epoch With the transaction Epoch Height Difference between 100000 above (Epoch Number growth 100000 The time varies from half a day to a few days ), The transaction will fail . in other words , Transactions that have not been packaged for too long will not be executed .
Recipient: Conflux Your address algorithm is different from Ethereum . The first four addresses generated by all public keys bits All are 0001, The first four of all contract addresses bits All are 1000. The first four of all built-in contract addresses bits All are 0000. If the payee's address recipient The first four bits Not one of the three , Transaction execution failed .
Other differences
Copy code
After the contract is created , The creator ( That is, when the contract is created msg.sender ) Automatically become the administrator of the contract . The administrator has the right to destroy the contract , Or transfer administrator privileges to others . The administrator can be a normal address , It can also be the contract address .
Conflux The maximum number of contract codes created is 49152 byte , Twice as much as Ethereum .
Please check whether there is a hard coded Ethereum address in your contract .
Conflux There are other differences in , It's something that contract developers and users don't need to care about , Here we omit .
copyright notice
author[Conflux Chinese community],Please bring the original link to reprint, thank you.
https://en.fheadline.com/2022/02/202202030039187840.html
The sidebar is recommended
- Tencent's 9 apps are gradually restored and updated: including QQ music, enterprise wechat, etc
- Release of anti food waste work plan: it is forbidden to produce audio and video such as eating mostly and overeating
- [Jieju] many countries secretly help Taiwan build submarines? No one dares to admit it
- A fire in a building in Osaka, Japan, has caused 27 people's lung function to stop
- Pingdingshan youth help! Official latest response
- Why did Shanghai's "wanghong" community stop selling from "10000 people grabbing"?
- Gaode map Lane level navigation adaptation oppo find n folding screen mobile phone
- Rivian's share price fell more than 11% after announcing its first financial report
- Suddenly lost contact! What kind of "Waterloo" has Wang Chaoyong, a 10 billion PE boss, experienced
- Alpha's smart city project was merged into Google's project, and the founder and CEO resigned
guess what you like
-
See unreasonable pressure again! The US Treasury will list eight Chinese science and technology enterprises in the "investment blacklist"
-
Autonomous vehicles hit pedestrians! Waymo clarified that the driver was driving manually
-
Reddit submitted an IPO application with a valuation of more than US $15 billion
-
The biggest acquisition in Oracle's history! It is said that it plans to buy Senna for us $30 billion
-
According to the industry chain news, Samsung has obtained the OEM order of Italian French semiconductor MCU for the next generation iPhone
-
US regulators investigate "buy before pay" service providers
-
Sources said that Facebook's acquisition of kustomer was approved by the European Union
-
Google joins hands with well-known female video creators to send her blessings
-
Openai taught gpt-3 how to surf the Internet, and the AI model of "omniscient and omnipotent" was launched
-
Shangtang is expected to restart its IPO next Monday, maintaining its target of $767 million
Random recommended
- This company makes AI technology and focuses on "people"
- AI's prediction of protein structure has reached the annual technological breakthrough of science and nature, and AI for science has infinite potential
- The Institute of automation of the Chinese Academy of Sciences and the Northern Institute of electronic equipment have proposed a multi input text face synthesis method, and the data code has been open source
- PKS "tens of thousands" ecological cooperation action plan will be released in late December
- Netease Ding Lei: the discussion and continuous exploration of the unknown world is the best moral character of mankind
- Micro step online selected in Gartner 2021 Global Threat Intelligence Market Guide
- Foreign media said that Japan had invited TSMC to invest and build a factory in 2019, but it was rejected
- Make a fortune in silence! This year, the share prices of these overseas upstream manufacturers far outperformed Tesla
- Why does Tesla stick to the pure visual route?
- Just a happy day! U.S. stock technology giants fell across the board, and they still can't escape the tightening storm of the federal reserve after all?
- Oracle plans to acquire Cerner, an electronic medical information company
- Can the mobile phone be used for a week without charging? Samsung and IBM launch new chip transistor
- Douban's recovery function was restored. It was suspended two weeks ago
- Rivian announced its first financial report after listing: a net loss of $1.233 billion in the third quarter, expanding year-on-year
- Cha Yan Yuese apologized for the salary dispute: managers will reflect and correct their misconduct and dereliction of duty
- India plans to spend $10 billion to attract semiconductor and display manufacturers
- Hungry? Upgrade the knight support system and improve the knight experience from five dimensions
- New value of quark app link from retrieval to ecological service
- US court approves US $460 million debt restructuring plan of Ruixing coffee
- Where is the next boundary of cloud services? Amazon cloud technology has sent cloud services into space
- CEO of cruise, GM's autonomous driving subsidiary, resigned
- Tearful eyes! Liu Yutan, thank you for coming
- Bona film applies for the trademark of shuimenqiao of Changjin Lake
- Convenience bee is accused of secretly photographing hundreds of thousands of pedestrian data
- Wangsu technology won the "China Patent Excellence Award"
- Tea Yan Yuese is exposed to salary civil strife, and the monthly salary of employees does not exceed 3000
- The divorce of the couple who are the actual controllers of saiteng shares involves the division of property of 3 billion yuan. The enterprise investigation shows that the profit in the first three quarters exceeded 100 million yuan
- The board of directors of Lianhua electronics approved US $2.7 billion in capital expenditure for the purchase of new equipment
- There are more than 570 companies in chayan Yuese commercial territory
- Join hands with Zeiss and other partners vivo 2021 vision + to convey "the joy of humanity" with images
- Enterprise investigation shows that China Post has added education consulting services to its business scope
- Nezha automobile will hold "New Year's tide play" on December 22
- one's fundamental views get totally twisted! Shanghai Baoma group's highly sought after "Disney celebrities" are sad at home
- Fairy's Thoughts on Friday (in memory of 2021)
- Hard core watch 488 Google called the NSO Pegasus vulnerability "the most technically complex vulnerability ever"
- Hungry? The application for the trademark of hungry meow was rejected
- He is only one meter tall, but he guards the health of more than 2000 people
- Shell once again responded to the muddy water short report: there are a lot of factual errors and lack of basic understanding of the industry
- Hikvision "supports", and the smart home ecology of fluorite network still needs to grow
- The second Ruixing coffee? Is it tenable for muddy water to short shells