Skip to content

Commit

Permalink
verifier logs (#1143)
Browse files Browse the repository at this point in the history
  • Loading branch information
kstoykov authored Sep 9, 2024
1 parent b0003ac commit 415b495
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
14 changes: 11 additions & 3 deletions zk/legacy_executor_verifier/legacy_executor_verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ func (vr *VerifierRequest) IsOverdue() bool {
return time.Since(vr.creationTime) > vr.timeout
}

func (vr *VerifierRequest) GetFirstBlockNumber() uint64 {
return vr.BlockNumbers[0]
}

func (vr *VerifierRequest) GetLastBlockNumber() uint64 {
return vr.BlockNumbers[len(vr.BlockNumbers)-1]
}
Expand Down Expand Up @@ -126,6 +130,7 @@ func NewLegacyExecutorVerifier(
}

func (v *LegacyExecutorVerifier) StartAsyncVerification(
logPrefix string,
forkId uint64,
batchNumber uint64,
stateRoot common.Hash,
Expand All @@ -143,13 +148,15 @@ func (v *LegacyExecutorVerifier) StartAsyncVerification(
promise = v.VerifyWithoutExecutor(request, blockNumbers)
}

v.appendPromise(promise)
size := v.appendPromise(promise)
log.Info(fmt.Sprintf("[%s] Starting verification request", logPrefix), "batch-number", batchNumber, "blocks-range", fmt.Sprintf("[%d;%d]", request.GetFirstBlockNumber(), request.GetLastBlockNumber()), "pending-requests", size)
}

func (v *LegacyExecutorVerifier) appendPromise(promise *Promise[*VerifierBundle]) {
func (v *LegacyExecutorVerifier) appendPromise(promise *Promise[*VerifierBundle]) int {
v.mtxPromises.Lock()
defer v.mtxPromises.Unlock()
v.promises = append(v.promises, promise)
return len(v.promises)
}

func (v *LegacyExecutorVerifier) VerifySync(tx kv.Tx, request *VerifierRequest, witness, streamBytes []byte, timestampLimit, firstBlockNumber uint64, l1InfoTreeMinTimestamps map[uint64]uint64) error {
Expand Down Expand Up @@ -309,7 +316,7 @@ func (v *LegacyExecutorVerifier) VerifyWithoutExecutor(request *VerifierRequest,
return promise
}

func (v *LegacyExecutorVerifier) ProcessResultsSequentially() ([]*VerifierBundle, error) {
func (v *LegacyExecutorVerifier) ProcessResultsSequentially(logPrefix string) ([]*VerifierBundle, error) {
v.mtxPromises.Lock()
defer v.mtxPromises.Unlock()

Expand Down Expand Up @@ -345,6 +352,7 @@ func (v *LegacyExecutorVerifier) ProcessResultsSequentially() ([]*VerifierBundle
break
}

log.Info(fmt.Sprintf("[%s] Finished verification request", logPrefix), "batch-number", verifierBundle.Request.BatchNumber, "blocks-range", fmt.Sprintf("[%d;%d]", verifierBundle.Request.GetFirstBlockNumber(), verifierBundle.Request.GetLastBlockNumber()), "is-valid", verifierBundle.Response.Valid, "pending-requests", len(v.promises)-1-idx)
verifierResponse = append(verifierResponse, verifierBundle)
}

Expand Down
2 changes: 1 addition & 1 deletion zk/stages/stage_sequence_execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ func SpawnSequencingStage(
if err != nil {
return err
}
cfg.legacyVerifier.StartAsyncVerification(batchState.forkId, batchState.batchNumber, block.Root(), counters.UsedAsMap(), batchState.builtBlocks, useExecutorForVerification, batchContext.cfg.zk.SequencerBatchVerificationTimeout)
cfg.legacyVerifier.StartAsyncVerification(batchContext.s.LogPrefix(), batchState.forkId, batchState.batchNumber, block.Root(), counters.UsedAsMap(), batchState.builtBlocks, useExecutorForVerification, batchContext.cfg.zk.SequencerBatchVerificationTimeout)

// check for new responses from the verifier
needsUnwind, err := updateStreamAndCheckRollback(batchContext, batchState, streamWriter, u)
Expand Down
2 changes: 1 addition & 1 deletion zk/stages/stage_sequence_execute_data_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func newSequencerBatchStreamWriter(batchContext *BatchContext, batchState *Batch
}

func (sbc *SequencerBatchStreamWriter) CommitNewUpdates() ([]*verifier.VerifierBundle, error) {
verifierBundles, err := sbc.legacyVerifier.ProcessResultsSequentially()
verifierBundles, err := sbc.legacyVerifier.ProcessResultsSequentially(sbc.logPrefix)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 415b495

Please sign in to comment.