Compare commits

...

11 Commits

Author SHA1 Message Date
e20ad560d0 check ipld-eth-db in test
Some checks failed
Test Ethereum Plugeth Fixturenet Stack / Test fixturenet-plugeth stack (push) Has been cancelled
Test Ethereum Fixturenet Stack / Run Ethereum Fixturenet stack test (push) Has been cancelled
2024-06-27 15:26:37 +08:00
66435eb60c bump alpine 2024-06-27 15:26:37 +08:00
7f9a8ff664 update eth-dump-genblock 2024-06-27 15:26:37 +08:00
15bc891299 add statediff config 2024-06-27 15:26:37 +08:00
2fdf11643b correct plugeth ref 2024-06-27 15:26:37 +08:00
5e0172a1d6 missing repo ref 2024-06-27 15:26:37 +08:00
20671b5456 consistent test name 2024-06-27 15:26:37 +08:00
709b048d5a add missing files 2024-06-27 15:26:37 +08:00
849bb0a4f1 fix command 2024-06-27 15:26:37 +08:00
80228a5e04 [dev] use patched SO 2024-06-27 15:26:37 +08:00
a3060bf1c1 add ipld-eth-db 2024-06-27 15:26:37 +08:00
13 changed files with 183 additions and 20 deletions

View File

@ -1,4 +1,4 @@
name: Test fixturenet-plugeth
name: Test Ethereum Plugeth Fixturenet Stack
on:
push:
@ -26,7 +26,15 @@ jobs:
- name: "Print Python version"
run: python3 --version
- name: "Install stack orchestrator"
run: ./scripts/install-so.sh
# FIXME: merge SO fixes and revert
# run: ./scripts/install-so.sh
uses: actions/checkout@v3
with:
repository: cerc-io/stack-orchestrator
ref: roysc/fix-various
path: .tools/stack-orchestrator
- name: "Install stack orchestrator"
run: pip3 install .tools/stack-orchestrator
- name: "Run stack tests"
run: |
PATH=$PATH:~/bin

View File

@ -27,6 +27,7 @@ services:
CERC_ALLOW_UNPROTECTED_TXS: ${CERC_ALLOW_UNPROTECTED_TXS:-false}
env_file:
- ../config/fixturenet-eth/fixturenet-eth.env
- ../config/fixturenet-eth/statediff.env
image: cerc/fixturenet-plugeth-plugeth:local
volumes:
- fixturenet_plugeth_geth_1_data:/root/ethdata

View File

@ -0,0 +1,29 @@
services:
migrations:
restart: on-failure
depends_on:
ipld-eth-db:
condition: service_healthy
image: cerc/ipld-eth-db:local
environment:
DATABASE_USER: "vdbm"
DATABASE_NAME: "cerc_testing"
DATABASE_PASSWORD: "password"
DATABASE_HOSTNAME: "ipld-eth-db"
DATABASE_PORT: 5432
ipld-eth-db:
image: timescale/timescaledb:2.8.1-pg14
restart: always
environment:
POSTGRES_USER: "vdbm"
POSTGRES_DB: "cerc_testing"
POSTGRES_PASSWORD: "password"
healthcheck:
test: ["CMD", "nc", "-v", "localhost", "5432"]
interval: 30s
timeout: 10s
retries: 10
start_period: 3s
ports:
- "127.0.0.1:8077:5432"

View File

@ -0,0 +1,9 @@
# DB connection settings for statediffing (see docker-compose-db.yml)
CERC_STATEDIFF_DB_HOST="ipld-eth-db"
CERC_STATEDIFF_DB_PORT=5432
CERC_STATEDIFF_DB_NAME="cerc_testing"
CERC_STATEDIFF_DB_USER="vdbm"
CERC_STATEDIFF_DB_PASSWORD="password"
CERC_STATEDIFF_DB_GOOSE_MIN_VER=${CERC_STATEDIFF_DB_GOOSE_MIN_VER:-18}
CERC_STATEDIFF_DB_LOG_STATEMENTS="${CERC_STATEDIFF_DB_LOG_STATEMENTS:-false}"
CERC_STATEDIFF_WORKERS=2

View File

@ -11,7 +11,7 @@ RUN pip3 install --break-system-packages --upgrade "web3==v6.15.1"
RUN pip3 install --break-system-packages --upgrade "typing-extensions"
# Install tool to generate initial block
RUN go install github.com/cerc-io/eth-dump-genblock@b29516740fc01cf1d1d623acbfd0e9a2b6440a96
RUN go install github.com/cerc-io/eth-dump-genblock@v0.2.0
# Build genesis config
COPY genesis /opt/genesis

