Skip to content

Commit 5ad00e7

Browse files
committed
feat: handle could prover name when assign task
2 parents b11f010 + dd3c9e1 commit 5ad00e7

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

coordinator/internal/logic/provertask/batch_prover_task.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func (bp *BatchProverTask) Assign(ctx *gin.Context, getTaskParameter *coordinato
6767
if taskCtx.ProverProviderType == uint8(coordinatorType.ProverProviderTypeExternal) {
6868
unassignedBatchCount, getCountError := bp.batchOrm.GetUnassignedBatchCount(ctx.Copy(), maxActiveAttempts, maxTotalAttempts)
6969
if getCountError != nil {
70-
log.Error("failed to get unassigned batch proving tasks count", "height", getTaskParameter.ProverHeight, "err", err)
70+
log.Error("failed to get unassigned batch proving tasks count", "height", getTaskParameter.ProverHeight, "err", getCountError)
7171
return nil, ErrCoordinatorInternalFailure
7272
}
7373
// Assign external prover if unassigned task number exceeds threshold
@@ -104,7 +104,7 @@ func (bp *BatchProverTask) Assign(ctx *gin.Context, getTaskParameter *coordinato
104104
// Don't dispatch the same failing job to the same prover
105105
proverTasks, getTaskError := bp.proverTaskOrm.GetFailedProverTasksByHash(ctx.Copy(), message.ProofTypeBatch, tmpBatchTask.Hash, 2)
106106
if getTaskError != nil {
107-
log.Error("failed to get prover tasks", "proof_type", message.ProofTypeBatch.String(), "taskID", tmpBatchTask.Hash, "error", getTaskError)
107+
log.Error("failed to get prover tasks", "proof type", message.ProofTypeBatch.String(), "task ID", tmpBatchTask.Hash, "error", getTaskError)
108108
return nil, ErrCoordinatorInternalFailure
109109
}
110110
for i := 0; i < len(proverTasks); i++ {

coordinator/internal/logic/provertask/bundle_prover_task.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func (bp *BundleProverTask) Assign(ctx *gin.Context, getTaskParameter *coordinat
6767
if taskCtx.ProverProviderType == uint8(coordinatorType.ProverProviderTypeExternal) {
6868
unassignedBundleCount, getCountError := bp.bundleOrm.GetUnassignedBundleCount(ctx.Copy(), maxActiveAttempts, maxTotalAttempts)
6969
if getCountError != nil {
70-
log.Error("failed to get unassigned batch proving tasks count", "height", getTaskParameter.ProverHeight, "err", err)
70+
log.Error("failed to get unassigned batch proving tasks count", "height", getTaskParameter.ProverHeight, "err", getCountError)
7171
return nil, ErrCoordinatorInternalFailure
7272
}
7373
// Assign external prover if unassigned task number exceeds threshold
@@ -104,7 +104,7 @@ func (bp *BundleProverTask) Assign(ctx *gin.Context, getTaskParameter *coordinat
104104
// Don't dispatch the same failing job to the same prover
105105
proverTasks, getTaskError := bp.proverTaskOrm.GetFailedProverTasksByHash(ctx.Copy(), message.ProofTypeBundle, tmpBundleTask.Hash, 2)
106106
if getTaskError != nil {
107-
log.Error("failed to get prover tasks", "proof_type", message.ProofTypeBundle.String(), "taskID", tmpBundleTask.Hash, "error", getTaskError)
107+
log.Error("failed to get prover tasks", "proof type", message.ProofTypeBundle.String(), "task ID", tmpBundleTask.Hash, "error", getTaskError)
108108
return nil, ErrCoordinatorInternalFailure
109109
}
110110
for i := 0; i < len(proverTasks); i++ {

coordinator/internal/logic/provertask/chunk_prover_task.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func (cp *ChunkProverTask) Assign(ctx *gin.Context, getTaskParameter *coordinato
6565
if taskCtx.ProverProviderType == uint8(coordinatorType.ProverProviderTypeExternal) {
6666
unassignedChunkCount, getCountError := cp.chunkOrm.GetUnassignedChunkCount(ctx.Copy(), maxActiveAttempts, maxTotalAttempts, getTaskParameter.ProverHeight)
6767
if getCountError != nil {
68-
log.Error("failed to get unassigned chunk proving tasks count", "height", getTaskParameter.ProverHeight, "err", err)
68+
log.Error("failed to get unassigned chunk proving tasks count", "height", getTaskParameter.ProverHeight, "err", getCountError)
6969
return nil, ErrCoordinatorInternalFailure
7070
}
7171
// Assign external prover if unassigned task number exceeds threshold
@@ -102,7 +102,7 @@ func (cp *ChunkProverTask) Assign(ctx *gin.Context, getTaskParameter *coordinato
102102
// Don't dispatch the same failing job to the same prover
103103
proverTasks, getTaskError := cp.proverTaskOrm.GetFailedProverTasksByHash(ctx.Copy(), message.ProofTypeChunk, tmpChunkTask.Hash, 2)
104104
if getTaskError != nil {
105-
log.Error("failed to get prover tasks", "proof_type", message.ProofTypeChunk.String(), "taskID", tmpChunkTask.Hash, "error", getTaskError)
105+
log.Error("failed to get prover tasks", "proof type", message.ProofTypeChunk.String(), "task ID", tmpChunkTask.Hash, "error", getTaskError)
106106
return nil, ErrCoordinatorInternalFailure
107107
}
108108
for i := 0; i < len(proverTasks); i++ {

coordinator/internal/orm/prover_task.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,24 @@ func (o *ProverTask) GetAssignedTaskOfOtherProvers(ctx context.Context, taskType
169169
return proverTasks, nil
170170
}
171171

172+
// GetTaskOfOtherProvers get the chunk/batch task of prover
173+
func (o *ProverTask) GetTaskOfProver(ctx context.Context, taskType message.ProofType, taskID, proverPublicKey, proverVersion string) (*ProverTask, error) {
174+
db := o.db.WithContext(ctx)
175+
db = db.Model(&ProverTask{})
176+
db = db.Where("task_type", int(taskType))
177+
db = db.Where("task_id", taskID)
178+
db = db.Where("prover_public_key", proverPublicKey)
179+
db = db.Where("prover_version", proverVersion)
180+
db = db.Limit(1)
181+
182+
var proverTask ProverTask
183+
err := db.Find(&proverTask).Error
184+
if err != nil {
185+
return nil, fmt.Errorf("ProverTask.GetTaskOfProver error: %w, taskID: %v, publicKey:%s", err, taskID, proverPublicKey)
186+
}
187+
return &proverTask, nil
188+
}
189+
172190
// GetProvingStatusByTaskID retrieves the proving status of a prover task
173191
func (o *ProverTask) GetProvingStatusByTaskID(ctx context.Context, taskType message.ProofType, taskID string) (types.ProverProveStatus, error) {
174192
db := o.db.WithContext(ctx)

0 commit comments

Comments
 (0)