Testrpc

“在數據庫中找不到密鑰”乙太坊橋錯誤

  • October 23, 2018

嘗試使用 ethereum bridge / ganache / truffle 執行基本查詢。

我似乎讓乙太坊橋執行正常。

iPod-Classic-3:ethereum-bridge benandre$ node bridge -H localhost:7545 --broadcast -a 0
Please wait...
[2018-03-04T11:46:28.162Z] INFO you are running ethereum-bridge - version: 0.5.5
[2018-03-04T11:46:28.163Z] INFO saving logs to: ./bridge.log
[2018-03-04T11:46:28.164Z] INFO using broadcast mode
[2018-03-04T11:46:28.164Z] INFO Connecting to eth node http://localhost:7545
[2018-03-04T11:46:29.217Z] INFO connected to node type EthereumJS TestRPC/v3.0.0-beta.0/ethereum-js
[2018-03-04T11:46:29.586Z] WARN Using 0xcd7f4a4af40f291f9f2bf1cf538fb44a6c94e4dc to query contracts on your blockchain, make sure it is unlocked and do not use the same address to deploy your contracts
[2018-03-04T11:46:29.681Z] WARN 0xcd7f4a4af40f291f9f2bf1cf538fb44a6c94e4dc doesn't have enough funds to cover transaction costs, please send at least 0.05 ETH
Authorize the bridge to move funds automatically from your node? [Y/n]: Y
Please choose the unlocked account index number in your node: 7
send 0.05 ETH from account 0x0f4f2ac550a1b4e2280d04c21cea7ebd822934b5 (index n.: 7) to 0xcd7f4a4af40f291f9f2bf1cf538fb44a6c94e4dc ? [Y/n]: Y
[2018-03-04T11:46:39.797Z] INFO received funds
[2018-03-04T11:46:39.799Z] INFO deploying the oraclize connector contract...
[2018-03-04T11:46:50.336Z] INFO connector deployed to: 0x5daf19eb687b6e9bc96b7920e7a1206f2c1e2555
[2018-03-04T11:46:50.430Z] INFO deploying the address resolver with a deterministic address...
[2018-03-04T11:47:11.640Z] INFO address resolver (OAR) deployed to: 0x6f485c8bf6fc43ea212e93bbf8ce046c7f1cb475
[2018-03-04T11:47:11.640Z] INFO updating connector pricing...
[2018-03-04T11:47:22.600Z] INFO successfully deployed all contracts
[2018-03-04T11:47:22.604Z] INFO instance configuration file saved to /Users/benandre/ethereum-bridge/config/instance/oracle_instance_20180304T064722.json

Please add this line to your contract constructor:

OAR = OraclizeAddrResolverI(0x6f485C8BF6fc43eA212E93BBF8ce046C7f1cb475);

[2018-03-04T11:47:22.611Z] WARN re-org block listen is disabled while using TestRPC
[2018-03-04T11:47:22.611Z] WARN if you are running a test suit with Truffle and TestRPC or your chain is reset often please use the --dev mode
[2018-03-04T11:47:22.612Z] INFO Listening @ 0x5daf19eb687b6e9bc96b7920e7a1206f2c1e2555 (Oraclize Connector)

這是我寫的契約。

contract testContract is usingOraclize {

   event callback_received(string goodies);

   function __callback(bytes32 myid, string result) {
       callback_received(result);
   }

   function testQuery() {
       oraclize_query("URL", "json(http://api.fixer.io/latest?symbols=USD,GBP).rates.GBP");
   }

   function testContract() {
       OAR = OraclizeAddrResolverI(0x6f485C8BF6fc43eA212E93BBF8ce046C7f1cb475);
   }

}

我有一個呼叫 testQuery 函式的松露測試。

乙太坊橋似乎確實聽到了請求,這很好。但是,它立即錯誤地出現這條消息,似乎沒有人在Google上發布過。這是什麼意思?數據庫saywhatnow?

**Error: Key not found in database
   at Object.InvalidResponse (/Users/benandre/ethereum-bridge/node_modules/web3/lib/web3/errors.js:38:16)
   at RequestManager.send (/Users/benandre/ethereum-bridge/node_modules/web3/lib/web3/requestmanager.js:61:22)
   at Eth.send [as getBlock] (/Users/benandre/ethereum-bridge/node_modules/web3/lib/web3/method.js:145:58)
   at parseLog (/Users/benandre/ethereum-bridge/lib/bridge-log-manager.js:130:59)
   at /Users/benandre/ethereum-bridge/node_modules/web3/lib/web3/filter.js:120:21
   at Array.forEach (native)
   at /Users/benandre/ethereum-bridge/node_modules/web3/lib/web3/filter.js:119:32
   at Array.forEach (native)
   at Object.onMessage [as callback] (/Users/benandre/ethereum-bridge/node_modules/web3/lib/web3/filter.js:117:22)
   at /Users/benandre/ethereum-bridge/node_modules/web3/lib/web3/requestmanager.js:259:20
   at Array.forEach (native)
   at /Users/benandre/ethereum-bridge/node_modules/web3/lib/web3/requestmanager.js:258:12
   at XMLHttpRequest.request.onreadystatechange (/Users/benandre/ethereum-bridge/node_modules/web3/lib/web3/httpprovider.js:118:13)
   at XMLHttpRequestEventTarget.dispatchEvent (/Users/benandre/ethereum-bridge/node_modules/xhr2/lib/xhr2.js:64:18)
   at XMLHttpRequest._setReadyState (/Users/benandre/ethereum-bridge/node_modules/xhr2/lib/xhr2.js:354:12)
   at XMLHttpRequest._onHttpResponseEnd (/Users/benandre/ethereum-bridge/node_modules/xhr2/lib/xhr2.js:509:12)**

