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

chore(eventindexer): ei update for state vars #18867

Merged
merged 4 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5,690 changes: 5,690 additions & 0 deletions packages/eventindexer/contracts/v2/taikol1/TaikoL1.go

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions packages/eventindexer/indexer/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/taikoxyz/taiko-mono/packages/eventindexer"
"github.com/taikoxyz/taiko-mono/packages/eventindexer/contracts/bridge"
"github.com/taikoxyz/taiko-mono/packages/eventindexer/contracts/taikol1"
v2 "github.com/taikoxyz/taiko-mono/packages/eventindexer/contracts/v2/taikol1"
"github.com/taikoxyz/taiko-mono/packages/eventindexer/pkg/db"
"github.com/taikoxyz/taiko-mono/packages/eventindexer/pkg/repo"
)
Expand Down Expand Up @@ -52,8 +53,9 @@ type Indexer struct {
blockBatchSize uint64
subscriptionBackoff time.Duration

taikol1 *taikol1.TaikoL1
bridge *bridge.Bridge
taikol1 *taikol1.TaikoL1
taikol1V2 *v2.TaikoL1
bridge *bridge.Bridge

indexNfts bool
indexERC20s bool
Expand Down Expand Up @@ -164,13 +166,20 @@ func InitFromConfig(ctx context.Context, i *Indexer, cfg *Config) error {

var taikoL1 *taikol1.TaikoL1

var taikol1V2 *v2.TaikoL1

if cfg.L1TaikoAddress.Hex() != ZeroAddress.Hex() {
slog.Info("setting l1TaikoAddress", "addr", cfg.L1TaikoAddress.Hex())

taikoL1, err = taikol1.NewTaikoL1(cfg.L1TaikoAddress, ethClient)
if err != nil {
return errors.Wrap(err, "contracts.NewTaikoL1")
}

taikol1V2, err = v2.NewTaikoL1(cfg.L1TaikoAddress, ethClient)
if err != nil {
return errors.Wrap(err, "contracts.NewTaikoL1")
}
}

var bridgeContract *bridge.Bridge
Expand All @@ -196,6 +205,7 @@ func InitFromConfig(ctx context.Context, i *Indexer, cfg *Config) error {

i.ethClient = ethClient
i.taikol1 = taikoL1
i.taikol1V2 = taikol1V2
i.bridge = bridgeContract
i.blockBatchSize = cfg.BlockBatchSize
i.subscriptionBackoff = time.Duration(cfg.SubscriptionBackoff) * time.Second
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@ func (i *Indexer) setInitialIndexingBlockByMode(
if i.taikol1 != nil {
slotA, _, err := i.taikol1.GetStateVariables(nil)
if err != nil {
return errors.Wrap(err, "i.taikoL1.GetStateVariables")
// check v2
slotA, _, err := i.taikol1V2.GetStateVariables(nil)
if err != nil {
return errors.Wrap(err, "i.taikol1.GetStateVariables")
}

startingBlock = slotA.GenesisHeight
} else {
startingBlock = slotA.GenesisHeight
}

startingBlock = slotA.GenesisHeight
}

switch mode {
Expand Down
23 changes: 23 additions & 0 deletions packages/eventindexer/scripts/abigen_v2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

if [ ! -d "../protocol/out" ]; then
echo "ABI not generated in protocol package yet. Please run npm install && pnpm run compile in ../protocol"
exit 1
fi

paths=("layer1/TaikoL1.sol")

names=("TaikoL1")


for (( i = 0; i < ${#paths[@]}; ++i ));
do
lower=$(echo "${names[i]}" | tr '[:upper:]' '[:lower:]')
jq .abi ../protocol/out/${paths[i]}/${names[i]}.json > contracts/v2/$lower/${names[i]}.json
abigen --abi contracts/v2/$lower/${names[i]}.json \
--pkg $lower \
--type ${names[i]} \
--out contracts/v2/$lower/${names[i]}.go
done

exit 0
Loading