From 9663e7b3c6e9b8471c6a8dbec245901fb94beb95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toni=20Ram=C3=ADrez?= <58293609+ToniRamirezM@users.noreply.github.com> Date: Fri, 29 Nov 2024 15:00:37 +0100 Subject: [PATCH] fix: clean proof table on start (#207) (#211) * fix: clean proof table on start --- aggregator/aggregator.go | 12 ++++++------ aggregator/aggregator_test.go | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/aggregator/aggregator.go b/aggregator/aggregator.go index d9ecb1a2a..a817320ce 100644 --- a/aggregator/aggregator.go +++ b/aggregator/aggregator.go @@ -325,12 +325,6 @@ func (a *Aggregator) Start() error { healthService := newHealthChecker() grpchealth.RegisterHealthServer(a.srv, healthService) - // Delete ungenerated recursive proofs - err = a.storage.DeleteUngeneratedProofs(a.ctx, nil) - if err != nil { - return fmt.Errorf("failed to initialize proofs cache %w", err) - } - // Get last verified batch number to set the starting point for verifications lastVerifiedBatchNumber, err := a.etherman.GetLatestVerifiedBatchNum() if err != nil { @@ -347,6 +341,12 @@ func (a *Aggregator) Start() error { a.logger.Infof("Starting AccInputHash:%v", accInputHash.String()) a.setAccInputHash(lastVerifiedBatchNumber, *accInputHash) + // Delete existing proofs + err = a.storage.DeleteGeneratedProofs(a.ctx, lastVerifiedBatchNumber, maxDBBigIntValue, nil) + if err != nil { + return fmt.Errorf("failed to delete proofs table %w", err) + } + a.resetVerifyProofTime() go a.cleanupLockedProofs() diff --git a/aggregator/aggregator_test.go b/aggregator/aggregator_test.go index 95b553679..086550ebf 100644 --- a/aggregator/aggregator_test.go +++ b/aggregator/aggregator_test.go @@ -86,7 +86,7 @@ func Test_Start(t *testing.T) { mockL1Syncr.On("Sync", mock.Anything).Return(nil) mockEtherman.On("GetLatestVerifiedBatchNum").Return(uint64(90), nil).Once() mockEtherman.On("GetBatchAccInputHash", mock.Anything, uint64(90)).Return(common.Hash{}, nil).Once() - mockStorage.On("DeleteUngeneratedProofs", mock.Anything, nil).Return(nil).Once() + mockStorage.On("DeleteGeneratedProofs", mock.Anything, uint64(90), mock.Anything, nil).Return(nil).Once() mockStorage.On("CleanupLockedProofs", mock.Anything, "", nil).Return(int64(0), nil) mockEthTxManager.On("Start").Return(nil)