1818import
1919 std/ typetraits,
2020 chronicles,
21- stew/ byteutils,
2221 json_serialization,
2322 ssz_serialization/ [merkleization, proofs],
2423 ssz_serialization/ types as sszTypes,
2524 ../ digest,
26- " ." / [base, phase0, altair, bellatrix, capella ]
25+ " ." / [base, phase0]
2726
2827from kzg4844 import KzgCommitment , KzgProof
28+ from stew/ bitops2 import log2trunc
29+ from stew/ byteutils import to0xHex
30+ from ./ altair import
31+ EpochParticipationFlags , InactivityScores , SyncAggregate , SyncCommittee ,
32+ TrustedSyncAggregate
33+ from ./ bellatrix import BloomLogs , ExecutionAddress , Transaction
34+ from ./ capella import
35+ HistoricalSummary , SignedBLSToExecutionChangeList , Withdrawal
2936from ./ deneb import Blobs , BlobsBundle , KzgCommitments , KzgProofs
3037
3138export json_serialization, base, kzg4844
3239
40+ const
41+ # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/altair/light-client/sync-protocol.md#constants
42+ # All of these indices are rooted in `BeaconState`.
43+ # The first member (`genesis_time`) is 64, subsequent members +1 each.
44+ # If there are ever more than 64 members in `BeaconState`, indices change!
45+ # `FINALIZED_ROOT_GINDEX` is one layer deeper, i.e., `84 * 2 + 1`.
46+ # https://github.com/ethereum/consensus-specs/blob/v1.4.0/ssz/merkle-proofs.md
47+ FINALIZED_ROOT_GINDEX = 169 .GeneralizedIndex # finalized_checkpoint > root
48+ CURRENT_SYNC_COMMITTEE_GINDEX = 86 .GeneralizedIndex # current_sync_committee
49+ NEXT_SYNC_COMMITTEE_GINDEX = 87 .GeneralizedIndex # next_sync_committee
50+
3351type
3452 # https://github.com/ethereum/consensus-specs/blob/94a0b6c581f2809aa8aca4ef7ee6fbb63f9d74e9/specs/electra/beacon-chain.md#depositreceipt
3553 DepositReceipt * = object
7593 blockValue* : Wei
7694 blobsBundle* : BlobsBundle
7795
78- # https://github.com/ethereum/consensus-specs/blob/82133085a1295e93394ebdf71df8f2f6e0962588 /specs/electra/beacon-chain.md#executionpayloadheader
96+ # https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.0 /specs/electra/beacon-chain.md#executionpayloadheader
7997 ExecutionPayloadHeader * = object
8098 # Execution block header fields
8199 parent_hash* : Eth2Digest
@@ -141,12 +159,21 @@ type
141159 source_index* : uint64
142160 target_index* : uint64
143161
162+ FinalityBranch =
163+ array [log2trunc (FINALIZED_ROOT_GINDEX ), Eth2Digest ]
164+
165+ CurrentSyncCommitteeBranch =
166+ array [log2trunc (CURRENT_SYNC_COMMITTEE_GINDEX ), Eth2Digest ]
167+
168+ NextSyncCommitteeBranch =
169+ array [log2trunc (NEXT_SYNC_COMMITTEE_GINDEX ), Eth2Digest ]
170+
144171 # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/capella/light-client/sync-protocol.md#modified-lightclientheader
145172 LightClientHeader * = object
146173 beacon* : BeaconBlockHeader
147174 # # Beacon block header
148175
149- execution* : ExecutionPayloadHeader
176+ execution* : electra. ExecutionPayloadHeader
150177 # # Execution payload header corresponding to `beacon.body_root` (from Capella onward)
151178 execution_branch* : capella.ExecutionBranch
152179
157184
158185 current_sync_committee* : SyncCommittee
159186 # # Current sync committee corresponding to `header.beacon.state_root`
160- current_sync_committee_branch* : altair. CurrentSyncCommitteeBranch
187+ current_sync_committee_branch* : CurrentSyncCommitteeBranch
161188
162189 # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/altair/light-client/sync-protocol.md#lightclientupdate
163190 LightClientUpdate * = object
@@ -167,11 +194,11 @@ type
167194 next_sync_committee* : SyncCommittee
168195 # # Next sync committee corresponding to
169196 # # `attested_header.beacon.state_root`
170- next_sync_committee_branch* : altair. NextSyncCommitteeBranch
197+ next_sync_committee_branch* : NextSyncCommitteeBranch
171198
172199 # Finalized header corresponding to `attested_header.beacon.state_root`
173200 finalized_header* : LightClientHeader
174- finality_branch* : altair. FinalityBranch
201+ finality_branch* : FinalityBranch
175202
176203 sync_aggregate* : SyncAggregate
177204 # # Sync committee aggregate signature
185212
186213 # Finalized header corresponding to `attested_header.beacon.state_root`
187214 finalized_header* : LightClientHeader
188- finality_branch* : altair. FinalityBranch
215+ finality_branch* : FinalityBranch
189216
190217 # Sync committee aggregate signature
191218 sync_aggregate* : SyncAggregate
405432 attester_slashings* :
406433 List [AttesterSlashing , Limit MAX_ATTESTER_SLASHINGS_ELECTRA ]
407434 # # [Modified in Electra:EIP7549]
408- attestations* : List [Attestation , Limit MAX_ATTESTATIONS_ELECTRA ]
435+ attestations* : List [phase0. Attestation , Limit MAX_ATTESTATIONS_ELECTRA ]
409436 # # [Modified in Electra:EIP7549]
410437 deposits* : List [Deposit , Limit MAX_DEPOSITS ]
411438 voluntary_exits* : List [SignedVoluntaryExit , Limit MAX_VOLUNTARY_EXITS ]
527554
528555 root* {.dontSerialize .}: Eth2Digest # cached root of signed beacon block
529556
557+ ElectraCommitteeValidatorsBits * =
558+ BitList [Limit MAX_VALIDATORS_PER_COMMITTEE * MAX_COMMITTEES_PER_SLOT ]
559+
530560 SomeSignedBeaconBlock * =
531561 SignedBeaconBlock |
532562 SigVerifiedSignedBeaconBlock |
0 commit comments