require.Equal(t,refB1,eq.SafeL2Head(),"L2 reset should go back to sequence window ago: blocks with origin E and D are not safe until we reconcile, C is extra, and B1 is the end we look for")
require.Equal(t,refB,eq.Progress().Origin,"Expecting to be set back derivation L1 progress to B")
require.Equal(t,refA1,eq.Finalized(),"A1 is recognized as finalized before we run any steps")
// we are not adding blocks in this test,
// but we can still trigger post-processing for the already existing safe head,
// so the engine can prepare to finalize that.
// now say C1 was included in D and became the new safe head
eq.progress.Origin=refD
eq.safeHead=refC1
eq.postProcessSafeL2()
// now say D0 was included in E and became the new safe head
eq.progress.Origin=refE
eq.safeHead=refD0
eq.postProcessSafeL2()
// let's finalize C, which included B0, but not B1
eq.Finalize(refC.ID())
// let's finalize D (current L1), from which we fully derived C1 (it was safe head), but not D0 (included in E)
eq.Finalize(refD.ID())
// Now a few steps later, without consuming any additional L1 inputs,
// we should be able to resolve that B0 is now finalized
// we should be able to resolve that B1 is now finalized, since it was included in finalized L1 block C
// Check L2 traversal against L2 Genesis data, to make sure the engine is on the correct chain, instead of attempting sync with different L2 destination.
fmt.Errorf("failed to fetch L2 block by hash %v: %w",n.ParentHash,err)
// Check L1 comparison against L1 Genesis data, to make sure the L1 data is from the correct chain, instead of attempting sync with different L1 source.
// sanity check that the L1 origin block number is coherent
ifparent.L1Origin.Number+1!=n.L1Origin.Number{
returnnil,fmt.Errorf("l2 parent %s of %s has L1 origin %s that is not before %s",parent,n,parent.L1Origin,n.L1Origin)
}
// sanity check that the later sequence number is 0, if it changed between the L2 blocks
ifn.SequenceNumber!=0{
returnnil,fmt.Errorf("l2 block %s has parent %s with different L1 origin %s, but non-zero sequence number %d",n,parent,parent.L1Origin,n.SequenceNumber)
}
// if the L1 origin is known to be canonical, then the parent must be too