From e2ade8ba5bb043fca39d8aa65507963abe5d5fce Mon Sep 17 00:00:00 2001 From: David Date: Wed, 7 Jun 2023 14:56:48 +0800 Subject: [PATCH 1/2] feat(pkg): optimize `WaitL1Origin` --- pkg/rpc/methods.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/pkg/rpc/methods.go b/pkg/rpc/methods.go index bb9bf0d8a..3b173b171 100644 --- a/pkg/rpc/methods.go +++ b/pkg/rpc/methods.go @@ -187,25 +187,25 @@ func (c *Client) WaitL1Origin(ctx context.Context, blockID *big.Int) (*rawdb.L1O } log.Debug("Start fetching L1Origin from L2 execution engine", "blockID", blockID) - - for { - select { - case <-ctxWithTimeout.Done(): + for ; true; <-ticker.C { + if ctxWithTimeout.Err() != nil { return nil, ctx.Err() - case <-ticker.C: - l1Origin, err = c.L2.L1OriginByID(ctxWithTimeout, blockID) - if err != nil { - log.Warn("Failed to fetch L1Origin from L2 execution engine", "blockID", blockID, "error", err) - continue - } + } - if l1Origin == nil { - continue - } + l1Origin, err = c.L2.L1OriginByID(ctxWithTimeout, blockID) + if err != nil { + log.Warn("L1Origin from L2 execution engine not found, keep retrying", "blockID", blockID, "error", err) + continue + } - return l1Origin, nil + if l1Origin == nil { + continue } + + return l1Origin, nil } + + return nil, fmt.Errorf("failed to fetch L1Origin from L2 execution engine, blockID: %d", blockID) } // GetPoolContent fetches the transactions list from L2 execution engine's transactions pool with given From 26703a87b487e706c54130ba06c4809458912e63 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 7 Jun 2023 15:01:26 +0800 Subject: [PATCH 2/2] feat: update `waitL1OriginPollingInterval` --- pkg/rpc/methods.go | 2 +- proposer/proposer.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/rpc/methods.go b/pkg/rpc/methods.go index 3b173b171..72481f64f 100644 --- a/pkg/rpc/methods.go +++ b/pkg/rpc/methods.go @@ -26,7 +26,7 @@ var ( // syncProgressRecheckDelay is the time delay of rechecking the L2 execution engine's sync progress again, // if the previous check failed. syncProgressRecheckDelay = 12 * time.Second - waitL1OriginPollingInterval = 6 * time.Second + waitL1OriginPollingInterval = 3 * time.Second defaultWaitL1OriginTimeout = 3 * time.Minute minTxGasLimit = 21000 ) diff --git a/proposer/proposer.go b/proposer/proposer.go index f3ead44d7..5f55507a3 100644 --- a/proposer/proposer.go +++ b/proposer/proposer.go @@ -332,8 +332,8 @@ func (p *Proposer) updateProposingTicker() { if p.proposingInterval != nil { duration = *p.proposingInterval } else { - // Random number between 12 - 60 - randomSeconds := rand.Intn(60-11) + 12 + // Random number between 12 - 120 + randomSeconds := rand.Intn(120-11) + 12 duration = time.Duration(randomSeconds) * time.Second }