-
-
Notifications
You must be signed in to change notification settings - Fork 460
feat: implement EIP 7688 #9390
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
base: unstable
Are you sure you want to change the base?
feat: implement EIP 7688 #9390
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,9 +10,8 @@ import { | |
| MIN_SYNC_COMMITTEE_PARTICIPANTS, | ||
| SLOTS_PER_EPOCH, | ||
| SYNC_COMMITTEE_SIZE, | ||
| forkPostAltair, | ||
| highestFork, | ||
| isForkPostElectra, | ||
| isForkPostGloas, | ||
| } from "@lodestar/params"; | ||
| import { | ||
| type IBeaconStateViewAltair, | ||
|
|
@@ -44,7 +43,6 @@ import { | |
| electra, | ||
| phase0, | ||
| ssz, | ||
| sszTypesFor, | ||
| } from "@lodestar/types"; | ||
| import {Logger, MapDef, byteArrayEquals, pruneSetToMax, toRootHex} from "@lodestar/utils"; | ||
| import {ZERO_HASH} from "../../constants/index.js"; | ||
|
|
@@ -230,8 +228,8 @@ export class LightClientServer { | |
| this.signal = signal; | ||
|
|
||
| this.zero = { | ||
| // Assign the hightest fork's default value because it can always be typecasted down to correct fork | ||
| finalizedHeader: sszTypesFor(highestFork(forkPostAltair)).LightClientHeader.defaultValue(), | ||
| // Assign the highest pre-Gloas light-client header because post-Gloas light-client updates are skipped for now. | ||
| finalizedHeader: ssz.electra.LightClientHeader.defaultValue(), | ||
| // Electra finalityBranch has fixed length of 5 whereas altair has 4. The fifth element will be ignored | ||
| // when serializing as altair LightClientUpdate | ||
| finalityBranch: ssz.electra.LightClientUpdate.fields.finalityBranch.defaultValue(), | ||
|
|
@@ -658,10 +656,17 @@ export class LightClientServer { | |
|
|
||
| const attestedFork = this.config.getForkName(attestedHeader.beacon.slot); | ||
| const numWitness = syncCommitteeWitness.witness.length; | ||
| if (isForkPostElectra(attestedFork) && numWitness !== NUM_WITNESS_ELECTRA) { | ||
| if ( | ||
| isForkPostGloas(attestedFork) && | ||
| (syncCommitteeWitness.currentSyncCommitteeBranch === undefined || | ||
| syncCommitteeWitness.nextSyncCommitteeBranch === undefined) | ||
| ) { | ||
| throw Error("Expected post-Gloas sync committee branches"); | ||
| } | ||
| if (!isForkPostGloas(attestedFork) && isForkPostElectra(attestedFork) && numWitness !== NUM_WITNESS_ELECTRA) { | ||
| throw Error(`Expected ${NUM_WITNESS_ELECTRA} witnesses in post-Electra numWitness=${numWitness}`); | ||
| } | ||
| if (!isForkPostElectra(attestedFork) && numWitness !== NUM_WITNESS) { | ||
| if (!isForkPostGloas(attestedFork) && !isForkPostElectra(attestedFork) && numWitness !== NUM_WITNESS) { | ||
| throw Error(`Expected ${NUM_WITNESS} witnesses in pre-Electra numWitness=${numWitness}`); | ||
| } | ||
|
Comment on lines
+659
to
671
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The logic for validating if (isForkPostGloas(attestedFork)) {
if (
syncCommitteeWitness.currentSyncCommitteeBranch === undefined ||
syncCommitteeWitness.nextSyncCommitteeBranch === undefined
) {
throw Error("Expected post-Gloas sync committee branches");
}
if (numWitness !== 0) {
throw Error(`Expected 0 witnesses in post-Gloas numWitness=${numWitness}`);
}
} else if (isForkPostElectra(attestedFork)) {
if (numWitness !== NUM_WITNESS_ELECTRA) {
throw Error(`Expected ${NUM_WITNESS_ELECTRA} witnesses in post-Electra numWitness=${numWitness}`);
}
} else if (numWitness !== NUM_WITNESS) {
throw Error(`Expected ${NUM_WITNESS} witnesses in pre-Electra numWitness=${numWitness}`);
} |
||
|
|
||
|
|
||
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.
The
finalizedHeaderis hardcoded tossz.electra.LightClientHeader.defaultValue(). While the comment mentions that post-Gloas updates are skipped for now, this PR introduces Gloas light-client header support and upgrades. It would be more consistent and forward-compatible to use the highest fork's default value or explicitly handle Gloas if the server is intended to support it eventually.