編輯:

我在活動模式下遇到同樣的錯誤。

iPod-Classic-3:ethereum-bridge benandre$ node bridge -H localhost:7545 -a 1 --dev
Please wait...
[2018-03-06T20:15:08.714Z] WARN --dev mode active, contract myid checks and pending queries are skipped, use this only when testing, not in production
[2018-03-06T20:15:08.715Z] INFO you are running ethereum-bridge - version: 0.5.5
[2018-03-06T20:15:08.715Z] INFO saving logs to: ./bridge.log
[2018-03-06T20:15:08.716Z] INFO using active mode
[2018-03-06T20:15:08.716Z] INFO Connecting to eth node http://localhost:7545
[2018-03-06T20:15:10.246Z] INFO connected to node type EthereumJS TestRPC/v3.0.0-beta.0/ethereum-js
[2018-03-06T20:15:10.608Z] WARN Using 0xf17f52151ebef6c7334fad080c5704d77216b732 to query contracts on your blockchain, make sure it is unlocked and do not use the same address to deploy your contracts
[2018-03-06T20:15:10.701Z] INFO deploying the oraclize connector contract...
[2018-03-06T20:15:21.042Z] INFO connector deployed to: 0xb9a219631aed55ebc3d998f17c3840b7ec39c0cc
[2018-03-06T20:15:21.134Z] INFO deploying the address resolver with a deterministic address...
[2018-03-06T20:15:42.197Z] INFO address resolver (OAR) deployed to: 0x6f485c8bf6fc43ea212e93bbf8ce046c7f1cb475
[2018-03-06T20:15:42.197Z] INFO updating connector pricing...
[2018-03-06T20:15:52.936Z] INFO successfully deployed all contracts
[2018-03-06T20:15:52.941Z] INFO instance configuration file saved to /Users/benandre/bridge/ethereum-bridge/config/instance/oracle_instance_20180306T151552.json

Please add this line to your contract constructor:

OAR = OraclizeAddrResolverI(0x6f485C8BF6fc43eA212E93BBF8ce046C7f1cb475);

[2018-03-06T20:15:52.951Z] WARN re-org block listen is disabled
[2018-03-06T20:15:52.951Z] INFO Listening @ 0xb9a219631aed55ebc3d998f17c3840b7ec39c0cc (Oraclize Connector)

(Ctrl+C to exit)

Error: Key not found in database
   at Object.InvalidResponse (/Users/benandre/bridge/ethereum-bridge/node_modules/web3/lib/web3/errors.js:38:16)
   at RequestManager.send (/Users/benandre/bridge/ethereum-bridge/node_modules/web3/lib/web3/requestmanager.js:61:22)
   at Eth.send [as getBlock] (/Users/benandre/bridge/ethereum-bridge/node_modules/web3/lib/web3/method.js:145:58)
   at parseLog (/Users/benandre/bridge/ethereum-bridge/lib/bridge-log-manager.js:130:59)
   at /Users/benandre/bridge/ethereum-bridge/node_modules/web3/lib/web3/filter.js:120:21
   at Array.forEach (native)
   at /Users/benandre/bridge/ethereum-bridge/node_modules/web3/lib/web3/filter.js:119:32
   at Array.forEach (native)
   at Object.onMessage [as callback] (/Users/benandre/bridge/ethereum-bridge/node_modules/web3/lib/web3/filter.js:117:22)
   at /Users/benandre/bridge/ethereum-bridge/node_modules/web3/lib/web3/requestmanager.js:259:20
   at Array.forEach (native)
   at /Users/benandre/bridge/ethereum-bridge/node_modules/web3/lib/web3/requestmanager.js:258:12
   at XMLHttpRequest.request.onreadystatechange (/Users/benandre/bridge/ethereum-bridge/node_modules/web3/lib/web3/httpprovider.js:118:13)
   at XMLHttpRequestEventTarget.dispatchEvent (/Users/benandre/bridge/ethereum-bridge/node_modules/xhr2/lib/xhr2.js:64:18)
   at XMLHttpRequest._setReadyState (/Users/benandre/bridge/ethereum-bridge/node_modules/xhr2/lib/xhr2.js:354:12)
   at XMLHttpRequest._onHttpResponseEnd (/Users/benandre/bridge/ethereum-bridge/node_modules/xhr2/lib/xhr2.js:509:12)

作為我之前答案的補充,這似乎是不正確的,但具有諷刺意味的是,確實解決了一些問題,真正的問題是在對橋樑進行一些修補後確定的。

當使用 ganache 等並執行單元測試時,區塊鏈的狀態會恢復到以前的狀態。如果進行查詢,然後讓測試突然結束而沒有通過 promise 等檢查最終的回調結果,truffle 會恢復 ganache 的狀態。乙太坊橋不知道這一點,並檢查包含查詢的塊雜湊。Ganache 然後回答Key not found in database錯誤。在 ethereum-bridge repo 中有一個解決這個問題,它看起來很快就會被合併。

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