Skip to content

Commit

Permalink
feat(pkg): optimize WaitL1Origin (taikoxyz#267)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha committed Jun 7, 2023
1 parent e61bfe5 commit 3f0a35a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
30 changes: 15 additions & 15 deletions pkg/rpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions proposer/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 3f0a35a

Please sign in to comment.