Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

op-node: find sync-start, discard candidate when ahead #11874

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions op-node/rollup/sync/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ func FindL2Heads(ctx context.Context, cfg *rollup.Config, l1 L1Chain, l2 L2Chain
}

if ahead {
// discard previous candidate
highestL2WithCanonicalL1Origin = eth.L2BlockRef{}
// keep the unsafe head if we can't tell if its L1 origin is canonical or not yet.
} else if l1Block.Hash == n.L1Origin.Hash {
// if L2 matches canonical chain, even if unsafe,
Expand Down
2 changes: 1 addition & 1 deletion op-node/rollup/sync/start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (c *syncStartTestCase) generateFakeL2(t *testing.T) (*testutils.FakeChainSo
log := testlog.Logger(t, log.LevelError)
chain := testutils.NewFakeChainSource([]string{c.L1, c.NewL1}, []string{c.L2}, int(c.GenesisL1Num), log)
chain.SetL2Head(len(c.L2) - 1)
genesis := testutils.FakeGenesis(c.GenesisL1, c.GenesisL2, int(c.GenesisL1Num))
genesis := testutils.FakeGenesis(c.GenesisL1, c.GenesisL2, c.GenesisL1Num)
chain.ReorgL1()
for i := 0; i < len(c.NewL1)-1; i++ {
chain.AdvanceL1()
Expand Down
2 changes: 1 addition & 1 deletion op-service/testutils/fake_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/ethereum-optimism/optimism/op-service/eth"
)

func FakeGenesis(l1 rune, l2 rune, l1GenesisNumber int) rollup.Genesis {
func FakeGenesis(l1 rune, l2 rune, l1GenesisNumber uint64) rollup.Genesis {
return rollup.Genesis{
L1: fakeID(l1, uint64(l1GenesisNumber)),
zhiqiangxu marked this conversation as resolved.
Show resolved Hide resolved
L2: fakeID(l2, 0),
Expand Down