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

feat(pkg): update WaitTillL2ExecutionEngineSynced #677

Merged
merged 1 commit into from
Apr 2, 2024
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
9 changes: 2 additions & 7 deletions pkg/rpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,10 @@ func (c *Client) ensureGenesisMatched(ctx context.Context) error {

// WaitTillL2ExecutionEngineSynced keeps waiting until the L2 execution engine is fully synced.
func (c *Client) WaitTillL2ExecutionEngineSynced(ctx context.Context) error {
if ctx.Err() != nil && !errors.Is(ctx.Err(), context.DeadlineExceeded) {
return ctx.Err()
}
start := time.Now()

return backoff.Retry(
func() error {
if ctx.Err() != nil && !errors.Is(ctx.Err(), context.DeadlineExceeded) {
return ctx.Err()
}
newCtx, cancel := context.WithTimeout(ctx, defaultTimeout)
defer cancel()
progress, err := c.L2ExecutionEngineSyncProgress(newCtx)
Expand All @@ -111,7 +106,7 @@ func (c *Client) WaitTillL2ExecutionEngineSynced(ctx context.Context) error {

return nil
},
backoff.NewExponentialBackOff(),
backoff.WithContext(backoff.NewExponentialBackOff(), ctx),
)
}

Expand Down
20 changes: 0 additions & 20 deletions pkg/rpc/methods_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ import (
"context"
"crypto/rand"
"testing"
"time"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/stretchr/testify/require"
"github.com/taikoxyz/taiko-client/bindings/encoding"
"golang.org/x/sync/errgroup"
)

var (
Expand Down Expand Up @@ -117,24 +115,6 @@ func TestWaitTillL2ExecutionEngineSyncedContextErr(t *testing.T) {
require.ErrorContains(t, err, "context canceled")
}

func TestWaitTillL2ExecutionEngineSyncedTimeoutErr(t *testing.T) {
client := newTestClient(t)
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
time.Sleep(1 * time.Second)
g, ctx := errgroup.WithContext(ctx)
g.Go(func() error {
err := client.WaitTillL2ExecutionEngineSynced(ctx)
if err != nil {
return err
}
return nil
})
cancel()
err := g.Wait()
require.ErrorContains(t, err, "context canceled")
}

func TestGetPoolContentValid(t *testing.T) {
client := newTestClient(t)
configs, err := client.TaikoL1.GetConfig(&bind.CallOpts{Context: context.Background()})
Expand Down
4 changes: 2 additions & 2 deletions proposer/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,13 @@ func (p *Proposer) eventLoop() {
// proposing interval timer has been reached
case <-p.proposingTimer.C:
metrics.ProposerProposeEpochCounter.Inc(1)
// attempt propose operation
// Attempt propose operation
if err := p.ProposeOp(p.ctx); err != nil {
if !errors.Is(err, errNoNewTxs) {
log.Error("Proposing operation error", "error", err)
continue
}
// if no new transactions and empty block interval has passed, propose an empty block
// If there is always no new transaction and the empty block interval has passed, propose an empty block.
if p.ProposeEmptyBlocksInterval != 0 {
if time.Now().Before(lastNonEmptyBlockProposedAt.Add(p.ProposeEmptyBlocksInterval)) {
continue
Expand Down
Loading