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

feat(prover): check proof status before sending the transaction #731

Merged
merged 4 commits into from
Apr 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions prover/proof_submitter/transaction/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package transaction

import (
"context"
"fmt"
"math/big"
"strings"

Expand Down Expand Up @@ -41,6 +42,15 @@ func (s *Sender) Send(
proofWithHeader *producer.ProofWithHeader,
buildTx TxBuilder,
) error {
// Check if we still need to generate a new proof for that block.
proofStatus, err := rpc.GetBlockProofStatus(ctx, s.rpc, proofWithHeader.BlockID, proofWithHeader.Opts.ProverAddress)
if err != nil {
return err
}
if proofStatus.IsSubmitted {
return fmt.Errorf("proof for block %d is already submitted", proofWithHeader.BlockID)
}

// Check if this proof is still needed to be submitted.
ok, err := s.validateProof(ctx, proofWithHeader)
if err != nil || !ok {
Expand Down
Loading