¶ Celo RPC endpoint detailsThis is a general guide on deploying an Celo RPC endpoint for your Chainlink Node(s). |
You Chainlink node has two connections methods. Websocket and HTTP.
As these can vary between networks, the default values for an Celo node are:
Websocket ws://<your_ip_address>:8546
HTTPhttp://<your_ip_address>:8545
Before we can get our Ethereum node running, we need to install some necessary software.
we'll install some packages that we'll need or will at least be handy to have.
sudo apt install -y git curl wget jq node-ws telnet traceroute build-essential make
Install dependencies first.
sudo apt update && sudo apt upgrade && sudo apt-get install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common
Now, we'll need to get our aptitude sources updated to include the Docker-CE repository.
These commands must be run as root.
sudo su
curl -fsSL
https://download.docker.com/linux/debian/gpg
| apt-key add -
add-apt-repository "deb [arch=amd64]
https://download.docker.com/linux/debian
$(lsb_release -cs) stable"
Once we have added the repo and the necessary key, we want to exit the root user. exit
Note: You should see your shell prompt displaying a $
if you're a non-root user. If you're in an elevated (root) TTY session, your shell prompt will display a #
Since we've modified our aptitude sources, we'll need to update them before we can install docker-ce
sudo apt update && sudo apt install docker-ce
Now that we have Docker-CE installed, we'll need to add our user to the docker group.
(The prevents us from having to run docker commands with elevated (root) permissions)
sudo usermod -aG docker $USER
Next, we'll get our Celo RPC And Relay nodes deployed and synced, but we'll create a docker network for the containers first.
Add the following line to your ~/.profile
(this sets the varaible $CELO_IMAGE to the path of the desired Celo Docker image hosted in GCP.
nano ~/.profile
export CELO_IMAGE=us.gcr.io/celo-org/geth:mainnet
For that new variable to take effect, we'll need to source the flat file
source ~/.profile
With that variable set, we can pull our Celo Docker image
docker pull $CELO_IMAGE
Make a directory to store the block data for your celo node
mkdir ~/celo-data-dir
Clone the celo-blockchain github repo
git clone https://github.com/celo-org/celo-blockchain.git
Navigate into the newly created directory
cd celo-blockchain
With the Docker image downloaded, we'll next need to create a Celo account and save its address.
docker run -v $PWD:/root/.celo --rm -it $CELO_IMAGE account new
This will prompt you for a password to encrypt the keys.
The scope of this guide is to simply deploy an RPC endpoint, so enter whatever password you like.
We'll need to update our ~/.profile again with another variable for the Account Address we just generated.
nano ~/.profile
Append the following to the end of the file
(use your own account address, the example below is zero'd out as an example)
export CELO_ACCOUNT_ADDRESS=0x0000000000000000000000000000000000000000
once again, we'll want to source our ~/.profile so that the changes take effect.
source ~/.profile
With all of that sorted, we can now start our Celo full node container with the following command
Note: Be sure to update the “-v /home/<username>/celo-data-dir…
" line to include your username, or if you placed your celo-data-dir
somewhere else, update the line to that path.
docker run \
--name celo-fullnode \
-d \
--restart unless-stopped \
--stop-timeout 300 \
-p 8545:8545 \
-p 8546:8546 \
-p 30303:30303 \
-p 30303:30303/udp \
-v /home/<username>/celo-data-dir:/root/.celo $CELO_IMAGE \
--verbosity 3 \
--syncmode fast \
--http --http.addr 0.0.0.0 \
--http.api eth,net,web3,debug,admin,personal \
--light.serve 90 \
--light.maxpeers 1000 \
--maxpeers 1100 \
--etherbase $CELO_ACCOUNT_ADDRESS \
--datadir /root/.celo
With the container running, we can confirm it's fetching data from peers by checking the container's logs
docker logs -f celo-fullnode
You can check the state of your sync against the Celo Explorer with a simple bash script like the one below.
#!/bin/bash
# bold
b=$(tput bold)
# blue foreground
blue_fg=$(tput setaf 6)
# yello foreground
yellow_fg=$(tput setaf 3)
# reset to default
reset=$(tput sgr0)
# SET VARS
BLOCK_HEIGHT=$(curl -s -H "Content-Type: application/json" http://localhost:8545 -d '{"jsonrpc": "2.0", "id": 123, "method": "eth_blockNumber"}' | jq -r .result)
CELOEXPLORER_BLOCK_HEIGHT=$(curl -s -X POST -H "Content-Type: application/json" --data '{"id":1, "jsonrpc":"2.0", "method": "eth_blockNumber","params": []}' https://explorer.celo.org/mainnet/api/eth-rpc | jq -r .result)
PEER_COUNT=$(curl -s -H "Content-Type: application/json" http://localhost:8545 -d '{"jsonrpc":"2.0","method":"net_peerCount","params":[],"id":74}' | jq -r .result)
IS_SYNCING=$(curl -s -H "Content-Type: application/json" http://localhost:8545 -d '{"jsonrpc": "2.0", "id": 123, "method": "eth_syncing"}' | jq .)
echo "----------------------"
echo "RPC Node block height: ${blue_fg}$((BLOCK_HEIGHT))${reset}"
echo "Ethersan block height: ${blue_fg}$((CELOEXPLORER_BLOCK_HEIGHT))${reset}"
echo "Current peer count: ${blue_fg}$((PEER_COUNT))${reset}"
VAR1=$(curl -s -H "Content-Type: application/json" http://localhost:8545 -d '{"jsonrpc": "2.0", "id": 123, "method": "eth_syncing"}' | jq .result)
VAR2="false"
if [ "$VAR1" = "$VAR2" ]; then
echo "Sync Status: ${blue_fg}Node is synced.${reset}"
else
echo "${blue_fg}Node is ${yellow_fg}NOT${blue_fg} synced.${reset}"
fi