Skip to content

Commit b396496

Browse files
committed
Fix logs and use blocktime instead of batchtime
1 parent fa9fab6 commit b396496

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

common/database/db.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (g *gormLogger) Error(_ context.Context, msg string, data ...interface{}) {
4141
func (g *gormLogger) Trace(_ context.Context, begin time.Time, fc func() (string, int64), err error) {
4242
elapsed := time.Since(begin)
4343
sql, rowsAffected := fc()
44-
g.gethLogger.Debug("gorm", "line", utils.FileWithLineNum(), "cost", elapsed, "sql", sql, "rowsAffected", rowsAffected, "err", err)
44+
g.gethLogger.Trace("gorm", "line", utils.FileWithLineNum(), "cost", elapsed, "sql", sql, "rowsAffected", rowsAffected, "err", err)
4545
}
4646

4747
// InitDB init the db handler

rollup/internal/controller/relayer/l2_relayer.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,15 @@ func (r *Layer2Relayer) ProcessPendingBatches() {
333333

334334
var forceSubmit bool
335335

336-
oldestBatchTimestamp := dbBatches[0].CreatedAt
336+
startChunk, err := r.chunkOrm.GetChunkByIndex(r.ctx, dbBatches[0].StartChunkIndex)
337+
oldestBlockTimestamp := time.Unix(int64(startChunk.StartBlockTime), 0)
338+
if err != nil {
339+
log.Error("failed to get first chunk", "err", err, "batch index", dbBatches[0].Index, "chunk index", dbBatches[0].StartChunkIndex)
340+
return
341+
}
342+
337343
// if the batch with the oldest index is too old, we force submit all batches that we have so far in the next step
338-
if r.cfg.BatchSubmission.TimeoutSec > 0 && time.Since(oldestBatchTimestamp) > time.Duration(r.cfg.BatchSubmission.TimeoutSec)*time.Second {
344+
if r.cfg.BatchSubmission.TimeoutSec > 0 && time.Since(oldestBlockTimestamp) > time.Duration(r.cfg.BatchSubmission.TimeoutSec)*time.Second {
339345
forceSubmit = true
340346
}
341347

@@ -346,7 +352,7 @@ func (r *Layer2Relayer) ProcessPendingBatches() {
346352

347353
if !forceSubmit {
348354
// check if we should skip submitting the batch based on the fee target
349-
skip, err := r.skipSubmitByFee(oldestBatchTimestamp)
355+
skip, err := r.skipSubmitByFee(oldestBlockTimestamp)
350356
// return if not hitting target price
351357
if skip {
352358
log.Debug("Skipping batch submission", "reason", err)
@@ -432,7 +438,7 @@ func (r *Layer2Relayer) ProcessPendingBatches() {
432438
}
433439

434440
if forceSubmit {
435-
log.Info("Forcing submission of batches due to timeout", "batch index", batchesToSubmit[0].Batch.Index, "created at", batchesToSubmit[0].Batch.CreatedAt)
441+
log.Info("Forcing submission of batches due to timeout", "batch index", batchesToSubmit[0].Batch.Index, "first block created at", oldestBlockTimestamp)
436442
}
437443

438444
// We have at least 1 batch to commit

0 commit comments

Comments
 (0)