From 8e1cca890ff6a18b5efefd64334d2ea65691903c Mon Sep 17 00:00:00 2001 From: NC <17676176+ensi321@users.noreply.github.com> Date: Mon, 2 Dec 2024 17:21:05 -0800 Subject: [PATCH 1/2] Handle 0x case of execution client commit --- packages/beacon-node/src/util/graffiti.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/beacon-node/src/util/graffiti.ts b/packages/beacon-node/src/util/graffiti.ts index 9a4bc3d9689b..6551ba8d1f42 100644 --- a/packages/beacon-node/src/util/graffiti.ts +++ b/packages/beacon-node/src/util/graffiti.ts @@ -18,10 +18,12 @@ export function getDefaultGraffiti( } if (executionClientVersion != null) { - const {code: executionCode, commit: executionCommit} = executionClientVersion; + let {code: executionCode, commit: executionCommit} = executionClientVersion; + + executionCommit = executionCommit.startsWith("0x") ? executionCommit.slice(2, 6) : executionCommit.slice(0, 4); // Follow the 2-byte commit format in https://github.com/ethereum/execution-apis/pull/517#issuecomment-1918512560 - return `${executionCode}${executionCommit.slice(0, 4)}${consensusClientVersion.code}${consensusClientVersion.commit.slice(0, 4)}`; + return `${executionCode}${executionCommit}${consensusClientVersion.code}${consensusClientVersion.commit.slice(0, 4)}`; } // No EL client info available. We still want to include CL info albeit not spec compliant From 8d2e04649fa9971f57157eb53497a4ed0b73dd9e Mon Sep 17 00:00:00 2001 From: NC <17676176+ensi321@users.noreply.github.com> Date: Mon, 2 Dec 2024 18:13:24 -0800 Subject: [PATCH 2/2] Update unit test --- packages/beacon-node/test/unit/util/graffiti.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/beacon-node/test/unit/util/graffiti.test.ts b/packages/beacon-node/test/unit/util/graffiti.test.ts index 89750d423790..6477d72dc733 100644 --- a/packages/beacon-node/test/unit/util/graffiti.test.ts +++ b/packages/beacon-node/test/unit/util/graffiti.test.ts @@ -29,7 +29,7 @@ describe("Graffiti helper", () => { }); describe("getDefaultGraffiti", () => { - const executionClientVersion = {code: ClientCode.BU, name: "Besu", version: "24.1.1", commit: "9b0e38fa"}; + const executionClientVersion = {code: ClientCode.BU, name: "Besu", version: "24.1.1", commit: "0x9b0e38fa"}; const consensusClientVersion = { code: ClientCode.LS, name: "Lodestar",