Skip to content

Commit

Permalink
feat: Make l2 rpc url required to start hubble ahead of mainnet migra…
Browse files Browse the repository at this point in the history
…tion (#1286)

* feat: Make l2 rpc url required to start hubble ahead of mainnet migration

* Fix build
  • Loading branch information
sanjayprabhu authored Aug 23, 2023
1 parent 930d863 commit be6ee3c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/new-penguins-end.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@farcaster/hubble": minor
---

feat: Make l2 rpc url required to start hubble ahead of mainnet migration
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:

- name: Run Hubble
shell: bash
run: docker run --name hub --detach -p2282:2282 -p2283:2283 farcasterxyz/hubble:test sh -c 'node build/cli.js identity create && node build/cli.js start --rpc-port 2283 --ip 0.0.0.0 --gossip-port 2282 --eth-rpc-url "https://eth-goerli.g.alchemy.com/v2/IvjMoCKt1hT66f9OJoL_dMXypnvQYUdd" --eth-mainnet-rpc-url "https://eth-mainnet.g.alchemy.com/v2/8cz__IXnQ5FK_GNYDlfooLzYhBAW7ta0" --network 3 --allowed-peers none'
run: docker run --name hub --detach -p2282:2282 -p2283:2283 farcasterxyz/hubble:test sh -c 'node build/cli.js identity create && node build/cli.js start --rpc-port 2283 --ip 0.0.0.0 --gossip-port 2282 --eth-rpc-url "https://eth-goerli.g.alchemy.com/v2/IvjMoCKt1hT66f9OJoL_dMXypnvQYUdd" --eth-mainnet-rpc-url "https://eth-mainnet.g.alchemy.com/v2/8cz__IXnQ5FK_GNYDlfooLzYhBAW7ta0" --l2-rpc-url "https://opt-mainnet.g.alchemy.com/v2/3xWX-cWV-an3IPXmVCRXX51PpQzc-8iJ" --network 3 --allowed-peers none'

- name: Download grpcurl
shell: bash
Expand Down
8 changes: 7 additions & 1 deletion apps/hubble/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,13 @@ app

await startupCheck.rpcCheck(options.ethRpcUrl, goerli, "L1");
await startupCheck.rpcCheck(options.ethMainnetRpcUrl, mainnet, "L1");
await startupCheck.rpcCheck(options.l2RpcUrl, optimism, "L2");
await startupCheck.rpcCheck(options.l2RpcUrl, optimism, "L2", options.l2ChainId);

if (startupCheck.anyFailedChecks()) {
logger.fatal({ reason: "Startup checks failed" }, "shutting down hub");
logger.flush();
process.exit(1);
}

const hubResult = Result.fromThrowable(
() => new Hub(options),
Expand Down
3 changes: 2 additions & 1 deletion apps/hubble/src/hubble.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,8 @@ export class Hub implements HubInterface {
options.l2RentExpiryOverride,
);
} else {
log.warn("No L2 RPC URL provided, not syncing with L2 contract events");
log.warn("No L2 RPC URL provided, unable to sync L2 contract events");
throw new HubError("bad_request.invalid_param", "Invalid l2 rpc url");
}

if (options.fnameServerUrl && options.fnameServerUrl !== "") {
Expand Down
10 changes: 8 additions & 2 deletions apps/hubble/src/utils/startupCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,13 @@ class StartupCheck {
}
}

async rpcCheck(rpcUrl: string | undefined, chain: Chain, prefix = "", status = StartupCheckStatus.ERROR) {
async rpcCheck(
rpcUrl: string | undefined,
chain: Chain,
prefix = "",
chainId?: number,
status = StartupCheckStatus.ERROR,
) {
const type = chain.name;
if (!rpcUrl) {
this.printStartupCheckStatus(
Expand All @@ -82,7 +88,7 @@ class StartupCheck {
// Check that the publicClient is reachable and returns the goerli chainId
const chainIdResult = await ResultAsync.fromPromise(publicClient.getChainId(), (err) => err);

if (chainIdResult.isErr() || chainIdResult.value !== chain.id) {
if (chainIdResult.isErr() || chainIdResult.value !== (chainId ?? chain.id)) {
console.log(chainIdResult);
this.printStartupCheckStatus(
status,
Expand Down

0 comments on commit be6ee3c

Please sign in to comment.