@@ -9,19 +9,18 @@ import (
99 "github.com/gin-gonic/gin"
1010 "github.com/prometheus/client_golang/prometheus"
1111 "github.com/prometheus/client_golang/prometheus/promauto"
12- "github.com/scroll-tech/da-codec/encoding"
1312 "github.com/scroll-tech/go-ethereum/log"
1413 "github.com/scroll-tech/go-ethereum/params"
1514 "gorm.io/gorm"
1615
17- "scroll-tech/common/types"
18- "scroll-tech/common/types/message"
19- "scroll-tech/common/utils"
20-
2116 "scroll-tech/coordinator/internal/config"
2217 "scroll-tech/coordinator/internal/orm"
2318 coordinatorType "scroll-tech/coordinator/internal/types"
2419 cutils "scroll-tech/coordinator/internal/utils"
20+
21+ "scroll-tech/common/types"
22+ "scroll-tech/common/types/message"
23+ "scroll-tech/common/utils"
2524)
2625
2726// BundleProverTask is prover task implement for bundle proof
@@ -77,6 +76,7 @@ func (bp *BundleProverTask) Assign(ctx *gin.Context, getTaskParameter *coordinat
7776 }
7877
7978 var bundleTask * orm.Bundle
79+ var hardForkName string
8080 for i := 0 ; i < 5 ; i ++ {
8181 var getTaskError error
8282 var tmpBundleTask * orm.Bundle
@@ -101,6 +101,16 @@ func (bp *BundleProverTask) Assign(ctx *gin.Context, getTaskParameter *coordinat
101101 return nil , nil
102102 }
103103
104+ taskCtx .taskType = message .ProofTypeBundle
105+ taskCtx .bundleTask = tmpBundleTask
106+
107+ var checkErr error
108+ hardForkName , checkErr = bp .hardForkSanityCheck (ctx , taskCtx )
109+ if checkErr != nil {
110+ log .Debug ("hard fork sanity check failed" , "height" , getTaskParameter .ProverHeight , "err" , checkErr )
111+ return nil , nil
112+ }
113+
104114 // Don't dispatch the same failing job to the same prover
105115 proverTasks , getTaskError := bp .proverTaskOrm .GetFailedProverTasksByHash (ctx .Copy (), message .ProofTypeBundle , tmpBundleTask .Hash , 2 )
106116 if getTaskError != nil {
@@ -135,22 +145,6 @@ func (bp *BundleProverTask) Assign(ctx *gin.Context, getTaskParameter *coordinat
135145 return nil , nil
136146 }
137147
138- hardForkName , getHardForkErr := bp .hardForkName (ctx , bundleTask )
139- if getHardForkErr != nil {
140- bp .recoverActiveAttempts (ctx , bundleTask )
141- log .Error ("retrieve hard fork name by bundle failed" , "task_id" , bundleTask .Hash , "err" , getHardForkErr )
142- return nil , ErrCoordinatorInternalFailure
143- }
144-
145- if _ , ok := taskCtx .HardForkNames [hardForkName ]; ! ok {
146- bp .recoverActiveAttempts (ctx , bundleTask )
147- log .Debug ("incompatible prover version" ,
148- "requisite hard fork name" , hardForkName ,
149- "prover hard fork name" , taskCtx .HardForkNames ,
150- "task_id" , bundleTask .Hash )
151- return nil , nil
152- }
153-
154148 log .Info ("start bundle proof generation session" , "task index" , bundleTask .Index , "public key" , taskCtx .PublicKey , "prover name" , taskCtx .ProverName )
155149 proverTask := orm.ProverTask {
156150 TaskID : bundleTask .Hash ,
@@ -188,26 +182,6 @@ func (bp *BundleProverTask) Assign(ctx *gin.Context, getTaskParameter *coordinat
188182 return taskMsg , nil
189183}
190184
191- func (bp * BundleProverTask ) hardForkName (ctx * gin.Context , bundleTask * orm.Bundle ) (string , error ) {
192- startBatch , getBatchErr := bp .batchOrm .GetBatchByHash (ctx , bundleTask .StartBatchHash )
193- if getBatchErr != nil {
194- return "" , getBatchErr
195- }
196-
197- startChunk , getChunkErr := bp .chunkOrm .GetChunkByHash (ctx , startBatch .StartChunkHash )
198- if getChunkErr != nil {
199- return "" , getChunkErr
200- }
201-
202- l2Block , getBlockErr := bp .blockOrm .GetL2BlockByNumber (ctx .Copy (), startChunk .StartBlockNumber )
203- if getBlockErr != nil {
204- return "" , getBlockErr
205- }
206-
207- hardForkName := encoding .GetHardforkName (bp .chainCfg , l2Block .Number , l2Block .BlockTimestamp )
208- return hardForkName , nil
209- }
210-
211185func (bp * BundleProverTask ) formatProverTask (ctx context.Context , task * orm.ProverTask , hardForkName string ) (* coordinatorType.GetTaskSchema , error ) {
212186 // get bundle from db
213187 batches , err := bp .batchOrm .GetBatchesByBundleHash (ctx , task .TaskID )
0 commit comments