Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(coordinator): prover task record unique #845

Merged
merged 62 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
d2f2dae
feat: make the prover_task to unique
georgehao Aug 21, 2023
0a5465a
feat: update
georgehao Aug 21, 2023
04fe23f
Merge branch 'develop' into feat/prover_task_unique
georgehao Aug 21, 2023
e16d50d
chore: auto version bump [bot]
georgehao Aug 21, 2023
0e12352
feat: update
georgehao Aug 21, 2023
e7bf8b0
feat: update
georgehao Aug 21, 2023
5607d18
feat: prover get/submit uuid
georgehao Aug 21, 2023
ab3de62
feat: update
georgehao Aug 21, 2023
aa2e3dc
feat: update
georgehao Aug 21, 2023
7bb047a
feat: update
georgehao Aug 21, 2023
3e8e08d
trigger ci
georgehao Aug 21, 2023
49c6e7d
feat: update
georgehao Aug 21, 2023
77a3de1
feat: update
georgehao Aug 21, 2023
ee03519
feat: update
georgehao Aug 22, 2023
3df2e02
chore: auto version bump [bot]
georgehao Aug 22, 2023
b32b023
Merge branch 'develop' into feat/prover_task_unique
georgehao Aug 22, 2023
965fbcf
chore: auto version bump [bot]
georgehao Aug 22, 2023
59d9bb2
feat: update uuid generate style
georgehao Aug 22, 2023
0676f23
Merge branch 'feat/prover_task_unique' of github.com:scroll-tech/scro…
georgehao Aug 22, 2023
95e146a
feat: updat
georgehao Aug 22, 2023
2e858a3
feat: fix conflict
georgehao Aug 22, 2023
a40e7d1
chore: auto version bump [bot]
georgehao Aug 22, 2023
98135e0
feat: update
georgehao Aug 22, 2023
edb75c8
Merge branch 'feat/prover_task_unique' of github.com:scroll-tech/scro…
georgehao Aug 22, 2023
8c05add
feat: remove debug code
georgehao Aug 22, 2023
d0d4b6e
feat: update
georgehao Aug 22, 2023
808c68b
feat: update
georgehao Aug 22, 2023
510a519
feat: add migrate sql
georgehao Aug 22, 2023
e523d61
feat: update
georgehao Aug 22, 2023
7b721a7
feat: fix conflict
georgehao Aug 22, 2023
5a3b911
chore: auto version bump [bot]
georgehao Aug 22, 2023
c5f2be4
feat: update
georgehao Aug 23, 2023
519fc61
Merge branch 'feat/prover_task_unique' of github.com:scroll-tech/scro…
georgehao Aug 23, 2023
8499b56
chore: auto version bump [bot]
georgehao Aug 23, 2023
2efb82d
Merge branch 'develop' of github.com:scroll-tech/scroll into feat/pro…
georgehao Aug 23, 2023
e4e3ca6
Merge branch 'feat/prover_task_unique' of github.com:scroll-tech/scro…
georgehao Aug 23, 2023
9351079
feat: update
georgehao Aug 23, 2023
404e442
chore: auto version bump [bot]
georgehao Aug 23, 2023
84bdae3
Merge branch 'develop' into feat/prover_task_unique
georgehao Aug 23, 2023
4b3a58a
chore: auto version bump [bot]
georgehao Aug 23, 2023
7dcfa17
Merge branch 'develop' into feat/prover_task_unique
georgehao Aug 23, 2023
5f7de85
chore: auto version bump [bot]
georgehao Aug 23, 2023
3f678a0
Update coordinator/internal/logic/provertask/chunk_prover_task.go
georgehao Aug 23, 2023
d64d646
chore: auto version bump [bot]
georgehao Aug 23, 2023
f33ec93
feat: update
georgehao Aug 23, 2023
b6afe29
Merge branch 'feat/prover_task_unique' of github.com:scroll-tech/scro…
georgehao Aug 23, 2023
8a70fc8
chore: auto version bump [bot]
georgehao Aug 23, 2023
4c738d7
feat: update
georgehao Aug 23, 2023
cee5d37
chore: auto version bump [bot]
georgehao Aug 23, 2023
7255f80
feat: updatge
georgehao Aug 23, 2023
8649d23
chore: auto version bump [bot]
georgehao Aug 23, 2023
42cb407
feat: update
georgehao Aug 23, 2023
f3bd134
Merge branch 'feat/prover_task_unique' of github.com:scroll-tech/scro…
georgehao Aug 23, 2023
382fad5
feat: update
georgehao Aug 23, 2023
35a52fc
feat: fix conflic
georgehao Aug 24, 2023
640a01d
chore: auto version bump [bot]
georgehao Aug 24, 2023
753d617
feat: conflict
georgehao Aug 25, 2023
7bd9d27
chore: auto version bump [bot]
georgehao Aug 25, 2023
d008023
Merge branch 'develop' of github.com:scroll-tech/scroll into feat/pro…
georgehao Aug 28, 2023
ab8d78f
Merge branch 'feat/prover_task_unique' of github.com:scroll-tech/scro…
georgehao Aug 28, 2023
b024eb1
chore: auto version bump [bot]
georgehao Aug 28, 2023
07fa55c
Update version.go
0xmountaintop Aug 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions common/types/message/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ func (a *ProofMsg) PublicKey() (string, error) {

// TaskMsg is a wrapper type around db ProveTask type.
type TaskMsg struct {
UUID string `json:"uuid"`
ID string `json:"id"`
Type ProofType `json:"type,omitempty"`
BatchTaskDetail *BatchTaskDetail `json:"batch_task_detail,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion common/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
)

var tag = "v4.1.117"
var tag = "v4.2.0"

var commit = func() string {
if info, ok := debug.ReadBuildInfo(); ok {
Expand Down
5 changes: 4 additions & 1 deletion coordinator/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ require (
google.golang.org/protobuf v1.31.0 // indirect
)

require github.com/prometheus/client_golang v1.14.0
require (
github.com/google/uuid v1.3.0
github.com/prometheus/client_golang v1.14.0
)

require (
github.com/beorn7/perks v1.0.1 // indirect
Expand Down
2 changes: 2 additions & 0 deletions coordinator/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/iden3/go-iden3-crypto v0.0.15 h1:4MJYlrot1l31Fzlo2sF56u7EVFeHHJkxGXXZCtESgK4=
Expand Down
10 changes: 4 additions & 6 deletions coordinator/internal/controller/cron/collect_proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,14 @@ func (c *Collector) check(assignedProverTasks []orm.ProverTask, timeout promethe
"prover public key", assignedProverTask.ProverPublicKey, "prover name", assignedProverTask.ProverName, "task type", assignedProverTask.TaskType)
err := c.db.Transaction(func(tx *gorm.DB) error {
// update prover task proving status as ProverProofInvalid
if err := c.proverTaskOrm.UpdateProverTaskProvingStatus(c.ctx, message.ProofType(assignedProverTask.TaskType),
assignedProverTask.TaskID, assignedProverTask.ProverPublicKey, types.ProverProofInvalid, tx); err != nil {
log.Error("update prover task proving status failure", "hash", assignedProverTask.TaskID, "pubKey", assignedProverTask.ProverPublicKey, "err", err)
if err := c.proverTaskOrm.UpdateProverTaskProvingStatus(c.ctx, assignedProverTask.UUID, types.ProverProofInvalid, tx); err != nil {
log.Error("update prover task proving status failure", "uuid", assignedProverTask.UUID, "hash", assignedProverTask.TaskID, "pubKey", assignedProverTask.ProverPublicKey, "err", err)
return err
}

// update prover task failure type
if err := c.proverTaskOrm.UpdateProverTaskFailureType(c.ctx, message.ProofType(assignedProverTask.TaskType),
assignedProverTask.TaskID, assignedProverTask.ProverPublicKey, types.ProverTaskFailureTypeTimeout, tx); err != nil {
log.Error("update prover task failure type failure", "hash", assignedProverTask.TaskID, "pubKey", assignedProverTask.ProverPublicKey, "err", err)
if err := c.proverTaskOrm.UpdateProverTaskFailureType(c.ctx, assignedProverTask.UUID, types.ProverTaskFailureTypeTimeout, tx); err != nil {
log.Error("update prover task failure type failure", "uuid", assignedProverTask.UUID, "hash", assignedProverTask.TaskID, "pubKey", assignedProverTask.ProverPublicKey, "err", err)
return err
}

Expand Down
19 changes: 10 additions & 9 deletions coordinator/internal/logic/provertask/batch_prover_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ func (bp *BatchProverTask) Assign(ctx *gin.Context, getTaskParameter *coordinato
}

// Store session info.
if err = bp.proverTaskOrm.SetProverTask(ctx, &proverTask); err != nil {
if err = bp.proverTaskOrm.InsertProverTask(ctx, &proverTask); err != nil {
bp.recoverProvingStatus(ctx, batchTask)
log.Error("db set session info fail", "task hash", batchTask.Hash, "prover name", proverName.(string), "prover pubKey", publicKey.(string), "err", err)
log.Error("insert batch prover task info fail", "taskID", batchTask.Hash, "publicKey", publicKey, "err", err)
return nil, ErrCoordinatorInternalFailure
}

taskMsg, err := bp.formatProverTask(ctx, batchTask.Hash)
taskMsg, err := bp.formatProverTask(ctx, &proverTask)
if err != nil {
bp.recoverProvingStatus(ctx, batchTask)
log.Error("format prover task failure", "hash", batchTask.Hash, "err", err)
Expand All @@ -146,11 +146,11 @@ func (bp *BatchProverTask) Assign(ctx *gin.Context, getTaskParameter *coordinato
return taskMsg, nil
}

func (bp *BatchProverTask) formatProverTask(ctx context.Context, taskID string) (*coordinatorType.GetTaskSchema, error) {
func (bp *BatchProverTask) formatProverTask(ctx context.Context, task *orm.ProverTask) (*coordinatorType.GetTaskSchema, error) {
// get chunk from db
chunks, err := bp.chunkOrm.GetChunksByBatchHash(ctx, taskID)
chunks, err := bp.chunkOrm.GetChunksByBatchHash(ctx, task.TaskID)
if err != nil {
err = fmt.Errorf("failed to get chunk proofs for batch task id:%s err:%w ", taskID, err)
err = fmt.Errorf("failed to get chunk proofs for batch task id:%s err:%w ", task.TaskID, err)
return nil, err
}

Expand All @@ -159,7 +159,7 @@ func (bp *BatchProverTask) formatProverTask(ctx context.Context, taskID string)
for _, chunk := range chunks {
var proof message.ChunkProof
if encodeErr := json.Unmarshal(chunk.Proof, &proof); encodeErr != nil {
return nil, fmt.Errorf("Chunk.GetProofsByBatchHash unmarshal proof error: %w, batch hash: %v, chunk hash: %v", encodeErr, taskID, chunk.Hash)
return nil, fmt.Errorf("Chunk.GetProofsByBatchHash unmarshal proof error: %w, batch hash: %v, chunk hash: %v", encodeErr, task.TaskID, chunk.Hash)
}
chunkProofs = append(chunkProofs, &proof)

Expand All @@ -181,11 +181,12 @@ func (bp *BatchProverTask) formatProverTask(ctx context.Context, taskID string)

chunkProofsBytes, err := json.Marshal(taskDetail)
if err != nil {
return nil, fmt.Errorf("failed to marshal chunk proofs, taskID:%s err:%w", taskID, err)
return nil, fmt.Errorf("failed to marshal chunk proofs, taskID:%s err:%w", task.TaskID, err)
}

taskMsg := &coordinatorType.GetTaskSchema{
TaskID: taskID,
UUID: task.UUID.String(),
TaskID: task.TaskID,
TaskType: int(message.ProofTypeBatch),
TaskData: string(chunkProofsBytes),
}
Expand Down
18 changes: 10 additions & 8 deletions coordinator/internal/logic/provertask/chunk_prover_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,14 @@ func (cp *ChunkProverTask) Assign(ctx *gin.Context, getTaskParameter *coordinato
// here why need use UTC time. see scroll/common/databased/db.go
AssignedAt: utils.NowUTC(),
}
if err = cp.proverTaskOrm.SetProverTask(ctx, &proverTask); err != nil {

if err = cp.proverTaskOrm.InsertProverTask(ctx, &proverTask); err != nil {
cp.recoverProvingStatus(ctx, chunkTask)
log.Error("db set session info fail", "task hash", chunkTask.Hash, "prover name", proverName.(string), "prover pubKey", publicKey.(string), "err", err)
log.Error("insert chunk prover task fail", "taskID", chunkTask.Hash, "publicKey", publicKey, "err", err)
return nil, ErrCoordinatorInternalFailure
}

taskMsg, err := cp.formatProverTask(ctx, chunkTask.Hash)
taskMsg, err := cp.formatProverTask(ctx, &proverTask)
if err != nil {
cp.recoverProvingStatus(ctx, chunkTask)
log.Error("format prover task failure", "hash", chunkTask.Hash, "err", err)
Expand All @@ -150,11 +151,11 @@ func (cp *ChunkProverTask) Assign(ctx *gin.Context, getTaskParameter *coordinato
return taskMsg, nil
}

func (cp *ChunkProverTask) formatProverTask(ctx context.Context, hash string) (*coordinatorType.GetTaskSchema, error) {
func (cp *ChunkProverTask) formatProverTask(ctx context.Context, task *orm.ProverTask) (*coordinatorType.GetTaskSchema, error) {
// Get block hashes.
wrappedBlocks, wrappedErr := cp.blockOrm.GetL2BlocksByChunkHash(ctx, hash)
wrappedBlocks, wrappedErr := cp.blockOrm.GetL2BlocksByChunkHash(ctx, task.TaskID)
if wrappedErr != nil || len(wrappedBlocks) == 0 {
return nil, fmt.Errorf("failed to fetch wrapped blocks, batch hash:%s err:%w", hash, wrappedErr)
return nil, fmt.Errorf("failed to fetch wrapped blocks, chunk hash:%s err:%w", task.TaskID, wrappedErr)
}

blockHashes := make([]common.Hash, len(wrappedBlocks))
Expand All @@ -167,11 +168,12 @@ func (cp *ChunkProverTask) formatProverTask(ctx context.Context, hash string) (*
}
blockHashesBytes, err := json.Marshal(taskDetail)
if err != nil {
return nil, fmt.Errorf("failed to marshal block hashes hash:%s, err:%w", hash, err)
return nil, fmt.Errorf("failed to marshal block hashes hash:%s, err:%w", task.TaskID, err)
}

proverTaskSchema := &coordinatorType.GetTaskSchema{
TaskID: hash,
UUID: task.UUID.String(),
TaskID: task.TaskID,
TaskType: int(message.ProofTypeChunk),
TaskData: string(blockHashesBytes),
}
Expand Down
4 changes: 0 additions & 4 deletions coordinator/internal/logic/provertask/prover_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ func (b *BaseProverTask) checkAttemptsExceeded(hash string, taskType message.Pro
log.Error("failed to update batch proving_status as failed", "msg.ID", hash, "error", err)
}
}
// update the prover task status to let timeout checker don't check it.
if err := b.proverTaskOrm.UpdateAllProverTaskProvingStatusOfTaskID(b.ctx, message.ProofType(proverTasks[0].TaskType), hash, types.ProverProofInvalid, tx); err != nil {
georgehao marked this conversation as resolved.
Show resolved Hide resolved
log.Error("failed to update prover task proving_status as failed", "msg.ID", hash, "error", err)
}
return nil
})
if transErr == nil {
Expand Down
Loading
Loading