Commit f8c01480 authored by Diederik Loerakker's avatar Diederik Loerakker Committed by GitHub

op-node: conf depth filter should not filter out genesis (#3042)

parent 301b518b
......@@ -30,7 +30,7 @@ func (c *confDepth) L1BlockRefByNumber(ctx context.Context, num uint64) (eth.L1B
// TODO: performance optimization: buffer the l1Head, invalidate any reorged previous buffer content,
// and instantly return the origin by number from the buffer if we can.
if c.depth == 0 || num+c.depth <= c.l1Head().Number {
if num == 0 || c.depth == 0 || num+c.depth <= c.l1Head().Number {
return c.L1Fetcher.L1BlockRefByNumber(ctx, num)
}
return eth.L1BlockRef{}, ethereum.NotFound
......
......@@ -53,6 +53,7 @@ func TestConfDepth(t *testing.T) {
{name: "two conf not like 1", head: 4, req: 3, depth: 2, pass: false},
{name: "two conf pass", head: 4, req: 2, depth: 2, pass: true},
{name: "easy pass", head: 100, req: 20, depth: 5, pass: true},
{name: "genesis case", head: 0, req: 0, depth: 4, pass: true},
}
for _, tc := range testCases {
t.Run(tc.name, tc.Run)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment