Web3js

Parity Aura - 錯誤:交易已被 EVM 還原

  • November 1, 2019

我針對兩個私有區塊鏈 parity-aura 和 geth-clique 執行以下程式碼。為什麼平價交易會恢復,為什麼它使用 6,000,000gas 而它實際上應該只使用大約 44709gas?

JS程式碼

contract = new web3.eth.Contract(KVStoreABI);
contract.options.address = contractAddress;
tx = contract.methods.set("hello", "world");
tx.send({ "from": fromAddress })
       .once('transactionHash', function (hash) {
           console.log("TX RECEIVED:", hash)
       })
       .once('receipt', function (receipt) {
           console.log("RECEIPT:\n", receipt)
       })
       .on('error', function (error) {
           console.log("ERROR\n:", error)
       })
       .then(function (receipt) {
           console.log("TX MINED:", receipt.transactionHash)
       });

kvstore.sol

pragma solidity ^0.5.7;

contract KVstore {

 mapping(string=>string) public store;

 function get(string memory key) public view returns(string memory) {
   return store[key];
 }
 function set(string memory key, string memory value) public {
   store[key] = value;
 }
}

奇偶光環

Contract at: 0xd653D36C16c01dC6c0802B571Bb4B129A2Cb2CD7
Sending  1txs...

TX RECEIVED: 0x0d5e8b19a8706bf2f1e1c46e35081353e140d5a0b608c0b65aae6225cd41a8b3
(node:29273) UnhandledPromiseRejectionWarning: Error: Transaction has been reverted by the EVM:
{
 "blockHash": "0xa1ef20cfdb0790d3fa00420cd892e7cfd59e013c45cd794d0766f8f076e54ff6",
 "blockNumber": 20,
 "contractAddress": null,
 "cumulativeGasUsed": 6000000,
 "from": "0x933e73c3f959759c169effa4019c8faf7d05ce33",
 "gasUsed": 6000000,
 "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
 "root": null,
 "status": false,
 "to": "0xd653d36c16c01dc6c0802b571bb4b129a2cb2cd7",
 "transactionHash": "0x0d5e8b19a8706bf2f1e1c46e35081353e140d5a0b608c0b65aae6225cd41a8b3",
 "transactionIndex": 0,
 "events": {}
}
at /home/ubuntu/node_modules/web3-core-method/src/index.js:412:37
at processTicksAndRejections (internal/process/task_queues.js:93:5)

桀斯集團

Contract at: 0x4032E20ea7bb7F1F9dA448D661B3B27EcbCa9DFd
Sending  1txs...

TX RECEIVED: 0x0d7766a5eab1fa3220c9401dc74444360653932fa467941b3e38e033aca132ad
RECEIPT:
{
 blockHash: '0x177e9d9c12bdfc8cfa895e7bc545e801baca1310e2637637d9dd3afd8a31e063',
 blockNumber: 326,
 contractAddress: null,
 cumulativeGasUsed: 44709,
 from: '0x933e73c3f959759c169effa4019c8faf7d05ce33',
 gasUsed: 44709,
 logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
 status: true,
 to: '0x4032e20ea7bb7f1f9da448d661b3b27ecbca9dfd',
 transactionHash: '0x0d7766a5eab1fa3220c9401dc74444360653932fa467941b3e38e033aca132ad',
 transactionIndex: 0,
 events: {}
}
TX MINED: 0x0d7766a5eab1fa3220c9401dc74444360653932fa467941b3e38e033aca132ad

我的理解是,隨著君士坦丁堡分叉和聖彼得堡的出現,EVM 程式碼發生了變化,並且使用solidity 0.5.5 及更高版本編譯的合約僅與執行君士坦丁堡/聖彼得堡的網路兼容

來自Github Parity-乙太坊

我用solidity 0.5.0編譯了合約,它解決了這個問題,現在可以執行兩種實現了!

引用自:https://ethereum.stackexchange.com/questions/76693