Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test_proposer_in_committee_without_participation__zero_pre_balance #3601

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

hwwhww
Copy link
Contributor

@hwwhww hwwhww commented Feb 14, 2024

Suggested by @dapplion, this is a spec test for proposer in sync committee with balance close to zero, and doesn't participate.

Testing target

In process_sync_aggregate

proposer_reward = Gwei(participant_reward * PROPOSER_WEIGHT // (WEIGHT_DENOMINATOR - PROPOSER_WEIGHT))
# Apply participant and proposer rewards
all_pubkeys = [v.pubkey for v in state.validators]
committee_indices = [ValidatorIndex(all_pubkeys.index(pubkey)) for pubkey in state.current_sync_committee.pubkeys]
for participant_index, participation_bit in zip(committee_indices, sync_aggregate.sync_committee_bits):
if participation_bit:
increase_balance(state, participant_index, participant_reward)
increase_balance(state, get_beacon_proposer_index(state), proposer_reward)
else:
decrease_balance(state, participant_index, participant_reward)

We have implemented a for-loop designed to go through the committee sequentially. It either increases or decreases the balances in the for-loop. The sequence in which these adjustments are applied is critical, as it significantly influences the final results.

Test case description

In this test case, we have (1) proposer in sync committee, (2) only "the validator next to the proposer in committee" has participated.

The proposer balance should get decreased and hit the lower bound 0 first, and then, increased with proposer reward in the next iteration on the participant.

As expected, the result doesn't match our testing helper check (validate_sync_committee_rewards.

Note that since we use effective balance to seed the proposer, the best I can mock in the test is setting state.balances[proposer_index] but not setting state.validators[proposer_index].effective_balance.

@hwwhww hwwhww mentioned this pull request Feb 15, 2024
6 tasks
@hwwhww hwwhww requested a review from dapplion March 4, 2024 06:53
validator_index = committee_indices[participant_index]
participation = [False for _ in committee_indices]
participation[participant_index] = True
participants = [validator_index]
Copy link
Collaborator

@dapplion dapplion Mar 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this approach triggers the condition. If I understand you code, there is exactly one committee participant, which is the proposer. The proposer starts with 0 balance, and gets rewarded for participating in the sync committee, but there's no balance decrease for the propose.

To trigger the condition we need to (1) have the non-participation penalty of the proposer index saturate to 0, and have a later participant reward increase the proposer balance to > 0. So we should set the proposer participation to False and at least one bit to True whose bit index is greater than the proposer location in the sync committee.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants