Skip to content
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
6 changes: 6 additions & 0 deletions op-batcher/batcher/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,12 @@ func (l *BatchSubmitter) loadBlocksIntoState(ctx context.Context, start, end uin
if end < start {
return fmt.Errorf("start number is > end number %d,%d", start, end)
}

// we don't want to print it in the 1-block case as `loadBlockIntoState` already does
if end > start {
l.Log.Info("Loading range of multiple blocks into state", "start", start, "end", end)
}

var latestBlock *types.Block
// Add all blocks to "state"
for i := start; i <= end; i++ {
Expand Down
22 changes: 13 additions & 9 deletions op-service/client/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,22 @@ func dialRPCClientWithBackoff(ctx context.Context, log log.Logger, addr string,
bOff = retry.Fixed(cfg.fixedDialBackoff)
}
return retry.Do(ctx, cfg.backoffAttempts, bOff, func() (*rpc.Client, error) {
if !IsURLAvailable(ctx, addr) {
log.Warn("failed to dial address, but may connect later", "addr", addr)
return nil, fmt.Errorf("address unavailable (%s)", addr)
}
client, err := rpc.DialOptions(ctx, addr, cfg.gethRPCOptions...)
if err != nil {
return nil, fmt.Errorf("failed to dial address (%s): %w", addr, err)
}
return client, nil
return CheckAndDial(ctx, log, addr, cfg.gethRPCOptions...)
})
}

func CheckAndDial(ctx context.Context, log log.Logger, addr string, options ...rpc.ClientOption) (*rpc.Client, error) {
if !IsURLAvailable(ctx, addr) {
log.Warn("failed to dial address, but may connect later", "addr", addr)
return nil, fmt.Errorf("address unavailable (%s)", addr)
}
client, err := rpc.DialOptions(ctx, addr, options...)
if err != nil {
return nil, fmt.Errorf("failed to dial address (%s): %w", addr, err)
}
return client, nil
}

func IsURLAvailable(ctx context.Context, address string) bool {
u, err := url.Parse(address)
if err != nil {
Expand Down
11 changes: 1 addition & 10 deletions op-service/dial/dial.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package dial

import (
"context"
"fmt"
"time"

"github.com/ethereum-optimism/optimism/op-service/client"
Expand Down Expand Up @@ -72,13 +71,5 @@ func dialRPCClientWithBackoff(ctx context.Context, log log.Logger, addr string)

// Dials a JSON-RPC endpoint once.
func dialRPCClient(ctx context.Context, log log.Logger, addr string) (*rpc.Client, error) {
if !client.IsURLAvailable(ctx, addr) {
log.Warn("failed to dial address, but may connect later", "addr", addr)
return nil, fmt.Errorf("address unavailable (%s)", addr)
}
client, err := rpc.DialOptions(ctx, addr)
if err != nil {
return nil, fmt.Errorf("failed to dial address (%s): %w", addr, err)
}
return client, nil
return client.CheckAndDial(ctx, log, addr)
}