mirror of
https://github.com/scroll-tech/scroll.git
synced 2026-04-23 03:00:50 -04:00
fix comments.
This commit is contained in:
@@ -25,9 +25,13 @@ func (r *Layer1Relayer) checkSubmittedMessages() error {
|
||||
fmt.Sprintf("AND queue_index > %d", index),
|
||||
fmt.Sprintf("ORDER BY queue_index ASC LIMIT %d", msgsSize),
|
||||
)
|
||||
if err != nil || len(msgs) == 0 {
|
||||
if err != nil {
|
||||
log.Error("failed to get l1 submitted messages", "queue_index", index, "err", err)
|
||||
return err
|
||||
}
|
||||
if len(msgs) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
index = msgs[len(msgs)-1].QueueIndex
|
||||
for _, msg := range msgs { //nolint:staticcheck
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math"
|
||||
"reflect"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -128,10 +127,6 @@ func (p *BatchProposer) Start() {
|
||||
p.tryCommitBatches()
|
||||
|
||||
go func() {
|
||||
if reflect.ValueOf(p.orm).IsNil() {
|
||||
panic("must run BatchProposer with DB")
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithCancel(p.ctx)
|
||||
|
||||
go utils.Loop(ctx, 2*time.Second, func() {
|
||||
|
||||
@@ -44,13 +44,17 @@ func (r *Layer2Relayer) checkRollupBatches() error {
|
||||
for {
|
||||
blockBatches, err := r.db.GetBlockBatches(
|
||||
map[string]interface{}{"rollup_status": types.RollupCommitting},
|
||||
fmt.Sprintf("AND commit_tx_hash IN (SELECT commit_tx_hash FROM block_batch WHERE index > %d GROUP BY commit_tx_hash LIMIT 1)", batchIndex),
|
||||
fmt.Sprintf("AND commit_tx_hash IN (SELECT commit_tx_hash FROM block_batch WHERE index > %d GROUP BY index, commit_tx_hash ORDER BY index LIMIT 1)", batchIndex),
|
||||
fmt.Sprintf("AND index > %d", batchIndex),
|
||||
"ORDER BY index ASC",
|
||||
)
|
||||
if err != nil || len(blockBatches) == 0 {
|
||||
if err != nil {
|
||||
log.Error("failed to get rollup committing block batches", "batch index", batchIndex, "err", err)
|
||||
return err
|
||||
}
|
||||
if len(blockBatches) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var batchDataBuffer []*types.BatchData
|
||||
batchIndex = blockBatches[len(blockBatches)-1].Index
|
||||
@@ -105,13 +109,8 @@ func (r *Layer2Relayer) checkRollupBatches() error {
|
||||
switch true {
|
||||
case err == nil:
|
||||
r.processingBatchesCommitment.Store(txID, batchHashes)
|
||||
case err.Error() == "Batch already commited": //nolint:misspell
|
||||
for _, batchHash := range batchHashes {
|
||||
if err = r.db.UpdateRollupStatus(r.ctx, batchHash, types.RollupCommitted); err != nil {
|
||||
log.Error("failed to update rollup status when check rollup batched", "batch_hash", batchHash, "err", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
case err.Error() == "execution reverted: Batch already commited": //nolint:misspell
|
||||
log.Warn("blockBatches already committed", "start index", blockBatches[0].Index, "end index", blockBatches[len(blockBatches)-1].Index)
|
||||
default:
|
||||
log.Error("failed to load or send batchData tx")
|
||||
return err
|
||||
|
||||
@@ -26,9 +26,13 @@ func (r *Layer2Relayer) checkFinalizingBatches() error {
|
||||
fmt.Sprintf("AND index > %d", batchIndex),
|
||||
fmt.Sprintf("ORDER BY index ASC LIMIT %d", batchLimit),
|
||||
)
|
||||
if err != nil || len(batches) == 0 {
|
||||
if err != nil {
|
||||
log.Error("failed to get Rollup finalizing batches", "batch index", batchIndex, "err", err)
|
||||
return err
|
||||
}
|
||||
if len(batches) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
batchIndex = batches[len(batches)-1].Index
|
||||
for _, batch := range batches { //nolint:staticcheck
|
||||
@@ -41,6 +45,7 @@ func (r *Layer2Relayer) checkFinalizingBatches() error {
|
||||
txHash common.Hash
|
||||
hash = batch.Hash
|
||||
)
|
||||
// Use empty txHash can let tx resent, if tx is already on block will be checked.
|
||||
if batch.CommitTxHash.Valid {
|
||||
txHash = common.HexToHash(batch.CommitTxHash.String)
|
||||
}
|
||||
@@ -63,7 +68,8 @@ func (r *Layer2Relayer) checkFinalizingBatches() error {
|
||||
switch true {
|
||||
case err == nil:
|
||||
r.processingFinalization.Store(txID, hash)
|
||||
case err.Error() == "Batch is already finalized":
|
||||
case err.Error() == "execution reverted: Batch is already finalized":
|
||||
log.Warn("block batch already rollup finalized", "batch index", batch.Index)
|
||||
if err = r.db.UpdateRollupStatus(r.ctx, hash, types.RollupFinalized); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -30,9 +30,13 @@ func (r *Layer2Relayer) checkSubmittedMessages() error {
|
||||
fmt.Sprintf("AND nonce > %d", nonce),
|
||||
fmt.Sprintf("ORDER BY nonce ASC LIMIT %d", processMsgLimit),
|
||||
)
|
||||
if err != nil || len(msgs) == 0 {
|
||||
if err != nil {
|
||||
log.Error("failed to get l2 submitted messages", "message nonce", nonce, "err", err)
|
||||
return err
|
||||
}
|
||||
if len(msgs) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var batch *types.BlockBatch
|
||||
nonce = msgs[len(msgs)-1].Nonce
|
||||
@@ -71,7 +75,7 @@ func (r *Layer2Relayer) checkSubmittedMessages() error {
|
||||
switch true {
|
||||
case err == nil:
|
||||
r.processingMessage.Store(msg.MsgHash, msg.MsgHash)
|
||||
case err.Error() == "execution reverted: Message expired":
|
||||
case err.Error() == "execution reverted: execution reverted: Message expired":
|
||||
if err = r.db.UpdateLayer2Status(r.ctx, msg.MsgHash, types.MsgExpired); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user