View File

@ -50,6 +50,58 @@ else
echo -n "$JWT" > /opt/testnet/build/el/jwtsecret
if [ "$CERC_RUN_STATEDIFF" == "detect" ] && [ -n "$CERC_STATEDIFF_DB_HOST" ]; then
dig_result=$(dig $CERC_STATEDIFF_DB_HOST +short)
dig_status_code=$?
if [[ $dig_status_code = 0 && -n $dig_result ]]; then
echo "Statediff DB at $CERC_STATEDIFF_DB_HOST"
CERC_RUN_STATEDIFF="true"
else
echo "No statediff DB available."
CERC_RUN_STATEDIFF="false"
fi
fi
STATEDIFF_OPTS=""
if [ "$CERC_RUN_STATEDIFF" == "true" ]; then
ready=0
echo "Waiting for statediff DB..."
while [ $ready -eq 0 ]; do
sleep 1
export PGPASSWORD="$CERC_STATEDIFF_DB_PASSWORD"
result=$(psql -h "$CERC_STATEDIFF_DB_HOST" \
-p "$CERC_STATEDIFF_DB_PORT" \
-U "$CERC_STATEDIFF_DB_USER" \
-d "$CERC_STATEDIFF_DB_NAME" \
-t -c 'select max(version_id) from goose_db_version;' 2>/dev/null | awk '{ print $1 }')
if [ -n "$result" ]; then
echo "DB ready."
if [ $result -ge $CERC_STATEDIFF_DB_GOOSE_MIN_VER ]; then
ready=1
else
echo "DB not at required version (want $CERC_STATEDIFF_DB_GOOSE_MIN_VER, have $result)"
fi
fi
done
STATEDIFF_OPTS="--statediff \
--statediff.db.host=$CERC_STATEDIFF_DB_HOST \
--statediff.db.name=$CERC_STATEDIFF_DB_NAME \
--statediff.db.nodeid=$CERC_STATEDIFF_DB_NODE_ID \
--statediff.db.password=$CERC_STATEDIFF_DB_PASSWORD \
--statediff.db.port=$CERC_STATEDIFF_DB_PORT \
--statediff.db.user=$CERC_STATEDIFF_DB_USER \
--statediff.db.logstatements=${CERC_STATEDIFF_DB_LOG_STATEMENTS:-false} \
--statediff.db.copyfrom=${CERC_STATEDIFF_DB_COPY_FROM:-true} \
--statediff.waitforsync=true \
--statediff.workers=${CERC_STATEDIFF_WORKERS:-1} \
--statediff.writing=true"
if [ -d "${CERC_PLUGINS_DIR}" ]; then
# With plugeth, we separate the statediff options by prefixing with ' -- '
STATEDIFF_OPTS="--pluginsdir "${CERC_PLUGINS_DIR}" -- ${STATEDIFF_OPTS}"
fi
fi
OTHER_OPTS=""
if [ "$CERC_ALLOW_UNPROTECTED_TXS" == "true" ]; then
# Allow for unprotected (non EIP155) txs to be submitted via RPC
@ -87,6 +139,7 @@ else
--log.vmodule="${CERC_GETH_VMODULE}" \
--miner.etherbase="${ETHERBASE}" \
${OTHER_OPTS} \
${STATEDIFF_OPTS} \
&
geth_pid=$!

View File

@ -0,0 +1,25 @@
FROM cerc/fixturenet-eth-genesis-postmerge:local as fnetgen
# Using the same golang image as used to build geth: https://github.com/cerc-io/go-ethereum/blob/HEAD/Dockerfile
FROM golang:1.21-alpine as delve
RUN go install github.com/go-delve/delve/cmd/dlv@latest
FROM cerc/plugeth-statediff:local as statediff
# FIXME: fork of plugeth, use stock after upstreaming patches
FROM cerc/plugeth:local as geth
FROM alpine:3.18
RUN apk add --no-cache bash wget python3 bind-tools postgresql-client
COPY run-el.sh /opt/testnet/run.sh
COPY --from=delve /go/bin/dlv /usr/local/bin/
COPY --from=geth /usr/local/bin/geth /usr/local/bin/
COPY --from=fnetgen /opt/genesis /opt/testnet
COPY --from=statediff /usr/local/lib/statediff.so /usr/local/lib/plugeth/
# Initialize the geth db with our config
RUN geth --datadir ~/ethdata init /opt/testnet/build/el/geth.json && rm -f ~/ethdata/geth/nodekey
ENTRYPOINT ["/opt/testnet/run.sh"]

View File

