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 19 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
dionysuzx 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions .github/workflows/eventindexer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
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: packages/eventindexer
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
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/protocol">eventindexer</a>: Event indexer
cyberhorsey marked this conversation as resolved.
Show resolved Hide resolved
│ ├── <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=relayer
cyberhorsey marked this conversation as resolved.
Show resolved Hide resolved
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
45 changes: 45 additions & 0 deletions packages/eventindexer/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# 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

run:
skip-dirs:
- contracts/*
cyberhorsey marked this conversation as resolved.
Show resolved Hide resolved
63 changes: 63 additions & 0 deletions packages/eventindexer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Changelog
cyberhorsey marked this conversation as resolved.
Show resolved Hide resolved

## [0.3.0](https://github.com/taikoxyz/taiko-mono/compare/relayer-v0.2.1...relayer-v0.3.0) (2023-03-15)


### Features

* **relayer:** add msgHash and event type lookups to findallbyaddress ([#13310](https://github.com/taikoxyz/taiko-mono/issues/13310)) ([8b753ee](https://github.com/taikoxyz/taiko-mono/commit/8b753ee07eeee51adf48e72343b62abcde3b2338))
* **relayer:** Event filter ([#13318](https://github.com/taikoxyz/taiko-mono/issues/13318)) ([f20d419](https://github.com/taikoxyz/taiko-mono/commit/f20d4195ac9d700dfd4a51192232c3fe7c4c0b43))
* **relayer:** MessageStatusChanged events ([#13272](https://github.com/taikoxyz/taiko-mono/issues/13272)) ([f5f4fc4](https://github.com/taikoxyz/taiko-mono/commit/f5f4fc4af16520a34e805e8f16c50e0de4902815))
* **relayer:** Pagination ([#13311](https://github.com/taikoxyz/taiko-mono/issues/13311)) ([9350006](https://github.com/taikoxyz/taiko-mono/commit/9350006aefa8f6423c663ea3a0377f7334a5b749))


### Bug Fixes

* **relayer:** estimate gas for tx, set gas to 2.5mil if not estimatable. works now. ([#13271](https://github.com/taikoxyz/taiko-mono/issues/13271)) ([3913ca5](https://github.com/taikoxyz/taiko-mono/commit/3913ca52242913dfb9502488f0a5558724f9ef2b))

## [0.2.1](https://github.com/taikoxyz/taiko-mono/compare/relayer-v0.2.0...relayer-v0.2.1) (2023-03-01)


### Bug Fixes

* **relayer:** estimate gas, now that gas estimation works again ([#13176](https://github.com/taikoxyz/taiko-mono/issues/13176)) ([b7ae677](https://github.com/taikoxyz/taiko-mono/commit/b7ae677ec2d84dce3e3ae50d369bf31dedc547c3))
* **relayer:** Save block progress when caught up and subscribing to new events ([#13177](https://github.com/taikoxyz/taiko-mono/issues/13177)) ([5ef2c0f](https://github.com/taikoxyz/taiko-mono/commit/5ef2c0f5d78764189d168aa527cec62238f1d6c6))

## [0.2.0](https://github.com/taikoxyz/taiko-mono/compare/relayer-v0.1.0...relayer-v0.2.0) (2023-02-15)


### Features

* **protocol:** change statevariables to return a struct ([#13113](https://github.com/taikoxyz/taiko-mono/issues/13113)) ([0bffeb0](https://github.com/taikoxyz/taiko-mono/commit/0bffeb0f3d17938bf2146772962719ae21ce22fa))
* **relayer:** catch relayer & status page up to new testnet ([#13114](https://github.com/taikoxyz/taiko-mono/issues/13114)) ([543f242](https://github.com/taikoxyz/taiko-mono/commit/543f242bfbf18b155f3476c2d172e79d3041ffc9))
* **relayer:** prepare bridge relayer API for frontend ([#13124](https://github.com/taikoxyz/taiko-mono/issues/13124)) ([ef1f691](https://github.com/taikoxyz/taiko-mono/commit/ef1f691ac9e6b3138b1ee80bc7bebcf53b749581))

## [0.1.0](https://github.com/taikoxyz/taiko-mono/compare/relayer-v0.0.1...relayer-v0.1.0) (2023-01-19)


### Features

* **bridge-ui:** process message ([#387](https://github.com/taikoxyz/taiko-mono/issues/387)) ([d1781c0](https://github.com/taikoxyz/taiko-mono/commit/d1781c0107110e70c87e76d3fc1f6a9bc2aa1a46))
* **bridge:** add faucet link to announcement ([#485](https://github.com/taikoxyz/taiko-mono/issues/485)) ([d1a4921](https://github.com/taikoxyz/taiko-mono/commit/d1a492183fd4ab8f195697864f54c35349dca93d))
* **bridge:** bridge design ([#369](https://github.com/taikoxyz/taiko-mono/issues/369)) ([04702db](https://github.com/taikoxyz/taiko-mono/commit/04702db23e3fd705133408e077b8d1a040951202))
* **bridge:** bridge transactions ([#411](https://github.com/taikoxyz/taiko-mono/issues/411)) ([19dd7ab](https://github.com/taikoxyz/taiko-mono/commit/19dd7abd4a2f5bc83e43d31938e43501472ff108))
* **bridge:** implement the bridge relayer ([#191](https://github.com/taikoxyz/taiko-mono/issues/191)) ([9f49e4c](https://github.com/taikoxyz/taiko-mono/commit/9f49e4c87304853c9d94693434d23a6b8258eac6))
* implement release-please workflow ([#12967](https://github.com/taikoxyz/taiko-mono/issues/12967)) ([b0c8b60](https://github.com/taikoxyz/taiko-mono/commit/b0c8b60da0af3160db758f83c1f6368a3a712593))
* **protocol:** implement & simulate tokenomics ([#376](https://github.com/taikoxyz/taiko-mono/issues/376)) ([191eb11](https://github.com/taikoxyz/taiko-mono/commit/191eb110990d60b49883eb3f3d7841c33421d067))
* **relayer:** Allow resync flag option to restart processing from block 0 ([#266](https://github.com/taikoxyz/taiko-mono/issues/266)) ([6b01cbe](https://github.com/taikoxyz/taiko-mono/commit/6b01cbe986d61795fc9a2ef256dbe85409251720))
* **relayer:** Asynchronous message processing, error handling, nonce management, and indexer folder structuring ([#259](https://github.com/taikoxyz/taiko-mono/issues/259)) ([ed6d551](https://github.com/taikoxyz/taiko-mono/commit/ed6d551744965440153eaa7a8c42c887fa26938c))
* **relayer:** header sync check before processing messages ([#441](https://github.com/taikoxyz/taiko-mono/issues/441)) ([e9fda8b](https://github.com/taikoxyz/taiko-mono/commit/e9fda8bb80ecfefcfd7d64062b50ebf5b5eec2ef))
* **relayer:** HTTP api for exposing events table for bridge UI ([#271](https://github.com/taikoxyz/taiko-mono/issues/271)) ([7b5e6b8](https://github.com/taikoxyz/taiko-mono/commit/7b5e6b809c0e2f6a8615896d57e2b0d2db98c80b))
* **relayer:** only process profitable transactions ([#408](https://github.com/taikoxyz/taiko-mono/issues/408)) ([b5d8180](https://github.com/taikoxyz/taiko-mono/commit/b5d81802e32b038b5bcdd26f233b0cd4b3eca3fa))
* **relayer:** run in http only mode, so we can scale up if necessary for requests and only have one indexer ([6500234](https://github.com/taikoxyz/taiko-mono/commit/6500234991702b203e6e8baeb496e5473b631f83))
* **relayer:** Wait N confirmations on source chain before processing message on destination chain ([#270](https://github.com/taikoxyz/taiko-mono/issues/270)) ([7ab1291](https://github.com/taikoxyz/taiko-mono/commit/7ab129193f3e08faf04cd1b7e09b5b5994636775))


### Bug Fixes

* **bridge-ui:** Eth fix ([#475](https://github.com/taikoxyz/taiko-mono/issues/475)) ([08175b8](https://github.com/taikoxyz/taiko-mono/commit/08175b803aaabdf6195f5a7a3ed8e0baf9558cc5))
* **protocol:** Remove enableDestChain functionality ([#12341](https://github.com/taikoxyz/taiko-mono/issues/12341)) ([362d083](https://github.com/taikoxyz/taiko-mono/commit/362d083497cc74b3bcd05a406beeff2101a422ef))
* **relayer:** fix migrations ([#300](https://github.com/taikoxyz/taiko-mono/issues/300)) ([151415e](https://github.com/taikoxyz/taiko-mono/commit/151415e71f2b6ac62c607d5cc928fa258064a679))
* **relayer:** gas limit + use loading as priorioty on bridge form ([#487](https://github.com/taikoxyz/taiko-mono/issues/487)) ([3747d4c](https://github.com/taikoxyz/taiko-mono/commit/3747d4c41e836ab533e864ec44073ae681bf4b36))
* **relayer:** save block by chain id ([#379](https://github.com/taikoxyz/taiko-mono/issues/379)) ([608e3e3](https://github.com/taikoxyz/taiko-mono/commit/608e3e3723586f8b412d71118d15f6bab86ad596))
* **tests:** cleanup tests to prepare for tokenomics testing ([#11316](https://github.com/taikoxyz/taiko-mono/issues/11316)) ([d63fae3](https://github.com/taikoxyz/taiko-mono/commit/d63fae30f1e3415d6f377adeab90c062fed5ad42))
19 changes: 19 additions & 0 deletions packages/eventindexer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM golang:1.19.3 as builder

RUN apt install git curl

RUN git clone --depth 1 https://github.com/taikoxyz/taiko-mono/taiko-mono

WORKDIR /taiko-mono/packages/eventindexer

RUN go mod download

RUN CGO_ENABLED=0 GOOS=linux go build -o ./bin/eventindexer cmd/main.go

FROM alpine:latest

RUN apk add --no-cache ca-certificates

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

ENTRYPOINT ["eventindexer"]
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.
Loading