Skip to content
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

feat(eventindexer): Event indexer #13439

Merged
merged 31 commits into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9c526db
eventindexer for blockproven / potentially other events, API for stat…
cyberhorsey Mar 23, 2023
813dfd5
add status page indicator
cyberhorsey Mar 23, 2023
cacc966
home
cyberhorsey Mar 23, 2023
02c147a
pr title + readme
cyberhorsey Mar 23, 2023
5a7cc98
Merge branch 'main' into event_indexer
cyberhorsey Mar 23, 2023
199ff00
rm depth 1
cyberhorsey Mar 23, 2023
65f9875
add details model
cyberhorsey Mar 23, 2023
1b2cdf1
error
cyberhorsey Mar 23, 2023
e3812ac
Merge branch 'main' into event_indexer
davidtaikocha Mar 24, 2023
2bd4255
Merge branch 'main' into event_indexer
cyberhorsey Mar 24, 2023
64a01d4
fixes
cyberhorsey Mar 24, 2023
66ddf7d
Merge branch 'event_indexer' of github.com:taikoxyz/taiko-mono into e…
cyberhorsey Mar 24, 2023
555a082
Merge branch 'main' into event_indexer
cyberhorsey Mar 24, 2023
8848d96
Merge branch 'event_indexer' of github.com:taikoxyz/taiko-mono into e…
cyberhorsey Mar 24, 2023
db4f416
Merge branch 'main' into event_indexer
d1onys1us Mar 27, 2023
f62f2a5
Merge branch 'main' into event_indexer
cyberhorsey Mar 27, 2023
626617c
Merge branch 'event_indexer' of github.com:taikoxyz/taiko-mono into e…
cyberhorsey Mar 27, 2023
279ab5d
.
cyberhorsey Mar 27, 2023
a150b62
.
cyberhorsey Mar 27, 2023
2886a68
use one dockerfile in root for all go apps
cyberhorsey Mar 27, 2023
92137c7
rm ls
cyberhorsey Mar 27, 2023
9b771a7
Update README.md
cyberhorsey Mar 27, 2023
a932d03
Update packages/eventindexer/.golangci.yml
cyberhorsey Mar 27, 2023
0580f62
Update packages/eventindexer/package.json
cyberhorsey Mar 27, 2023
53f447b
Update packages/eventindexer/package.json
cyberhorsey Mar 27, 2023
e26cc1e
rm changelog
cyberhorsey Mar 27, 2023
bdd4ddb
Merge branch 'event_indexer' of github.com:taikoxyz/taiko-mono into e…
cyberhorsey Mar 27, 2023
6374965
.env defaults
cyberhorsey Mar 27, 2023
31a9170
Update packages/status-page/src/pages/home/Home.svelte
cyberhorsey Mar 27, 2023
a89bba5
rm unecessary field on block
cyberhorsey Mar 27, 2023
2f17c0d
Merge branch 'event_indexer' of github.com:taikoxyz/taiko-mono into e…
cyberhorsey Mar 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
99 changes: 99 additions & 0 deletions .github/workflows/eventindexer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Eventindexer

on:
push:
branches: [main, alpha-2]
paths:
- "packages/eventindexer/**"
pull_request:
paths:
- "packages/eventindexer/**"

jobs:
lint:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.19
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: latest

# Optional: working directory, useful for monorepos
working-directory: ./packages/eventindexer
args: --config=.golangci.yml

test:
runs-on: ubuntu-latest
needs: lint
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.11.0
with:
access_token: ${{ github.token }}

- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: ">=1.19.0"

- name: eventindexer - Unit Tests
working-directory: ./packages/eventindexer
run: go test `go list ./... | grep -v ./contracts | grep -v ./mock | grep -v ./cmd` -coverprofile=coverage.txt -covermode=atomic

- name: eventindexer - Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: ./packages/eventindexer/coverage.txt
flags: eventindexer

