Skip to content

Commit

Permalink
polygon: fix bor_heimdall stage unwinding due to event processed bloc…
Browse files Browse the repository at this point in the history
…ks 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
  • Loading branch information
taratorio authored Oct 1, 2024
1 parent 858d6d5 commit 2c1b97e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions eth/stagedsync/stage_polygon_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -276,6 +277,7 @@ type HeimdallUnwindCfg struct {
KeepSpanBlockProducerSelections bool
KeepCheckpoints bool
KeepMilestones bool
Astrid bool
}

func (cfg *HeimdallUnwindCfg) ApplyUserUnwindTypeOverrides(userUnwindTypeOverrides []string) {
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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
}
Expand All @@ -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
}
Expand Down

0 comments on commit 2c1b97e

Please sign in to comment.