PR feedback from danny
This commit is contained in:
parent
3b749d72c8
commit
2d895e9388
|
@ -76,18 +76,18 @@ def get_shard_latest_attesting_balance(store: Store, shard_store: ShardStore, ro
|
||||||
```python
|
```python
|
||||||
def get_shard_head(store: Store, shard_store: ShardStore) -> Root:
|
def get_shard_head(store: Store, shard_store: ShardStore) -> Root:
|
||||||
# Execute the LMD-GHOST fork choice
|
# Execute the LMD-GHOST fork choice
|
||||||
shard_blocks = shard_store.blocks
|
beacon_head_root = get_head(store)
|
||||||
head_beacon_root = get_head(store)
|
shard_head_state = store.block_states[beacon_head_root].shard_states[shard_store.shard]
|
||||||
head_shard_state = store.block_states[head_beacon_root].shard_states[shard_store.shard]
|
shard_head_root = shard_head_state.latest_block_root
|
||||||
shard_head_root = head_shard_state.latest_block_root
|
shard_blocks = {
|
||||||
|
root: shard_block for root, shard_block in shard_store.blocks.items()
|
||||||
|
if shard_block.slot > shard_head_state.slot
|
||||||
|
}
|
||||||
while True:
|
while True:
|
||||||
# Find the valid child block roots
|
# Find the valid child block roots
|
||||||
children = [
|
children = [
|
||||||
root for root in shard_store.blocks.keys()
|
root for root, shard_block in shard_blocks.items()
|
||||||
if (
|
if shard_block.shard_parent_root == shard_head_root
|
||||||
shard_blocks[root].shard_parent_root == shard_head_root
|
|
||||||
and shard_blocks[root].slot > head_shard_state.slot
|
|
||||||
)
|
|
||||||
]
|
]
|
||||||
if len(children) == 0:
|
if len(children) == 0:
|
||||||
return shard_head_root
|
return shard_head_root
|
||||||
|
@ -107,7 +107,7 @@ def get_shard_ancestor(store: Store, shard_store: ShardStore, root: Root, slot:
|
||||||
elif block.slot == slot:
|
elif block.slot == slot:
|
||||||
return root
|
return root
|
||||||
else:
|
else:
|
||||||
# root is older than queried slot, thus a skip slot. Return earliest root prior to slot
|
# root is older than queried slot, thus a skip slot. Return most recent root prior to slot
|
||||||
return root
|
return root
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ def get_shard_ancestor(store: Store, shard_store: ShardStore, root: Root, slot:
|
||||||
```python
|
```python
|
||||||
def get_pending_shard_blocks(store: Store, shard_store: ShardStore) -> Sequence[ShardBlock]:
|
def get_pending_shard_blocks(store: Store, shard_store: ShardStore) -> Sequence[ShardBlock]:
|
||||||
"""
|
"""
|
||||||
Return the shard blocks branch that from shard head to beacon head.
|
Return the canonical shard block branch that has not yet been crosslinked.
|
||||||
"""
|
"""
|
||||||
shard = shard_store.shard
|
shard = shard_store.shard
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue