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

fix: update engine_getClientVersionV1 commit encoding #7282

Merged
merged 1 commit into from
Dec 6, 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
5 changes: 3 additions & 2 deletions packages/beacon-node/src/execution/engine/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {Logger} from "@lodestar/logger";
import {ForkName, ForkSeq, SLOTS_PER_EPOCH} from "@lodestar/params";
import {ExecutionPayload, ExecutionRequests, Root, RootHex, Wei} from "@lodestar/types";
import {BlobAndProof} from "@lodestar/types/deneb";
import {strip0xPrefix} from "@lodestar/utils";
import {
ErrorJsonRpcResponse,
HttpRpcError,
Expand Down Expand Up @@ -522,11 +523,11 @@ export class ExecutionEngineHttp implements IExecutionEngine {
const response = await this.rpc.fetchWithRetries<
EngineApiRpcReturnTypes[typeof method],
EngineApiRpcParamTypes[typeof method]
>({method, params: [clientVersion]});
>({method, params: [{...clientVersion, commit: `0x${clientVersion.commit}`}]});

const clientVersions = response.map((cv) => {
const code = cv.code in ClientCode ? ClientCode[cv.code as keyof typeof ClientCode] : ClientCode.XX;
return {code, name: cv.name, version: cv.version, commit: cv.commit};
return {code, name: cv.name, version: cv.version, commit: strip0xPrefix(cv.commit)};
});

if (clientVersions.length === 0) {
Expand Down
9 changes: 1 addition & 8 deletions packages/beacon-node/src/util/kzg.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from "node:fs";
import path from "node:path";
import {fileURLToPath} from "node:url";
import {fromHex, toHex} from "@lodestar/utils";
import {fromHex, strip0xPrefix, toHex} from "@lodestar/utils";

// "c-kzg" has hardcoded the mainnet value, do not use params
export const FIELD_ELEMENTS_PER_BLOB_MAINNET = 4096;
Expand Down Expand Up @@ -154,10 +154,3 @@ export function trustedSetupJsonToTxt(data: TrustedSetupJSON): TrustedSetupTXT {
...data.setup_G2.map(strip0xPrefix),
].join("\n");
}

function strip0xPrefix(hex: string): string {
if (hex.startsWith("0x")) {
return hex.slice(2);
}
return hex;
}
6 changes: 1 addition & 5 deletions packages/config/src/genesisConfig/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {DOMAIN_VOLUNTARY_EXIT, ForkName, SLOTS_PER_EPOCH} from "@lodestar/params";
import {DomainType, ForkDigest, Root, Slot, Version, phase0, ssz} from "@lodestar/types";
import {toHex} from "@lodestar/utils";
import {strip0xPrefix, toHex} from "@lodestar/utils";
import {ChainForkConfig} from "../beaconConfig.js";
import {CachedGenesis, ForkDigestHex} from "./types.js";
export type {ForkDigestContext} from "./types.js";
Expand Down Expand Up @@ -142,10 +142,6 @@ function toHexStringNoPrefix(hex: string | Uint8Array): string {
return strip0xPrefix(typeof hex === "string" ? hex : toHex(hex));
}

function strip0xPrefix(hex: string): string {
return hex.startsWith("0x") ? hex.slice(2) : hex;
}

function computeForkDigest(currentVersion: Version, genesisValidatorsRoot: Root): ForkDigest {
return computeForkDataRoot(currentVersion, genesisValidatorsRoot).slice(0, 4);
}
7 changes: 7 additions & 0 deletions packages/utils/src/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,10 @@ export function prettyMsToTime(timeMs: number): string {
const date = new Date(0, 0, 0, 0, 0, 0, timeMs);
return `${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}.${date.getMilliseconds()}`;
}

/**
* Remove 0x prefix from a string
*/
export function strip0xPrefix(hex: string): string {
return hex.startsWith("0x") ? hex.slice(2) : hex;
}
Loading