Skip to content

Client: (WIP) rework CLI startup logic using RpcConfig (#3983) #4013

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

ether-wan
Copy link

@ether-wan ether-wan commented Apr 23, 2025

This PR starts addressing #3983 by refactoring the client CLI

Description

  • Introduced a new RpcConfig class for RPC endpoints (eth/engine, http/ws)
  • Added a generateRpcConfigs() func to generate all server configurations from CLI args
  • Refactored startRPCServers() to use these configs instead of cli args
  • Removed repeated logic for creating, starting and logging HTTP/WS servers
  • Split the run() function to improve testability:
    • run() now handles only CLI argument parsing, config generation, and dispatch
    • New startClientAndServers() function performs the client and RPC server startup
    • This split improves separation of concerns and makes the CLI flow easier to test

This is still a work in progress — if the current structure looks good, I’ll follow up with unit tests for the new helpers and config logic in a separate commit!

const opts: any = {
rpcCors,
if (rpcConfig.transport === 'ws') {
const wsOpts: any = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to add typing for this instead of casting to any?


export type RPCNamespace = (typeof RPCNamespace)[keyof typeof RPCNamespace]

export const RPCTransport = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the keys of this mapping and similar ones, we can switch to using lowercase key names, like here.

public static readonly DEFAULT_WS_ENGINE_ADDR = '0.0.0.0'
public static readonly DEFAULT_RPC_PORT = 8545
public static readonly DEFAULT_ENGINE_PORT = 8551
public static readonly DEFAULT_WS_PORT = 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the default websocket port is 8546 and other defaults should be likely made consistent with any defaults that already exist in getArgs

Copy link

codecov bot commented May 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.90%. Comparing base (7d60a4f) to head (995587c).

Additional details and impacted files

Impacted file tree graph

Flag Coverage Δ
block 84.33% <ø> (ø)
blockchain ?
client ?
common 97.51% <ø> (ø)
devp2p ?
evm ?
mpt ?
statemanager 69.06% <ø> (ø)
static 99.11% <ø> (ø)
tx ?
util ?
vm ?

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@am1r021
Copy link
Contributor

am1r021 commented May 13, 2025

This seems to be heading in the right direction, but make sure to work in small chunks and check the CI to catch any issues or bugs early and respond to them iteratively.

@ether-wan
Copy link
Author

his seems to be heading in the right direction

Thank you! I'll look into it asap

@@ -14,7 +14,7 @@ import { LevelDB } from '../src/execution/level.ts'
import { generateVKTStateRoot } from '../src/util/vkt.ts'

import { helpRPC, startRPCServers } from './startRPC.ts'
import { generateClientConfig, getArgs } from './utils.ts'
import { generateClientConfig, generateRpcConfigs, getArgs } from './utils.ts'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generateRpcConfigs -> generateRpcConfig (so: without the s)

to align with generateClientConfig

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(also further down the line there are a few Configs, can you please also rename consistently? Thanks! (we are a bit picky on naming things 🙂 ))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants