From 29bf563631e61ec6546f8b3dd7d67b488208540b Mon Sep 17 00:00:00 2001 From: nischit Date: Thu, 11 Dec 2025 17:44:41 +0545 Subject: [PATCH 1/7] debug reorg --- cmd/committer.go | 4 ++-- internal/committer/reorg.go | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/committer.go b/cmd/committer.go index eef0bba..34121d3 100644 --- a/cmd/committer.go +++ b/cmd/committer.go @@ -32,6 +32,6 @@ func RunCommitter(cmd *cobra.Command, args []string) { committer.Init() committer.InitReorg() - go committer.RunReorgValidator() - committer.CommitStreaming() + committer.RunReorgValidator() + // committer.CommitStreaming() } diff --git a/internal/committer/reorg.go b/internal/committer/reorg.go index c235544..42a3269 100644 --- a/internal/committer/reorg.go +++ b/internal/committer/reorg.go @@ -72,6 +72,8 @@ func getReorgRange() (int64, int64, error) { } func getLastValidBlock() (int64, error) { + return 23796980, nil + // Try to get last reorg checked block number lastReorgBlock, err := libs.GetReorgLastValidBlock(libs.ChainIdStr) if err != nil { From 03cb2409885729e831d7e7611648ba7889c9d2ed Mon Sep 17 00:00:00 2001 From: nischit Date: Thu, 11 Dec 2025 17:51:31 +0545 Subject: [PATCH 2/7] reorg debug redis key --- internal/committer/reorg.go | 5 +++-- internal/libs/redis.go | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/committer/reorg.go b/internal/committer/reorg.go index 42a3269..42e4605 100644 --- a/internal/committer/reorg.go +++ b/internal/committer/reorg.go @@ -72,8 +72,6 @@ func getReorgRange() (int64, int64, error) { } func getLastValidBlock() (int64, error) { - return 23796980, nil - // Try to get last reorg checked block number lastReorgBlock, err := libs.GetReorgLastValidBlock(libs.ChainIdStr) if err != nil { @@ -206,6 +204,9 @@ func handleReorgForRange(startBlock uint64, endBlock uint64) error { return nil } + log.Debug().Msgf("Reorg detected from block %d to %d", startBlock, endBlock) + return nil + // will panic if any block is invalid newblockDataArray := libblockdata.GetValidBlockDataInBatch(endBlock, startBlock) expectedBlockNumber := startBlock diff --git a/internal/libs/redis.go b/internal/libs/redis.go index 6827282..b612c01 100644 --- a/internal/libs/redis.go +++ b/internal/libs/redis.go @@ -12,7 +12,7 @@ import ( var RedisClient *redis.Client -const RedisReorgLastValidBlock = "reorg_last_valid" +const RedisReorgLastValidBlock = "reorg_last_valid_debug" // InitRedis initializes the Redis client func InitRedis() { From ac87b4410623ec204d89422de92c8b3044a22934 Mon Sep 17 00:00:00 2001 From: nischit Date: Thu, 11 Dec 2025 18:05:11 +0545 Subject: [PATCH 3/7] minor change --- internal/committer/reorg.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/committer/reorg.go b/internal/committer/reorg.go index 42e4605..f7a3a2f 100644 --- a/internal/committer/reorg.go +++ b/internal/committer/reorg.go @@ -34,7 +34,7 @@ func RunReorgValidator() { } if endBlock == lastBlockCheck || endBlock-startBlock < 100 { - log.Debug().Msg("Not enough new blocks to check. Sleeping for 1 minute.") + log.Debug().Int64("last_block_check", lastBlockCheck).Int64("start_block", startBlock).Int64("end_block", endBlock).Msg("Not enough new blocks to check. Sleeping for 1 minute.") time.Sleep(1 * time.Minute) continue } From 605a66d9680f90bd4712ad1c53a522dc5eb997fa Mon Sep 17 00:00:00 2001 From: nischit Date: Thu, 11 Dec 2025 18:23:37 +0545 Subject: [PATCH 4/7] minor change --- internal/committer/reorg.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/internal/committer/reorg.go b/internal/committer/reorg.go index f7a3a2f..6cc48e0 100644 --- a/internal/committer/reorg.go +++ b/internal/committer/reorg.go @@ -33,8 +33,15 @@ func RunReorgValidator() { continue } - if endBlock == lastBlockCheck || endBlock-startBlock < 100 { - log.Debug().Int64("last_block_check", lastBlockCheck).Int64("start_block", startBlock).Int64("end_block", endBlock).Msg("Not enough new blocks to check. Sleeping for 1 minute.") + // Only skip when the current window is too small; allow re-checking the same + // endBlock so that once detectAndHandleReorgs advances lastValidBlock, we + // can move the window forward in the next iteration. + if endBlock-startBlock < 100 { + log.Debug(). + Int64("last_block_check", lastBlockCheck). + Int64("start_block", startBlock). + Int64("end_block", endBlock). + Msg("Not enough new blocks to check. Sleeping for 1 minute.") time.Sleep(1 * time.Minute) continue } From 3fad53231726a5abe32e93e908749b75ff4f5802 Mon Sep 17 00:00:00 2001 From: nischit Date: Thu, 11 Dec 2025 18:34:49 +0545 Subject: [PATCH 5/7] perfrom reorg --- internal/committer/reorg.go | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/internal/committer/reorg.go b/internal/committer/reorg.go index 6cc48e0..9e4fc4b 100644 --- a/internal/committer/reorg.go +++ b/internal/committer/reorg.go @@ -33,15 +33,8 @@ func RunReorgValidator() { continue } - // Only skip when the current window is too small; allow re-checking the same - // endBlock so that once detectAndHandleReorgs advances lastValidBlock, we - // can move the window forward in the next iteration. if endBlock-startBlock < 100 { - log.Debug(). - Int64("last_block_check", lastBlockCheck). - Int64("start_block", startBlock). - Int64("end_block", endBlock). - Msg("Not enough new blocks to check. Sleeping for 1 minute.") + log.Debug().Int64("last_block_check", lastBlockCheck).Int64("start_block", startBlock).Int64("end_block", endBlock).Msg("Not enough new blocks to check. Sleeping for 1 minute.") time.Sleep(1 * time.Minute) continue } @@ -211,9 +204,6 @@ func handleReorgForRange(startBlock uint64, endBlock uint64) error { return nil } - log.Debug().Msgf("Reorg detected from block %d to %d", startBlock, endBlock) - return nil - // will panic if any block is invalid newblockDataArray := libblockdata.GetValidBlockDataInBatch(endBlock, startBlock) expectedBlockNumber := startBlock From 68f2bc1446c3149f2a227c7f4904cc32fb779781 Mon Sep 17 00:00:00 2001 From: nischit Date: Thu, 11 Dec 2025 18:41:33 +0545 Subject: [PATCH 6/7] minor logging fix --- internal/libs/clickhouse.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/internal/libs/clickhouse.go b/internal/libs/clickhouse.go index 3aa33ef..d5f1076 100644 --- a/internal/libs/clickhouse.go +++ b/internal/libs/clickhouse.go @@ -243,14 +243,12 @@ func GetBlockDataFromClickHouseV2(chainId uint64, startBlockNumber uint64, endBl if blocksRaw[i].TransactionCount != uint64(len(transactionsRaw[i])) { log.Info(). Any("transactionCount", blocksRaw[i].TransactionCount). - Any("transactionsRaw", transactionsRaw[i]). Msg("skipping block because transactionCount does not match") continue } if (blocksRaw[i].LogsBloom != "" && blocksRaw[i].LogsBloom != EMPTY_LOGS_BLOOM) && len(logsRaw[i]) == 0 { log.Info(). Any("logsBloom", blocksRaw[i].LogsBloom). - Any("logsRaw", logsRaw[i]). Msg("skipping block because logsBloom is not empty and logsRaw is empty") continue } From ce6aacf3da75f4ec764967a5e655c0cad1a931c4 Mon Sep 17 00:00:00 2001 From: nischit Date: Thu, 11 Dec 2025 19:00:15 +0545 Subject: [PATCH 7/7] debug --- cmd/committer.go | 4 ++-- internal/libs/redis.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/committer.go b/cmd/committer.go index 34121d3..eef0bba 100644 --- a/cmd/committer.go +++ b/cmd/committer.go @@ -32,6 +32,6 @@ func RunCommitter(cmd *cobra.Command, args []string) { committer.Init() committer.InitReorg() - committer.RunReorgValidator() - // committer.CommitStreaming() + go committer.RunReorgValidator() + committer.CommitStreaming() } diff --git a/internal/libs/redis.go b/internal/libs/redis.go index b612c01..6827282 100644 --- a/internal/libs/redis.go +++ b/internal/libs/redis.go @@ -12,7 +12,7 @@ import ( var RedisClient *redis.Client -const RedisReorgLastValidBlock = "reorg_last_valid_debug" +const RedisReorgLastValidBlock = "reorg_last_valid" // InitRedis initializes the Redis client func InitRedis() {