Commit ea82c698 authored by Andreas Bigger's avatar Andreas Bigger

fix dialing

parent 9f1aaccf
...@@ -16,7 +16,6 @@ import ( ...@@ -16,7 +16,6 @@ import (
oppprof "github.com/ethereum-optimism/optimism/op-service/pprof" oppprof "github.com/ethereum-optimism/optimism/op-service/pprof"
"github.com/ethereum-optimism/optimism/op-service/txmgr" "github.com/ethereum-optimism/optimism/op-service/txmgr"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
) )
...@@ -36,11 +35,10 @@ func NewService(ctx context.Context, logger log.Logger, cfg *config.Config) (*Se ...@@ -36,11 +35,10 @@ func NewService(ctx context.Context, logger log.Logger, cfg *config.Config) (*Se
return nil, fmt.Errorf("failed to create the transaction manager: %w", err) return nil, fmt.Errorf("failed to create the transaction manager: %w", err)
} }
rpcClient, err := client.DialRPCClientWithTimeout(client.DefaultDialTimeout, logger, cfg.L1EthRpc) l1Client, err := client.DialEthClientWithTimeout(client.DefaultDialTimeout, logger, cfg.L1EthRpc)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to dial L1: %w", err) return nil, fmt.Errorf("failed to dial L1: %w", err)
} }
l1Client := ethclient.NewClient(rpcClient)
pprofConfig := cfg.PprofConfig pprofConfig := cfg.PprofConfig
if pprofConfig.Enabled { if pprofConfig.Enabled {
...@@ -79,7 +77,7 @@ func NewService(ctx context.Context, logger log.Logger, cfg *config.Config) (*Se ...@@ -79,7 +77,7 @@ func NewService(ctx context.Context, logger log.Logger, cfg *config.Config) (*Se
return fault.NewGamePlayer(ctx, logger, m, cfg, dir, addr, txMgr, l1Client) return fault.NewGamePlayer(ctx, logger, m, cfg, dir, addr, txMgr, l1Client)
}) })
pollClient, err := opClient.NewRPCWithClient(ctx, logger, cfg.L1EthRpc, opClient.NewBaseRPCClient(rpcClient), cfg.PollInterval) pollClient, err := opClient.NewRPCWithClient(ctx, logger, cfg.L1EthRpc, opClient.NewBaseRPCClient(l1Client.Client()), cfg.PollInterval)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to create RPC client: %w", err) return nil, fmt.Errorf("failed to create RPC client: %w", err)
} }
......
...@@ -33,21 +33,6 @@ func DialEthClientWithTimeout(timeout time.Duration, log log.Logger, url string) ...@@ -33,21 +33,6 @@ func DialEthClientWithTimeout(timeout time.Duration, log log.Logger, url string)
return ethclient.NewClient(c), nil return ethclient.NewClient(c), nil
} }
// DialRPCClientWithTimeout attempts to dial the L1 provider using the provided
// URL. If the dial doesn't complete within defaultDialTimeout seconds, this
// method will return an error.
func DialRPCClientWithTimeout(timeout time.Duration, log log.Logger, url string) (*rpc.Client, error) {
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
c, err := dialRPCClientWithBackoff(ctx, log, url)
if err != nil {
return nil, err
}
return c, nil
}
// DialRollupClientWithTimeout attempts to dial the RPC provider using the provided URL. // DialRollupClientWithTimeout attempts to dial the RPC provider using the provided URL.
// If the dial doesn't complete within timeout seconds, this method will return an error. // If the dial doesn't complete within timeout seconds, this method will return an error.
func DialRollupClientWithTimeout(timeout time.Duration, log log.Logger, url string) (*sources.RollupClient, error) { func DialRollupClientWithTimeout(timeout time.Duration, log log.Logger, url string) (*sources.RollupClient, error) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment