From 2c1b97e0476973c44232fcebc2dffdc6db3990e6 Mon Sep 17 00:00:00 2001 From: milen <94537774+taratorio@users.noreply.github.com> Date: Tue, 1 Oct 2024 14:15:40 +0200 Subject: [PATCH] polygon: fix bor_heimdall stage unwinding due to event processed blocks table (#12148) fixes ``` INFO] [09-30|16:59:20.466] aggregator unwind step=2940 txUnwindTo=4595202440 stepsRangeInDB="accounts:0.9, storage:0.9, code:0.9, commitment:0.0, receipt:0.9, logaddrs: 0.9, logtopics: 0.9, tracesfrom: 0.9, tracesto: 0.9" [EROR] [09-30|16:59:20.671] Staged Sync err="[3/9 BorHeimdall] unexpected missing first processed block info entry when unwinding" ``` that table is only populated as part of astrid, so bor heimdall stage should not attempt to unwind it --- eth/stagedsync/stage_polygon_sync.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/eth/stagedsync/stage_polygon_sync.go b/eth/stagedsync/stage_polygon_sync.go index 9d9d9fce418..0e905762ead 100644 --- a/eth/stagedsync/stage_polygon_sync.go +++ b/eth/stagedsync/stage_polygon_sync.go @@ -153,6 +153,7 @@ func NewPolygonSyncStageCfg( // below are handled via the Bridge.Unwind logic in Astrid KeepEventNums: true, KeepEventProcessedBlocks: true, + Astrid: true, } if len(userUnwindTypeOverrides) > 0 { unwindCfg.ApplyUserUnwindTypeOverrides(userUnwindTypeOverrides) @@ -276,6 +277,7 @@ type HeimdallUnwindCfg struct { KeepSpanBlockProducerSelections bool KeepCheckpoints bool KeepMilestones bool + Astrid bool } func (cfg *HeimdallUnwindCfg) ApplyUserUnwindTypeOverrides(userUnwindTypeOverrides []string) { @@ -309,6 +311,7 @@ func (cfg *HeimdallUnwindCfg) ApplyUserUnwindTypeOverrides(userUnwindTypeOverrid // our config unwinds everything by default defaultCfg := HeimdallUnwindCfg{} + defaultCfg.Astrid = cfg.Astrid // flip the config for the unseen type overrides for unwindType := range unwindTypes { switch unwindType { @@ -327,6 +330,8 @@ func (cfg *HeimdallUnwindCfg) ApplyUserUnwindTypeOverrides(userUnwindTypeOverrid panic(fmt.Sprintf("missing override logic for unwindType %s, please add it", unwindType)) } } + + *cfg = defaultCfg } func UnwindHeimdall(tx kv.RwTx, u *UnwindState, unwindCfg HeimdallUnwindCfg) error { @@ -342,7 +347,7 @@ func UnwindHeimdall(tx kv.RwTx, u *UnwindState, unwindCfg HeimdallUnwindCfg) err } } - if !unwindCfg.KeepEventProcessedBlocks { + if !unwindCfg.KeepEventProcessedBlocks && unwindCfg.Astrid { if err := bridge.UnwindEventProcessedBlocks(tx, u.UnwindPoint); err != nil { return err } @@ -354,7 +359,7 @@ func UnwindHeimdall(tx kv.RwTx, u *UnwindState, unwindCfg HeimdallUnwindCfg) err } } - if !unwindCfg.KeepSpanBlockProducerSelections { + if !unwindCfg.KeepSpanBlockProducerSelections && unwindCfg.Astrid { if err := UnwindSpanBlockProducerSelections(tx, u.UnwindPoint); err != nil { return err }