fix: Comments about SyncBatch vs L1 and wait for batch persisted (BFT-474) #154
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What ❔
SyncBatch::proof
requiring L1 inclusion - that was based on a misunderstanding that theproof
was a Merkle proof starting from the L1 state root hash, rather than a field inside the zksync system contract on L1. We only need an L1 client to validate the proof, but we can produce it offline as soon as we have the commitment locally.AttesterRunner
so that it waits forpersisted
state of theBatchStore
to indicate that the next batch number is available. This will be when theSyncBatch
can be constructed, so it's when the commitment is ready too (or will be, not currently) and we're ready to sign the payload.BatchStore::last_batch_number
; I wanted to usepersisted.last
, which can beNone
in the beginning untilSyncBatch::proof
is available, with a fallback toPersistentBatchStore::last_batch
which just looks at the latestl1_batches
record, but I wasn't sure whether a next batch can be created before the commitment for the previous one is available, which would cause a regression in the value returned. Instead we just useBatchStore::wait_for_persisted(0)
to tell us what the starting value is after the first batch is ready.Why ❔
To remove misleading comments, and to reduce unneeded polling of the database itself - now we wait until the memory indicates it's worth hitting the DB.