Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: rename prover CLI start command as proxy and make it default #6428

Merged
merged 3 commits into from
Feb 16, 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
2 changes: 1 addition & 1 deletion packages/prover/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ You can also invoke the package as binary.
```bash
npm -i g @lodestar/prover

lodestar-prover start \
lodestar-prover proxy \
--network sepolia \
--execution-rpc https://lodestar-sepoliarpc.chainsafe.io \
--mode rest \
Expand Down
5 changes: 4 additions & 1 deletion packages/prover/src/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import yargs from "yargs";
import {hideBin} from "yargs/helpers";
import {registerCommandToYargs} from "../utils/command.js";
import {getVersionData} from "../utils/version.js";
import {cmds} from "./cmds/index.js";
import {cmds, proverProxyStartCommand} from "./cmds/index.js";
import {globalOptions} from "./options.js";

const {version} = getVersionData();
Expand Down Expand Up @@ -48,6 +48,9 @@ export function getLodestarProverCli(): yargs.Argv {
registerCommandToYargs(prover, cmd);
}

// Register the proxy command as the default one
registerCommandToYargs(prover, {...proverProxyStartCommand, command: "*"});

// throw an error if we see an unrecognized cmd
prover.recommendCommands().strict();

Expand Down
1 change: 1 addition & 0 deletions packages/prover/src/cli/cmds/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {CliCommand} from "../../utils/command.js";
import {GlobalArgs} from "../options.js";
import {proverProxyStartCommand} from "./start/index.js";
export {proverProxyStartCommand} from "./start/index.js";

export const cmds: Required<CliCommand<GlobalArgs, Record<never, never>>>["subcommands"] = [proverProxyStartCommand];
2 changes: 1 addition & 1 deletion packages/prover/src/cli/cmds/start/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {proverProxyStartHandler} from "./handler.js";
import {StartArgs, startOptions} from "./options.js";

export const proverProxyStartCommand: CliCommand<StartArgs, GlobalArgs> = {
command: "start",
command: "proxy",
describe: "Start proxy server",
examples: [
{
Expand Down
12 changes: 6 additions & 6 deletions packages/prover/test/e2e/cli/cmds/start.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ import {rpcUrl, beaconUrl, proxyPort, proxyUrl, chainId, waitForCapellaFork, con

const cli = getLodestarProverCli();

describe("prover/start", () => {
describe("prover/proxy", () => {
it("should show help", async () => {
const output = await runCliCommand(cli, ["start", "--help"]);
const output = await runCliCommand(cli, ["proxy", "--help"]);

expect(output).toEqual(expect.stringContaining("Show help"));
});

it("should fail when --executionRpcUrl is missing", async () => {
await expect(runCliCommand(cli, ["start", "--port", "8088"])).rejects.toThrow(
await expect(runCliCommand(cli, ["proxy", "--port", "8088"])).rejects.toThrow(
"Missing required argument: executionRpcUrl"
);
});

it("should fail when --beaconUrls and --beaconBootnodes are provided together", async () => {
await expect(
runCliCommand(cli, [
"start",
"proxy",
"--beaconUrls",
"http://localhost:4000",
"--beaconBootnodes",
Expand All @@ -38,7 +38,7 @@ describe("prover/start", () => {

it("should fail when both of --beaconUrls and --beaconBootnodes are not provided", async () => {
await expect(
runCliCommand(cli, ["start", "--port", "8088", "--executionRpcUrl", "http://localhost:3000"])
runCliCommand(cli, ["proxy", "--port", "8088", "--executionRpcUrl", "http://localhost:3000"])
).rejects.toThrow("Either --beaconUrls or --beaconBootnodes must be provided");
});

Expand All @@ -55,7 +55,7 @@ describe("prover/start", () => {
proc = await spawnCliCommand(
"packages/prover/bin/lodestar-prover.js",
[
"start",
"proxy",
"--port",
String(proxyPort as number),
"--executionRpcUrl",
Expand Down
Loading