@ -0,0 +1,11 @@
#!/usr/bin/env bash
# Build cerc/fixturenet-plugeth-plugeth
set -x
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
cp -fp ${SCRIPT_DIR}/../cerc-fixturenet-eth-geth/run-el.sh ${SCRIPT_DIR}/
docker build -t cerc/fixturenet-plugeth-plugeth:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} $SCRIPT_DIR

View File

@ -0,0 +1,4 @@
#!/usr/bin/env bash
# Build cerc/ipld-eth-db
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
docker build -t cerc/ipld-eth-db:local ${build_command_args} ${CERC_REPO_BASE_DIR}/ipld-eth-db

View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
# Build cerc/plugeth-statediff
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
# Pass Go auth token if present
if [[ -n "${CERC_GO_AUTH_TOKEN}" ]]; then
build_command_args="${build_command_args} --build-arg GIT_VDBTO_TOKEN=${CERC_GO_AUTH_TOKEN}"
fi
docker build -t cerc/plugeth-statediff:local ${build_command_args} ${CERC_REPO_BASE_DIR}/plugeth-statediff

View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
# Build cerc/plugeth
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
# Pass Go auth token if present
if [[ -n "${CERC_GO_AUTH_TOKEN}" ]]; then
build_command_args="${build_command_args} --build-arg GIT_VDBTO_TOKEN=${CERC_GO_AUTH_TOKEN}"
fi
docker build -t cerc/plugeth:local ${build_command_args} ${CERC_REPO_BASE_DIR}/plugeth

View File

@ -2,9 +2,10 @@ version: "1.1"
name: fixturenet-plugeth
description: "Plugeth Ethereum Indexing Fixturenet"
repos:
- git.vdb.to/cerc-io/plugeth@statediff-patches
- git.vdb.to/cerc-io/plugeth@statediff
- git.vdb.to/cerc-io/plugeth-statediff
- git.vdb.to/cerc-io/lighthouse
- git.vdb.to/cerc-io/ipld-eth-db
containers:
- cerc/plugeth-statediff
- cerc/plugeth

View File

@ -56,7 +56,7 @@ test_deployment_spec=$CERC_REPO_BASE_DIR/test-deployment-spec.yml
$SO_COMMAND --stack ${stack_name} deploy init --output $test_deployment_spec
# Check the file now exists
if [ ! -f "$test_deployment_spec" ]; then
test_fail_exit "deploy init test: spec fille not present"
test_fail_exit "deploy init test: spec file not present"
fi
echo "deploy init test: passed"
@ -69,7 +69,7 @@ echo "deploy create test: passed"
$SO_COMMAND deployment --dir $test_deployment_dir start
geth_endpoint=localhost:$($SO_COMMAND deployment --dir $test_deployment_dir ports fixturenet-eth-geth-1 8545 | cut -d: -f2)
geth_endpoint=localhost:$($SO_COMMAND deployment --dir $test_deployment_dir port fixturenet-eth-geth-1 8545 | cut -d: -f2)
timeout=900 # 15 minutes
log_info "Getting initial block number. Timeout set to $timeout seconds"
@ -109,18 +109,24 @@ log_info "Results of block height queries:"
echo "Initial block height: $initial_block_number"
echo "Subsequent block height: $subsequent_block_number"
# Block height difference should be between 1 and some small number
if [[ $block_number_difference -gt 1 && $block_number_difference -lt 100 ]]; then
echo "Test passed"
test_result=0
else
echo "Test failed: block numbers were ${initial_block_number} and ${subsequent_block_number}"
echo "Logs from stack:"
dump_logs () {
echo "Test failed. Logs from stack:"
$SO_COMMAND deployment --dir $test_deployment_dir logs
test_result=1
fi
$SO_COMMAND deployment --dir $test_deployment_dir stop --delete-volumes
log_info "Removing cloned repositories"
rm -rf $CERC_REPO_BASE_DIR
log_info "Test finished"
exit $test_result
}
trap dump_logs ERR
# Block height difference should be between 1 and some small number
[[ $block_number_difference -gt 1 && $block_number_difference -lt 100 ]]
# Check that the block hash is present in the ipld-eth-db
echo "Querying ipld-eth-db for block number $subsequent_block_number"
block_hash_query="SELECT block_hash from eth.header_cids where block_number = $subsequent_block_number"
block_hash=$(
$SO_COMMAND deployment --dir $test_deployment_dir exec ipld-eth-db \
"psql -qtA -U vdbm -c '$block_hash_query' cerc_testing"
)
echo "Block hash in ipld-eth-db: $block_hash"
[[ -n $block_hash ]]
echo "Test passed."