Initial statediff plugin #2

Merged
roysc merged 6 commits from wip into main 2023-07-14 06:08:08 +00:00
7 changed files with 135 additions and 20 deletions
Showing only changes of commit 03f5622bea - Show all commits

89
.gitea/workflows/test.yml Normal file
View File

@ -0,0 +1,89 @@
name: Test
on:
pull_request:
branches: '*'
push:
branches:
- main
- ci-test
# Needed until we can incorporate docker startup into the executor container
env:
DOCKER_HOST: unix:///var/run/dind.sock
jobs:
unit-tests:
name: "Run unit tests"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
check-latest: true
- name: "Run dockerd"
run: |
dockerd -H $DOCKER_HOST --userland-proxy=false &
sleep 5
- name: "Run DB container"
run: |
docker compose -f test/compose.yml up --wait
- name: "Set up Gitea access token"
env:
TOKEN: ${{ secrets.CICD_REPO_TOKEN }}
run: |
git config --global url."https://$TOKEN:@git.vdb.to/".insteadOf https://git.vdb.to/
- name: "Run tests"
run: go test -v ./...
integration-tests:
name: "Run integration tests"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
path: ./plugeth-statediff
# TODO: replace with release
- uses: actions/checkout@v3
with:
repository: cerc-io/plugeth
ref: statediff-wip
path: ./plugeth
- name: "Run dockerd"
run: dockerd -H $DOCKER_HOST --userland-proxy=false &
# These images need access tokens configured
- name: "Build docker image"
env:
TOKEN: ${{ secrets.CICD_REPO_TOKEN }}
run: |
[[ -n "$TOKEN" ]]
docker build ./plugeth-statediff -t cerc/plugeth-statediff:local \
--build-arg GIT_VDBTO_TOKEN="$TOKEN"
docker build ./plugeth -t cerc/plugeth:local \
--build-arg GIT_VDBTO_TOKEN="$TOKEN"
- name: "Install stack-orchestrator"
uses: actions/checkout@v3
with:
repository: roysc/stack-orchestrator
ref: plugeth-testing
path: ./stack-orchestrator
- run: |
apt-get update && apt-get install -y python3-pip
pip install ./stack-orchestrator
- name: "Run testnet stack"
working-directory: ./plugeth-statediff
run: ./scripts/integration-setup.sh
- name: "Clone system-tests"
uses: actions/checkout@v3
with:
repository: cerc-io/system-tests
ref: main
path: ./system-tests
- name: "Run tests"
working-directory: ./system-tests
run: |
pip install pytest
pip install -r requirements.txt
pytest -v -k test_basic_db

View File

@ -1,18 +1,21 @@
# Using the same base golang image as geth # Using the same base golang image as plugeth
FROM golang:1.20-alpine as builder FROM golang:1.20-alpine3.18 as builder
RUN apk add --no-cache gcc musl-dev binutils-gold linux-headers git RUN apk add --no-cache gcc musl-dev binutils-gold linux-headers git
WORKDIR /plugeth-statediff/ # Configure creds for gitea
ARG GIT_VDBTO_TOKEN
# Get and cache deps # Get and cache deps
COPY go.mod . WORKDIR /plugeth-statediff/
COPY go.sum . COPY go.mod go.sum ./
RUN go mod download RUN if [ -n "$GIT_VDBTO_TOKEN" ]; then git config --global url."https://$GIT_VDBTO_TOKEN:@git.vdb.to/".insteadOf "https://git.vdb.to/"; fi && \
go mod download && \
rm -f ~/.gitconfig
ADD . . COPY . .
RUN go build --tags linkgeth --buildmode=plugin --trimpath -o statediff.so ./main RUN go build --tags linkgeth --buildmode=plugin --trimpath -o statediff.so ./main
FROM alpine:latest FROM alpine:3.18
COPY --from=builder /plugeth-statediff/statediff.so /usr/local/lib/ COPY --from=builder /plugeth-statediff/statediff.so /usr/local/lib/

6
go.mod
View File

@ -122,8 +122,6 @@ require (
) )
replace ( replace (
// github.com/ethereum/go-ethereum => ../plugeth github.com/ethereum/go-ethereum => git.vdb.to/cerc-io/plugeth v0.0.0-20230710223804-34971d65a36a
// github.com/openrelayxyz/plugeth-utils => ../plugeth-utils github.com/openrelayxyz/plugeth-utils => git.vdb.to/cerc-io/plugeth-utils v0.0.0-20230706160122-cd41de354c46
github.com/ethereum/go-ethereum => git.vdb.to/cerc-io/plugeth v0.0.0-20230629081247-feb6ccc72b3f
github.com/openrelayxyz/plugeth-utils => git.vdb.to/cerc-io/plugeth-utils v0.0.0-20230622072028-1d3da8ce80ee
) )

