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): Timeseries data indexing + refactor to taiko-client/relayer CLI approach and architecture #14663

Merged
merged 28 commits into from
Sep 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
604864b
wip
cyberhorsey Sep 6, 2023
6d50639
Refactor to taiko-client/relayer architecture, start indexing transac…
cyberhorsey Sep 7, 2023
6350ace
generator command
cyberhorsey Sep 7, 2023
44771ed
first generator task for total transactions
cyberhorsey Sep 7, 2023
4ca4a16
errgroup for raw block data parsing
cyberhorsey Sep 7, 2023
d3f3fbd
Merge branch 'main' into timeseries_data_indexing
cyberhorsey Sep 7, 2023
72ead58
Merge branch 'timeseries_data_indexing' of github.com:taikoxyz/taiko-…
cyberhorsey Sep 7, 2023
221472e
totaltx and txbyday, refactor of generator
cyberhorsey Sep 7, 2023
0c3b8c0
block data
cyberhorsey Sep 7, 2023
1f08f41
accounts processing
cyberhorsey Sep 7, 2023
37f8e5c
subscribe for new head parsing
cyberhorsey Sep 7, 2023
8deb001
proveblock, proposeblock, contract deployment tasks
cyberhorsey Sep 8, 2023
79b2a13
lints
cyberhorsey Sep 8, 2023
23de2f2
Merge branch 'main' into timeseries_data_indexing
cyberhorsey Sep 8, 2023
3d1c56f
Merge branch 'main' of github.com:taikoxyz/taiko-mono into timeseries…
cyberhorsey Sep 8, 2023
1b04d15
transactedat for events
cyberhorsey Sep 8, 2023
e3c4f4a
relayer typo
cyberhorsey Sep 8, 2023
442aa46
Merge branch 'timeseries_data_indexing' of github.com:taikoxyz/taiko-…
cyberhorsey Sep 8, 2023
f46646e
add task log
cyberhorsey Sep 8, 2023
8302cea
linbt
cyberhorsey Sep 8, 2023
20ffcb7
http server needs chart
cyberhorsey Sep 8, 2023
67596bd
tasks rf
cyberhorsey Sep 8, 2023
9fd4464
index all messages
cyberhorsey Sep 9, 2023
7fed061
config test
cyberhorsey Sep 9, 2023
41961d5
accidentally deleted file, teehee
cyberhorsey Sep 9, 2023
2d0ea58
close generator
cyberhorsey Sep 9, 2023
ddf5ff0
comments
cyberhorsey Sep 9, 2023
4848097
sigterM'
cyberhorsey Sep 10, 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
24 changes: 12 additions & 12 deletions packages/eventindexer/.l1.env
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
HTTP_PORT=4100
PROMETHEUS_HTTP_PORT=6063
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=0x6375394335f34848b850114b66A49D6F47f2cdA8
BRIDGE_ADDRESS=0x7D992599E1B8b4508Ba6E2Ba97893b4C36C23A28
PROVER_POOL_ADDRESS=0x7D992599E1B8b4508Ba6E2Ba97893b4C36C23A28
RPC_URL=wss://l1ws.test.taiko.xyz
DATABASE_USER=root
DATABASE_PASSWORD=root
DATABASE_NAME=eventindexer
DATABASE_HOST=localhost:3306
DATABASE_MAX_IDLE_CONNS=50
DATABASE_MAX_OPEN_CONNS=3000
DATABASE_CONN_MAX_LIFETIME_IN_MS=100000
L1_TAIKO_ADDRESS=0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82
BRIDGE_ADDRESS=0x9A9f2CCfdE556A7E9Ff0848998Aa4a0CFD8863AE
RPC_URL=wss://l1ws.internal.taiko.xyz
CORS_ORIGINS=*
BLOCK_BATCH_SIZE=100
BLOCK_BATCH_SIZE=10
CACHE_INTERVAL_IN_SECONDS=60
LAYER=l1
25 changes: 12 additions & 13 deletions packages/eventindexer/.l2.env
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
HTTP_PORT=4100
PROMETHEUS_HTTP_PORT=6063
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
PROVER_POOL_ADDRESS=0x7D992599E1B8b4508Ba6E2Ba97893b4C36C23A28
SWAP_ADDRESSES=0x501f63210aE6D7Eeb50DaE74DA5Ae407515ee246,0x926815A3fb587DDF5e2d2A03ea235630c0A53a16,0x2223D60359736532958DF6a4E9A5e4A5a71729A1
RPC_URL=wss://ws.test.taiko.xyz
HTTP_PORT=4009
METRICS_HTTP_PORT=6067
DATABASE_USER=root
DATABASE_PASSWORD=root
DATABASE_NAME=eventindexer
DATABASE_HOST=localhost:3306
DATABASE_MAX_IDLE_CONNS=50
DATABASE_MAX_OPEN_CONNS=3000
DATABASE_CONN_MAX_LIFETIME_IN_MS=100000
RPC_URL=wss://ws.internal.taiko.xyz
CORS_ORIGINS=*
BLOCK_BATCH_SIZE=1000
BLOCK_BATCH_SIZE=100
CACHE_INTERVAL_IN_SECONDS=60
LAYER=l2
6 changes: 6 additions & 0 deletions packages/eventindexer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@ 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.

