Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

feat(pkg): optimize WaitL1Origin #267

Merged
merged 2 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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