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

feat: rebased electra branch - DONOTMERGE just for testing/CI #6899

Closed
wants to merge 51 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
9b71394
feat: placeholder PR for electra
g11tech Jan 24, 2024
d3f59cc
feat: implement EIP-6110 (#6042)
ensi321 Feb 19, 2024
c2aadf5
chore: fix CI failure due to recent merge from `unstable` (#6646)
ensi321 Apr 12, 2024
ade5c5d
feat: implement execution layer exits eip 7002 (#6651)
g11tech Apr 22, 2024
507d94d
chore: update spec test version for electra fork (#6717)
ensi321 May 1, 2024
ea52e9d
feat: add presets and ssz types for EIP-7549 (#6715)
ensi321 May 4, 2024
929e49e
chore: fix the rebase build (#6735)
g11tech May 4, 2024
2b8866d
feat: upgrade 7002 exits to withdrawal request (#6736)
g11tech May 5, 2024
6ae385a
feat: implement maxEB EIP-7251 (#6539)
ensi321 May 7, 2024
86b15bc
feat: beacon node process electra attestations EIP-7549 (#6738)
ensi321 May 7, 2024
7050f8e
feat: handle the EL payload sending data in deposit requests instead …
g11tech May 8, 2024
825f488
feat: implement EIP-7549 (#6689)
ensi321 May 8, 2024
1705888
fix: attestation pool for electra (#6744)
twoeths May 8, 2024
6c34113
feat: update engineapi endpoints to v4 (#6747)
g11tech May 8, 2024
a046aef
feat: rename deposit receipt to deposit request for Pectra (#6748)
ensi321 May 8, 2024
5c1fb95
test: enable spec tests related to eip-7549 (#6741)
nazarhussain May 8, 2024
e7abb89
fix: fix e2e test in electra-fork (#6751)
ensi321 May 8, 2024
d4dd8da
feat: get the basic integration working with the ethereumjs electra b…
g11tech May 8, 2024
aed7d7f
feat: apply some fixes and hacks to get the single node devnet workin…
g11tech May 9, 2024
14695b5
fix: get aggregate and proofs signature sets (#6757)
twoeths May 10, 2024
4a55211
test(spec): fix attestors slashing specs for electra fork (#6758)
nazarhussain May 10, 2024
fda27b8
chore: fix types and lint (#6750)
g11tech May 13, 2024
96f7701
fix: fix electra genesis spec test (#6764)
ensi321 May 14, 2024
41b857a
feat: support missing electra spec test (#6765)
ensi321 May 14, 2024
4fc06af
test: fix ssz types in fork_choice spec tests (#6767)
nflaig May 14, 2024
27cf29a
chore: update EffectiveBalanceIncrements type (#6763)
jeluard May 14, 2024
c476b94
Fix ssz_static
ensi321 May 14, 2024
0707a60
fix: inline sourcemaps to help with debugging (#6768)
matthewkeil May 14, 2024
4b8a315
fix: additional epoch calculation logic for consolidation churn (#6770)
nazarhussain May 14, 2024
4f99b2e
fix: electra fork transition spec tests (#6769)
twoeths May 14, 2024
5b80b00
test: fix ssz_static spec tests for all forks (#6771)
nflaig May 14, 2024
f814364
chore(spec): remove the skip specs for electra (#6772)
nazarhussain May 14, 2024
d1b5769
fix: use mutable validator object (#6774)
ensi321 May 14, 2024
baeb740
test: fix balance spec tests (#6777)
matthewkeil May 14, 2024
8d18fbd
fix: effective balance cache is not in sync with validator effective …
ensi321 May 14, 2024
0668076
fix: make electra-fork passes lint and check-types (#6785)
ensi321 May 16, 2024
f0dc964
fix: update data format of WithdrawalRequestV1 (#6789)
nflaig May 16, 2024
ef4092c
fix: publish attestations with non-zero committee index (#6790)
ensi321 May 16, 2024
cb6b706
fix: validator monitor summaries should not render during epoch 0 (#6…
ensi321 May 16, 2024
81b993a
fix: attestation duty validation (#6792)
ensi321 May 16, 2024
e78ee55
fix: align BeaconBlockBody and BlindedBeaconBlockBody (#6782)
wemeetagain May 16, 2024
fdefed8
test: improve ssz tests consistency (#6776)
jeluard May 16, 2024
22a2980
fix: batch validation for electra attestations (#6788)
twoeths May 16, 2024
29f066b
fix: update withdrawal request container to match consensus spec (#6797)
nflaig May 16, 2024
65627c1
fix: get seen AttData key from SignedAggregateAndProof electra (#6802)
twoeths May 17, 2024
aadd017
test: only skip ssz_static tests associated to missing type (#6798)
nflaig May 23, 2024
4ab68ae
chore: types and lint fixes (#6819)
g11tech May 25, 2024
03da487
feat: add engine_getPayloadBodiesByHash and ByRange V2 (#6852)
ensi321 Jun 8, 2024
2476698
fix: align WithdrawalRequestV1 field names with latest spec (#6877)
nflaig Jun 12, 2024
4239f72
feat: move attestation committee at the end of attestation (#6883)
ensi321 Jun 14, 2024
4f800e5
rebase fixes
g11tech Jun 19, 2024
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
2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
},
"dependencies": {
"@chainsafe/persistent-merkle-tree": "^0.7.1",
"@chainsafe/ssz": "^0.15.1",
"@chainsafe/ssz": "^0.16.0",
"@lodestar/config": "^1.19.0",
"@lodestar/params": "^1.19.0",
"@lodestar/types": "^1.19.0",
Expand Down
73 changes: 62 additions & 11 deletions packages/api/src/beacon/routes/beacon/pool.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable @typescript-eslint/naming-convention */
import {ValueOf} from "@chainsafe/ssz";
import {ChainForkConfig} from "@lodestar/config";
import {ForkSeq} from "@lodestar/params";
import {phase0, capella, CommitteeIndex, Slot, ssz} from "@lodestar/types";
import {Schema, Endpoint, RouteDefinitions} from "../../../utils/index.js";
import {
Expand All @@ -12,18 +13,25 @@ import {
EmptyRequest,
EmptyResponseCodec,
EmptyResponseData,
WithVersion,
} from "../../../utils/codecs.js";
import {MetaHeader, VersionCodec, VersionMeta} from "../../../utils/metadata.js";
import {toForkName} from "../../../utils/fork.js";
import {fromHeaders} from "../../../utils/headers.js";

// See /packages/api/src/routes/index.ts for reasoning and instructions to add new routes

const AttestationListType = ArrayOf(ssz.phase0.Attestation);
const AttestationListTypePhase0 = ArrayOf(ssz.phase0.Attestation);
const AttestationListTypeElectra = ArrayOf(ssz.electra.Attestation);
const AttesterSlashingListType = ArrayOf(ssz.phase0.AttesterSlashing);
const ProposerSlashingListType = ArrayOf(ssz.phase0.ProposerSlashing);
const SignedVoluntaryExitListType = ArrayOf(ssz.phase0.SignedVoluntaryExit);
const SignedBLSToExecutionChangeListType = ArrayOf(ssz.capella.SignedBLSToExecutionChange);
const SyncCommitteeMessageListType = ArrayOf(ssz.altair.SyncCommitteeMessage);

type AttestationList = ValueOf<typeof AttestationListType>;
type AttestationListPhase0 = ValueOf<typeof AttestationListTypePhase0>;
type AttestationListElectra = ValueOf<typeof AttestationListTypeElectra>;
type AttestationList = AttestationListPhase0 | AttestationListElectra;
type AttesterSlashingList = ValueOf<typeof AttesterSlashingListType>;
type ProposerSlashingList = ValueOf<typeof ProposerSlashingListType>;
type SignedVoluntaryExitList = ValueOf<typeof SignedVoluntaryExitListType>;
Expand All @@ -40,7 +48,7 @@ export type Endpoints = {
{slot?: Slot; committeeIndex?: CommitteeIndex},
{query: {slot?: number; committee_index?: number}},
AttestationList,
EmptyMeta
VersionMeta
>;

/**
Expand Down Expand Up @@ -106,7 +114,7 @@ export type Endpoints = {
submitPoolAttestations: Endpoint<
"POST",
{signedAttestations: AttestationList},
{body: unknown},
{body: unknown; headers: {[MetaHeader.Version]: string}},
EmptyResponseData,
EmptyMeta
>;
Expand Down Expand Up @@ -172,7 +180,7 @@ export type Endpoints = {
>;
};

export function getDefinitions(_config: ChainForkConfig): RouteDefinitions<Endpoints> {
export function getDefinitions(config: ChainForkConfig): RouteDefinitions<Endpoints> {
return {
getPoolAttestations: {
url: "/eth/v1/beacon/pool/attestations",
Expand All @@ -183,8 +191,10 @@ export function getDefinitions(_config: ChainForkConfig): RouteDefinitions<Endpo
schema: {query: {slot: Schema.Uint, committee_index: Schema.Uint}},
},
resp: {
data: AttestationListType,
meta: EmptyMetaCodec,
data: WithVersion((fork) =>
ForkSeq[fork] >= ForkSeq.electra ? AttestationListTypeElectra : AttestationListTypePhase0
),
meta: VersionCodec,
},
},
getPoolAttesterSlashings: {
Expand Down Expand Up @@ -227,12 +237,53 @@ export function getDefinitions(_config: ChainForkConfig): RouteDefinitions<Endpo
url: "/eth/v1/beacon/pool/attestations",
method: "POST",
req: {
writeReqJson: ({signedAttestations}) => ({body: AttestationListType.toJson(signedAttestations)}),
parseReqJson: ({body}) => ({signedAttestations: AttestationListType.fromJson(body)}),
writeReqSsz: ({signedAttestations}) => ({body: AttestationListType.serialize(signedAttestations)}),
parseReqSsz: ({body}) => ({signedAttestations: AttestationListType.deserialize(body)}),
writeReqJson: ({signedAttestations}) => {
const fork = config.getForkName(signedAttestations[0].data.slot);
return {
body:
ForkSeq[fork] >= ForkSeq.electra
? AttestationListTypeElectra.toJson(signedAttestations as AttestationListElectra)
: AttestationListTypePhase0.toJson(signedAttestations as AttestationListPhase0),
headers: {[MetaHeader.Version]: fork},
};
},
parseReqJson: ({body, headers}) => {
const versionHeader = fromHeaders(headers, MetaHeader.Version, false);
const fork =
versionHeader !== undefined
? toForkName(versionHeader)
: config.getForkName(Number((body as {data: {slot: string}}[])[0]?.data.slot ?? 0));
g11tech marked this conversation as resolved.
Show resolved Hide resolved

return {
signedAttestations:
ForkSeq[fork] >= ForkSeq.electra
? AttestationListTypeElectra.fromJson(body)
: AttestationListTypePhase0.fromJson(body),
};
},
writeReqSsz: ({signedAttestations}) => {
const fork = config.getForkName(signedAttestations[0].data.slot);
return {
body:
ForkSeq[fork] >= ForkSeq.electra
? AttestationListTypeElectra.serialize(signedAttestations as AttestationListElectra)
: AttestationListTypePhase0.serialize(signedAttestations as AttestationListPhase0),
headers: {[MetaHeader.Version]: fork},
};
},
parseReqSsz: ({body, headers}) => {
const versionHeader = fromHeaders(headers, MetaHeader.Version, true);
const fork = toForkName(versionHeader);
return {
signedAttestations:
ForkSeq[fork] >= ForkSeq.electra
? AttestationListTypeElectra.deserialize(body)
: AttestationListTypePhase0.deserialize(body),
};
},
schema: {
body: Schema.ObjectArray,
headers: {[MetaHeader.Version]: Schema.String},
},
},
resp: EmptyResponseCodec,
Expand Down
8 changes: 4 additions & 4 deletions packages/api/src/beacon/routes/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ export type EventData = {
block: RootHex;
executionOptimistic: boolean;
};
[EventType.attestation]: phase0.Attestation;
[EventType.attestation]: {version: ForkName; data: allForks.Attestation};
g11tech marked this conversation as resolved.
Show resolved Hide resolved
[EventType.voluntaryExit]: phase0.SignedVoluntaryExit;
[EventType.proposerSlashing]: phase0.ProposerSlashing;
[EventType.attesterSlashing]: phase0.AttesterSlashing;
[EventType.attesterSlashing]: {version: ForkName; data: allForks.AttesterSlashing};
[EventType.blsToExecutionChange]: capella.SignedBLSToExecutionChange;
[EventType.finalizedCheckpoint]: {
block: RootHex;
Expand Down Expand Up @@ -212,10 +212,10 @@ export function getTypeByEvent(): {[K in EventType]: TypeJson<EventData[K]>} {
{jsonCase: "eth2"}
),

[EventType.attestation]: ssz.phase0.Attestation,
[EventType.attestation]: WithVersion((fork) => (ssz.allForks[fork] as allForks.AllForksSSZTypes).Attestation),
[EventType.voluntaryExit]: ssz.phase0.SignedVoluntaryExit,
[EventType.proposerSlashing]: ssz.phase0.ProposerSlashing,
[EventType.attesterSlashing]: ssz.phase0.AttesterSlashing,
[EventType.attesterSlashing]: WithVersion((fork) => ssz.allForks[fork].AttesterSlashing),
[EventType.blsToExecutionChange]: ssz.capella.SignedBLSToExecutionChange,

[EventType.finalizedCheckpoint]: new ContainerType(
Expand Down
108 changes: 86 additions & 22 deletions packages/api/src/beacon/routes/validator.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/naming-convention */
import {ContainerType, fromHexString, toHexString, Type, ValueOf} from "@chainsafe/ssz";
import {ChainForkConfig} from "@lodestar/config";
import {isForkBlobs} from "@lodestar/params";
import {isForkBlobs, ForkSeq} from "@lodestar/params";
import {
allForks,
altair,
Expand Down Expand Up @@ -40,6 +40,7 @@ import {
VersionMeta,
VersionType,
} from "../../utils/metadata.js";
import {fromHeaders} from "../../utils/headers.js";

// See /packages/api/src/routes/index.ts for reasoning and instructions to add new routes

Expand Down Expand Up @@ -207,7 +208,8 @@ export const ValidatorIndicesType = ArrayOf(ssz.ValidatorIndex);
export const AttesterDutyListType = ArrayOf(AttesterDutyType);
export const ProposerDutyListType = ArrayOf(ProposerDutyType);
export const SyncDutyListType = ArrayOf(SyncDutyType);
export const SignedAggregateAndProofListType = ArrayOf(ssz.phase0.SignedAggregateAndProof);
export const SignedAggregateAndProofListPhase0Type = ArrayOf(ssz.phase0.SignedAggregateAndProof);
export const SignedAggregateAndProofListElectaType = ArrayOf(ssz.electra.SignedAggregateAndProof);
export const SignedContributionAndProofListType = ArrayOf(ssz.altair.SignedContributionAndProof);
export const BeaconCommitteeSubscriptionListType = ArrayOf(BeaconCommitteeSubscriptionType);
export const SyncCommitteeSubscriptionListType = ArrayOf(SyncCommitteeSubscriptionType);
Expand All @@ -224,7 +226,9 @@ export type ProposerDuty = ValueOf<typeof ProposerDutyType>;
export type ProposerDutyList = ValueOf<typeof ProposerDutyListType>;
export type SyncDuty = ValueOf<typeof SyncDutyType>;
export type SyncDutyList = ValueOf<typeof SyncDutyListType>;
export type SignedAggregateAndProofList = ValueOf<typeof SignedAggregateAndProofListType>;
export type SignedAggregateAndProofListPhase0 = ValueOf<typeof SignedAggregateAndProofListPhase0Type>;
export type SignedAggregateAndProofListElecta = ValueOf<typeof SignedAggregateAndProofListElectaType>;
export type SignedAggregateAndProofList = SignedAggregateAndProofListPhase0 | SignedAggregateAndProofListElecta;
export type SignedContributionAndProofList = ValueOf<typeof SignedContributionAndProofListType>;
export type BeaconCommitteeSubscription = ValueOf<typeof BeaconCommitteeSubscriptionType>;
export type BeaconCommitteeSubscriptionList = ValueOf<typeof BeaconCommitteeSubscriptionListType>;
Expand Down Expand Up @@ -424,10 +428,11 @@ export type Endpoints = {
/** HashTreeRoot of AttestationData that validator want's aggregated */
attestationDataRoot: Root;
slot: Slot;
committeeIndex: number;
},
{query: {attestation_data_root: string; slot: number}},
phase0.Attestation,
EmptyMeta
{query: {attestation_data_root: string; slot: number; committeeIndex: number}},
allForks.Attestation,
VersionMeta
>;

/**
Expand All @@ -437,7 +442,7 @@ export type Endpoints = {
publishAggregateAndProofs: Endpoint<
"POST",
{signedAggregateAndProofs: SignedAggregateAndProofList},
{body: unknown},
{body: unknown; headers: {[MetaHeader.Version]: string}},
EmptyResponseData,
EmptyMeta
>;
Expand Down Expand Up @@ -554,7 +559,7 @@ export type Endpoints = {
>;
};

export function getDefinitions(_config: ChainForkConfig): RouteDefinitions<Endpoints> {
export function getDefinitions(config: ChainForkConfig): RouteDefinitions<Endpoints> {
return {
getAttesterDuties: {
url: "/eth/v1/validator/duties/attester/{epoch}",
Expand Down Expand Up @@ -846,33 +851,92 @@ export function getDefinitions(_config: ChainForkConfig): RouteDefinitions<Endpo
url: "/eth/v1/validator/aggregate_attestation",
method: "GET",
req: {
writeReq: ({attestationDataRoot, slot}) => ({
query: {attestation_data_root: toHexString(attestationDataRoot), slot},
writeReq: ({attestationDataRoot, slot, committeeIndex}) => ({
query: {attestation_data_root: toHexString(attestationDataRoot), slot, committeeIndex},
}),
parseReq: ({query}) => ({
attestationDataRoot: fromHexString(query.attestation_data_root),
slot: query.slot,
committeeIndex: query.committeeIndex,
}),
parseReq: ({query}) => ({attestationDataRoot: fromHexString(query.attestation_data_root), slot: query.slot}),
schema: {
query: {attestation_data_root: Schema.StringRequired, slot: Schema.UintRequired},
query: {
attestation_data_root: Schema.StringRequired,
slot: Schema.UintRequired,
committeeIndex: Schema.UintRequired,
},
},
},
resp: {
data: ssz.phase0.Attestation,
meta: EmptyMetaCodec,
data: WithVersion((fork) =>
ForkSeq[fork] >= ForkSeq.electra ? ssz.electra.Attestation : ssz.phase0.Attestation
),
meta: VersionCodec,
},
},
publishAggregateAndProofs: {
url: "/eth/v1/validator/aggregate_and_proofs",
method: "POST",
req: {
writeReqJson: ({signedAggregateAndProofs}) => ({
body: SignedAggregateAndProofListType.toJson(signedAggregateAndProofs),
}),
parseReqJson: ({body}) => ({signedAggregateAndProofs: SignedAggregateAndProofListType.fromJson(body)}),
writeReqSsz: ({signedAggregateAndProofs}) => ({
body: SignedAggregateAndProofListType.serialize(signedAggregateAndProofs),
}),
parseReqSsz: ({body}) => ({signedAggregateAndProofs: SignedAggregateAndProofListType.deserialize(body)}),
writeReqJson: ({signedAggregateAndProofs}) => {
const fork = config.getForkName(signedAggregateAndProofs[0]?.message.aggregate.data.slot ?? 0);
return {
body:
ForkSeq[fork] >= ForkSeq.electra
? SignedAggregateAndProofListElectaType.toJson(
signedAggregateAndProofs as SignedAggregateAndProofListElecta
)
: SignedAggregateAndProofListPhase0Type.toJson(
signedAggregateAndProofs as SignedAggregateAndProofListPhase0
),
headers: {[MetaHeader.Version]: fork},
};
},
parseReqJson: ({body, headers}) => {
const versionHeader = fromHeaders(headers, MetaHeader.Version, false);
const fork =
versionHeader !== undefined
? toForkName(versionHeader)
: config.getForkName(
Number(
(body as {message: {aggregate: {data: {slot: string}}}}[])[0]?.message.aggregate.data.slot ?? 0
)
);

return {
signedAggregateAndProofs:
ForkSeq[fork] >= ForkSeq.electra
? SignedAggregateAndProofListElectaType.fromJson(body)
: SignedAggregateAndProofListPhase0Type.fromJson(body),
};
},
writeReqSsz: ({signedAggregateAndProofs}) => {
const fork = config.getForkName(signedAggregateAndProofs[0]?.message.aggregate.data.slot ?? 0);
return {
body:
ForkSeq[fork] >= ForkSeq.electra
? SignedAggregateAndProofListElectaType.serialize(
signedAggregateAndProofs as SignedAggregateAndProofListElecta
)
: SignedAggregateAndProofListPhase0Type.serialize(
signedAggregateAndProofs as SignedAggregateAndProofListPhase0
),
headers: {[MetaHeader.Version]: fork},
};
},
parseReqSsz: ({body, headers}) => {
const versionHeader = fromHeaders(headers, MetaHeader.Version, true);
const fork = toForkName(versionHeader);
return {
signedAggregateAndProofs:
ForkSeq[fork] >= ForkSeq.electra
? SignedAggregateAndProofListElectaType.deserialize(body)
: SignedAggregateAndProofListPhase0Type.deserialize(body),
};
},
schema: {
body: Schema.ObjectArray,
headers: {[MetaHeader.Version]: Schema.String},
},
},
resp: EmptyResponseCodec,
Expand Down
2 changes: 1 addition & 1 deletion packages/api/test/unit/beacon/testData/beacon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const testData: GenericServerTestCases<Endpoints> = {

getPoolAttestations: {
args: {slot: 1, committeeIndex: 2},
res: {data: [ssz.phase0.Attestation.defaultValue()]},
res: {data: [ssz.phase0.Attestation.defaultValue()], meta: {version: ForkName.deneb}},
},
getPoolAttesterSlashings: {
args: undefined,
Expand Down
Loading
Loading