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: implement focil EIP-7805 #7342

Draft
wants to merge 71 commits into
base: unstable
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
092df19
Add focil fork definition and constant
ensi321 Dec 10, 2024
4423f75
lint
ensi321 Dec 10, 2024
93e5525
Add IL committee duty stub
ensi321 Jan 9, 2025
75bb159
Add engine API
ensi321 Jan 9, 2025
6ccd78e
Gossip handling inclusion list
ensi321 Jan 10, 2025
4ae1f28
reqresp
ensi321 Jan 10, 2025
bfb0022
lint
ensi321 Jan 10, 2025
b1f5255
Fix SignedInclusionList container
nflaig Jan 14, 2025
97138af
Add new beacon apis
nflaig Jan 14, 2025
581e08c
Add IL committee to EpochShuffling
ensi321 Jan 15, 2025
253544a
Deduplicate validator index in committee assignments
nflaig Jan 15, 2025
4f6580a
Update execution payload with inclusion list transactions
nflaig Jan 17, 2025
8ec99e4
Subscribe to inclusion list topic
nflaig Jan 17, 2025
ce0615f
Update constant names to match latest spec
nflaig Jan 17, 2025
0032f38
Lint
nflaig Jan 17, 2025
12bbf66
Add remark to minimal preset values
nflaig Jan 17, 2025
7bd39aa
Merge branch 'unstable' into focil
nflaig Jan 18, 2025
3ac7876
Add SingleAttestation focil types by fork
nflaig Jan 18, 2025
d4bfda3
Fix various type issues
nflaig Jan 18, 2025
0e5e6ab
Update ssz types
nflaig Jan 18, 2025
4bc01b8
Add InclusionListPool
nflaig Jan 22, 2025
5656694
Tweak naming
nflaig Jan 22, 2025
a69881d
Merge branch 'unstable' into focil
nflaig Jan 23, 2025
ad54d7b
Merge branch 'unstable' into focil
nflaig Jan 23, 2025
34c225e
Add IL to validatior store
ensi321 Jan 24, 2025
f331c33
Inclusion list service and duty
ensi321 Jan 24, 2025
54901a4
implement publishInclusionList
ensi321 Jan 24, 2025
48200e2
Lint and add todos
ensi321 Jan 24, 2025
ba40039
Add IL to pool during publishing
nflaig Jan 24, 2025
6cc78ac
Fix lint issues
nflaig Jan 24, 2025
72d52c4
Only store transactions in op pool and deduplicate
nflaig Jan 24, 2025
38d1d72
Use MAX_TRANSACTIONS_PER_PAYLOAD value to limit IL container size
nflaig Jan 24, 2025
b6d6627
Reject ILs on gossip that exceed maximum size
nflaig Jan 24, 2025
6b4953e
Merge branch 'unstable' into focil
nflaig Jan 24, 2025
a7a330c
Remove MAX_TRANSACTIONS_PER_INCLUSION_LIST and use bellatrix.Transact…
nflaig Jan 24, 2025
f5210ff
Fix gossip publishing
nflaig Jan 24, 2025
9f48028
Add inclusion_list event
nflaig Jan 24, 2025
f49f1df
Add unit test to sanity check gossip publishing
nflaig Jan 24, 2025
25bfff0
Add version meta to produce and publish api
nflaig Jan 24, 2025
1331488
Add todo regarding resp value of produce api
nflaig Jan 24, 2025
93e73c2
Update config values
nflaig Jan 24, 2025
ce4deb2
Add ILC definition for computing root
ensi321 Jan 24, 2025
1394cfe
Shuffling cache to store ILC root
ensi321 Jan 24, 2025
4960ab6
Check ILC root and validator index in gossip validation
ensi321 Jan 24, 2025
d97fdf8
Add remark regarding transactions list limit
nflaig Jan 27, 2025
211b8f5
Call IL Pool before engine_newPayloadV5
ensi321 Jan 28, 2025
b20b7b3
Call IL Pool before engine_newPayloadV5
ensi321 Jan 28, 2025
467c593
Add focil flag to ProtoBlock
ensi321 Jan 28, 2025
c545627
Update fcstore and add IL equivocators detection
ensi321 Jan 28, 2025
ca38f3c
Update fcstore and add IL equivocators detection
ensi321 Jan 28, 2025
1aedf80
Reorg out IL-invalid head block for attestation and sync committee
ensi321 Jan 28, 2025
8e8fa7b
Handle IL-invalid execution payload
ensi321 Jan 28, 2025
10a68ef
lint
ensi321 Jan 28, 2025
5d40a9a
Wire in forkchoice.onInclusionList
ensi321 Jan 28, 2025
2d680d5
Add committee root to IL duty
ensi321 Jan 28, 2025
feee1a3
Add getInclusionList to execution engine
ensi321 Jan 28, 2025
ec9fecc
produceInclusionList to return lists of transactions
ensi321 Jan 28, 2025
a20f4f2
Fix a bunch of lint errors
nflaig Jan 28, 2025
84f6265
Update fork constants to work with kurtosis
nflaig Jan 28, 2025
5f27657
Update InclusionListDuty to match spec
nflaig Jan 28, 2025
8989b7f
fix InclusionListRpc
ensi321 Feb 4, 2025
8638384
Disable schedulePayloadInclusionListUpdate pre-focil
ensi321 Feb 4, 2025
a2820c1
update engine_updatePayloadWithInclusionListV1 return type
ensi321 Feb 4, 2025
68f0648
Add ILService to Validator
ensi321 Feb 5, 2025
abb8cb3
Fixed time to call engine_updatePayloadWithInclusionListV1
ensi321 Feb 5, 2025
7d45609
fix IL validation
ensi321 Feb 5, 2025
0df5ba8
Use correct parentHash
ensi321 Feb 5, 2025
e6dcd2b
Handle pre-focil api and duty behaviour
ensi321 Feb 5, 2025
5f0182a
Handle pre-focil api and duty behaviour
ensi321 Feb 6, 2025
efbeed9
lint
ensi321 Feb 7, 2025
dffb1ac
Temporary workaround for Dora
ensi321 Feb 7, 2025
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
7 changes: 7 additions & 0 deletions packages/api/src/beacon/routes/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
altair,
capella,
electra,
focil,
phase0,
ssz,
sszTypesFor,
Expand Down Expand Up @@ -76,6 +77,8 @@ export enum EventType {
payloadAttributes = "payload_attributes",
/** The node has received a valid blobSidecar (from P2P or API) */
blobSidecar = "blob_sidecar",
/** The node has received a valid inclusion list (from P2P or API) */
inclusionList = "inclusion_list",
}

