Skip to content

Commit 2c3a6f5

Browse files
committed
extend data structures for gloas forkchoice
1 parent a49ed22 commit 2c3a6f5

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

beacon_chain/fork_choice/fork_choice_types.nim

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,28 +126,55 @@ type
126126
current_root*: Eth2Digest
127127
next_root*: Eth2Digest
128128
next_epoch*: Epoch
129+
next_slot*: Slot
130+
payload_present*: bool
129131

130132
ForkChoiceBackend* = object
131133
proto_array*: ProtoArray
132134
votes*: seq[VoteTracker]
133135
balances*: seq[Gwei]
136+
# Additional state tracking for Gloas
137+
execution_payload_states*: Table[Eth2Digest, Eth2Digest] # root -> state_root
138+
ptc_vote*: Table[Eth2Digest, seq[bool]]
134139

135140
QueuedAttestation* = object
136141
slot*: Slot
137142
attesting_indices*: seq[ValidatorIndex]
138143
block_root*: Eth2Digest
139144
target_epoch*: Epoch
145+
# Gloas - track committee index for payload preference
146+
committee_index*: CommitteeIndex
140147

141148
ForkChoice* = object
142149
backend*: ForkChoiceBackend
143150
checkpoints*: Checkpoints
144151
queuedAttestations*: seq[QueuedAttestation]
145152

153+
# New Fork choice types for Gloas
154+
# ----------------------------------------------------------------------
155+
156+
type
157+
# https://github.com/ethereum/consensus-specs/blob/v1.6.1/specs/gloas/fork-choice.md#custom-types
158+
PayloadStatus* = uint8
159+
160+
ForkChoiceNode* = object
161+
root*: Eth2Digest
162+
payloadStatus*: PayloadStatus
163+
164+
const
165+
# https://github.com/ethereum/consensus-specs/blob/v1.6.1/specs/gloas/fork-choice.md#constants
166+
PAYLOAD_TIMELY_THRESHOLD*: uint64 = PTC_SIZE div 2
167+
PAYLOAD_STATUS_PENDING* = PayloadStatus(0)
168+
PAYLOAD_STATUS_EMPTY* = PayloadStatus(1)
169+
PAYLOAD_STATUS_FULL* = PayloadStatus(2)
170+
146171
func shortLog*(vote: VoteTracker): auto =
147172
(
148173
current_root: shortLog(vote.current_root),
149174
next_root: shortLog(vote.next_root),
150-
next_epoch: vote.next_epoch
175+
next_epoch: vote.next_epoch,
176+
next_slot: vote.next_slot,
177+
payload_present: vote.payload_present
151178
)
152179

153180
chronicles.formatIt VoteTracker: it.shortLog

beacon_chain/spec/datatypes/gloas.nim

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,10 @@ from ./deneb import
3636

3737
export json_serialization, base
3838

39-
type
40-
# https://github.com/ethereum/consensus-specs/blob/v1.6.0-alpha.6/specs/gloas/fork-choice.md#custom-types
41-
PayloadStatus* = uint8
42-
4339
const
4440
# https://github.com/ethereum/consensus-specs/blob/v1.6.0-alpha.6/specs/gloas/beacon-chain.md#state-list-lengths
4541
BUILDER_PENDING_WITHDRAWALS_LIMIT*: uint64 = 1_048_576
4642

47-
# https://github.com/ethereum/consensus-specs/blob/v1.6.0-alpha.6/specs/gloas/fork-choice.md#constants
48-
PAYLOAD_TIMELY_THRESHOLD*: uint64 = PTC_SIZE div 2
49-
PAYLOAD_STATUS_PENDING* = PayloadStatus(0)
50-
PAYLOAD_STATUS_EMPTY* = PayloadStatus(1)
51-
PAYLOAD_STATUS_FULL* = PayloadStatus(2)
52-
5343
type
5444
# https://github.com/ethereum/consensus-specs/blob/v1.6.0-beta.1/specs/gloas/p2p-interface.md#modified-datacolumnsidecar
5545
DataColumnSidecar* = object

0 commit comments

Comments
 (0)