mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-01-12 19:54:34 +00:00
Merge pull request #2760 from ethereum/fix-proposer-boost-apply
Apply proposer boost to ancestors correctly
This commit is contained in:
commit
876c5b0944
@ -181,8 +181,14 @@ def get_latest_attesting_balance(store: Store, root: Root) -> Gwei:
|
||||
if (i in store.latest_messages
|
||||
and get_ancestor(store, store.latest_messages[i].root, store.blocks[root].slot) == root)
|
||||
))
|
||||
if store.proposer_boost_root == Root():
|
||||
# Return only attestation score if ``proposer_boost_root`` is not set
|
||||
return attestation_score
|
||||
|
||||
# Calculate proposer score if ``proposer_boost_root`` is set
|
||||
proposer_score = Gwei(0)
|
||||
if store.proposer_boost_root != Root() and root == store.proposer_boost_root:
|
||||
# Boost is applied if ``root`` is an ancestor of ``proposer_boost_root``
|
||||
if get_ancestor(store, store.proposer_boost_root, store.blocks[root].slot) == root:
|
||||
num_validators = len(get_active_validator_indices(state, get_current_epoch(state)))
|
||||
avg_balance = get_total_active_balance(state) // num_validators
|
||||
committee_size = num_validators // SLOTS_PER_EPOCH
|
||||
|
@ -166,6 +166,9 @@ def test_shorter_chain_but_heavier_weight(spec, state):
|
||||
signed_short_block = state_transition_and_sign_block(spec, short_state, short_block)
|
||||
yield from tick_and_add_block(spec, store, signed_short_block, test_steps)
|
||||
|
||||
# Since the long chain has higher proposer_score at slot 1, the latest long block is the head
|
||||
assert spec.get_head(store) == spec.hash_tree_root(long_block)
|
||||
|
||||
short_attestation = get_valid_attestation(spec, short_state, short_block.slot, signed=True)
|
||||
yield from tick_and_run_on_attestation(spec, store, short_attestation, test_steps)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user