export const eventTypes: {[K in EventType]: K} = {
Expand All @@ -94,6 +97,7 @@ export const eventTypes: {[K in EventType]: K} = {
[EventType.lightClientFinalityUpdate]: EventType.lightClientFinalityUpdate,
[EventType.payloadAttributes]: EventType.payloadAttributes,
[EventType.blobSidecar]: EventType.blobSidecar,
[EventType.inclusionList]: EventType.inclusionList,
};

export type EventData = {
Expand Down Expand Up @@ -138,6 +142,7 @@ export type EventData = {
[EventType.lightClientFinalityUpdate]: {version: ForkName; data: LightClientFinalityUpdate};
[EventType.payloadAttributes]: {version: ForkName; data: SSEPayloadAttributes};
[EventType.blobSidecar]: BlobSidecarSSE;
[EventType.inclusionList]: {version: ForkName; data: focil.SignedInclusionList};
};

export type BeaconEvent = {[K in EventType]: {type: K; message: EventData[K]}}[EventType];
Expand Down Expand Up @@ -291,6 +296,8 @@ export function getTypeByEvent(config: ChainForkConfig): {[K in EventType]: Type
[EventType.lightClientFinalityUpdate]: WithVersion(
(fork) => getLightClientForkTypes(fork).LightClientFinalityUpdate
),

[EventType.inclusionList]: WithVersion(() => ssz.focil.SignedInclusionList),
};
}

Expand Down
127 changes: 127 additions & 0 deletions packages/api/src/beacon/routes/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {
UintBn64,
ValidatorIndex,
altair,
bellatrix,
focil,
phase0,
ssz,
sszTypesFor,
Expand Down Expand Up @@ -104,6 +106,20 @@ export const AttesterDutyType = new ContainerType(
{jsonCase: "eth2"}
);

export const InclusionListDutyType = new ContainerType(
{
/** The validator's public key, uniquely identifying them */
pubkey: ssz.BLSPubkey,
/** Index of validator in validator registry */
validatorIndex: ssz.ValidatorIndex,
/** The slot at which the validator must propose the inclusion list*/
slot: ssz.Slot,
/** Inclusion List Committee Root */
inclusionListCommitteeRoot: ssz.Root,
},
{jsonCase: "eth2"}
);

export const ProposerDutyType = new ContainerType(
{
slot: ssz.Slot,
Expand Down Expand Up @@ -202,6 +218,7 @@ export const ValidatorIndicesType = ArrayOf(ssz.ValidatorIndex);
export const AttesterDutyListType = ArrayOf(AttesterDutyType);
export const ProposerDutyListType = ArrayOf(ProposerDutyType);
export const SyncDutyListType = ArrayOf(SyncDutyType);
export const InclusionListDutyListType = ArrayOf(InclusionListDutyType);
export const SignedAggregateAndProofListPhase0Type = ArrayOf(ssz.phase0.SignedAggregateAndProof);
export const SignedAggregateAndProofListElectraType = ArrayOf(ssz.electra.SignedAggregateAndProof);
export const SignedContributionAndProofListType = ArrayOf(ssz.altair.SignedContributionAndProof);
Expand All @@ -220,6 +237,8 @@ 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 InclusionListDuty = ValueOf<typeof InclusionListDutyType>;
export type InclusionListDutyList = ValueOf<typeof InclusionListDutyListType>;
export type SignedAggregateAndProofListPhase0 = ValueOf<typeof SignedAggregateAndProofListPhase0Type>;
export type SignedAggregateAndProofListElectra = ValueOf<typeof SignedAggregateAndProofListElectraType>;
export type SignedAggregateAndProofList = SignedAggregateAndProofListPhase0 | SignedAggregateAndProofListElectra;
Expand Down Expand Up @@ -288,6 +307,23 @@ export type Endpoints = {
ExecutionOptimisticMeta
>;

/**
* Get inclusion list committee duties
* Requests the beacon node to provide a set of inclusion list committee duties for a particular epoch.
*/
getInclusionListCommitteeDuties: Endpoint<
"POST",
{
/** Should only be allowed 1 epoch ahead */
epoch: Epoch;
/** An array of the validator indices for which to obtain the duties */
indices: ValidatorIndices;
},
{params: {epoch: Epoch}; body: unknown},
InclusionListDutyList,
ExecutionOptimisticAndDependentRootMeta
>;

/**
* Requests a beacon node to produce a valid block, which can then be signed by a validator.
* Metadata in the response indicates the type of block produced, and the supported types of block
Expand Down Expand Up @@ -392,6 +428,21 @@ export type Endpoints = {
EmptyMeta
>;

/**
* Produce an inclusion list
* Requests the beacon node to produce an inclusion list.
*/
produceInclusionList: Endpoint<
"GET",
{
/** The slot for which an inclusion list should be created */
slot: Slot;
},
{query: {slot: number}},
bellatrix.Transactions,
VersionMeta
>;

/**
* Get aggregated attestation
* Aggregates all attestations matching given attestation data root and slot
Expand Down Expand Up @@ -459,6 +510,18 @@ export type Endpoints = {
EmptyMeta
>;

/**
* Publish inclusion list
* Verifies given inclusion list and publishes it on appropriate gossipsub topic.
*/
publishInclusionList: Endpoint<
"POST",
{signedInclusionList: focil.SignedInclusionList},
{body: unknown; headers: {[MetaHeader.Version]: string}},
EmptyResponseData,
EmptyMeta
>;

/**
* Signal beacon node to prepare for a committee subnet
* After beacon node receives this request,
Expand Down Expand Up @@ -616,6 +679,24 @@ export function getDefinitions(config: ChainForkConfig): RouteDefinitions<Endpoi
meta: ExecutionOptimisticCodec,
},
},
getInclusionListCommitteeDuties: {
url: "/eth/v1/validator/duties/inclusion_list/{epoch}",
method: "POST",
req: {
writeReqJson: ({epoch, indices}) => ({params: {epoch}, body: ValidatorIndicesType.toJson(indices)}),
parseReqJson: ({params, body}) => ({epoch: params.epoch, indices: ValidatorIndicesType.fromJson(body)}),
writeReqSsz: ({epoch, indices}) => ({params: {epoch}, body: ValidatorIndicesType.serialize(indices)}),
parseReqSsz: ({params, body}) => ({epoch: params.epoch, indices: ValidatorIndicesType.deserialize(body)}),
schema: {
params: {epoch: Schema.UintRequired},
body: Schema.StringArray,
},
},
resp: {
data: InclusionListDutyListType,
meta: ExecutionOptimisticAndDependentRootCodec,
},
},
produceBlockV2: {
url: "/eth/v2/validator/blocks/{slot}",
method: "GET",
Expand Down Expand Up @@ -825,6 +906,21 @@ export function getDefinitions(config: ChainForkConfig): RouteDefinitions<Endpoi
meta: EmptyMetaCodec,
},
},
produceInclusionList: {
url: "/eth/v1/validator/inclusion_list",
method: "GET",
req: {
writeReq: ({slot}) => ({query: {slot}}),
parseReq: ({query}) => ({slot: query.slot}),
schema: {
query: {slot: Schema.UintRequired},
},
},
resp: {
data: ssz.bellatrix.Transactions,
meta: VersionCodec,
},
},
getAggregatedAttestation: {
url: "/eth/v1/validator/aggregate_attestation",
method: "GET",
Expand Down Expand Up @@ -966,6 +1062,37 @@ export function getDefinitions(config: ChainForkConfig): RouteDefinitions<Endpoi
},
resp: EmptyResponseCodec,
},
publishInclusionList: {
url: "/eth/v1/validator/inclusion_list",
method: "POST",
req: {
writeReqJson: ({signedInclusionList}) => {
const fork = config.getForkName(signedInclusionList.message.slot);
return {
body: ssz.focil.SignedInclusionList.toJson(signedInclusionList),
headers: {
[MetaHeader.Version]: fork,
},
};
},
parseReqJson: ({body}) => ({signedInclusionList: ssz.focil.SignedInclusionList.fromJson(body)}),
writeReqSsz: ({signedInclusionList}) => {
const fork = config.getForkName(signedInclusionList.message.slot);
return {
body: ssz.focil.SignedInclusionList.serialize(signedInclusionList),
headers: {
[MetaHeader.Version]: fork,
},
};
},
parseReqSsz: ({body}) => ({signedInclusionList: ssz.focil.SignedInclusionList.deserialize(body)}),
schema: {
body: Schema.Object,
headers: {[MetaHeader.Version]: Schema.String},
},
},
resp: EmptyResponseCodec,
},
prepareBeaconCommitteeSubnet: {
url: "/eth/v1/validator/beacon_committee_subscriptions",
method: "POST",
Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/utils/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export const ExecutionOptimisticAndVersionCodec: ResponseMetadataCodec<Execution
fromJson: (val) => ExecutionOptimisticAndVersionType.fromJson(val),
toHeadersObject: (val) => ({
[MetaHeader.ExecutionOptimistic]: val.executionOptimistic.toString(),
[MetaHeader.Version]: val.version,
[MetaHeader.Version]: val.version === ForkName.focil ? ForkName.electra : val.version,
[HttpHeader.ExposeHeaders]: [MetaHeader.ExecutionOptimistic, MetaHeader.Version].toString(),
}),
fromHeaders: (headers) => ({
Expand Down Expand Up @@ -144,7 +144,7 @@ export const ExecutionOptimisticFinalizedAndVersionCodec: ResponseMetadataCodec<
toHeadersObject: (val) => ({
[MetaHeader.ExecutionOptimistic]: val.executionOptimistic.toString(),
[MetaHeader.Finalized]: val.finalized.toString(),
[MetaHeader.Version]: val.version,
[MetaHeader.Version]: val.version === ForkName.focil ? ForkName.electra : val.version,
[HttpHeader.ExposeHeaders]: [MetaHeader.ExecutionOptimistic, MetaHeader.Finalized, MetaHeader.Version].toString(),
}),
fromHeaders: (headers) => ({
Expand Down
14 changes: 14 additions & 0 deletions packages/api/test/unit/beacon/testData/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,18 @@ export const eventTestData: EventData = {
slot: "1",
versioned_hash: "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
}),
// TODO FOCIL: update example value
[EventType.inclusionList]: {
version: ForkName.focil,
data: ssz.focil.SignedInclusionList.fromJson({
message: {
slot: "0",
validator_index: "0",
inclusion_list_committee_root: "0x0000000000000000000000000000000000000000000000000000000000000000",
transactions: ["0x0000000000000000000000000000000000000000000000000000000000000000"],
},
signature:
"0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
}),
},
};
22 changes: 22 additions & 0 deletions packages/api/test/unit/beacon/testData/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,20 @@ export const testData: GenericServerTestCases<Endpoints> = {
meta: {executionOptimistic: true},
},
},
getInclusionListCommitteeDuties: {
args: {epoch: 0, indices: [1, 2, 3]},
res: {
data: [
{
pubkey: new Uint8Array(48).fill(1),
validatorIndex: 2,
slot: 3,
inclusionListCommitteeRoot: ZERO_HASH,
},
],
meta: {executionOptimistic: true, dependentRoot: ZERO_HASH_HEX},
},
},
produceBlockV2: {
args: {
slot: 32000,
Expand Down Expand Up @@ -98,6 +112,10 @@ export const testData: GenericServerTestCases<Endpoints> = {
args: {slot: 32000, subcommitteeIndex: 2, beaconBlockRoot: ZERO_HASH},
res: {data: ssz.altair.SyncCommitteeContribution.defaultValue()},
},
produceInclusionList: {
args: {slot: 32000},
res: {data: [ssz.bellatrix.Transaction.defaultValue()], meta: {version: ForkName.focil}},
},
getAggregatedAttestation: {
args: {attestationDataRoot: ZERO_HASH, slot: 32000},
res: {data: ssz.phase0.Attestation.defaultValue()},
Expand All @@ -118,6 +136,10 @@ export const testData: GenericServerTestCases<Endpoints> = {
args: {contributionAndProofs: [ssz.altair.SignedContributionAndProof.defaultValue()]},
res: undefined,
},
publishInclusionList: {
args: {signedInclusionList: ssz.focil.SignedInclusionList.defaultValue()},
res: undefined,
},
prepareBeaconCommitteeSubnet: {
args: {subscriptions: [{validatorIndex: 1, committeeIndex: 2, committeesAtSlot: 3, slot: 4, isAggregator: true}]},
res: undefined,
Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-node/src/api/impl/beacon/blocks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ export function getBeaconBlockApi({
};
}
} else if (blockId === "head") {
const head = chain.forkChoice.getHead();
const head = chain.forkChoice.getAttesterHead();
return {
data: {root: fromHex(head.blockRoot)},
meta: {executionOptimistic: isOptimisticBlock(head), finalized: false},
Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-node/src/api/impl/beacon/state/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export function getBeaconStateApi({
`No shuffling found to calculate committees for epoch: ${epoch} and decisionRoot: ${decisionRoot}`
);
}
const committees = shuffling.committees;
const committees = shuffling.beaconCommittees;
const committeesFlat = committees.flatMap((slotCommittees, slotInEpoch) => {
const slot = startSlot + slotInEpoch;
if (filters.slot !== undefined && filters.slot !== slot) {
Expand Down
Loading