Skip to content

Commit

Permalink
fix(coordinator): fix issue devnet's coordinator can not set genesis'…
Browse files Browse the repository at this point in the history
…s curieBlock to 0
  • Loading branch information
amoylan2 committed Jul 18, 2024
1 parent c812288 commit 79f86c8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
11 changes: 5 additions & 6 deletions coordinator/internal/logic/provertask/batch_prover_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package provertask
import (
"context"
"encoding/json"
"errors"
"fmt"
"math"
"time"
Expand Down Expand Up @@ -190,7 +191,7 @@ func (bp *BatchProverTask) doAssignTaskWithinChunkRange(ctx *gin.Context, taskCt
func (bp *BatchProverTask) getChunkRangeByName(ctx *gin.Context, hardForkName string) (*chunkIndexRange, error) {
hardForkNumber, err := bp.getHardForkNumberByName(hardForkName)
if err != nil {
log.Error("batch assign failure because of the hard fork name don't exist", "fork name", hardForkName)
// log.Error("batch assign failure because of the hard fork name don't exist", "fork name", hardForkName)
return nil, err
}

Expand Down Expand Up @@ -246,10 +247,7 @@ func (bp *BatchProverTask) assignWithTwoCircuits(ctx *gin.Context, taskCtx *prov
for i := 0; i < 2; i++ {
hardForkNames[i] = bp.reverseVkMap[getTaskParameter.VKs[i]]
chunkRanges[i], err = bp.getChunkRangeByName(ctx, hardForkNames[i])
if err != nil {
return nil, err
}
if chunkRanges[i] != nil {
if err == nil && chunkRanges[i] != nil {
if chunkRange == nil {
chunkRange = chunkRanges[i]
} else {
Expand All @@ -258,7 +256,8 @@ func (bp *BatchProverTask) assignWithTwoCircuits(ctx *gin.Context, taskCtx *prov
}
}
if chunkRange == nil {
return nil, nil
log.Error("chunkRange empty")
return nil, errors.New("chunkRange empty")
}
var hardForkName string
getHardForkName := func(batch *orm.Batch) (string, error) {
Expand Down
25 changes: 18 additions & 7 deletions coordinator/internal/logic/provertask/chunk_prover_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package provertask
import (
"context"
"encoding/json"
"errors"
"fmt"
"time"

Expand Down Expand Up @@ -181,21 +182,31 @@ func (cp *ChunkProverTask) assignWithTwoCircuits(ctx *gin.Context, taskCtx *prov
blockRanges [2]*blockRange
err error
)
var blockRange *blockRange
for i := 0; i < 2; i++ {
hardForkNames[i] = cp.reverseVkMap[getTaskParameter.VKs[i]]
blockRanges[i], err = cp.getBlockRangeByName(hardForkNames[i])
if err != nil {
return nil, err
if err == nil && blockRanges[i] != nil {
if blockRange == nil {
blockRange = blockRanges[i]
} else {
var err2 error
blockRange, err2 = blockRange.merge(*blockRanges[i])
if err2 != nil {
return nil, err2
}
}
}
}
blockRange, err := blockRanges[0].merge(*blockRanges[1])
if err != nil {
return nil, err
if blockRange == nil {
log.Error("blockRange empty")
return nil, errors.New("blockRange empty")
}

var hardForkName string
getHardForkName := func(chunk *orm.Chunk) (string, error) {
for i := 0; i < 2; i++ {
if blockRanges[i].contains(chunk.StartBlockNumber, chunk.EndBlockNumber) {
if blockRanges[i] != nil && blockRanges[i].contains(chunk.StartBlockNumber, chunk.EndBlockNumber) {
hardForkName = hardForkNames[i]
break
}
Expand Down Expand Up @@ -235,7 +246,7 @@ func (r *blockRange) contains(start, end uint64) bool {
func (cp *ChunkProverTask) getBlockRangeByName(hardForkName string) (*blockRange, error) {
hardForkNumber, err := cp.getHardForkNumberByName(hardForkName)
if err != nil {
log.Error("chunk assign failure because of the hard fork name don't exist", "fork name", hardForkName)
// log.Error("chunk assign failure because of the hard fork name don't exist", "fork name", hardForkName)
return nil, err
}

Expand Down

0 comments on commit 79f86c8

Please sign in to comment.