push-docker-image:
# only push docker image on PR merge to main
if: ${{ github.event }} == 'push'
name: Build and push docker image
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Login to GCR
uses: docker/login-action@v2
with:
registry: gcr.io
username: _json_key
password: ${{ secrets.GCR_JSON_KEY }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
gcr.io/evmchain/eventindexer
tags: |
type=ref,event=branch
type=ref,event=pr
type=ref,event=tag
type=sha

- name: Build and push
uses: docker/build-push-action@v2
with:
platforms: linux/amd64
push: true
context: .
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
PACKAGE=eventindexer
4 changes: 3 additions & 1 deletion .github/workflows/relayer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ jobs:
with:
platforms: linux/amd64
push: true
context: packages/relayer
context: .
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
PACKAGE=relayer
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM golang:1.19.3 as builder

ARG PACKAGE=eventindexer

RUN apt install git curl

RUN mkdir /taiko-mono

WORKDIR /taiko-mono

COPY . .

RUN go mod download

WORKDIR /taiko-mono/packages/$PACKAGE

RUN CGO_ENABLED=0 GOOS=linux go build -o /taiko-mono/packages/$PACKAGE/bin/${PACKAGE} /taiko-mono/packages/$PACKAGE/cmd/main.go

FROM alpine:latest

ARG PACKAGE

RUN apk add --no-cache ca-certificates

COPY --from=builder /taiko-mono/packages/$PACKAGE/bin/$PACKAGE /usr/local/bin/

ENTRYPOINT ["$PACKAGE"]
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ taiko-mono
├── <a href="./packages">packages</a>
│ ├── <a href="./packages/branding">branding</a>: Taiko branding materials
│ ├── <a href="./packages/bridge-ui">bridge-ui</a>: Taiko Bridge frontend UI
│ ├── <a href="./packages/eventindexer">eventindexer</a>: Event indexer
│ ├── <a href="./packages/protocol">protocol</a>: Taiko ZK-Rollup L2 Protocol and Taiko Bridge smart contracts
│ ├── <a href="./packages/relayer">relayer</a>: Bridge relayer (backend)
│ ├── <a href="./packages/status-page">status-page</a>: Taiko Protocol status page
Expand Down
13 changes: 13 additions & 0 deletions packages/eventindexer/.default.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
HTTP_PORT=4101
PROMETHEUS_HTTP_PORT=6061
MYSQL_USER=root
MYSQL_PASSWORD=root
MYSQL_DATABASE=eventindexer
MYSQL_HOST=localhost:3306
MYSQL_MAX_IDLE_CONNS=50
MYSQL_MAX_OPEN_CONNS=3000
MYSQL_CONN_MAX_LIFETIME_IN_MS=100000
L1_TAIKO_ADDRESS=0x7B3AF414448ba906f02a1CA307C56c4ADFF27ce7
L1_RPC_URL=wss://l1ws.a2.taiko.xyz
CORS_ORIGINS=*
BLOCK_BATCH_SIZE=10
46 changes: 46 additions & 0 deletions packages/eventindexer/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
.netrc
.env
.test.env
main
coverage.txt

# Local .terraform directories
.terraform

# .tfstate files
*.tfstate
*.tfstate.*

# Crash log files
crash.log

# Exclude all .tfvars files, which are likely to contain sentitive data, such as
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# to change depending on the environment.
#
*.tfvars

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json

# Include override files you do wish to add to version control using negated pattern
#
# !example_override.tf

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*

# Ignore CLI configuration files
.terraformrc
terraform.rc

.idea

Bridge.json
TaikoL2.json
IHeaderSync.json
42 changes: 42 additions & 0 deletions packages/eventindexer/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# See: https://golangci-lint.run/usage/configuration/
#
# Note: for VSCode, you must have the following settings to use this configuration:
#
# "go.lintTool": "golangci-lint",
# "go.lintFlags": [
# "--fast",
# "--config=${workspaceFolder}/.golangci.yml"
# ],

output:
format: colored-line-number

linters:
enable:
- errcheck
- funlen
- gocognit
- gocritic
- gofmt
- golint
- gosec
- gosimple
- lll
- unused
- whitespace
- wsl

linters-settings:
funlen:
lines: 137
statements: 54
gocognit:
min-complexity: 43

issues:
exclude-rules:
# Exclude some linters from running on tests files.
- path: _test\.go
linters:
- funlen

2 changes: 1 addition & 1 deletion packages/eventindexer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ Catches events, stores them in the database to be queried via API.

run `cp .default.env .env`, and add your own private key as `RELAYER_ECDSA_KEY` in `.env`. You need to be running a MySQL instance, and replace all the `MYSQL_` env vars with yours.

Run `go run cmd/main.go --help` to see a list of possible configuration flags, or `go run cmd/main.go` to run with defaults, which will process messages from L1 to L2, and from L2 to L1, and start indexing blocks from 0.
Run `go run cmd/main.go --help` to see a list of possible configuration flags, or `go run cmd/main.go` to run with defaults, which will process messages from L1 to L2, and from L2 to L1, and start indexing blocks from 0.