Commit 20242af4 authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

fix: get last confirmed enqueue (#846)

* l2geth: fix get last confirmed enqueue

* chore: add changeset

* client: return error correctly
parent 7d8d2946
---
'@eth-optimism/l2geth': patch
---
Fixes a bug in L2geth that causes it to skip the first deposit if there have been no deposits batch-submitted yet
......@@ -449,23 +449,26 @@ func (c *Client) GetLastConfirmedEnqueue() (*types.Transaction, error) {
if err != nil {
return nil, fmt.Errorf("Cannot get latest enqueue: %w", err)
}
// This should only happen if the database is empty
// This should only happen if there are no L1 to L2 transactions yet
if enqueue == nil {
return nil, nil
return nil, errElementNotFound
}
// Work backwards looking for the first enqueue
// to have an index, which means it has been included
// in the canonical transaction chain.
for {
meta := enqueue.GetMeta()
// The enqueue has an index so it has been confirmed
if meta.Index != nil {
return enqueue, nil
}
// There is no queue index so this is a bug
if meta.QueueIndex == nil {
return nil, fmt.Errorf("queue index is nil")
}
// No enqueue transactions have been confirmed yet
if *meta.QueueIndex == uint64(0) {
return enqueue, nil
return nil, errElementNotFound
}
next, err := c.GetEnqueue(*meta.QueueIndex - 1)
if err != nil {
......
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