mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 13:46:43 +00:00
working on blockscout
This commit is contained in:
parent
75c8e81d8e
commit
0483fc5526
8 changed files with 239 additions and 115 deletions
99
.github/workflows/deploy-devnet.yml
vendored
99
.github/workflows/deploy-devnet.yml
vendored
|
|
@ -20,7 +20,6 @@ jobs:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# capture SHA as an env variables
|
|
||||||
- name: Get short commit SHA
|
- name: Get short commit SHA
|
||||||
id: vars
|
id: vars
|
||||||
run: echo "COMMIT_SHA=$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV
|
run: echo "COMMIT_SHA=$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV
|
||||||
|
|
@ -32,33 +31,9 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
docker run -d \
|
docker run -d \
|
||||||
--name $CONTAINER_NAME \
|
--name $CONTAINER_NAME \
|
||||||
-p 8545:8545 \
|
-p 8545:8545 -p 4000:4000 \
|
||||||
$BASE_IMAGE \
|
$BASE_IMAGE \
|
||||||
--dev --http --http.addr 0.0.0.0 --http.vhosts "*" --http.api eth,net,web3,personal
|
/bin/sh /start.sh
|
||||||
|
|
||||||
|
|
||||||
# - name: check if curl is installed
|
|
||||||
# run: docker exec $CONTAINER_NAME which curl
|
|
||||||
# - name: Wait for Geth RPC to become available
|
|
||||||
# run: |
|
|
||||||
# echo "Waiting for Geth RPC to be ready..."
|
|
||||||
# for i in {1..30}; do
|
|
||||||
# if docker exec $CONTAINER_NAME curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:8545 > /dev/null; then
|
|
||||||
# echo "Geth RPC is up!"
|
|
||||||
# break
|
|
||||||
# fi
|
|
||||||
# echo "Attempt $i: Not yet ready..."
|
|
||||||
# sleep 2
|
|
||||||
# done
|
|
||||||
|
|
||||||
# if ! docker exec $CONTAINER_NAME curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:8545 > /dev/null; then
|
|
||||||
# echo "❌ Geth RPC did not start within 60 seconds."
|
|
||||||
# echo "--- Container logs ---"
|
|
||||||
# docker logs $CONTAINER_NAME
|
|
||||||
# echo "--- Container status ---"
|
|
||||||
# docker ps -a
|
|
||||||
# exit 1
|
|
||||||
# fi
|
|
||||||
|
|
||||||
- name: Set up Node.js
|
- name: Set up Node.js
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
|
|
@ -69,9 +44,44 @@ jobs:
|
||||||
working-directory: ./hardhat
|
working-directory: ./hardhat
|
||||||
run: npm install
|
run: npm install
|
||||||
|
|
||||||
- name: Deploy contracts to devnet
|
- name: Deploy contracts to devnet and capture address
|
||||||
working-directory: ./hardhat
|
working-directory: ./hardhat
|
||||||
run: npx hardhat run scripts/deploy.js --network localhost
|
run: |
|
||||||
|
DEPLOY_OUTPUT=$(npx hardhat run scripts/deploy.js --network localhost)
|
||||||
|
echo "$DEPLOY_OUTPUT"
|
||||||
|
echo "$DEPLOY_OUTPUT" > deploy.log
|
||||||
|
echo "CONTRACT_ADDRESS=$(echo \"$DEPLOY_OUTPUT\" | grep -i 'Lock deployed to:' | awk '{ print $NF }')" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Retry contract verification on Blockscout
|
||||||
|
working-directory: ./hardhat
|
||||||
|
run: |
|
||||||
|
echo "🔍 Verifying contract at $CONTRACT_ADDRESS"
|
||||||
|
for i in {1..5}; do
|
||||||
|
npx hardhat verify --network localhost $CONTRACT_ADDRESS && break
|
||||||
|
echo "Retry $i: Verification failed. Waiting for Blockscout sync..."
|
||||||
|
sleep 10
|
||||||
|
done
|
||||||
|
|
||||||
|
- name: Confirm contract is visible in Blockscout
|
||||||
|
run: |
|
||||||
|
echo "Waiting for Blockscout explorer to index contract..."
|
||||||
|
for i in {1..30}; do
|
||||||
|
CODE=$(curl -s http://localhost:4000/api \
|
||||||
|
-d "module=contract" \
|
||||||
|
-d "action=getsourcecode" \
|
||||||
|
-d "address=$CONTRACT_ADDRESS" | jq -r '.result[0].SourceCode')
|
||||||
|
|
||||||
|
if [ "$CODE" != "" ] && [ "$CODE" != "null" ]; then
|
||||||
|
echo "✅ Contract is now visible in Blockscout"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "⏳ Not indexed yet, retrying ($i)..."
|
||||||
|
sleep 5
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "❌ Contract not found in Blockscout after timeout."
|
||||||
|
exit 1
|
||||||
|
|
||||||
- name: Commit container with deployed contracts
|
- name: Commit container with deployed contracts
|
||||||
run: |
|
run: |
|
||||||
|
|
@ -96,25 +106,28 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
docker run -d \
|
docker run -d \
|
||||||
--name test-node \
|
--name test-node \
|
||||||
-p 8545:8545 \
|
-p 8545:8545 -p 4000:4000 \
|
||||||
$FINAL_IMAGE:latest \
|
$FINAL_IMAGE:latest \
|
||||||
--dev --http --http.addr 0.0.0.0 --http.vhosts "*" --http.api eth,net,web3,personal
|
/bin/sh /start.sh
|
||||||
sleep 20
|
sleep 20
|
||||||
|
|
||||||
# - name: Wait for RPC to be ready
|
- name: Check Blockscout Explorer
|
||||||
# run: |
|
run: |
|
||||||
# echo "Waiting for devnet to be ready..."
|
echo "Waiting for Blockscout..."
|
||||||
# for i in {1..20}; do
|
for i in {1..30}; do
|
||||||
# if curl -s http://localhost:8545 > /dev/null; then
|
if curl -s http://localhost:4000 | grep -qi "blockscout"; then
|
||||||
# echo "RPC is ready."
|
echo "✅ Blockscout UI is up!"
|
||||||
# break
|
exit 0
|
||||||
# fi
|
fi
|
||||||
# sleep 2
|
sleep 5
|
||||||
# done
|
done
|
||||||
|
echo "❌ Blockscout did not respond."
|
||||||
|
docker logs test-node
|
||||||
|
exit 1
|
||||||
|
|
||||||
- name: Run Hardhat tests
|
- name: Run Hardhat tests
|
||||||
working-directory: ./hardhat
|
working-directory: ./hardhat
|
||||||
run: npx hardhat test # --network localhost
|
run: npx hardhat test
|
||||||
|
|
||||||
- name: Stop and remove test container
|
- name: Stop and remove test container
|
||||||
run: docker rm -f test-node
|
run: docker rm -f test-node
|
||||||
48
Dockerfile
48
Dockerfile
|
|
@ -1,33 +1,35 @@
|
||||||
# Support setting various labels on the final image
|
# Base Geth build stage remains the same
|
||||||
ARG COMMIT=""
|
|
||||||
ARG VERSION=""
|
|
||||||
ARG BUILDNUM=""
|
|
||||||
|
|
||||||
# Build Geth in a stock Go builder container
|
# Additional stage for Blockscout dependencies
|
||||||
FROM golang:1.24-alpine AS builder
|
FROM hexpm/elixir:1.14.5-erlang-25.3.2.6-alpine-3.18.0 as blockscout-builder
|
||||||
|
|
||||||
RUN apk add --no-cache gcc musl-dev linux-headers git
|
RUN apk add --no-cache build-base git curl postgresql-dev inotify-tools npm gcompat
|
||||||
|
|
||||||
# Get dependencies - will also be cached if we won't change go.mod/go.sum
|
# Clone Blockscout source
|
||||||
COPY go.mod /go-ethereum/
|
RUN git clone https://github.com/blockscout/blockscout.git /blockscout
|
||||||
COPY go.sum /go-ethereum/
|
|
||||||
RUN cd /go-ethereum && go mod download
|
|
||||||
|
|
||||||
ADD . /go-ethereum
|
WORKDIR /blockscout
|
||||||
RUN cd /go-ethereum && go run build/ci.go install -static ./cmd/geth
|
|
||||||
|
|
||||||
# Pull Geth into a second stage deploy alpine container
|
RUN mix local.hex --force && \
|
||||||
|
mix local.rebar --force && \
|
||||||
|
mix deps.get && \
|
||||||
|
mix compile
|
||||||
|
|
||||||
|
RUN mix do ecto.create, ecto.migrate
|
||||||
|
|
||||||
|
RUN mix phx.digest && MIX_ENV=prod mix release
|
||||||
|
|
||||||
|
# Final image
|
||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
|
|
||||||
RUN apk add --no-cache ca-certificates
|
RUN apk add --no-cache ca-certificates libstdc++ postgresql-client su-exec bash curl
|
||||||
|
|
||||||
COPY --from=builder /go-ethereum/build/bin/geth /usr/local/bin/
|
COPY --from=builder /go-ethereum/build/bin/geth /usr/local/bin/
|
||||||
|
COPY --from=blockscout-builder /blockscout /blockscout
|
||||||
|
|
||||||
EXPOSE 8545 8546 30303 30303/udp
|
# Custom entrypoint
|
||||||
ENTRYPOINT ["geth", "--dev", "--http", "--http.addr", "0.0.0.0", "--http.vhosts", "*", "--http.api", "eth,net,web3,personal"]
|
COPY start.sh /start.sh
|
||||||
|
RUN chmod +x /start.sh
|
||||||
|
|
||||||
# Add some metadata labels to help programmatic image consumption
|
EXPOSE 8545 8546 30303 4000
|
||||||
ARG COMMIT=""
|
ENTRYPOINT ["/bin/sh", "/start.sh"]
|
||||||
ARG VERSION=""
|
|
||||||
ARG BUILDNUM=""
|
|
||||||
|
|
||||||
LABEL commit="$COMMIT" version="$VERSION" buildnum="$BUILDNUM"
|
|
||||||
|
|
|
||||||
33
OldDfile
Normal file
33
OldDfile
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
# Support setting various labels on the final image
|
||||||
|
ARG COMMIT=""
|
||||||
|
ARG VERSION=""
|
||||||
|
ARG BUILDNUM=""
|
||||||
|
|
||||||
|
# Build Geth in a stock Go builder container
|
||||||
|
FROM golang:1.24-alpine AS builder
|
||||||
|
|
||||||
|
RUN apk add --no-cache gcc musl-dev linux-headers git
|
||||||
|
|
||||||
|
# Get dependencies - will also be cached if we won't change go.mod/go.sum
|
||||||
|
COPY go.mod /go-ethereum/
|
||||||
|
COPY go.sum /go-ethereum/
|
||||||
|
RUN cd /go-ethereum && go mod download
|
||||||
|
|
||||||
|
ADD . /go-ethereum
|
||||||
|
RUN cd /go-ethereum && go run build/ci.go install -static ./cmd/geth
|
||||||
|
|
||||||
|
# Pull Geth into a second stage deploy alpine container
|
||||||
|
FROM alpine:latest
|
||||||
|
|
||||||
|
RUN apk add --no-cache ca-certificates
|
||||||
|
COPY --from=builder /go-ethereum/build/bin/geth /usr/local/bin/
|
||||||
|
|
||||||
|
EXPOSE 8545 8546 30303 30303/udp
|
||||||
|
ENTRYPOINT ["geth", "--dev", "--http", "--http.addr", "0.0.0.0", "--http.vhosts", "*", "--http.api", "eth,net,web3,personal"]
|
||||||
|
|
||||||
|
# Add some metadata labels to help programmatic image consumption
|
||||||
|
ARG COMMIT=""
|
||||||
|
ARG VERSION=""
|
||||||
|
ARG BUILDNUM=""
|
||||||
|
|
||||||
|
LABEL commit="$COMMIT" version="$VERSION" buildnum="$BUILDNUM"
|
||||||
|
|
@ -8,55 +8,11 @@ services:
|
||||||
- "8545:8545"
|
- "8545:8545"
|
||||||
- "8546:8546"
|
- "8546:8546"
|
||||||
- "30303:30303"
|
- "30303:30303"
|
||||||
|
- "4000:4000"
|
||||||
volumes:
|
volumes:
|
||||||
- geth-data:/root/.ethereum
|
- geth-data:/root/.ethereum
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
command: [
|
command: ["/bin/sh", "/start.sh"]
|
||||||
"geth",
|
|
||||||
"--dev",
|
|
||||||
"--http",
|
|
||||||
"--http.addr", "0.0.0.0",
|
|
||||||
"--http.vhosts", "*",
|
|
||||||
"--http.api", "personal,eth,net,web3,miner",
|
|
||||||
"--http.corsdomain", "*",
|
|
||||||
"--ws",
|
|
||||||
"--ws.addr", "0.0.0.0",
|
|
||||||
"--ws.api", "personal,eth,net,web3,miner",
|
|
||||||
"--allow-insecure-unlock",
|
|
||||||
"--mine",
|
|
||||||
"--nodiscover"
|
|
||||||
]
|
|
||||||
|
|
||||||
# postgres:
|
|
||||||
# image: postgres:13
|
|
||||||
# container_name: blockscout-db
|
|
||||||
# environment:
|
|
||||||
# POSTGRES_USER: postgres
|
|
||||||
# POSTGRES_PASSWORD: postgres
|
|
||||||
# POSTGRES_DB: blockscout
|
|
||||||
# ports:
|
|
||||||
# - "5432:5432"
|
|
||||||
# volumes:
|
|
||||||
# - pg-data:/var/lib/postgresql/data
|
|
||||||
|
|
||||||
# blockscout:
|
|
||||||
# image: blockscout/blockscout:latest
|
|
||||||
# container_name: blockscout
|
|
||||||
# depends_on:
|
|
||||||
# - geth-node
|
|
||||||
# - postgres
|
|
||||||
# ports:
|
|
||||||
# - "4000:4000"
|
|
||||||
# environment:
|
|
||||||
# ETHEREUM_JSONRPC_HTTP_URL: http://geth-node:8545
|
|
||||||
# DATABASE_URL: postgresql://postgres:postgres@postgres:5432/blockscout
|
|
||||||
# NETWORK: "Devnet"
|
|
||||||
# SUBNETWORK: "Geth Dev Mode"
|
|
||||||
# COIN: "ETH"
|
|
||||||
# MIX_ENV: "prod"
|
|
||||||
# PORT: 4000
|
|
||||||
# BLOCKSCOUT_HOST: "0.0.0.0"
|
|
||||||
# restart: unless-stopped
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
geth-data:
|
geth-data:
|
||||||
|
|
|
||||||
64
docker-compose_old.yaml
Normal file
64
docker-compose_old.yaml
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
services:
|
||||||
|
geth-node:
|
||||||
|
image: yohands/my_first_container
|
||||||
|
container_name: geth-devnet
|
||||||
|
ports:
|
||||||
|
- "8545:8545"
|
||||||
|
- "8546:8546"
|
||||||
|
- "30303:30303"
|
||||||
|
- "4000:4000"
|
||||||
|
volumes:
|
||||||
|
- geth-data:/root/.ethereum
|
||||||
|
restart: unless-stopped
|
||||||
|
command: [
|
||||||
|
"geth",
|
||||||
|
"--dev",
|
||||||
|
"--http",
|
||||||
|
"--http.addr", "0.0.0.0",
|
||||||
|
"--http.vhosts", "*",
|
||||||
|
"--http.api", "personal,eth,net,web3,miner",
|
||||||
|
"--http.corsdomain", "*",
|
||||||
|
"--ws",
|
||||||
|
"--ws.addr", "0.0.0.0",
|
||||||
|
"--ws.api", "personal,eth,net,web3,miner",
|
||||||
|
"--allow-insecure-unlock",
|
||||||
|
"--mine",
|
||||||
|
"--nodiscover"
|
||||||
|
]
|
||||||
|
|
||||||
|
# postgres:
|
||||||
|
# image: postgres:13
|
||||||
|
# container_name: blockscout-db
|
||||||
|
# environment:
|
||||||
|
# POSTGRES_USER: postgres
|
||||||
|
# POSTGRES_PASSWORD: postgres
|
||||||
|
# POSTGRES_DB: blockscout
|
||||||
|
# ports:
|
||||||
|
# - "5432:5432"
|
||||||
|
# volumes:
|
||||||
|
# - pg-data:/var/lib/postgresql/data
|
||||||
|
|
||||||
|
# blockscout:
|
||||||
|
# image: blockscout/blockscout:latest
|
||||||
|
# container_name: blockscout
|
||||||
|
# depends_on:
|
||||||
|
# - geth-node
|
||||||
|
# - postgres
|
||||||
|
# ports:
|
||||||
|
# - "4000:4000"
|
||||||
|
# environment:
|
||||||
|
# ETHEREUM_JSONRPC_HTTP_URL: http://geth-node:8545
|
||||||
|
# DATABASE_URL: postgresql://postgres:postgres@postgres:5432/blockscout
|
||||||
|
# NETWORK: "Devnet"
|
||||||
|
# SUBNETWORK: "Geth Dev Mode"
|
||||||
|
# COIN: "ETH"
|
||||||
|
# MIX_ENV: "prod"
|
||||||
|
# PORT: 4000
|
||||||
|
# BLOCKSCOUT_HOST: "0.0.0.0"
|
||||||
|
# restart: unless-stopped
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
geth-data:
|
||||||
|
pg-data:
|
||||||
|
|
@ -3,4 +3,25 @@ require("@nomicfoundation/hardhat-toolbox");
|
||||||
/** @type import('hardhat/config').HardhatUserConfig */
|
/** @type import('hardhat/config').HardhatUserConfig */
|
||||||
module.exports = {
|
module.exports = {
|
||||||
solidity: "0.8.28",
|
solidity: "0.8.28",
|
||||||
|
networks: {
|
||||||
|
localhost: {
|
||||||
|
url: "http://127.0.0.1:8545",
|
||||||
|
chainId: 1337
|
||||||
|
}
|
||||||
|
},
|
||||||
|
etherscan: {
|
||||||
|
apiKey: {
|
||||||
|
localhost: "abc123" // dummy or optional if not enforced
|
||||||
|
},
|
||||||
|
customChains: [
|
||||||
|
{
|
||||||
|
network: "localhost",
|
||||||
|
chainId: 1337,
|
||||||
|
urls: {
|
||||||
|
apiURL: "http://localhost:4000/api",
|
||||||
|
browserURL: "http://localhost:4000"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
};
|
};
|
||||||
26
start.sh
Normal file
26
start.sh
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# Start PostgreSQL for Blockscout
|
||||||
|
docker-entrypoint.sh postgres &
|
||||||
|
|
||||||
|
# Wait for DB to be ready
|
||||||
|
until pg_isready -h localhost -p 5432; do
|
||||||
|
echo "Waiting for Postgres..."
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
|
||||||
|
# Start Geth
|
||||||
|
geth --dev \
|
||||||
|
--http --http.addr 0.0.0.0 \
|
||||||
|
--http.vhosts "*" --http.api eth,net,web3,personal \
|
||||||
|
--ws --ws.addr 0.0.0.0 \
|
||||||
|
--allow-insecure-unlock --mine --nodiscover &
|
||||||
|
|
||||||
|
# Start Blockscout
|
||||||
|
cd /blockscout && \
|
||||||
|
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/blockscout \
|
||||||
|
ETHEREUM_JSONRPC_HTTP_URL=http://localhost:8545 \
|
||||||
|
PORT=4000 \
|
||||||
|
MIX_ENV=prod \
|
||||||
|
/blockscout/_build/prod/rel/blockscout/bin/blockscout start
|
||||||
|
|
||||||
|
wait
|
||||||
9
terraform.tfstate
Normal file
9
terraform.tfstate
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"version": 4,
|
||||||
|
"terraform_version": "1.12.2",
|
||||||
|
"serial": 1,
|
||||||
|
"lineage": "40f0fde9-d9f7-345b-6b37-4ce3b96e72ae",
|
||||||
|
"outputs": {},
|
||||||
|
"resources": [],
|
||||||
|
"check_results": null
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue