-
Notifications
You must be signed in to change notification settings - Fork 153
[M1] Add Otterscan & Sourcify integration to playground #4000
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 10 commits
872d4db
d6e322b
3c11ff2
6e8acb6
8519ffa
98fa7ec
ff75c1f
f7e8ff5
0660cb8
f92810a
a62d78e
775f11a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| FROM otterscan/otterscan:latest | ||
|
|
||
| COPY otterscan-entrypoint.sh /entrypoint.sh | ||
| RUN chmod +x /entrypoint.sh | ||
|
|
||
| ENTRYPOINT ["/entrypoint.sh"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| FROM node:22-bookworm-slim | ||
|
|
||
| # Install dependencies | ||
| RUN apt-get update && apt-get install -y git curl postgresql-client && \ | ||
| curl -fsSL -o /usr/local/bin/dbmate https://github.com/amacneil/dbmate/releases/download/v2.21.0/dbmate-linux-amd64 && \ | ||
| chmod +x /usr/local/bin/dbmate && \ | ||
| apt-get clean && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Clone Sourcify with submodules | ||
| RUN git clone --depth 1 --recurse-submodules https://github.com/ethereum/sourcify.git /sourcify | ||
jmg-duarte marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| WORKDIR /sourcify | ||
|
|
||
| # Install dependencies and build | ||
| RUN npm install && npm run build:lerna | ||
|
|
||
| # Prepare migrations | ||
| WORKDIR /sourcify/services/database | ||
| RUN mkdir -p /migrations && \ | ||
| cp -r database-specs/migrations/* /migrations/ 2>/dev/null || true && \ | ||
| cp -r migrations/* /migrations/ 2>/dev/null || true | ||
|
|
||
| WORKDIR /sourcify/services/server | ||
|
|
||
| # Copy custom entrypoint | ||
| COPY sourcify-entrypoint.sh /entrypoint.sh | ||
| RUN chmod +x /entrypoint.sh | ||
|
|
||
| EXPOSE 5555 | ||
|
|
||
| ENTRYPOINT ["/entrypoint.sh"] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -202,6 +202,66 @@ services: | |
| ports: | ||
| - 8000:80 | ||
|
|
||
| # Sourcify - Contract verification service | ||
| sourcify-db: | ||
| image: postgres:15-alpine | ||
|
||
| restart: always | ||
| environment: | ||
| - POSTGRES_USER=sourcify | ||
| - POSTGRES_PASSWORD=sourcify | ||
| - POSTGRES_DB=sourcify | ||
| volumes: | ||
| - sourcify-postgres:/var/lib/postgresql/data | ||
| healthcheck: | ||
| test: ["CMD-SHELL", "pg_isready -U sourcify"] | ||
| interval: 5s | ||
| timeout: 5s | ||
| retries: 5 | ||
|
|
||
| sourcify: | ||
| build: | ||
| context: . | ||
| dockerfile: Dockerfile.sourcify | ||
| restart: always | ||
| depends_on: | ||
| sourcify-db: | ||
| condition: service_healthy | ||
| environment: | ||
| - SOURCIFY_POSTGRES_HOST=sourcify-db | ||
| - SOURCIFY_POSTGRES_PORT=5432 | ||
| - SOURCIFY_POSTGRES_USER=sourcify | ||
| - SOURCIFY_POSTGRES_PASSWORD=sourcify | ||
| - SOURCIFY_POSTGRES_DB=sourcify | ||
| - NODE_ENV=development | ||
| volumes: | ||
| - ./sourcify-chains.json:/sourcify/services/server/dist/sourcify-chains.json | ||
| ports: | ||
| - 5555:5555 | ||
| healthcheck: | ||
| test: ["CMD", "curl", "-f", "http://localhost:5555/health"] | ||
| interval: 10s | ||
| timeout: 5s | ||
| retries: 5 | ||
| start_period: 30s | ||
|
|
||
| # Otterscan - Local blockchain block explorer for Anvil | ||
| otterscan: | ||
| build: | ||
| context: . | ||
| dockerfile: Dockerfile.otterscan | ||
| restart: always | ||
| environment: | ||
| - ERIGON_URL=http://127.0.0.1:8545 | ||
| - SOURCIFY_MODE=${SOURCIFY_MODE:-cloud} | ||
| - LOCAL_SOURCIFY_URL=http://sourcify:5555 | ||
| ports: | ||
| - 8003:80 | ||
| depends_on: | ||
| chain: | ||
| condition: service_healthy | ||
| sourcify: | ||
| condition: service_healthy | ||
|
|
||
| explorer: | ||
| build: | ||
| context: . | ||
|
|
@@ -231,7 +291,6 @@ services: | |
| volumes: | ||
| - ./grafana-prometheus.yml:/etc/grafana/provisioning/datasources/prometheus.yml | ||
|
|
||
|
|
||
| prometheus: | ||
| image: prom/prometheus:latest | ||
| container_name: prometheus | ||
|
|
@@ -243,3 +302,4 @@ services: | |
|
|
||
| volumes: | ||
| postgres: | ||
| sourcify-postgres: | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,51 @@ | ||||||
| #!/bin/sh | ||||||
| # Otterscan entrypoint that configures Sourcify based on SOURCIFY_MODE | ||||||
|
|
||||||
| CONFIG_FILE="/usr/share/nginx/html/config.json" | ||||||
| ERIGON_URL="${ERIGON_URL:-http://127.0.0.1:8545}" | ||||||
| LOCAL_SOURCIFY_URL="${LOCAL_SOURCIFY_URL:-http://localhost:5555}" | ||||||
|
|
||||||
| echo "=== Otterscan Entrypoint ===" | ||||||
| echo "SOURCIFY_MODE: ${SOURCIFY_MODE}" | ||||||
|
|
||||||
| case "${SOURCIFY_MODE:-cloud}" in | ||||||
| local) | ||||||
| echo "Using LOCAL Sourcify as primary source" | ||||||
| cat > "$CONFIG_FILE" << 'EOF' | ||||||
|
||||||
| cat > "$CONFIG_FILE" << 'EOF' | |
| cat > "$CONFIG_FILE" << EOF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ Fixed
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
| cat > "$CONFIG_FILE" << 'EOF' | |
| cat > "$CONFIG_FILE" << EOF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ Fixed
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| { | ||
| "1": { | ||
| "sourcifyName": "Mainnet (Forked)", | ||
| "supported": true, | ||
| "rpc": ["http://chain:8545"] | ||
| }, | ||
| "31337": { | ||
| "sourcifyName": "Anvil Local", | ||
| "supported": true, | ||
| "rpc": ["http://chain:8545"] | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| #!/bin/bash | ||
| set -e | ||
|
|
||
| echo "=== Sourcify Server Starting ===" | ||
|
|
||
| # Wait for database to be ready | ||
| echo "Waiting for database..." | ||
| until pg_isready -h "$SOURCIFY_POSTGRES_HOST" -p "$SOURCIFY_POSTGRES_PORT" -U "$SOURCIFY_POSTGRES_USER" -d "$SOURCIFY_POSTGRES_DB" > /dev/null 2>&1; do | ||
| echo "Database not ready, waiting..." | ||
| sleep 2 | ||
| done | ||
| echo "Database is ready!" | ||
|
|
||
| # Run migrations | ||
| echo "Running database migrations..." | ||
| DATABASE_URL="postgres://${SOURCIFY_POSTGRES_USER}:${SOURCIFY_POSTGRES_PASSWORD}@${SOURCIFY_POSTGRES_HOST}:${SOURCIFY_POSTGRES_PORT}/${SOURCIFY_POSTGRES_DB}?sslmode=disable" | ||
| dbmate --url "$DATABASE_URL" --migrations-dir /migrations --no-dump-schema up | ||
| echo "Migrations complete!" | ||
|
|
||
| # Start the server | ||
| echo "Starting Sourcify server..." | ||
| exec node dist/server/cli.js |
Uh oh!
There was an error while loading. Please reload this page.