Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(worker): short-circuit l1 message iteration #525

Merged
merged 2 commits into from
Sep 29, 2023

Conversation

Thegaram
Copy link

1. Purpose or design rationale of this PR

Occasionally, the sequencer will crash (OOM or other issue) at IterateL1MessagesFrom in the worker. The suspected reason is that two kinds of DB entries have an overlapping prefix:

txLookupPrefix        = []byte("l")
l1MessagePrefix       = []byte("l1")

In the iterator code, we will not mistakenly return txLookup entries as l1Message entries since these two have different key lengths, and this is checked in Next:

func (it *L1MessageIterator) Next() bool {
	for it.inner.Next() {
		key := it.inner.Key()
		if len(key) == it.keyLength {
			return true
		}
	}
	return false
}

However, it is still possible that we will keep reading and discarding txLookup entries in it.inner.Next().

This PR attempts to fix this by short-circuiting iteration at the highest queue index.

2. PR title

Your PR title must follow conventional commits (as we are doing squash merge for each PR), so it must start with one of the following types:

  • fix: A bug fix

3. Deployment tag versioning

Has the version in params/version.go been updated?

  • This PR doesn't involve a new deployment, git tag, docker image tag, and it doesn't affect traces
  • Yes

4. Breaking change label

Does this PR have the breaking-change label?

  • This PR is not a breaking change
  • Yes

colinlyguo
colinlyguo previously approved these changes Sep 29, 2023
core/rawdb/accessors_l1_message_test.go Outdated Show resolved Hide resolved
Co-authored-by: colin <102356659+colinlyguo@users.noreply.github.com>
@Thegaram Thegaram merged commit fe8232a into develop Sep 29, 2023
5 checks passed
@Thegaram Thegaram deleted the short-circuit-l1-message-iteration branch September 29, 2023 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants