From 83f57df50a334b227aa3a5cea57631ddea890941 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 9 May 2024 23:32:31 +0800 Subject: [PATCH] feat(prover): fix an issue in `BlockProposed` event handler --- prover/event_handler/block_proposed.go | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/prover/event_handler/block_proposed.go b/prover/event_handler/block_proposed.go index 7192be5a2..d5295eae3 100644 --- a/prover/event_handler/block_proposed.go +++ b/prover/event_handler/block_proposed.go @@ -293,14 +293,22 @@ func (h *BlockProposedEventHandler) checkExpirationAndSubmitProof( ) return nil } - - // The proof submitted to protocol is invalid. - h.proofContestCh <- &proofProducer.ContestRequestBody{ - BlockID: e.BlockId, - ProposedIn: new(big.Int).SetUint64(e.Raw.BlockNumber), - ParentHash: proofStatus.ParentHeader.Hash(), - Meta: &e.Meta, - Tier: e.Meta.MinTier, + // If the current proof has not been contested, we should contest it at first. + if proofStatus.CurrentTransitionState.Contester == rpc.ZeroAddress { + h.proofContestCh <- &proofProducer.ContestRequestBody{ + BlockID: e.BlockId, + ProposedIn: new(big.Int).SetUint64(e.Raw.BlockNumber), + ParentHash: proofStatus.ParentHeader.Hash(), + Meta: &e.Meta, + Tier: e.Meta.MinTier, + } + } else { + // The invalid proof submitted to protocol is contested by another prover, + // we need to submit a proof with a higher tier. + h.proofSubmissionCh <- &proofProducer.ProofRequestBody{ + Tier: proofStatus.CurrentTransitionState.Tier + 1, + Event: e, + } } return nil }