Trying to perform a basic query using ethereum bridge / ganache / truffle.

I appear to have ethereum bridge running correctly.

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)

This is a contract that I have written.

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);
    }

}

I have a truffle test that calls the testQuery function.

ethereum bridge does seem to hear the request, which is good. However, it immediately errors out with this message that nobody seems to have has posted about on google. What does it mean? Database 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)**

Edit:

I am getting the same error in active mode.

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)
  • I've been facing the same issue – Adil Mar 6 at 14:55
up vote 0 down vote accepted

As an addendum to my previous answer, which appears to have been incorrect, but ironically did fix the issue for some, the real issue was identified after some tinkering with the bridge.

When using ganache or the like, and running unit tests, the blockchain's state is reverted to a previous state. If making a query, and then having the tests abruptly end without ever checking the eventual callback result via a promise or the like, truffle reverts ganache's state. The ethereum-bridge is not aware of this, and checks for the block hash that contained the query. Ganache then replies with Key not found in database error. There is a fix for this in the ethereum-bridge repo which will look to be merged soon.

The culprit in your case is that you're running the bridge in an alternative mode, due to the --broadcast flag, in which case it will not piggyback the accounts of your web3 node, but instead will use some manually added private keys entered into the bridge, of course you have not done this, so the bridge will fail with Key not found in database.

The simple solution is to run without the --broadcast flag, which is the turnkey solution for using it with ganache etc.

  • Might be good to add a straightforward explanation about the difference between these to the readme --github.com/oraclize/ethereum-bridge/blob/master/README.md – jazzhole Mar 6 at 17:26
  • I'm still getting the same error in active mode. – jazzhole Mar 6 at 20:17
  • Okie dokie -- it's working now that I'm starting ganache with the command line tool and unlocking account 1. with ganache-cli -u 0 -u 1 and then starting ethereum bridge with node bridge -H localhost:7545 -a 1 --dev and then running truffle test. Though my contracts aren't deploying correctly now. But ethereum bridge is working. – jazzhole Mar 6 at 20:40
  • Now I'm getting this error again. Confusing. – jazzhole Mar 8 at 4:59
  • So the verdict is that my call works about 5% of the time. As far as I can tell, ethereum bridge is just broken, as I'm following all documentation and instructions and am still getting this "key not found in database" error. Maybe I'll create a github issue. – jazzhole Mar 8 at 16:27

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.