diff --git a/coordinator/cmd/tool/tool.go b/coordinator/cmd/tool/tool.go index 2b234a543a..ec96e9cf1c 100644 --- a/coordinator/cmd/tool/tool.go +++ b/coordinator/cmd/tool/tool.go @@ -66,7 +66,7 @@ func action(ctx *cli.Context) error { for _, batch := range batches { var proof message.BatchProof if encodeErr := json.Unmarshal(batch.Proof, &proof); encodeErr != nil { - log.Error("failed to unmarshal proof") + log.Error("failed to unmarshal batch proof") return fmt.Errorf("failed to unmarshal proof: %w, bundle hash: %v, batch hash: %v", encodeErr, taskID, batch.Hash) } batchProofs = append(batchProofs, &proof) @@ -78,8 +78,8 @@ func action(ctx *cli.Context) error { batchProofsBytes, err := json.Marshal(taskDetail) if err != nil { - log.Error("failed to marshal proof") - return fmt.Errorf("failed to marshal chunk proofs, taskID:%s err:%w", taskID, err) + log.Error("failed to marshal batch proof") + return fmt.Errorf("failed to marshal batch proofs, taskID:%s err:%w", taskID, err) } taskMsg := &coordinatorType.GetTaskSchema{ diff --git a/coordinator/internal/controller/cron/collect_proof.go b/coordinator/internal/controller/cron/collect_proof.go index 7ffa6d050b..92ff0576f4 100644 --- a/coordinator/internal/controller/cron/collect_proof.go +++ b/coordinator/internal/controller/cron/collect_proof.go @@ -363,7 +363,7 @@ func (c *Collector) checkBundleAllBatchReady() { for _, bundle := range bundles { allReady, checkErr := c.batchOrm.CheckIfBundleBatchProofsAreReady(c.ctx, bundle.Hash) if checkErr != nil { - log.Warn("checkBatchAllChunkReady CheckIfBatchChunkProofsAreReady failure", "error", checkErr, "hash", bundle.Hash) + log.Warn("checkBundleAllBatchReady CheckIfBundleBatchProofsAreReady failure", "error", checkErr, "hash", bundle.Hash) continue } @@ -371,8 +371,8 @@ func (c *Collector) checkBundleAllBatchReady() { continue } - if updateErr := c.bundleOrm.UpdateBatchProofsStatusByBatchHash(c.ctx, bundle.Hash, types.BatchProofsStatusReady); updateErr != nil { - log.Warn("checkBundleAllBatchReady UpdateBatchProofsStatusByBatchHash failure", "error", checkErr, "hash", bundle.Hash) + if updateErr := c.bundleOrm.UpdateBatchProofsStatusByBundleHash(c.ctx, bundle.Hash, types.BatchProofsStatusReady); updateErr != nil { + log.Warn("checkBundleAllBatchReady UpdateBatchProofsStatusByBundleHash failure", "error", checkErr, "hash", bundle.Hash) } } diff --git a/coordinator/internal/logic/provertask/bundle_prover_task.go b/coordinator/internal/logic/provertask/bundle_prover_task.go index dd0523c6a4..d244d2280b 100644 --- a/coordinator/internal/logic/provertask/bundle_prover_task.go +++ b/coordinator/internal/logic/provertask/bundle_prover_task.go @@ -205,7 +205,7 @@ func (bp *BundleProverTask) formatProverTask(ctx context.Context, task *orm.Prov batchProofsBytes, err := json.Marshal(taskDetail) if err != nil { - return nil, fmt.Errorf("failed to marshal chunk proofs, taskID:%s err:%w", task.TaskID, err) + return nil, fmt.Errorf("failed to marshal batch proofs, taskID:%s err:%w", task.TaskID, err) } taskMsg := &coordinatorType.GetTaskSchema{ diff --git a/coordinator/internal/orm/batch.go b/coordinator/internal/orm/batch.go index 5b5cddaeb5..a4f8bd77dc 100644 --- a/coordinator/internal/orm/batch.go +++ b/coordinator/internal/orm/batch.go @@ -211,23 +211,6 @@ func (o *Batch) GetBatchByHash(ctx context.Context, hash string) (*Batch, error) return &batch, nil } -// GetLatestFinalizedBatch retrieves the latest finalized batch from the database. -func (o *Batch) GetLatestFinalizedBatch(ctx context.Context) (*Batch, error) { - db := o.db.WithContext(ctx) - db = db.Model(&Batch{}) - db = db.Where("rollup_status = ?", int(types.RollupFinalized)) - db = db.Order("index desc") - - var latestFinalizedBatch Batch - if err := db.First(&latestFinalizedBatch).Error; err != nil { - if errors.Is(err, gorm.ErrRecordNotFound) { - return nil, nil - } - return nil, fmt.Errorf("Batch.GetLatestBatch error: %w", err) - } - return &latestFinalizedBatch, nil -} - // GetBatchesByBundleHash retrieves the given batch. func (o *Batch) GetBatchesByBundleHash(ctx context.Context, bundleHash string) ([]*Batch, error) { db := o.db.WithContext(ctx) diff --git a/coordinator/internal/orm/bundle.go b/coordinator/internal/orm/bundle.go index ea77343430..5deeff1114 100644 --- a/coordinator/internal/orm/bundle.go +++ b/coordinator/internal/orm/bundle.go @@ -28,7 +28,6 @@ type Bundle struct { BatchProofsStatus int16 `json:"batch_proofs_status" gorm:"column:batch_proofs_status;default:1"` ProvingStatus int16 `json:"proving_status" gorm:"column:proving_status;default:1"` Proof []byte `json:"proof" gorm:"column:proof;default:NULL"` - ProverAssignedAt *time.Time `json:"prover_assigned_at" gorm:"column:prover_assigned_at;default:NULL"` ProvedAt *time.Time `json:"proved_at" gorm:"column:proved_at;default:NULL"` ProofTimeSec int32 `json:"proof_time_sec" gorm:"column:proof_time_sec;default:NULL"` TotalAttempts int16 `json:"total_attempts" gorm:"column:total_attempts;default:0"` @@ -136,14 +135,14 @@ func (o *Bundle) GetUnassignedAndBatchesUnreadyBundles(ctx context.Context, offs return bundles, nil } -// UpdateBatchProofsStatusByBatchHash updates the status of batch_proofs_status field for a given bundle hash. -func (o *Bundle) UpdateBatchProofsStatusByBatchHash(ctx context.Context, bundleHash string, status types.BatchProofsStatus) error { +// UpdateBatchProofsStatusByBundleHash updates the status of batch_proofs_status field for a given bundle hash. +func (o *Bundle) UpdateBatchProofsStatusByBundleHash(ctx context.Context, bundleHash string, status types.BatchProofsStatus) error { db := o.db.WithContext(ctx) db = db.Model(&Bundle{}) db = db.Where("hash = ?", bundleHash) if err := db.Update("batch_proofs_status", status).Error; err != nil { - return fmt.Errorf("Bundle.UpdateBatchProofsStatusByBatchHash error: %w, bundle hash: %v, status: %v", err, bundleHash, status.String()) + return fmt.Errorf("Bundle.UpdateBatchProofsStatusByBundleHash error: %w, bundle hash: %v, status: %v", err, bundleHash, status.String()) } return nil } diff --git a/database/migrate/migrations/00021_bundle.sql b/database/migrate/migrations/00021_bundle.sql index c4007b5322..a5f50f5f68 100644 --- a/database/migrate/migrations/00021_bundle.sql +++ b/database/migrate/migrations/00021_bundle.sql @@ -14,7 +14,6 @@ CREATE TABLE bundle ( batch_proofs_status SMALLINT NOT NULL DEFAULT 1, proving_status SMALLINT NOT NULL DEFAULT 1, proof BYTEA DEFAULT NULL, - prover_assigned_at TIMESTAMP(0) DEFAULT NULL, proved_at TIMESTAMP(0) DEFAULT NULL, proof_time_sec INTEGER DEFAULT NULL, total_attempts SMALLINT NOT NULL DEFAULT 0, diff --git a/prover/src/prover.rs b/prover/src/prover.rs index 388c55dbba..7de83906e0 100644 --- a/prover/src/prover.rs +++ b/prover/src/prover.rs @@ -71,7 +71,6 @@ impl<'a> Prover<'a> { let mut req = GetTaskRequest { task_types: get_task_types(self.config.prover_type), prover_height: None, - // vks: self.circuits_handler_provider.borrow().get_vks(), }; if self.config.prover_type == ProverType::Chunk { diff --git a/rollup/cmd/rollup_relayer/app/app.go b/rollup/cmd/rollup_relayer/app/app.go index 4968d3a997..74a9e17e0c 100644 --- a/rollup/cmd/rollup_relayer/app/app.go +++ b/rollup/cmd/rollup_relayer/app/app.go @@ -85,19 +85,8 @@ func action(ctx *cli.Context) error { } chunkProposer := watcher.NewChunkProposer(subCtx, cfg.L2Config.ChunkProposerConfig, genesis.Config, db, registry) - if err != nil { - log.Crit("failed to create chunkProposer", "config file", cfgFile, "error", err) - } - batchProposer := watcher.NewBatchProposer(subCtx, cfg.L2Config.BatchProposerConfig, genesis.Config, db, registry) - if err != nil { - log.Crit("failed to create batchProposer", "config file", cfgFile, "error", err) - } - bundleProposer := watcher.NewBundleProposer(subCtx, cfg.L2Config.BundleProposerConfig, genesis.Config, db, registry) - if err != nil { - log.Crit("failed to create bundleProposer", "config file", cfgFile, "error", err) - } l2watcher := watcher.NewL2WatcherClient(subCtx, l2client, cfg.L2Config.Confirmations, cfg.L2Config.L2MessageQueueAddress, cfg.L2Config.WithdrawTrieRootSlot, db, registry) diff --git a/rollup/internal/controller/relayer/l2_relayer.go b/rollup/internal/controller/relayer/l2_relayer.go index bb7b470016..fb0e84933b 100644 --- a/rollup/internal/controller/relayer/l2_relayer.go +++ b/rollup/internal/controller/relayer/l2_relayer.go @@ -490,7 +490,6 @@ func (r *Layer2Relayer) ProcessCommittedBatches() { "batch proving failed", "Index", batch.Index, "Hash", batch.Hash, - "ProverAssignedAt", batch.ProverAssignedAt, "ProvedAt", batch.ProvedAt, "ProofTimeSec", batch.ProofTimeSec, ) @@ -538,7 +537,7 @@ func (r *Layer2Relayer) ProcessPendingBundles() { // stop the ledger, fix the limit, revert all the violating blocks, // chunks, batches, bundles and all subsequent ones, and resume, // i.e. this case requires manual resolution. - log.Error("bundle proving failed", "index", bundle.Index, "hash", bundle.Hash, "prover assigned at", bundle.ProverAssignedAt, "proved at", bundle.ProvedAt, "proof time sec", bundle.ProofTimeSec) + log.Error("bundle proving failed", "index", bundle.Index, "hash", bundle.Hash, "proved at", bundle.ProvedAt, "proof time sec", bundle.ProofTimeSec) default: log.Error("encounter unreachable case in ProcessPendingBundles", "proving status", status) @@ -652,11 +651,11 @@ func (r *Layer2Relayer) finalizeBatch(dbBatch *orm.Batch, withProof bool) error // Updating the proving status when finalizing without proof, thus the coordinator could omit this task. // it isn't a necessary step, so don't put in a transaction with UpdateFinalizeTxHashAndRollupStatus if !withProof { - txErr := r.db.Transaction(func(tx *gorm.DB) error { - if updateErr := r.batchOrm.UpdateProvingStatus(r.ctx, dbBatch.Hash, types.ProvingTaskVerified); updateErr != nil { + txErr := r.db.Transaction(func(dbTX *gorm.DB) error { + if updateErr := r.batchOrm.UpdateProvingStatus(r.ctx, dbBatch.Hash, types.ProvingTaskVerified, dbTX); updateErr != nil { return updateErr } - if updateErr := r.chunkOrm.UpdateProvingStatusByBatchHash(r.ctx, dbBatch.Hash, types.ProvingTaskVerified); updateErr != nil { + if updateErr := r.chunkOrm.UpdateProvingStatusByBatchHash(r.ctx, dbBatch.Hash, types.ProvingTaskVerified, dbTX); updateErr != nil { return updateErr } return nil @@ -735,11 +734,11 @@ func (r *Layer2Relayer) finalizeBundle(bundle *orm.Bundle, withProof bool) error // Updating the proving status when finalizing without proof, thus the coordinator could omit this task. // it isn't a necessary step, so don't put in a transaction with UpdateFinalizeTxHashAndRollupStatus if !withProof { - txErr := r.db.Transaction(func(tx *gorm.DB) error { - if updateErr := r.bundleOrm.UpdateProvingStatus(r.ctx, bundle.Hash, types.ProvingTaskVerified); updateErr != nil { + txErr := r.db.Transaction(func(dbTX *gorm.DB) error { + if updateErr := r.bundleOrm.UpdateProvingStatus(r.ctx, bundle.Hash, types.ProvingTaskVerified, dbTX); updateErr != nil { return updateErr } - if updateErr := r.batchOrm.UpdateProvingStatusByBundleHash(r.ctx, bundle.Hash, types.ProvingTaskVerified); updateErr != nil { + if updateErr := r.batchOrm.UpdateProvingStatusByBundleHash(r.ctx, bundle.Hash, types.ProvingTaskVerified, dbTX); updateErr != nil { return updateErr } for batchIndex := bundle.StartBatchIndex; batchIndex <= bundle.EndBatchIndex; batchIndex++ { @@ -747,7 +746,7 @@ func (r *Layer2Relayer) finalizeBundle(bundle *orm.Bundle, withProof bool) error if getErr != nil { return getErr } - if updateErr := r.chunkOrm.UpdateProvingStatusByBatchHash(r.ctx, tmpBatch.Hash, types.ProvingTaskVerified); updateErr != nil { + if updateErr := r.chunkOrm.UpdateProvingStatusByBatchHash(r.ctx, tmpBatch.Hash, types.ProvingTaskVerified, dbTX); updateErr != nil { return updateErr } } diff --git a/rollup/internal/orm/batch.go b/rollup/internal/orm/batch.go index ee1d8ba140..dc572c2f98 100644 --- a/rollup/internal/orm/batch.go +++ b/rollup/internal/orm/batch.go @@ -488,7 +488,7 @@ func (o *Batch) UpdateProvingStatusByBundleHash(ctx context.Context, bundleHash return nil } -// UpdateFinalizeTxHashAndRollupStatusByBundleHash updates the the finalize transaction hash and rollup status for batches within the specified bundle_hash +// UpdateFinalizeTxHashAndRollupStatusByBundleHash updates the finalize transaction hash and rollup status for batches with the specified bundle_hash func (o *Batch) UpdateFinalizeTxHashAndRollupStatusByBundleHash(ctx context.Context, bundleHash string, finalizeTxHash string, status types.RollupStatus, dbTX ...*gorm.DB) error { updateFields := make(map[string]interface{}) updateFields["finalize_tx_hash"] = finalizeTxHash diff --git a/rollup/internal/orm/bundle.go b/rollup/internal/orm/bundle.go index 28ed3209bd..6965f6dfae 100644 --- a/rollup/internal/orm/bundle.go +++ b/rollup/internal/orm/bundle.go @@ -35,7 +35,6 @@ type Bundle struct { BatchProofsStatus int16 `json:"batch_proofs_status" gorm:"column:batch_proofs_status;default:1"` ProvingStatus int16 `json:"proving_status" gorm:"column:proving_status;default:1"` Proof []byte `json:"proof" gorm:"column:proof;default:NULL"` - ProverAssignedAt *time.Time `json:"prover_assigned_at" gorm:"column:prover_assigned_at;default:NULL"` ProvedAt *time.Time `json:"proved_at" gorm:"column:proved_at;default:NULL"` ProofTimeSec int32 `json:"proof_time_sec" gorm:"column:proof_time_sec;default:NULL"` @@ -214,10 +213,6 @@ func (o *Bundle) UpdateProvingStatus(ctx context.Context, hash string, status ty updateFields["proving_status"] = int(status) switch status { - case types.ProvingTaskAssigned: - updateFields["prover_assigned_at"] = time.Now() - case types.ProvingTaskUnassigned: - updateFields["prover_assigned_at"] = nil case types.ProvingTaskVerified: updateFields["proved_at"] = time.Now() } diff --git a/rollup/internal/orm/orm_test.go b/rollup/internal/orm/orm_test.go index 1f93486d3c..85ff5b96e4 100644 --- a/rollup/internal/orm/orm_test.go +++ b/rollup/internal/orm/orm_test.go @@ -503,7 +503,6 @@ func TestBundleOrm(t *testing.T) { err = db.Where("hash = ?", bundle1.Hash).First(&bundle).Error assert.NoError(t, err) assert.Equal(t, int16(types.ProvingTaskAssigned), bundle.ProvingStatus) - assert.NotNil(t, bundle.ProverAssignedAt) err = bundleOrm.UpdateProvingStatus(context.Background(), bundle1.Hash, types.ProvingTaskVerified) assert.NoError(t, err) diff --git a/tests/integration-test/genesis.json b/tests/integration-test/genesis.json index 774df8beeb..5de1c798b7 100644 --- a/tests/integration-test/genesis.json +++ b/tests/integration-test/genesis.json @@ -14,9 +14,9 @@ "londonBlock": 0, "archimedesBlock": 0, "shanghaiBlock": 0, - "bernoulliBlock": 2, - "curieBlock": 3, - "darwinTime": 1719558098, + "bernoulliBlock": 0, + "curieBlock": 0, + "darwinTime": 0, "clique": { "period": 3, "epoch": 30000