Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
ref impl: undo extra refL1 return param
Browse files Browse the repository at this point in the history
  • Loading branch information
protolambda committed Jan 19, 2022
1 parent 77c0b07 commit 8c74a7a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion opnode/l2/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (e *EngineDriver) Drive(ctx context.Context, dl Downloader, l1Heads <-chan
continue
}
e.Log.Debug("finding next sync step, engine syncing", "l2", e.l2Head, "l1", e.l1Head)
_, nextRefL1, refL2, err := FindSyncStart(ctx, e.SyncRef, &e.Genesis)
nextRefL1, refL2, err := FindSyncStart(ctx, e.SyncRef, &e.Genesis)
if err != nil {
e.Log.Error("Failed to find sync starting point", "err", err)
continue
Expand Down
3 changes: 2 additions & 1 deletion opnode/l2/sync_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ var WrongChainErr = errors.New("wrong chain")

// FindSyncStart finds nextRefL1: the L1 block needed next for sync, to derive into a L2 block on top of refL2.
// If the L1 reorgs then this will find the common history to build on top of and then follow the first step of the reorg.
func FindSyncStart(ctx context.Context, reference SyncReference, genesis *Genesis) (refL1, nextRefL1, refL2 eth.BlockID, err error) {
func FindSyncStart(ctx context.Context, reference SyncReference, genesis *Genesis) (nextRefL1, refL2 eth.BlockID, err error) {
var refL1 eth.BlockID // the L1 block the refL2 was derived from
var parentL2 common.Hash // the parent of refL2
// Start at L2 head
refL1, refL2, parentL2, err = reference.RefByL2Num(ctx, nil, genesis)
Expand Down
2 changes: 1 addition & 1 deletion opnode/l2/sync_start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (c *syncStartTestCase) Run(t *testing.T) {
}
expectedRefL2 := mockID(c.ExpectedRefL2, expectedRefL2Num)

_, nextRefL1, refL2, err := FindSyncStart(context.Background(), msr, genesis)
nextRefL1, refL2, err := FindSyncStart(context.Background(), msr, genesis)
if c.ExpectedErr != nil {
assert.Error(t, err, "got next L1 %s (%d), onto L2: %s (%d)", nextRefL1.Hash[:1], nextRefL1.Number, refL2.Hash[:1], refL2.Number)
assert.ErrorIs(t, err, c.ExpectedErr)
Expand Down

0 comments on commit 8c74a7a

Please sign in to comment.