keep-network / local-setup

Allow to easily set up tBTC and Keep locally for development and test purposes.
MIT License
8 stars 16 forks source link

Add a Dockerized electrs server #72

Closed beaurancourt closed 3 years ago

beaurancourt commented 3 years ago

This PR adds a local electrs server to the ./run-bitcoin.sh script by adding a new docker container to the docker-compose file.

This goes hand-in-hand with the work in https://github.com/keep-network/keep-ecdsa/pull/768, which supplies a configurable electrs endpoint. Having the dockerized electrs server allows a developer to run run-bitcoin.sh and be able to point their ecdsa node at their local electrs, which in turn is running a local bitcoin node. Having all of this running locally speeds up the iterative development process!

To test:

$ ./run-bitcoin.sh

and then test an endpoint:

curl localhost:3002/blocks/1

beaushinkle@Beaus-MBP ~/local (run-electrs-docker)> curl localhost:3002/blocks/1
[{"id":"1964ee983389e337555eb88f0c698633b98825d0ddb33a91cadf744083c178b6","height":1,"version":536870912,"timestamp":1619039529,"tx_count":1,"size":249,"weight":888,"merkle_root":"1764c165f2e4dca8c4f902ed7951980774b2a76185ae23d045a3a4b03fa77afe","previousblockhash":"0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206","mediantime":1619039529,"nonce":0,"bits":545259519,"difficulty":0},{"id":"0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206","height":0,"version":1,"timestamp":1296688602,"tx_count":1,"size":285,"weight":1140,"merkle_root":"4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b","previousblockhash":null,"mediantime":1296688602,"nonce":2,"bits":545259519,"difficulty":0}]

If ./run-bitcoin.sh doesn't finish compiling, you may need to increase the amount of memory allocated to docker:

image

tagging @michalinacienciala for some initial review (I think this falls in your wheelhouse, but feel free to correct me if I'm wrong)

beaurancourt commented 3 years ago

Okay, went through and changed the dockerfile to use rust:alpine, and then verified that we were installing the minimum required packages to get it to compile

beaurancourt commented 3 years ago

What does your bitcoin/electrs/electrs folder look like? If it's empty, you probably need to run git submodule update or the like (or ./install-repositories.sh)

nkuba commented 3 years ago

Thanks for the tips @beaushinkle! Right now I'm getting Error: An unknown argument '--cookie' was specified.

➜  local-setup git:(run-electrs-docker) ✗ ./run-bitcoin.sh 

Starting bitcoind, electrs, and electrumX...

If the build step fails, try increasing the memory allocated to docker.
Creating electrs   ... done
Creating bitcoind  ... done
Creating electrumx ... done
Attaching to electrs, bitcoind, electrumx
electrs      | Error: An unknown argument '--cookie' was specified.
electrumx    | Generating a RSA private key
electrs exited with code 1
beaurancourt commented 3 years ago

Okay - good for another try!

beaurancourt commented 3 years ago

good for another look here