diff --git a/prover/proof_submitter/transaction/sender.go b/prover/proof_submitter/transaction/sender.go index d42ad45b5..55b0dc2bd 100644 --- a/prover/proof_submitter/transaction/sender.go +++ b/prover/proof_submitter/transaction/sender.go @@ -2,6 +2,7 @@ package transaction import ( "context" + "fmt" "math/big" "strings" @@ -41,6 +42,15 @@ func (s *Sender) Send( proofWithHeader *producer.ProofWithHeader, buildTx TxBuilder, ) error { + // Check if the proof has already been submitted. + proofStatus, err := rpc.GetBlockProofStatus(ctx, s.rpc, proofWithHeader.BlockID, proofWithHeader.Opts.ProverAddress) + if err != nil { + return err + } + if proofStatus.IsSubmitted && !proofStatus.Invalid { + return fmt.Errorf("a valid 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 { diff --git a/prover/proof_submitter/transaction/sender_test.go b/prover/proof_submitter/transaction/sender_test.go index ac7d9fcad..d3f9db5ee 100644 --- a/prover/proof_submitter/transaction/sender_test.go +++ b/prover/proof_submitter/transaction/sender_test.go @@ -93,40 +93,6 @@ func (s *TransactionTestSuite) TestSendTxWithBackoff() { }, func(*bind.TransactOpts) (*txmgr.TxCandidate, error) { return nil, errors.New("L1_TEST") }, )) - - s.Nil(s.sender.Send( - context.Background(), - &producer.ProofWithHeader{ - Meta: meta, - BlockID: common.Big1, - Header: &types.Header{}, - Opts: &producer.ProofRequestOptions{EventL1Hash: l1Head.Hash()}, - }, - func(*bind.TransactOpts) (*txmgr.TxCandidate, error) { - height, err := s.RPCClient.L1.BlockNumber(context.Background()) - s.Nil(err) - - var block *types.Block - for { - block, err = s.RPCClient.L1.BlockByNumber(context.Background(), new(big.Int).SetUint64(height)) - s.Nil(err) - if block.Transactions().Len() != 0 { - break - } - height-- - } - - tx := block.Transactions()[0] - - return &txmgr.TxCandidate{ - TxData: tx.Data(), - Blobs: nil, - To: tx.To(), - GasLimit: tx.Gas(), - Value: tx.Value(), - }, nil - }, - )) } func TestTxSenderTestSuite(t *testing.T) {