dshackle
Dshackle is a Blockchain API Load Balancer with automatic discovery and health checking, authentication and TLS termination. It can be used as an edge proxy, middle proxy or API gateway.
Dshackle provided a high level aggregated API on top of several underlying upstreams (blockchain nodes or providers, such as Geth, Parity, Infura, etc), it automatically verifies their availability and the current status of the network, executes commands making sure that the response is consistent and/or data successfully broadcasted to the network.
Project goals:
Dshackle connects to several upstreams via JSON RPC, Websockets or gRPC protocols. It verifies if a node ("upstream") is fully synchronized (not in initial sync mode), has enough peers and its height is not behind other nodes. If an upstream lags behind others, lost peers, started to resync, or simply went down then Dshackle temporarily excludes it from requests and returns back when the the upstream problem is fixed.
Create file dshackle.yaml with following content:
version: v1
port: 2449
tls:
enabled: false
upstreams:
config: "upstreams.yaml"
Which sets the following:
upstreams.yaml in the current directoryNow create file upstreams.yaml:
version: v1
upstreams:
- id: infura-eth
chain: ethereum
connection:
ethereum:
rpc:
url: "https://mainnet.infura.io/v3/${INFURA_USER}"
ws:
url: "wss://mainnet.infura.io/ws/v3/${INFURA_USER}"
- id: infura-kovan
chain: kovan
connection:
ethereum:
rpc:
url: "https://kovan.infura.io/v3/${INFURA_USER}"
This configures:
${INFURA_USER} will be provided through environment variableOfficial Docker image you can find at: https://hub.docker.com/r/emeraldpay/dshackle
Setup Infura username:
export INFURA_USER=...
Run Dshackle:
docker run -p 2449:2449 -v $(pwd):/etc/dshackle -e "INFURA_USER=$INFURA_USER" emeraldpay/dshackle
Now it listen on port 2449 at the localhost and can be connected from any gRPC compatible client. Tools such as https://github.com/fullstorydev/grpcurl can automatically parse protobuf definitions and connect to it (actual Protobuf sources are located in a separate repository which you can find at https://github.com/emeraldpay/proto)
.Connect and listen for new blocks on Ethereum Mainnet
grpcurl -import-path ./proto/ -proto blockchain.proto -d "{\"type\": 100}" -plaintext 127.0.0.1:2449 io.emeraldpay.api.Blockchain/SubscribeHead
.Output would be like
{
"chain": "CHAIN_ETHEREUM",
"height": 8396159,
"blockId": "fc58a258adccc94466ae967b1178eea721349b0667f59d5fe1b0b436460bce75",
"timestamp": 1566423564000,
"weight": "AnMcf2VJB5kOSQ=="
}
{
"chain": "CHAIN_ETHEREUM",
"height": 8396160,
"blockId": "787899711b862b77df8d2faa69de664048598265a9f96abf178d341076e200e0",
"timestamp": 1566423574000,
"weight": "AnMch35tO6hSGg=="
}
...
...
The output above is for a streaming subscription to all new blocks on Ethereum Mainnet. It's one of services provided by Dshackle, in additional to standard methods provided by RPC JSON of underlying nodes.
For detailed documentation see https://github.com/emeraldpay/dshackle/tree/master/docs
Content type
Image
Digest
sha256:7a34df3cb…
Size
263 MB
Last updated
about 1 month ago
Requires Docker Desktop 4.37.1 or later.