The difference between concepts: Epoch & storageLimit

In the Ethereum blockchain, only the transactions on the main chain are valid, so it can be considered that the Ethereum blockchain ledger is a single chain, and each block from front to back has a number called the block number. , conflux has developed a new ledger structure: tree graph, which achieves high throughput and low latency.

In the tree graph block structure, if you only look at the parent side, it is a Tree, and if the parent side refers to both sides, it is a Graph. It is this structure that allows the Conflux network to issue blocks concurrently, that is, multiple blocks can all be generated after a certain block. So there is no concept of block number in Conflux. However, in order to achieve total order, Conflux starts from the genesis block through the GHAST rule, and selects the heaviest subtree block as the pivot block among all its sub-blocks. All the pivot block chains to one block also form a chain defined as pivot chain. If Just look at the pivot chain, which is consistent with the ordinary blockchain structure. An Epoch is defined based on each pivot block on this chain. Therefore, you can understand the Epoch in conflux as a concept corresponding to the block number, except that the Epoch in conflux There may be multiple blocks in each epoch.

In the real world, sending a transfer transaction requires paying a fee to the bank, sending a transaction in Bitcoin requires paying a fee to the miner, and the same is true in Ethereum. Specifically, the transaction of the Ethereum network is finally executed by the EVM run by the miner. Gas is used to measure the workload of a transaction (which can be understood as the working hours). The sender of the transaction can specify the willingness to send the transaction. The price paid for each workload is gasPrice. So the final transaction fee is gas * gasPrice. The gas specified when sending a transaction is a limit value, that is, the sender is willing to pay so much gas for a transaction. be executed.

In the Dapp system, transaction execution requires miners to perform calculations and pay for computing resources, but also requires miners to store the state of the contract, so it needs to pay for storage resources. When sending a transaction in the Conflux system, it is also necessary to mortgage a part of the fee for state storage. Therefore, when sending a transaction in Conflux, there is one more storageLimit parameter than Ethereum, which is used to set the upper limit of the fee that is willing to be mortgaged for a certain transaction. After the contract releases the used storage space, the staking fee will also be returned.

Development tool difference

Conflux block chain existing development tools are Conflux Truffle and Conflux Studio , and its main function corresponding to Ethernet Square, the most widely used development tools Truffle and Remix .

Conflux-Truffle Vs Truffle

Conflux-Truffle as to Truffle as the prototype for the transformation of service contracts conflux block development tool chain. For details, please refer to Conflux-Truffle usage tutorial . The main differences between it and Truffle are as follows.

1. Name

project namenpmjs package nameThe name of the command line program after installation
Conflux-Truffleconflux-trufflecfxtruffle
Truffletruffletruffle

2. Ganache VS conflux-rust docker

Ganache is a tool officially provided by Truffle to facilitate the quick start of the Ethereum private chain when developing smart contracts.

conflux Buyer No Ganache corresponding version, but conflux provides conflux-docker , is also very easy to use, start conflux-docker default will start a private chain, the initial allocation of 10 accounts and assign cfx, and will automatically unlock these accounts.

The biggest difference between them is that Ganache provides a graphical interface to view the operation of the private chain and do some simple functional interactions. conflux will improve user experience related functions in the future.

3. subcommand

subcommandDoes Truffle supportDoes Conflux-Truffle support
buildobsoleteN
compileYY
configYY
consoleYY
createYY
debugYY
deployYY
developYN
execYY
helpYY
initYY
installYY
migrateYY
networksYY
obtainYY
opcodeYY
publishYY
runYY
testYY
unboxYY
versionYY
watchYY

ctxtruffle does not support subcommand cfxtruffle develop , other subcommand names and usage are the same as trffule ; this function will be added in subsequent versions.

4. subcommand context

When running cfxtruffle console/exec/run time, still can js-sdk related api and conflux interaction, but also injected js-conflux-sdk of Conflux and Util module, you can cfx and cfxutil use. As follows

