From d5313803dd40aa738a105665b6c56ab53ee74e04 Mon Sep 17 00:00:00 2001 From: Sebastian <379651+czarly@users.noreply.github.com> Date: Sun, 18 Dec 2022 12:02:30 +0100 Subject: [PATCH] update the polygon erigon setup to be able to use public rpcs and the new official supported version --- erigon-polygon.yml | 12 ++++++------ polygon/erigon/Dockerfile | 21 ++++++++++++++++++++- polygon/erigon/scripts/entrypoint.sh | 16 +++++++++------- 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/erigon-polygon.yml b/erigon-polygon.yml index b0c0f64a..83293be4 100644 --- a/erigon-polygon.yml +++ b/erigon-polygon.yml @@ -4,19 +4,19 @@ services: erigon-polygon: build: args: - ERIGON_VERSION: v0.0.3 + ERIGON_VERSION: v0.0.4 context: ./polygon/erigon dockerfile: Dockerfile environment: - - SNAPSHOT_URL=https://matic-blockchain-snapshots.s3-accelerate.amazonaws.com/matic-mainnet/erigon-archive-snapshot-2022-11-17.tar.gz + - SNAPSHOT_URL=https://matic-blockchain-snapshots.s3-accelerate.amazonaws.com/matic-mainnet/erigon-archive-snapshot-2022-12-13.tar.gz - BOOTSTRAP=1 + - HEIMDALLD=${HEIMDALLD:-http://heimdalld:26657} + - HEIMDALLR=${HEIMDALLR:-http://heimdallr:1317} volumes: - "polygon-archive_data:/datadir" ports: - - "40303:40303" - - "40303:40303/udp" - depends_on: - - heimdallr + - "27113:27113" + - "27113:27113/udp" restart: unless-stopped stop_grace_period: 1m labels: diff --git a/polygon/erigon/Dockerfile b/polygon/erigon/Dockerfile index 9e165bcf..d13d002b 100644 --- a/polygon/erigon/Dockerfile +++ b/polygon/erigon/Dockerfile @@ -5,7 +5,7 @@ FROM golang:1.19-alpine as builder RUN apk add --no-cache make g++ gcc musl-dev linux-headers git # Grab ERIGON_VERSION from Build Args -ARG ERIGON_VERSION +ARG ERIGON_VERSION=v0.0.4 # Clone the repo to that folder RUN git clone --recurse-submodules -j8 https://github.com/maticnetwork/erigon.git @@ -25,6 +25,25 @@ FROM alpine:latest RUN apk add --no-cache ca-certificates curl jq libstdc++ libgcc COPY --from=builder /go/erigon/build/bin/erigon /usr/local/bin/ +# ENV HEIMDALLD=http://heimdalld:26657 +# ENV HEIMDALLR=http://heimdallr:1317 + +ENV HEIMDALLD=https://polygon-mainnet-rpc.allthatnode.com:26657 +ENV HEIMDALLR=https://polygon-mainnet-rpc.allthatnode.com:1317 + +# P2P +EXPOSE 27113 + +# HTTP / WS +EXPOSE 8545 + +# Metrics +EXPOSE 6060 + +# PProf +EXPOSE 6061 + + # Set entrypoint COPY ./scripts/entrypoint.sh /usr/local/bin/entrypoint.sh RUN chmod u+x /usr/local/bin/entrypoint.sh diff --git a/polygon/erigon/scripts/entrypoint.sh b/polygon/erigon/scripts/entrypoint.sh index ba4ae92a..d5db1a0b 100644 --- a/polygon/erigon/scripts/entrypoint.sh +++ b/polygon/erigon/scripts/entrypoint.sh @@ -5,31 +5,33 @@ set -e # Set Bor Home Directory ERIGON_HOME=/datadir -HEIMDALL_RPC=heimdall:26657 +#HEIMDALLD=http://heimdalld:26657 +#HEIMDALLR=http://heimdallr:1317 if [ "${BOOTSTRAP}" == 1 ] && [ -n "${SNAPSHOT_URL}" ] && [ ! -f "${ERIGON_HOME}/bootstrapped" ]; then echo "downloading snapshot from ${SNAPSHOT_URL}" - mkdir -p ${ERIGON_HOME} - wget --tries=0 -O - "${SNAPSHOT_URL}" | tar -xz -C ${ERIGON_HOME} && touch ${ERIGON_HOME}/bootstrapped + mkdir -p ${ERIGON_HOME:-/datadir} + wget --tries=0 -O - "${SNAPSHOT_URL}" | tar -xz -C ${ERIGON_HOME:-/datadir} && touch ${ERIGON_HOME:-/datadir}/bootstrapped fi -READY=$(curl -s http://heimdalld:26657/status | jq '.result.sync_info.catching_up') +READY=$(curl -s ${HEIMDALLD:-http://heimdalld:26657}/status | jq '.result.sync_info.catching_up') while [[ "${READY}" != "false" ]]; do echo "Waiting for heimdalld to catch up." sleep 30 - READY=$(curl -s heimdalld:26657/status | jq '.result.sync_info.catching_up') + READY=$(curl -s ${HEIMDALLD:-http://heimdalld:26657}/status | jq '.result.sync_info.catching_up') done # add snap.keepblocks=true as mentioned on https://snapshot.polygon.technology/ exec erigon \ --chain=bor-mainnet \ - --bor.heimdall=http://heimdallr:1317 \ + --bor.heimdall=${HEIMDALLR:-http://heimdallr:1317} \ --datadir=${ERIGON_HOME} \ --http --http.addr="0.0.0.0" --http.port="8545" --http.compression --http.vhosts="*" --http.corsdomain="*" --http.api="eth,debug,net,trace,web3,erigon,bor" \ - --ws --ws.compression \ + --ws --ws.compression --ws.port="8545" \ + --port=27113 --snap.keepblocks=true \ --snapshots="true" \ --torrent.upload.rate="1250mb" --torrent.download.rate="1250mb" \