# Block data

1. parse data
2. store
3. cron job that updates every 24 hours
18 changes: 18 additions & 0 deletions packages/eventindexer/account.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package eventindexer

import (
"context"
"time"

"github.com/ethereum/go-ethereum/common"
)

type Account struct {
ID int `json:"id"`
Address string `json:"address"`
TransactedAt time.Time `json:"transactedAt"`
}

type AccountRepository interface {
Save(ctx context.Context, address common.Address, transactedAt time.Time) error
}
28 changes: 21 additions & 7 deletions packages/eventindexer/block.go
Original file line number Diff line number Diff line change
@@ -1,30 +1,44 @@
package eventindexer

import (
"context"
"math/big"
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
)

// Block is a database model representing simple header types
// ProcessedBlock is a database model representing simple header types
// to keep track of our most recently processed block number and hash.
type Block struct {
type ProcessedBlock struct {
ID int `json:"id"`
Height uint64 `json:"blockHeight" gorm:"column:block_height"`
Hash string `json:"hash"`
ChainID int64 `json:"chainID"`
}

// SaveBlockOpts is required to store a new block
type SaveBlockOpts struct {
// SaveProcessedBlockOpts is required to store a new block
type SaveProcessedBlockOpts struct {
Height uint64
Hash common.Hash
ChainID *big.Int
}

// BlockRepository defines methods necessary for interacting with
// ProcessedBlockRepository defines methods necessary for interacting with
// the block store.
type ProcessedBlockRepository interface {
Save(opts SaveProcessedBlockOpts) error
GetLatestBlockProcessed(chainID *big.Int) (*ProcessedBlock, error)
}

type Block struct {
ID int `json:"id"`
ChainID int64 `json:"chainID"`
BlockID int64 `json:"blockID"`
TransactedAt time.Time `json:"transactedAt"`
}

type BlockRepository interface {
Save(opts SaveBlockOpts) error
GetLatestBlockProcessed(chainID *big.Int) (*Block, error)
Save(ctx context.Context, tx *types.Block, chainID *big.Int) error
}
21 changes: 21 additions & 0 deletions packages/eventindexer/chart.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package eventindexer

import "context"

type ChartResponse struct {
Chart []ChartItem `json:"chart"`
}

type ChartItem struct {
Date string `json:"date"`
Value string `json:"value"`
}

type ChartRepository interface {
Find(
ctx context.Context,
task string,
start string,
end string,
) (*ChartResponse, error)
}
Loading
Loading