From 20242af4e7afd772588bff9d54302a8c906ce0ad Mon Sep 17 00:00:00 2001 From: Mark Tyneway Date: Wed, 12 May 2021 15:57:43 -0700 Subject: [PATCH] fix: get last confirmed enqueue (#846) * l2geth: fix get last confirmed enqueue * chore: add changeset * client: return error correctly --- .changeset/big-moose-type.md | 5 +++++ l2geth/rollup/client.go | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 .changeset/big-moose-type.md diff --git a/.changeset/big-moose-type.md b/.changeset/big-moose-type.md new file mode 100644 index 000000000..e87e713c4 --- /dev/null +++ b/.changeset/big-moose-type.md @@ -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 diff --git a/l2geth/rollup/client.go b/l2geth/rollup/client.go index 729848017..79045f3dc 100644 --- a/l2geth/rollup/client.go +++ b/l2geth/rollup/client.go @@ -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 {