-
-
Notifications
You must be signed in to change notification settings - Fork 300
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: handle 0x prefix from execution client commit #7273
base: unstable
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## unstable #7273 +/- ##
============================================
- Coverage 48.51% 48.50% -0.01%
============================================
Files 600 600
Lines 40138 40138
Branches 2058 2057 -1
============================================
- Hits 19471 19470 -1
- Misses 20629 20630 +1
Partials 38 38 |
Performance Report✔️ no performance regression detected Full benchmark results
|
const {code: executionCode, commit: executionCommit} = executionClientVersion; | ||
let {code: executionCode, commit: executionCommit} = executionClientVersion; | ||
|
||
executionCommit = executionCommit.startsWith("0x") ? executionCommit.slice(2, 6) : executionCommit.slice(0, 4); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is there are 0x prefix in the first place? I think our deserialization is not correct, we also don't serialize it correctly according to #7217
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commit
has the type DATA
as per https://github.com/ethereum/execution-apis/blob/main/src/engine/identification.md#clientversionv1
DATA
type must be prepended by 0x
as per https://github.com/ethereum/execution-apis/blob/main/src/engine/common.md#encoding
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we also don't serialize it correctly according to #7217
Yea will address it in a separate PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DATA type must be prepended by 0x as per https://github.com/ethereum/execution-apis/blob/main/src/engine/common.md#encoding
but isn't that the encoding in transit, e.g. see parentHash
for example, it's bytes internally but will be hex encoded in transit
parentHash: bytesToData(data.parentHash), |
see data conversion functions
lodestar/packages/beacon-node/src/eth1/provider/utils.ts
Lines 101 to 119 in 84e0699
export function bytesToData(bytes: Uint8Array): DATA { | |
return toHex(bytes); | |
} | |
/** | |
* DATA as defined in ethereum execution layer JSON RPC https://eth.wiki/json-rpc/API | |
*/ | |
export function dataToBytes(hex: DATA, fixedLength: number | null): Uint8Array { | |
try { | |
const bytes = fromHex(hex); | |
if (fixedLength != null && bytes.length !== fixedLength) { | |
throw Error(`Wrong data length ${bytes.length} expected ${fixedLength}`); | |
} | |
return bytes; | |
} catch (e) { | |
(e as Error).message = `Invalid hex string: ${(e as Error).message}`; | |
throw e; | |
} | |
} |
Lodestar currently sets default graffiti containing execution client commit with 0x prefix eg.
GE0x2bLSae1f
.We should not include the prefix in the graffiti.