Skip to content
This repository was archived by the owner on May 11, 2024. It is now read-only.

Commit 83f57df

Browse files
committed
feat(prover): fix an issue in BlockProposed event handler
1 parent 3c8d88d commit 83f57df

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

prover/event_handler/block_proposed.go

+16-8
Original file line numberDiff line numberDiff line change
@@ -293,14 +293,22 @@ func (h *BlockProposedEventHandler) checkExpirationAndSubmitProof(
293293
)
294294
return nil
295295
}
296-
297-
// The proof submitted to protocol is invalid.
298-
h.proofContestCh <- &proofProducer.ContestRequestBody{
299-
BlockID: e.BlockId,
300-
ProposedIn: new(big.Int).SetUint64(e.Raw.BlockNumber),
301-
ParentHash: proofStatus.ParentHeader.Hash(),
302-
Meta: &e.Meta,
303-
Tier: e.Meta.MinTier,
296+
// If the current proof has not been contested, we should contest it at first.
297+
if proofStatus.CurrentTransitionState.Contester == rpc.ZeroAddress {
298+
h.proofContestCh <- &proofProducer.ContestRequestBody{
299+
BlockID: e.BlockId,
300+
ProposedIn: new(big.Int).SetUint64(e.Raw.BlockNumber),
301+
ParentHash: proofStatus.ParentHeader.Hash(),
302+
Meta: &e.Meta,
303+
Tier: e.Meta.MinTier,
304+
}
305+
} else {
306+
// The invalid proof submitted to protocol is contested by another prover,
307+
// we need to submit a proof with a higher tier.
308+
h.proofSubmissionCh <- &proofProducer.ProofRequestBody{
309+
Tier: proofStatus.CurrentTransitionState.Tier + 1,
310+
Event: e,
311+
}
304312
}
305313
return nil
306314
}

0 commit comments

Comments
 (0)