Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ensi321 committed Oct 24, 2023
1 parent 20dcfec commit fef1859
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
5 changes: 2 additions & 3 deletions packages/beacon-node/src/eth1/provider/jsonRpcHttpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ export class JsonRpcHttpClient implements IJsonRpcHttpClient {
jwtSecret?: Uint8Array;
/** If jwtSecret and jwtId are provided, jwtId will be included in JwtClaim.id */
jwtId?: string;
/** If jwtSecret is provided, jwtVersion will be included in JwtClaim.clv.
* jwtVersion has default value of empty string */
/** If jwtSecret and jwtVersion are provided, jwtVersion will be included in JwtClaim.clv. */
jwtVersion?: string;
/** Retry attempts */
retryAttempts?: number;
Expand All @@ -133,7 +132,7 @@ export class JsonRpcHttpClient implements IJsonRpcHttpClient {

this.jwtSecret = opts?.jwtSecret;
this.jwtId = opts?.jwtId;
this.jwtVersion = opts?.jwtVersion ?? "";
this.jwtVersion = opts?.jwtVersion;
this.metrics = opts?.metrics ?? null;

this.metrics?.configUrlsCount.set(urls.length);
Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-node/test/unit/eth1/jwt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe("ExecutionEngine / jwt", () => {

it("encode/decode correctly with id and clv", () => {
const jwtSecret = Buffer.from(Array.from({length: 32}, () => Math.round(Math.random() * 255)));
const claim = {iat: Math.floor(new Date().getTime() / 1000), id: "4ac0", clv: "v1.11.3"};
const claim = {iat: Math.floor(new Date().getTime() / 1000), id: "4ac0", clv: "Lodestar/v0.36.0/80c248bb"};
const token = encodeJwtToken(claim, jwtSecret);
const decoded = decodeJwtToken(token, jwtSecret);
expect(decoded).toEqual(claim);
Expand Down
10 changes: 5 additions & 5 deletions packages/cli/src/cmds/beacon/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,14 @@ export async function beaconHandlerInit(args: BeaconArgs & GlobalArgs) {
if (args.private) {
beaconNodeOptions.set({network: {private: true}});
} else {
const versionStr = `Lodestar/${version}`;
const simpleVersionStr = version.split("/")[0];
// Add simple version string for libp2p agent version
beaconNodeOptions.set({network: {version: version.split("/")[0]}});
beaconNodeOptions.set({network: {version: simpleVersionStr}});
// Add User-Agent header to all builder requests
beaconNodeOptions.set({executionBuilder: {userAgent: `Lodestar/${version}`}});
beaconNodeOptions.set({executionBuilder: {userAgent: versionStr}});
// Set jwt version with version string
beaconNodeOptions.set({executionEngine: {jwtVersion: `Lodestar/${version}`}});
// Set jwt version with version string
beaconNodeOptions.set({eth1: {jwtVersion: `Lodestar/${version}`}});
beaconNodeOptions.set({executionEngine: {jwtVersion: versionStr}, eth1: {jwtVersion: versionStr}});
}

// Render final options
Expand Down
1 change: 0 additions & 1 deletion packages/cli/src/options/beaconNodeOptions/eth1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export type Eth1Args = {
export function parseArgs(args: Eth1Args & Partial<ExecutionEngineArgs>): IBeaconNodeOptions["eth1"] {
let jwtSecretHex: string | undefined;
let jwtId: string | undefined;
let jwtVersion: string | undefined;

let providerUrls = args["eth1.providerUrls"];

Expand Down

0 comments on commit fef1859

Please sign in to comment.