diff --git a/zk/legacy_executor_verifier/executor.go b/zk/legacy_executor_verifier/executor.go index 6d60a832fc7..4f3474b559b 100644 --- a/zk/legacy_executor_verifier/executor.go +++ b/zk/legacy_executor_verifier/executor.go @@ -86,7 +86,7 @@ func (e *Executor) Close() { } } -func (e *Executor) Verify(p *Payload, request *VerifierRequest) (bool, error) { +func (e *Executor) Verify(p *Payload, request *VerifierRequest, oldStateRoot common.Hash) (bool, error) { ctx, cancel := context.WithTimeout(context.Background(), time.Second) defer cancel() @@ -122,7 +122,15 @@ func (e *Executor) Verify(p *Payload, request *VerifierRequest) (bool, error) { counters += fmt.Sprintf("[P: %v]", resp.CntPoseidonHashes) counters += fmt.Sprintf("[S: %v]", resp.CntSteps) counters += fmt.Sprintf("[D: %v]", resp.CntPoseidonPaddings) - log.Info("executor result", "batch", request.BatchNumber, "counters", counters, "root", common.BytesToHash(resp.NewStateRoot), "our-root", request.StateRoot) + + log.Info("executor result", + "batch", request.BatchNumber, + "counters", counters, + "exec-root", common.BytesToHash(resp.NewStateRoot), + "our-root", request.StateRoot, + "exec-old-root", common.BytesToHash(resp.OldStateRoot), + "our-old-root", oldStateRoot) + log.Debug("Received response from executor", "grpcUrl", e.grpcUrl, "response", resp) return responseCheck(resp, request.StateRoot) diff --git a/zk/legacy_executor_verifier/executor_test.go b/zk/legacy_executor_verifier/executor_test.go index 8d183acc4ff..d413a2d5bde 100644 --- a/zk/legacy_executor_verifier/executor_test.go +++ b/zk/legacy_executor_verifier/executor_test.go @@ -70,7 +70,7 @@ func TestExecutor_Verify(t *testing.T) { ContextId: "cdk-erigon-test", } - _, err := executor.Verify(payload, &VerifierRequest{StateRoot: *tt.expectedStateRoot}) + _, err := executor.Verify(payload, &VerifierRequest{StateRoot: *tt.expectedStateRoot}, common.Hash{}) if (err != nil) != tt.wantErr { t.Errorf("Executor.Verify() error = %v, wantErr %v", err, tt.wantErr) } diff --git a/zk/legacy_executor_verifier/legacy_executor_verifier.go b/zk/legacy_executor_verifier/legacy_executor_verifier.go index 3ddea6ca24e..493b19e277b 100644 --- a/zk/legacy_executor_verifier/legacy_executor_verifier.go +++ b/zk/legacy_executor_verifier/legacy_executor_verifier.go @@ -38,7 +38,7 @@ type VerifierResponse struct { } type ILegacyExecutor interface { - Verify(*Payload, *VerifierRequest) (bool, error) + Verify(*Payload, *VerifierRequest, common.Hash) (bool, error) } type WitnessGenerator interface { @@ -211,7 +211,9 @@ func (v *LegacyExecutorVerifier) handleRequest(ctx context.Context, request *Ver ContextId: strconv.Itoa(int(request.BatchNumber)), } - ok, err := execer.Verify(payload, request) + previousBlock, _ := rawdb.ReadBlockByNumber(tx, blocks[0]-1) + + ok, err := execer.Verify(payload, request, previousBlock.Root()) if err != nil { return err } diff --git a/zk/stages/stage_batches.go b/zk/stages/stage_batches.go index 0de4379f803..c62f1d7ff0a 100644 --- a/zk/stages/stage_batches.go +++ b/zk/stages/stage_batches.go @@ -324,6 +324,12 @@ func SpawnStageBatches( return err } + // save the latest verified batch number as well just in case this node is upgraded + // to a sequencer in the future + if err := stages.SaveStageProgress(tx, stages.SequenceExecutorVerify, highestSeenBatchNo); err != nil { + return fmt.Errorf("save stage progress error: %w", err) + } + // stop printing blocks written progress routine elapsed := time.Since(startSyncTime) log.Info(fmt.Sprintf("[%s] Finished writing blocks", logPrefix), "blocksWritten", blocksWritten, "elapsed", elapsed)