From 115f6817e645457fb68a3d4725973e3ed293118c Mon Sep 17 00:00:00 2001 From: Mohammed Sohail Date: Mon, 4 Nov 2024 08:33:14 +0300 Subject: [PATCH 1/3] fix: remove required redis configs --- cmd/service/main.go | 9 ++++++--- dev/docker-compose.yaml | 13 ------------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/cmd/service/main.go b/cmd/service/main.go index df4248f..4824be0 100644 --- a/cmd/service/main.go +++ b/cmd/service/main.go @@ -79,15 +79,18 @@ func main() { os.Exit(1) } - cache, err := cache.New(cache.CacheOpts{ + cacheOpts := cache.CacheOpts{ Chain: chain, Registries: ko.Strings("bootstrap.ge_registries"), Watchlist: ko.Strings("bootstrap.watchlist"), Blacklist: ko.Strings("bootstrap.blacklist"), CacheType: ko.MustString("core.cache_type"), - RedisDSN: ko.MustString("redis.dsn"), Logg: lo, - }) + } + if ko.MustString("core.cache_type") == "redis" { + cacheOpts.RedisDSN = ko.MustString("redis.dsn") + } + cache, err := cache.New(cacheOpts) if err != nil { lo.Error("could not initialize cache", "error", err) os.Exit(1) diff --git a/dev/docker-compose.yaml b/dev/docker-compose.yaml index 29054e9..b5668c6 100644 --- a/dev/docker-compose.yaml +++ b/dev/docker-compose.yaml @@ -1,17 +1,4 @@ services: - redis: - image: redis:7-alpine - restart: unless-stopped - command: redis-server --save 60 1 --loglevel warning - volumes: - - tracker-redis:/data - ports: - - "127.0.0.1:6379:6379" - healthcheck: - test: ["CMD-SHELL", "redis-cli ping | grep PONG"] - interval: 10s - timeout: 5s - retries: 5 nats: image: nats:2 restart: unless-stopped From dca3b4d211058731d51f37e9609cf00898f43e94 Mon Sep 17 00:00:00 2001 From: Mohammed Sohail Date: Tue, 12 Nov 2024 10:36:29 +0300 Subject: [PATCH 2/3] fix: temp patch to load a single registry * We seem to have an issue loading a slice from env --- Makefile | 1 - config.toml | 2 +- internal/cache/cache.go | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 6e23cdc..b602fd6 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,6 @@ clean-db: rm ${DB_FILE} build: - ${BUILD_CONF} go build -ldflags="-X main.build=${BUILD_COMMIT} -s -w" -o ${BOOTSTRAP_BIN} cmd/bootstrap/main.go ${BUILD_CONF} go build -ldflags="-X main.build=${BUILD_COMMIT} -s -w" -o ${BIN} cmd/service/*.go run-bootstrap: diff --git a/config.toml b/config.toml index c534e2a..82dc646 100644 --- a/config.toml +++ b/config.toml @@ -27,7 +27,7 @@ start_block = 0 [bootstrap] # This will bootstrap the cache on which addresses to track -ge_registries = ["0xE979a64D375F5D363d7cecF3c93B9aFD40Ba9f55"] +ge_registry = "0x0f8E97ef2d6A42CF62549D4924FCBdcE83A1C6A5" watchlist = [""] blacklist = [""] diff --git a/internal/cache/cache.go b/internal/cache/cache.go index bd5dbbe..2ec7fc4 100644 --- a/internal/cache/cache.go +++ b/internal/cache/cache.go @@ -27,6 +27,7 @@ type ( ) func New(o CacheOpts) (Cache, error) { + o.Logg.Info("initializing cache", "registries", o.Registries, "watchlist", o.Watchlist, "blacklist", o.Blacklist) var cache Cache switch o.CacheType { From fd1cced053a08c22d22e3f42f014a4290f0ca7de Mon Sep 17 00:00:00 2001 From: Mohammed Sohail Date: Tue, 12 Nov 2024 10:48:47 +0300 Subject: [PATCH 3/3] fix: load registries --- cmd/service/main.go | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/cmd/service/main.go b/cmd/service/main.go index c98e77d..f5e3dd5 100644 --- a/cmd/service/main.go +++ b/cmd/service/main.go @@ -44,11 +44,11 @@ func init() { lo = util.InitLogger() ko = util.InitConfig(lo, confFlag) - - lo.Info("starting celo tracker", "build", build) } func main() { + lo.Info("starting celo tracker", "build", build) + var wg sync.WaitGroup ctx, stop := notifyShutdown() @@ -60,6 +60,7 @@ func main() { lo.Error("could not initialize chain client", "error", err) os.Exit(1) } + lo.Debug("loaded rpc fetcher") db, err := db.New(db.DBOpts{ Logg: lo, @@ -69,10 +70,11 @@ func main() { lo.Error("could not initialize blocks db", "error", err) os.Exit(1) } + lo.Debug("loaded blocks db") cacheOpts := cache.CacheOpts{ Chain: chain, - Registries: ko.Strings("bootstrap.ge_registries"), + Registries: []string{ko.MustString("bootstrap.ge_registry")}, Watchlist: ko.Strings("bootstrap.watchlist"), Blacklist: ko.Strings("bootstrap.blacklist"), CacheType: ko.MustString("core.cache_type"), @@ -86,6 +88,7 @@ func main() { lo.Error("could not initialize cache", "error", err) os.Exit(1) } + lo.Debug("loaded and boostrapped cache") jetStreamPub, err := pub.NewJetStreamPub(pub.JetStreamOpts{ Endpoint: ko.MustString("jetstream.endpoint"), @@ -96,8 +99,10 @@ func main() { lo.Error("could not initialize jetstream pub", "error", err) os.Exit(1) } + lo.Debug("loaded jetstream publisher") router := bootstrapEventRouter(cache, jetStreamPub.Send) + lo.Debug("bootstrapped event router") blockProcessor := processor.NewProcessor(processor.ProcessorOpts{ Cache: cache, @@ -106,6 +111,7 @@ func main() { Router: router, Logg: lo, }) + lo.Debug("bootstrapped processor") poolOpts := pool.PoolOpts{ Logg: lo, @@ -117,12 +123,14 @@ func main() { poolOpts.WorkerCount = runtime.NumCPU() * 3 } workerPool := pool.New(poolOpts) + lo.Debug("bootstrapped worker pool") stats := stats.New(stats.StatsOpts{ Cache: cache, Logg: lo, Pool: workerPool, }) + lo.Debug("bootstrapped stats provider") chainSyncer, err := syncer.New(syncer.SyncerOpts{ DB: db, @@ -137,6 +145,7 @@ func main() { lo.Error("could not initialize chain syncer", "error", err) os.Exit(1) } + lo.Debug("bootstrapped realtime syncer") backfill := backfill.New(backfill.BackfillOpts{ BatchSize: ko.MustInt("core.batch_size"), @@ -144,16 +153,20 @@ func main() { Logg: lo, Pool: workerPool, }) + lo.Debug("bootstrapped backfiller") apiServer := &http.Server{ Addr: ko.MustString("api.address"), Handler: api.New(), } + lo.Debug("bootstrapped API server") + lo.Debug("starting routines") wg.Add(1) go func() { defer wg.Done() chainSyncer.Start() + lo.Debug("started chain syncer") }() wg.Add(1) @@ -162,7 +175,9 @@ func main() { if err := backfill.Run(false); err != nil { lo.Error("backfiller initial run error", "error", err) } + lo.Debug("completed initial backfill run") backfill.Start() + lo.Debug("started periodic backfiller") }() wg.Add(1)