Skip to content

Commit

Permalink
fix: get last confirmed enqueue (#846)
Browse files Browse the repository at this point in the history
* l2geth: fix get last confirmed enqueue

* chore: add changeset

* client: return error correctly
  • Loading branch information
tynes authored May 12, 2021
1 parent 7d8d294 commit 20242af
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/big-moose-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@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
9 changes: 6 additions & 3 deletions l2geth/rollup/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 20242af

Please sign in to comment.