Skip to content

Commit

Permalink
feat: use multiple RPCs for relayer (#527)
Browse files Browse the repository at this point in the history
  • Loading branch information
aloknerurkar authored Dec 10, 2024
1 parent 16db7b9 commit b7a79a4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
12 changes: 6 additions & 6 deletions bridge/standard/cmd/relayer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ var (
},
})

optionL1RPCUrl = altsrc.NewStringFlag(&cli.StringFlag{
Name: "l1-rpc-url",
Usage: "URL for L1 RPC",
EnvVars: []string{"STANDARD_BRIDGE_RELAYER_L1_RPC_URL"},
optionL1RPCUrls = altsrc.NewStringSliceFlag(&cli.StringSliceFlag{
Name: "l1-rpc-urls",
Usage: "URLs for L1 RPC",
EnvVars: []string{"STANDARD_BRIDGE_RELAYER_L1_RPC_URLS"},
Required: true,
})

Expand Down Expand Up @@ -158,7 +158,7 @@ func main() {
optionLogFmt,
optionLogLevel,
optionLogTags,
optionL1RPCUrl,
optionL1RPCUrls,
optionSettlementRPCUrl,
optionL1ContractAddr,
optionSettlementContractAddr,
Expand Down Expand Up @@ -219,7 +219,7 @@ func start(c *cli.Context) error {
Logger: logger,
HTTPPort: c.Int(optionHTTPPort.Name),
Signer: signer,
L1RPCURL: c.String(optionL1RPCUrl.Name),
L1RPCURLs: c.StringSlice(optionL1RPCUrls.Name),
L1GatewayContractAddr: common.HexToAddress(c.String(optionL1ContractAddr.Name)),
SettlementRPCURL: c.String(optionSettlementRPCUrl.Name),
SettlementContractAddr: common.HexToAddress(c.String(optionSettlementContractAddr.Name)),
Expand Down
14 changes: 7 additions & 7 deletions bridge/standard/pkg/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type Options struct {
Logger *slog.Logger
HTTPPort int
Signer keysigner.KeySigner
L1RPCURL string
L1RPCURLs []string
L1GatewayContractAddr common.Address
SettlementRPCURL string
SettlementContractAddr common.Address
Expand Down Expand Up @@ -100,7 +100,7 @@ func NewNode(opts *Options) (*Node, error) {
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel()

client, err := ethclient.DialContext(ctx, opts.L1RPCURL)
client, err := ethclient.DialContext(ctx, opts.L1RPCURLs[0])
if err != nil {
return nil, fmt.Errorf("failed to connect to the Ethereum node: %w", err)
}
Expand All @@ -125,7 +125,7 @@ func NewNode(opts *Options) (*Node, error) {
ctx,
"l1",
opts.Logger,
opts.L1RPCURL,
opts.L1RPCURLs,
opts.Signer,
opts.L1GatewayContractAddr,
l1Store,
Expand All @@ -139,7 +139,7 @@ func NewNode(opts *Options) (*Node, error) {
ctx,
"settlement",
opts.Logger,
opts.SettlementRPCURL,
[]string{opts.SettlementRPCURL},
opts.Signer,
opts.SettlementContractAddr,
settlementStore,
Expand Down Expand Up @@ -243,12 +243,12 @@ func (n *Node) createGatewayContract(
ctx context.Context,
component string,
logger *slog.Logger,
rpcURL string,
rpcURLs []string,
signer keysigner.KeySigner,
contractAddr common.Address,
st *store.Store,
) error {
client, err := ethclient.Dial(rpcURL)
client, err := ethclient.Dial(rpcURLs[0])
if err != nil {
return fmt.Errorf("failed to connect to the Ethereum node: %w", err)
}
Expand Down Expand Up @@ -288,7 +288,7 @@ func (n *Node) createGatewayContract(

wrappedClient, err := ethwrapper.NewClient(
logger.With("component", fmt.Sprintf("%s/ethwrapper", component)),
[]string{rpcURL},
rpcURLs,
opts...,
)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ job "{{ job.name }}" {
{{- end }}
{{- end }}
{% endraw %}
STANDARD_BRIDGE_RELAYER_L1_RPC_URL="{{ job.env['l1_rpc_url'] }}"
STANDARD_BRIDGE_RELAYER_L1_RPC_URLS="{{ job.env['l1_rpc_urls'] }}"
L1_CHAIN_ID="{{ job.env['l1_chain_id'] }}"
CONTRACTS_PATH="local/contracts"
ARTIFACT_OUT_PATH="local"
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/nomad/playbooks/variables/profiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ jobs:
to: 5433
env:
l1_chain_id: "{{ environments[env].chain_id }}"
l1_rpc_url: "{{ resolved_l1_rpc_urls.split(',')[0] }}"
l1_rpc_urls: "{{ resolved_l1_rpc_urls }}"

mev_commit_faucet: &mev_commit_faucet_job
name: mev-commit-faucet
Expand Down

0 comments on commit b7a79a4

Please sign in to comment.