diff --git a/contracts/zkconfig.json b/contracts/zkconfig.json index 9bd08921..c419255f 100644 --- a/contracts/zkconfig.json +++ b/contracts/zkconfig.json @@ -1,5 +1,5 @@ { - "startingBlockNumber": 16795981, + "startingBlockNumber": 16833525, "l2RollupNode": "", "submissionInterval": 150, "l2BlockTime": 2, diff --git a/proposer/op/proposer/db/db.go b/proposer/op/proposer/db/db.go index 59fef1fb..8c1e139b 100644 --- a/proposer/op/proposer/db/db.go +++ b/proposer/op/proposer/db/db.go @@ -211,6 +211,26 @@ func (db *ProofDB) GetLatestEndBlock() (uint64, error) { return uint64(maxEnd.EndBlock), nil } +// If a proof failed to be sent to the prover network, it's status will be set to FAILED, but the prover request ID will be empty. +// This function returns all such proofs. +func (db *ProofDB) GetProofsFailedOnServer() ([]*ent.ProofRequest, error) { + proofs, err := db.client.ProofRequest.Query(). + Where( + proofrequest.StatusEQ(proofrequest.StatusFAILED), + proofrequest.ProverRequestIDEQ(""), + ). + All(context.Background()) + + if err != nil { + if ent.IsNotFound(err) { + return nil, nil + } + return nil, fmt.Errorf("failed to query failed proof: %w", err) + } + + return proofs, nil +} + // Get all pending proofs with a status of requested and a prover ID that is not empty. func (db *ProofDB) GetAllPendingProofs() ([]*ent.ProofRequest, error) { proofs, err := db.client.ProofRequest.Query(). diff --git a/proposer/op/proposer/prove.go b/proposer/op/proposer/prove.go index 122ebda1..6cabf2b7 100644 --- a/proposer/op/proposer/prove.go +++ b/proposer/op/proposer/prove.go @@ -16,9 +16,10 @@ import ( "github.com/succinctlabs/op-succinct-go/proposer/db/ent/proofrequest" ) -// 1) Retry all failed proofs +// Process all of the pending proofs. func (l *L2OutputSubmitter) ProcessPendingProofs() error { - failedReqs, err := l.db.GetAllProofsWithStatus(proofrequest.StatusFAILED) + // Retrieve all proofs that failed without reaching the prover network (specifically, proofs that failed with no proof ID). + failedReqs, err := l.db.GetProofsFailedOnServer() if err != nil { return fmt.Errorf("failed to get proofs failed on server: %w", err) } @@ -30,7 +31,8 @@ func (l *L2OutputSubmitter) ProcessPendingProofs() error { } // Get all pending proofs with a status of requested and a prover ID that is not empty. - // TODO: There should be a proofrequest status where the prover ID is not empty. + // TODO: There should be a separate proofrequest status for proofs that failed before reaching the prover network, + // and those that failed after reaching the prover network. reqs, err := l.db.GetAllPendingProofs() if err != nil { return err @@ -83,22 +85,22 @@ func (l *L2OutputSubmitter) RetryRequest(req *ent.ProofRequest) error { l.Log.Error("failed to add new proof request", "err") return err } - } + } else { + // If a SPAN proof failed, assume it was too big and the SP1 runtime OOM'd. + // Therefore, create two new entries for the original proof split in half. + l.Log.Info("span proof failed, splitting in half to retry", "req", req) + tmpStart := req.StartBlock + tmpEnd := tmpStart + ((req.EndBlock - tmpStart) / 2) + for i := 0; i < 2; i++ { + err := l.db.NewEntryWithReqAddedTimestamp("SPAN", tmpStart, tmpEnd, 0) + if err != nil { + l.Log.Error("failed to add new proof request", "err", err) + return err + } - // If a SPAN proof failed, assume it was too big and the SP1 runtime OOM'd. - // Therefore, create two new entries for the original proof split in half. - l.Log.Info("span proof failed, splitting in half to retry", "req", req) - tmpStart := req.StartBlock - tmpEnd := tmpStart + ((req.EndBlock - tmpStart) / 2) - for i := 0; i < 2; i++ { - err := l.db.NewEntryWithReqAddedTimestamp("SPAN", tmpStart, tmpEnd, 0) - if err != nil { - l.Log.Error("failed to add new proof request", "err", err) - return err + tmpStart = tmpEnd + 1 + tmpEnd = req.EndBlock } - - tmpStart = tmpEnd + 1 - tmpEnd = req.EndBlock } return nil