From 81575502e88f06f34a2f36baa6bad66d0fa12884 Mon Sep 17 00:00:00 2001 From: jeff <113397187+cyberhorsey@users.noreply.github.com> Date: Mon, 11 Sep 2023 19:10:10 -0700 Subject: [PATCH] fix(prover): check latest verified ID on proof submission (#387) --- prover/proof_submitter/util.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/prover/proof_submitter/util.go b/prover/proof_submitter/util.go index 253befe30..a8e02cc56 100644 --- a/prover/proof_submitter/util.go +++ b/prover/proof_submitter/util.go @@ -109,6 +109,26 @@ func sendTxWithBackoff( return nil } + // check if latest verified head is ahead of this block proof + stateVars, err := cli.GetProtocolStateVariables(&bind.CallOpts{Context: ctx}) + if err != nil { + log.Warn("failed to fetch state vars", + "blockID", blockID, + "error", err, + ) + return err + } + + latestVerifiedId := stateVars.LastVerifiedBlockId + + if new(big.Int).SetUint64(latestVerifiedId).Cmp(blockID) >= 0 { + log.Warn("Block is already verified, skip current proof submission", + "blockID", blockID.Uint64(), + "latestVerifiedId", latestVerifiedId, + ) + return nil + } + tx, err := sendTxFunc() if err != nil { err = encoding.TryParsingCustomError(err)