# cfx
cfxtruffle(development)> await cfx.getBalance('0x148A9696F8DCf4d6cB01eC80F1047a3476bA5C56')
cfxtruffle(development)> await cfx.getNextNonce("0xbbd9e9be525ab967e633bcdaeac8bd5723ed4d6b")
# cfxutil
cfxtruffle(development)> let drip = cfxutil.unit.fromCFXToGDrip(0.1)
cfxtruffle(development)> let randomKey = cfxutil.sign.randomPrivateKey()

5. Local signature remote deployment

truffle , you can call the local wallet to sign HDWalletProvider cfxtruffle , you only need to set the privateKeys field in the network configuration. This field is an array of private keys. When sending a transaction or deploying a contract, it will automatically select the corresponding privateKeys the private key to sign. Examples are as follows

Truffle settings

// truffle-config.js
testnet: {
    provider: new HDWalletProvider("3f841bf589fdf83a521e55d51afddc34fa65351161eead24f064855fc29c9580", "http://localhost:7545"),        
    network_id: "*",       
    // 注意:从 portal 获取的私钥需要添加 0x 前缀,privateKeys 也可以指定单个 key,若配置了私钥,请注意不要将代码上传到公开代码仓储中。
    // privateKeys: ['your-private-key']  
}

Conflux-Trffle settings

// truffle-config.js
testnet: {
    host: "test.confluxrpc.org",
    port: 80,            
    network_id: "*",       
    // 注意:从 portal 获取的私钥需要添加 0x 前缀,privateKeys 也可以指定单个 key,若配置了私钥,请注意不要将代码上传到公开代码仓储中。
    // privateKeys: ['your-private-key']  
    privateKeys: ['0x3f841bf589fdf83a521e55d51afddc34fa65351161eead24f064855fc29c9583','0x4f841bf589fdf83a521e55d51afddc34fa65351161eead24f064855fc29c9581']
}

6. Parameters when calling rpc

As shown above, since the consensus method in conflux is different from that of Ethereum, and the concepts of epoch and storageLimit are added, these parameters are often required to be passed when interacting with conflux through rpc. For details, please refer to the difference between rpc and sdk.

Conflux Studio VS Remix

Conflux Studio is an integrated development environment that helps developers quickly develop Conflux smart contracts. Similar to Remix provides a graphical interface for developers to interact with contracts.
Remix is a browser-based application, while Conflux Studio is an independent executable program. In addition to the differences in program types, there are also many differences in its functions and usage methods.

FeaturesRemixConflux Studio
Edit contractYY
Debug contract codeYN
Contract error checkingYN
Compile and deploy contractsYY operates on the Project page, and the internal implementation is to call Conflux-Truffle compile
Display compilation and deployment result UI (including ABI and Bytecode)YY View the ABI of the contract compilation history in ABI Storage,
set gaslimitYN
Set constructor parameters when deploying the contractYN
Load contract instance based on ABI and addressYN
Tuple parameterYN
Support compilation optimizationYN
Support automatic compilation of contractsYN
Contract interaction UIYY operates on the Contract page
command terminalYY
Interact with sdk in command terminalweb3 injected in command terminalN
connection nodeConnect by setting the node urlProvides a Network tab, you can create nodes locally, you can also choose testnet and mainnet
Create and manage nodesYN
Built-in execution environment JavaScript VMYN
Initial Account AccountsAutomatically assigned, or imported via metamaskImport manually based on keystore or create via IDE
Support plug-in installationYN
Record the transaction for replay (including the transaction hash, the abi of the transaction creation contract)YN
Unit TestYN
import projectImport projects from local and other sources, such as github, gist, ipfs, etc.Built-in smart contract template, operate on the Project page
Account browserNY Enter the account address in the address bar of the Explorer page to view

database:


Conflux中文社区
66 声望19 粉丝

Conflux网址:[链接]