Skip to content
Draft
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
16 changes: 12 additions & 4 deletions yarn-project/p2p/src/testbench/worker_client_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,16 @@ class WorkerClientManager {
* Note: We send the raw peerIdPrivateKey string instead of SecretValue
* because SecretValue.toJSON() returns '[Redacted]', losing the value.
* The worker must re-wrap it in SecretValue.
* We also omit priceBumpPercentage since it's a bigint and can't be
* serialized over IPC (which uses JSON under the hood).
*/
private createClientConfig(
clientIndex: number,
port: number,
otherNodes: string[],
): Omit<P2PConfig, 'peerIdPrivateKey'> & { peerIdPrivateKey: string } & Partial<ChainConfig> {
return {
): Omit<P2PConfig, 'peerIdPrivateKey' | 'priceBumpPercentage'> & { peerIdPrivateKey: string } & Partial<ChainConfig> {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { priceBumpPercentage: _, ...config } = {
...getP2PDefaultConfig(),
p2pEnabled: true,
peerIdPrivateKey: this.peerIdPrivateKeys[clientIndex],
Expand All @@ -96,15 +99,20 @@ class WorkerClientManager {
p2pPort: port,
bootstrapNodes: [...otherNodes],
...this.p2pConfig,
} as Omit<P2PConfig, 'peerIdPrivateKey'> & { peerIdPrivateKey: string } & Partial<ChainConfig>;
} as Record<string, unknown>;
return config as Omit<P2PConfig, 'peerIdPrivateKey' | 'priceBumpPercentage'> & {
peerIdPrivateKey: string;
} & Partial<ChainConfig>;
}

/**
* Spawns a worker process and returns a promise that resolves when the worker is ready.
* Config uses raw string for peerIdPrivateKey (not SecretValue) for IPC serialization.
*/
private spawnWorkerProcess(
config: Omit<P2PConfig, 'peerIdPrivateKey'> & { peerIdPrivateKey: string } & Partial<ChainConfig>,
config: Omit<P2PConfig, 'peerIdPrivateKey' | 'priceBumpPercentage'> & {
peerIdPrivateKey: string;
} & Partial<ChainConfig>,
clientIndex: number,
): [ChildProcess, Promise<void>] {
const useCompiled = existsSync(workerJsPath);
Expand Down
Loading