Skip to content

Commit 03f4e46

Browse files
authored
Merge branch 'develop' into optimize_abs
2 parents 4d72c98 + f92029a commit 03f4e46

File tree

5 files changed

+34
-19
lines changed

5 files changed

+34
-19
lines changed

common/version/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"runtime/debug"
66
)
77

8-
var tag = "v4.4.83"
8+
var tag = "v4.4.84"
99

1010
var commit = func() string {
1111
if info, ok := debug.ReadBuildInfo(); ok {

rollup/internal/controller/relayer/l2_relayer.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ func (r *Layer2Relayer) ProcessPendingBundles() {
530530
}
531531

532532
case types.ProvingTaskVerified:
533-
log.Info("Start to roll up zk proof", "bundle hash", bundle.Hash)
533+
log.Info("Start to roll up zk proof", "index", bundle.Index, "bundle hash", bundle.Hash)
534534
r.metrics.rollupL2RelayerProcessPendingBundlesFinalizedTotal.Inc()
535535
if err := r.finalizeBundle(bundle, true); err != nil {
536536
log.Error("failed to finalize bundle with proof", "bundle index", bundle.Index, "start batch index", bundle.StartBatchIndex, "end batch index", bundle.EndBatchIndex, "err", err)
@@ -637,8 +637,22 @@ func (r *Layer2Relayer) finalizeBundle(bundle *orm.Bundle, withProof bool) error
637637
log.Info("finalizeBundle in layer1", "with proof", withProof, "index", bundle.Index, "start batch index", bundle.StartBatchIndex, "end batch index", bundle.EndBatchIndex, "tx hash", txHash.String())
638638

639639
// Updating rollup status in database.
640-
if err := r.bundleOrm.UpdateFinalizeTxHashAndRollupStatus(r.ctx, bundle.Hash, txHash.String(), types.RollupFinalizing); err != nil {
641-
log.Error("UpdateFinalizeTxHashAndRollupStatus failed", "index", bundle.Index, "bundle hash", bundle.Hash, "tx hash", txHash.String(), "err", err)
640+
err = r.db.Transaction(func(dbTX *gorm.DB) error {
641+
if err = r.batchOrm.UpdateFinalizeTxHashAndRollupStatusByBundleHash(r.ctx, bundle.Hash, txHash.String(), types.RollupFinalizing, dbTX); err != nil {
642+
log.Warn("UpdateFinalizeTxHashAndRollupStatusByBundleHash failed", "index", bundle.Index, "bundle hash", bundle.Hash, "tx hash", txHash.String(), "err", err)
643+
return err
644+
}
645+
646+
if err = r.bundleOrm.UpdateFinalizeTxHashAndRollupStatus(r.ctx, bundle.Hash, txHash.String(), types.RollupFinalizing, dbTX); err != nil {
647+
log.Warn("UpdateFinalizeTxHashAndRollupStatus failed", "index", bundle.Index, "bundle hash", bundle.Hash, "tx hash", txHash.String(), "err", err)
648+
return err
649+
}
650+
651+
return nil
652+
})
653+
654+
if err != nil {
655+
log.Warn("failed to update rollup status of bundle and batches", "err", err)
642656
return err
643657
}
644658

rollup/internal/orm/batch.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -347,11 +347,11 @@ func (o *Batch) UpdateProvingStatus(ctx context.Context, hash string, status typ
347347

348348
switch status {
349349
case types.ProvingTaskAssigned:
350-
updateFields["prover_assigned_at"] = time.Now()
350+
updateFields["prover_assigned_at"] = utils.NowUTC()
351351
case types.ProvingTaskUnassigned:
352352
updateFields["prover_assigned_at"] = nil
353353
case types.ProvingTaskVerified:
354-
updateFields["proved_at"] = time.Now()
354+
updateFields["proved_at"] = utils.NowUTC()
355355
}
356356

357357
db := o.db
@@ -419,7 +419,7 @@ func (o *Batch) UpdateFinalizeTxHashAndRollupStatus(ctx context.Context, hash st
419419
updateFields["finalize_tx_hash"] = finalizeTxHash
420420
updateFields["rollup_status"] = int(status)
421421
if status == types.RollupFinalized {
422-
updateFields["finalized_at"] = time.Now()
422+
updateFields["finalized_at"] = utils.NowUTC()
423423
}
424424

425425
db := o.db.WithContext(ctx)
@@ -478,11 +478,11 @@ func (o *Batch) UpdateProvingStatusByBundleHash(ctx context.Context, bundleHash
478478

479479
switch status {
480480
case types.ProvingTaskAssigned:
481-
updateFields["prover_assigned_at"] = time.Now()
481+
updateFields["prover_assigned_at"] = utils.NowUTC()
482482
case types.ProvingTaskUnassigned:
483483
updateFields["prover_assigned_at"] = nil
484484
case types.ProvingTaskVerified:
485-
updateFields["proved_at"] = time.Now()
485+
updateFields["proved_at"] = utils.NowUTC()
486486
}
487487

488488
db := o.db

rollup/internal/orm/bundle.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func (o *Bundle) UpdateFinalizeTxHashAndRollupStatus(ctx context.Context, hash s
194194
updateFields["finalize_tx_hash"] = finalizeTxHash
195195
updateFields["rollup_status"] = int(status)
196196
if status == types.RollupFinalized {
197-
updateFields["finalized_at"] = time.Now()
197+
updateFields["finalized_at"] = utils.NowUTC()
198198
}
199199

200200
db := o.db
@@ -218,7 +218,7 @@ func (o *Bundle) UpdateProvingStatus(ctx context.Context, hash string, status ty
218218

219219
switch status {
220220
case types.ProvingTaskVerified:
221-
updateFields["proved_at"] = time.Now()
221+
updateFields["proved_at"] = utils.NowUTC()
222222
}
223223

224224
db := o.db
@@ -241,7 +241,7 @@ func (o *Bundle) UpdateRollupStatus(ctx context.Context, hash string, status typ
241241
updateFields := make(map[string]interface{})
242242
updateFields["rollup_status"] = int(status)
243243
if status == types.RollupFinalized {
244-
updateFields["finalized_at"] = time.Now()
244+
updateFields["finalized_at"] = utils.NowUTC()
245245
}
246246

247247
db := o.db.WithContext(ctx)

rollup/internal/orm/chunk.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ import (
1111
"gorm.io/gorm"
1212

1313
"scroll-tech/common/types"
14+
"scroll-tech/common/utils"
1415

15-
"scroll-tech/rollup/internal/utils"
16+
rutils "scroll-tech/rollup/internal/utils"
1617
)
1718

1819
// Chunk represents a chunk of blocks in the database.
@@ -177,7 +178,7 @@ func (o *Chunk) GetChunksByBatchHash(ctx context.Context, batchHash string) ([]*
177178
}
178179

179180
// InsertChunk inserts a new chunk into the database.
180-
func (o *Chunk) InsertChunk(ctx context.Context, chunk *encoding.Chunk, codecVersion encoding.CodecVersion, metrics utils.ChunkMetrics, dbTX ...*gorm.DB) (*Chunk, error) {
181+
func (o *Chunk) InsertChunk(ctx context.Context, chunk *encoding.Chunk, codecVersion encoding.CodecVersion, metrics rutils.ChunkMetrics, dbTX ...*gorm.DB) (*Chunk, error) {
181182
if chunk == nil || len(chunk.Blocks) == 0 {
182183
return nil, errors.New("invalid args")
183184
}
@@ -202,7 +203,7 @@ func (o *Chunk) InsertChunk(ctx context.Context, chunk *encoding.Chunk, codecVer
202203
parentChunkStateRoot = parentChunk.StateRoot
203204
}
204205

205-
chunkHash, err := utils.GetChunkHash(chunk, totalL1MessagePoppedBefore, codecVersion)
206+
chunkHash, err := rutils.GetChunkHash(chunk, totalL1MessagePoppedBefore, codecVersion)
206207
if err != nil {
207208
log.Error("failed to get chunk hash", "err", err)
208209
return nil, fmt.Errorf("Chunk.InsertChunk error: %w", err)
@@ -261,11 +262,11 @@ func (o *Chunk) UpdateProvingStatus(ctx context.Context, hash string, status typ
261262

262263
switch status {
263264
case types.ProvingTaskAssigned:
264-
updateFields["prover_assigned_at"] = time.Now()
265+
updateFields["prover_assigned_at"] = utils.NowUTC()
265266
case types.ProvingTaskUnassigned:
266267
updateFields["prover_assigned_at"] = nil
267268
case types.ProvingTaskVerified:
268-
updateFields["proved_at"] = time.Now()
269+
updateFields["proved_at"] = utils.NowUTC()
269270
}
270271

271272
db := o.db
@@ -289,11 +290,11 @@ func (o *Chunk) UpdateProvingStatusByBatchHash(ctx context.Context, batchHash st
289290

290291
switch status {
291292
case types.ProvingTaskAssigned:
292-
updateFields["prover_assigned_at"] = time.Now()
293+
updateFields["prover_assigned_at"] = utils.NowUTC()
293294
case types.ProvingTaskUnassigned:
294295
updateFields["prover_assigned_at"] = nil
295296
case types.ProvingTaskVerified:
296-
updateFields["proved_at"] = time.Now()
297+
updateFields["proved_at"] = utils.NowUTC()
297298
}
298299

299300
db := o.db

0 commit comments

Comments
 (0)