8
go.sum
View File

@ -1,8 +1,8 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
git.vdb.to/cerc-io/plugeth v0.0.0-20230629081247-feb6ccc72b3f h1:QGxQXUa53S1Ci+gp17zjw5TI62q4fyZ/PTvHQ72FxZw= git.vdb.to/cerc-io/plugeth v0.0.0-20230710223804-34971d65a36a h1:R3DoXSTTXc0xc3M/hOFppVitj1lk1cn2VWTsZloYZ/8=
git.vdb.to/cerc-io/plugeth v0.0.0-20230629081247-feb6ccc72b3f/go.mod h1:odpOaIpK01aVThIoAuw9YryLBJeHYOsDn9Mxm4LhB5s= git.vdb.to/cerc-io/plugeth v0.0.0-20230710223804-34971d65a36a/go.mod h1:odpOaIpK01aVThIoAuw9YryLBJeHYOsDn9Mxm4LhB5s=
git.vdb.to/cerc-io/plugeth-utils v0.0.0-20230622072028-1d3da8ce80ee h1:DJ1bR/2k7PopUtchEoTw5QHV1DHb9p0ubcb3yKJc10I= git.vdb.to/cerc-io/plugeth-utils v0.0.0-20230706160122-cd41de354c46 h1:KYcbbne/RXd7AuxbUd/3hgk1jPN+33k2CKiNsUsMCC0=
git.vdb.to/cerc-io/plugeth-utils v0.0.0-20230622072028-1d3da8ce80ee/go.mod h1:p5Jc8deG2yxXI8DzmrH3kHNEwlQqcOQS0pmGulsqg+M= git.vdb.to/cerc-io/plugeth-utils v0.0.0-20230706160122-cd41de354c46/go.mod h1:VpDN61dxy64zGff05F0adujR5enD/JEdXBkTQ+PaIsQ=
github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0= github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0=

27
scripts/integration-setup.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/bash
set -eux
cluster="${1:-test}"
laconic_so="${LACONIC_SO:-laconic-so} --stack fixturenet-plugeth-tx --verbose"
CONFIG_DIR=$(readlink -f "${CONFIG_DIR:-$(mktemp -d)}")
# By default assume we are running in the project root
export CERC_REPO_BASE_DIR="${CERC_REPO_BASE_DIR:-$(realpath $(git rev-parse --show-toplevel)/..)}"
# v5 migrations only go up to version 18
echo CERC_STATEDIFF_DB_GOOSE_MIN_VER=18 >> $CONFIG_DIR/stack.env
# Build and deploy a cluster with only what we need from the stack
$laconic_so setup-repositories \
--exclude github.com/dboreham/foundry,github.com/cerc-io/tx-spammer,github.com/cerc-io/ipld-eth-server,git.vdb.to/cerc-io/plugeth,git.vdb.to/cerc-io/plugeth-statediff \
--branches-file ./test/stack-refs.txt
$laconic_so build-containers \
--exclude cerc/ipld-eth-server,cerc/keycloak,cerc/tx-spammer,cerc/foundry,cerc/plugeth,cerc/plugeth-statediff
$laconic_so deploy \
--exclude foundry,keycloak,tx-spammer,ipld-eth-server \
--env-file $CONFIG_DIR/stack.env \
--cluster "$cluster" up

View File

@ -1,5 +1,3 @@
version: "3.2"
services: services:
migrations: migrations:
restart: on-failure restart: on-failure
@ -16,12 +14,11 @@ services:
ipld-eth-db: ipld-eth-db:
image: timescale/timescaledb:latest-pg14 image: timescale/timescaledb:latest-pg14
restart: always restart: always
command: ["postgres", "-c", "log_statement=all"]
environment: environment:
POSTGRES_USER: "vdbm" POSTGRES_USER: "vdbm"
POSTGRES_DB: "cerc_testing" POSTGRES_DB: "cerc_testing"
POSTGRES_PASSWORD: "password" POSTGRES_PASSWORD: "password"
ports: ports:
- "127.0.0.1:8077:5432" - 127.0.0.1:8077:5432
volumes: volumes:
- ../indexer/database/file:/file_indexer - ../indexer/database/file:/file_indexer

1
test/stack-refs.txt Normal file
View File

@ -0,0 +1 @@
github.com/cerc-io/ipld-eth-db v5.0.2-alpha