Skip to content

Commit

Permalink
finalize reorg
Browse files Browse the repository at this point in the history
  • Loading branch information
Intizar-T committed Dec 18, 2024
1 parent 8e8f3a1 commit f48223e
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions sequencer/coordinator/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,6 @@ func (c *Coordinator) SendMsg(ctx context.Context, msg interface{}) {
}
}

// TODO: implement
func (c *Coordinator) handleReorg(ctx context.Context, msg *MsgSyncReorg) error {
c.stats = msg.Stats
c.syncSCVars(msg.Vars)
Expand All @@ -522,21 +521,21 @@ func (c *Coordinator) handleReorg(ctx context.Context, msg *MsgSyncReorg) error
c.pipeline.SetSyncStatsVars(ctx, &msg.Stats, &msg.Vars)
}

// TODO: implement other state roots
// TODO: discuss if implementing other roots (vouch and score) is necessary
// A pipeline keeps a record of the last batch info from the rollup contract
if c.stats.Sync.LastBatch.StateRoot == nil ||
c.pipelineFromBatch.StateRoot == nil ||
c.stats.Sync.LastBatch.StateRoot.Cmp(c.pipelineFromBatch.StateRoot) != 0 {
if c.stats.Sync.LastBatch.AccountRoot == nil ||
c.pipelineFromBatch.AccountRoot == nil ||
c.stats.Sync.LastBatch.AccountRoot.Cmp(c.pipelineFromBatch.AccountRoot) != 0 {
// There's been a reorg and the batch state root from which the
// pipeline was started has changed (probably because it was in
// a block that was discarded), and it was sent by a different
// coordinator than us. That batch may never be in the main
// chain, so we stop the pipeline (it will be started again
// once the node is in sync).
log.Infow("Coordinator.handleReorg StopPipeline sync.LastBatch.ForgerAddr != cfg.ForgerAddr "+
"& sync.LastBatch.StateRoot != pipelineFromBatch.StateRoot",
"sync.LastBatch.StateRoot", c.stats.Sync.LastBatch.StateRoot,
"pipelineFromBatch.StateRoot", c.pipelineFromBatch.StateRoot)
"& sync.LastBatch.AccountRoot != pipelineFromBatch.AccountRoot",
"sync.LastBatch.AccountRoot", c.stats.Sync.LastBatch.AccountRoot,
"pipelineFromBatch.AccountRoot", c.pipelineFromBatch.AccountRoot)
// c.txManager.DiscardPipeline(ctx, c.pipelineNum)
if err := c.handleStopPipeline(ctx, "reorg", 0); err != nil {
return common.Wrap(err)
Expand Down

0 comments on commit f48223e

Please sign in to comment.