okTurtles / dnschain

A blockchain-based DNS + HTTP server that fixes HTTPS security, and more!
https://okturtles.com
Other
1.74k stars 169 forks source link

Feature-ethereum #61

Closed wemeetagain closed 9 years ago

wemeetagain commented 9 years ago

Adds rudimentary support for Ethereum blockchain lookups. It currently assumes ethereum, the go client, is running, with JSON-RPC enabled. This is defaulted to port 8080 currently.

Querying the Ethereum chain requires two parameters, the address, and key. Address is the contract address to look up, and key is the storage slot within the contract to query. These parameters are currently deduced by using the root element of the URL path as the address, and the rest as the key. ie: ethereum.dns/ADDRESS/KEY

taoeffect commented 9 years ago

OK, so I installed go-ethereum following Option 1 here for OS X, and I've got mist running with mist -rpc=true -upnp=true, but having difficulties from there.

First off, mist doesn't seem to be going very far past block 0: http://pastebin.com/iHSDHWf5

ethereum -rpc=true -upnp=true doesn't seem to be doing much better: http://pastebin.com/R3d1deM0

I tried querying either ethereum or mist via JSON-RPC (via cURL) and that doesn't work (but maybe something here is wrong):

-> % curl --data-binary '{"jsonrpc":"1.0","id":"curltext","method":"EthereumApi.GetStorageAt","params":[{"address": "blah", "key": "foo"]}' -H 'content-type:text/plain;' http://127.0.0.1:8080
curl: (52) Empty reply from server
taoeffect commented 9 years ago

Checked out this PR and tried: curl -H 'HOST: ethereum.dns' http://127.0.0.1:8088/foo/bar

DNSChain gave output:

2014-11-25T00:47:14.202Z - debug: [HTTP] request (<callback> http.coffee:47) 
{ path: 'foo/bar', url: '/foo/bar' }
2014-11-25T00:47:14.209Z - debug: [ETH] eth resolve (<resolve> eth.coffee:36) 
{ path: 'foo/bar' }

And curl just hung there.

taoeffect commented 9 years ago

Err, that might have been, not sure, because go-ethereum crashed: http://pastebin.com/2aDTrMRU

Edit: nope, restarted and still observing that hang.

wemeetagain commented 9 years ago

So it looks like there are two separate issues at play.

  1. Due to Ethereum's inability to handle HTTP RPC requests, we currently open a raw TCP socket for RPC on initialization, https://github.com/WeMeetAgain/dnschain/blob/feature-ethereum/src/lib/eth.coffee#L27, and use that same open socket for the lifetime of the application.

    This strategy fails when something breaks the socket (like ethereum crashing). Instead, we should open (and close) a new socket per RPC, to mirror what is done with the other chains.

  2. Ethereum's JSON-RPC is very fragile. Sending non-hex strings as parameters seems to cause a panic.
taoeffect commented 9 years ago

Great job, the hang seems to be gone! :+1:

Looks like this is almost ready to merge. :smile:

Ethereum is still crashing though, so how do you recommend I test it?

taoeffect commented 9 years ago

Just a note: according to @WeMeetAgain this PR is on hold until Ethereum gets their client into a stable state and finishes some refactoring project.

taoeffect commented 9 years ago

@WeMeetAgain said:

lets close for now