|
|
|
|
@@ -121,7 +121,7 @@ func NewSubmitProofReceiverLogic(cfg *config.ProverManager, db *gorm.DB, reg pro
|
|
|
|
|
// HandleZkProof handle a ZkProof submitted from a prover.
|
|
|
|
|
// For now only proving/verifying error will lead to setting status as skipped.
|
|
|
|
|
// db/unmarshal errors will not because they are errors on the business logic side.
|
|
|
|
|
func (m *ProofReceiverLogic) HandleZkProof(ctx *gin.Context, proofMsg *message.ProofMsg) error {
|
|
|
|
|
func (m *ProofReceiverLogic) HandleZkProof(ctx *gin.Context, proofMsg *message.ProofMsg, proofParameter coordinatorType.SubmitProofParameter) error {
|
|
|
|
|
m.proofReceivedTotal.Inc()
|
|
|
|
|
pk := ctx.GetString(coordinatorType.PublicKey)
|
|
|
|
|
if len(pk) == 0 {
|
|
|
|
|
@@ -144,7 +144,7 @@ func (m *ProofReceiverLogic) HandleZkProof(ctx *gin.Context, proofMsg *message.P
|
|
|
|
|
log.Info("handling zk proof", "proof id", proofMsg.ID, "prover name", proverTask.ProverName,
|
|
|
|
|
"prover pk", pk, "prove type", proverTask.TaskType, "proof time", proofTimeSec)
|
|
|
|
|
|
|
|
|
|
if err = m.validator(ctx, proverTask, pk, proofMsg); err != nil {
|
|
|
|
|
if err = m.validator(ctx, proverTask, pk, proofMsg, proofParameter); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -161,7 +161,7 @@ func (m *ProofReceiverLogic) HandleZkProof(ctx *gin.Context, proofMsg *message.P
|
|
|
|
|
|
|
|
|
|
if verifyErr != nil || !success {
|
|
|
|
|
m.verifierFailureTotal.WithLabelValues(proverVersion).Inc()
|
|
|
|
|
m.proofFailure(ctx, proofMsg.ID, pk, proofMsg)
|
|
|
|
|
m.proofRecover(ctx, proofMsg.ID, pk, proofMsg)
|
|
|
|
|
|
|
|
|
|
log.Info("proof verified by coordinator failed", "proof id", proofMsg.ID, "prover name", proverTask.ProverName,
|
|
|
|
|
"prover pk", pk, "prove type", proofMsg.Type, "proof time", proofTimeSec, "error", verifyErr)
|
|
|
|
|
@@ -205,7 +205,7 @@ func (m *ProofReceiverLogic) checkAreAllChunkProofsReady(ctx context.Context, ch
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ProofReceiverLogic) validator(ctx context.Context, proverTask *orm.ProverTask, pk string, proofMsg *message.ProofMsg) (err error) {
|
|
|
|
|
func (m *ProofReceiverLogic) validator(ctx context.Context, proverTask *orm.ProverTask, pk string, proofMsg *message.ProofMsg, proofParameter coordinatorType.SubmitProofParameter) (err error) {
|
|
|
|
|
defer func() {
|
|
|
|
|
if err != nil {
|
|
|
|
|
m.validateFailureTotal.Inc()
|
|
|
|
|
@@ -232,14 +232,12 @@ func (m *ProofReceiverLogic) validator(ctx context.Context, proverTask *orm.Prov
|
|
|
|
|
proofTimeSec := uint64(proofTime.Seconds())
|
|
|
|
|
|
|
|
|
|
if proofMsg.Status != message.StatusOk {
|
|
|
|
|
m.proofRecover(ctx, proofMsg.ID, pk, proofMsg)
|
|
|
|
|
m.validateFailureProverTaskStatusNotOk.Inc()
|
|
|
|
|
log.Info("proof generated by prover failed", "proof id", proofMsg.ID, "prover name", proverTask.ProverName,
|
|
|
|
|
"prover pk", pk, "prove type", proofMsg.Type, "error", proofMsg.Error)
|
|
|
|
|
|
|
|
|
|
if updateErr := m.proverTaskOrm.UpdateProverTaskProvingStatus(ctx, proofMsg.Type, proofMsg.ID, pk, types.ProverProofInvalid); updateErr != nil {
|
|
|
|
|
log.Error("proof generated by prover failed update prover task proving status failure", "proof id", proofMsg.ID,
|
|
|
|
|
"prover name", proverTask.ProverName, "prover pk", pk, "prove type", proofMsg.Type, "error", proofMsg.Error)
|
|
|
|
|
}
|
|
|
|
|
log.Info("proof generated by prover failed",
|
|
|
|
|
"prove type", proofMsg.Type, "proof id", proofMsg.ID,
|
|
|
|
|
"prover name", proverTask.ProverName, "prover version", proverTask.ProverVersion,
|
|
|
|
|
"prover pk", "failure type", proofParameter.FailureType, "failure message", proofParameter.FailureMsg)
|
|
|
|
|
return ErrValidatorFailureProofMsgStatusNotOk
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -267,14 +265,14 @@ func (m *ProofReceiverLogic) validator(ctx context.Context, proverTask *orm.Prov
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ProofReceiverLogic) proofFailure(ctx context.Context, hash string, pubKey string, proofMsg *message.ProofMsg) {
|
|
|
|
|
log.Info("proof failure update proof status", "hash", hash, "public key", pubKey,
|
|
|
|
|
"proof type", proofMsg.Type.String(), "status", types.ProvingTaskFailed.String())
|
|
|
|
|
|
|
|
|
|
if err := m.updateProofStatus(ctx, hash, pubKey, proofMsg, types.ProvingTaskFailed, 0); err != nil {
|
|
|
|
|
log.Error("failed to updated proof status ProvingTaskFailed", "hash", hash, "pubKey", pubKey, "error", err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//func (m *ProofReceiverLogic) proofFailure(ctx context.Context, hash string, pubKey string, proofMsg *message.ProofMsg) {
|
|
|
|
|
// log.Info("proof failure update proof status", "hash", hash, "public key", pubKey,
|
|
|
|
|
// "proof type", proofMsg.Type.String(), "status", types.ProvingTaskFailed.String())
|
|
|
|
|
//
|
|
|
|
|
// if err := m.updateProofStatus(ctx, hash, pubKey, proofMsg, types.ProvingTaskFailed, 0); err != nil {
|
|
|
|
|
// log.Error("failed to updated proof status ProvingTaskFailed", "hash", hash, "pubKey", pubKey, "error", err)
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
func (m *ProofReceiverLogic) proofRecover(ctx context.Context, hash string, pubKey string, proofMsg *message.ProofMsg) {
|
|
|
|
|
log.Info("proof recover update proof status", "hash", hash, "public key", pubKey,
|
|
|
|
|
|