Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
35 changes: 24 additions & 11 deletions specs/gloas/fork-choice.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
- [Modified `get_node_children`](#modified-get_node_children)
- [Modified `get_head`](#modified-get_head)
- [Modified `record_block_timeliness`](#modified-record_block_timeliness)
- [Modified `get_dependent_root`](#modified-get_dependent_root)
- [Modified `update_proposer_boost_root`](#modified-update_proposer_boost_root)
- [Modified `validate_on_attestation`](#modified-validate_on_attestation)
- [Modified `is_head_late`](#modified-is_head_late)
Expand Down Expand Up @@ -596,25 +597,37 @@ def record_block_timeliness(store: Store, root: Root) -> None:
]
```

### Modified `get_dependent_root`

```python
def get_dependent_root(store: Store, root: Root) -> Root:
epoch = get_current_store_epoch(store)
if epoch <= MIN_SEED_LOOKAHEAD:
# Genesis block parent
return Root()

# [Modified in Gloas:EIP7732]
node = ForkChoiceNode(
root=root,
payload_status=PAYLOAD_STATUS_PENDING,
)
dependent_slot = Slot(compute_start_slot_at_epoch(epoch - MIN_SEED_LOOKAHEAD) - 1)
return get_ancestor(store, node, dependent_slot).root
```

### Modified `update_proposer_boost_root`

```python
def update_proposer_boost_root(store: Store, head: Root, root: Root) -> None:
is_first_block = store.proposer_boost_root == Root()
# [Modified in Gloas:EIP7732]
is_timely = store.block_timeliness[root][ATTESTATION_TIMELINESS_INDEX]
is_same_dependent_root = get_dependent_root(store, root) == get_dependent_root(store, head)

# Add proposer score boost if the block is the first timely block
# for this slot, with the same proposer as the canonical chain.
if is_timely and is_first_block:
head_state = copy(store.block_states[head])
slot = get_current_slot(store)
if head_state.slot < slot:
process_slots(head_state, slot)
block = store.blocks[root]
# Only update if the proposer is the same as on the canonical chain
if block.proposer_index == get_beacon_proposer_index(head_state):
store.proposer_boost_root = root
# Add proposer score boost if the block is timely, not conflicting with an
# existing block, with the same dependent root as the canonical chain head.
if is_timely and is_first_block and is_same_dependent_root:
store.proposer_boost_root = root
```

### Modified `validate_on_attestation`
Expand Down
29 changes: 19 additions & 10 deletions specs/phase0/fork-choice.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
- [`update_latest_messages`](#update_latest_messages)
- [`on_block` helpers](#on_block-helpers)
- [`record_block_timeliness`](#record_block_timeliness)
- [`get_dependent_root`](#get_dependent_root)
- [`update_proposer_boost_root`](#update_proposer_boost_root)
- [Handlers](#handlers)
- [`on_tick`](#on_tick)
Expand Down Expand Up @@ -853,24 +854,32 @@ def record_block_timeliness(store: Store, root: Root) -> None:
store.block_timeliness[root] = is_timely
```

##### `get_dependent_root`

```python
def get_dependent_root(store: Store, root: Root) -> Root:
epoch = get_current_store_epoch(store)
if epoch <= MIN_SEED_LOOKAHEAD:
# Genesis block parent
return Root()

node = ForkChoiceNode(root=root)
dependent_slot = Slot(compute_start_slot_at_epoch(epoch - MIN_SEED_LOOKAHEAD) - 1)
return get_ancestor(store, node, dependent_slot).root
```

##### `update_proposer_boost_root`

```python
def update_proposer_boost_root(store: Store, head: Root, root: Root) -> None:
is_first_block = store.proposer_boost_root == Root()
is_timely = store.block_timeliness[root]
is_same_dependent_root = get_dependent_root(store, root) == get_dependent_root(store, head)

# Add proposer score boost if the block is timely, not conflicting with an
# existing block, with the same the proposer as the canonical chain.
if is_timely and is_first_block:
head_state = copy(store.block_states[head])
slot = get_current_slot(store)
if head_state.slot < slot:
process_slots(head_state, slot)
block = store.blocks[root]
# Only update if the proposer is the same as on the canonical chain
if block.proposer_index == get_beacon_proposer_index(head_state):
store.proposer_boost_root = root
# existing block, with the same dependent root as the canonical chain head.
Comment thread
jihoonsong marked this conversation as resolved.
if is_timely and is_first_block and is_same_dependent_root:
store.proposer_boost_root = root
```

### Handlers
Expand Down