Renaming PendingPartialWithdrawal.index to validator_index

This commit is contained in:
Lucas Saldanha 2024-12-09 11:59:55 +13:00
parent ee135b1b4b
commit 757a73bd70
No known key found for this signature in database
6 changed files with 21 additions and 21 deletions

View File

@ -1571,7 +1571,7 @@ def process_withdrawal_request(
exit_queue_epoch = compute_exit_epoch_and_update_churn(state, to_withdraw)
withdrawable_epoch = Epoch(exit_queue_epoch + MIN_VALIDATOR_WITHDRAWABILITY_DELAY)
state.pending_partial_withdrawals.append(PendingPartialWithdrawal(
index=index,
validator_index=index,
amount=to_withdraw,
withdrawable_epoch=withdrawable_epoch,
))

View File

@ -999,7 +999,7 @@ def test_incorrect_source_has_pending_withdrawal(spec, state):
# Create pending withdrawal
pending_withdrawal = spec.PendingPartialWithdrawal(
index=0, amount=excess_balance, withdrawable_epoch=current_epoch
validator_index=0, amount=excess_balance, withdrawable_epoch=current_epoch
)
state.pending_partial_withdrawals.append(pending_withdrawal)

View File

@ -401,7 +401,7 @@ def test_invalid_validator_has_pending_withdrawal(spec, state):
state.pending_partial_withdrawals.append(
spec.PendingPartialWithdrawal(
index=validator_index,
validator_index=validator_index,
amount=1,
withdrawable_epoch=spec.compute_activation_exit_epoch(current_epoch),
)

View File

@ -81,7 +81,7 @@ def run_withdrawal_request_processing(
+ spec.config.MIN_VALIDATOR_WITHDRAWABILITY_DELAY
)
expected_partial_withdrawal = spec.PendingPartialWithdrawal(
index=validator_index,
validator_index=validator_index,
amount=expected_amount_to_withdraw,
withdrawable_epoch=expected_withdrawable_epoch,
)
@ -196,7 +196,7 @@ def test_basic_withdrawal_request_with_full_partial_withdrawal_queue(spec, state
# Fill the partial withdrawal queue to the max (with a different validator index)
partial_withdrawal = spec.PendingPartialWithdrawal(
index=1, amount=1, withdrawable_epoch=current_epoch
validator_index=1, amount=1, withdrawable_epoch=current_epoch
)
state.pending_partial_withdrawals = [
partial_withdrawal
@ -353,7 +353,7 @@ def test_unknown_pubkey(spec, state):
@with_electra_and_later
@spec_state_test
@with_presets([MINIMAL])
def test_basic_partial_withdrawal_request(spec, state):
def test_basic_partial_withdrawal_request(spec, state):
rng = random.Random(1344)
state.slot += spec.config.SHARD_COMMITTEE_PERIOD * spec.SLOTS_PER_EPOCH
current_epoch = spec.get_current_epoch(state)
@ -471,7 +471,7 @@ def test_partial_withdrawal_request_with_pending_withdrawals(spec, state):
# Add pending withdrawals
partial_withdrawal = spec.PendingPartialWithdrawal(
index=validator_index, amount=amount, withdrawable_epoch=current_epoch
validator_index=validator_index, amount=amount, withdrawable_epoch=current_epoch
)
state.pending_partial_withdrawals = [partial_withdrawal] * 2
@ -513,7 +513,7 @@ def test_partial_withdrawal_request_with_pending_withdrawals_and_high_amount(
# Add many pending withdrawals
partial_withdrawal = spec.PendingPartialWithdrawal(
index=validator_index,
validator_index=validator_index,
amount=spec.EFFECTIVE_BALANCE_INCREMENT,
withdrawable_epoch=current_epoch,
)
@ -661,7 +661,7 @@ def test_partial_withdrawal_queue_full(spec, state):
# Fill the partial withdrawal queue to the max
partial_withdrawal = spec.PendingPartialWithdrawal(
index=1, amount=1, withdrawable_epoch=current_epoch
validator_index=1, amount=1, withdrawable_epoch=current_epoch
)
state.pending_partial_withdrawals = [
partial_withdrawal
@ -746,7 +746,7 @@ def test_pending_withdrawals_consume_all_excess_balance(spec, state):
# Add pending withdrawals totalling an amount equal to the excess balance
partial_withdrawal = spec.PendingPartialWithdrawal(
index=validator_index, amount=amount, withdrawable_epoch=current_epoch
validator_index=validator_index, amount=amount, withdrawable_epoch=current_epoch
)
state.pending_partial_withdrawals = [partial_withdrawal] * 10
@ -951,7 +951,7 @@ def test_full_exit_request_has_partial_withdrawal(spec, state):
state.balances[validator_index] = spec.MAX_EFFECTIVE_BALANCE_ELECTRA
state.pending_partial_withdrawals.append(
spec.PendingPartialWithdrawal(
index=validator_index,
validator_index=validator_index,
amount=1,
withdrawable_epoch=spec.compute_activation_exit_epoch(current_epoch),
)

View File

@ -91,14 +91,14 @@ def test_success_excess_balance_but_no_max_effective_balance_compounding(spec, s
@with_electra_and_later
@spec_state_test
def test_pending_withdrawals_one_skipped_one_effective(spec, state):
index_0 = 3
index_1 = 5
validator_index_0 = 3
validator_index_1 = 5
pending_withdrawal_0 = prepare_pending_withdrawal(spec, state, index_0)
pending_withdrawal_1 = prepare_pending_withdrawal(spec, state, index_1)
pending_withdrawal_0 = prepare_pending_withdrawal(spec, state, validator_index_0)
pending_withdrawal_1 = prepare_pending_withdrawal(spec, state, validator_index_1)
# If validator doesn't have an excess balance pending withdrawal is skipped
state.balances[index_0] = spec.MIN_ACTIVATION_BALANCE
state.balances[validator_index_0] = spec.MIN_ACTIVATION_BALANCE
execution_payload = build_empty_execution_payload(spec, state)
assert state.pending_partial_withdrawals == [pending_withdrawal_0, pending_withdrawal_1]
@ -155,7 +155,7 @@ def test_pending_withdrawals_exiting_validator(spec, state):
validator_index = len(state.validators) // 2
pending_withdrawal = prepare_pending_withdrawal(spec, state, validator_index)
spec.initiate_validator_exit(state, pending_withdrawal.index)
spec.initiate_validator_exit(state, pending_withdrawal.validator_index)
execution_payload = build_empty_execution_payload(spec, state)
yield from run_withdrawals_processing(spec, state, execution_payload, num_expected_withdrawals=0)
@ -169,7 +169,7 @@ def test_pending_withdrawals_low_effective_balance(spec, state):
validator_index = len(state.validators) // 2
pending_withdrawal = prepare_pending_withdrawal(spec, state, validator_index)
state.validators[pending_withdrawal.index].effective_balance = (
state.validators[pending_withdrawal.validator_index].effective_balance = (
spec.MIN_ACTIVATION_BALANCE - spec.EFFECTIVE_BALANCE_INCREMENT
)
@ -185,7 +185,7 @@ def test_pending_withdrawals_no_excess_balance(spec, state):
validator_index = len(state.validators) // 2
pending_withdrawal = prepare_pending_withdrawal(spec, state, validator_index)
state.balances[pending_withdrawal.index] = spec.MIN_ACTIVATION_BALANCE
state.balances[pending_withdrawal.validator_index] = spec.MIN_ACTIVATION_BALANCE
execution_payload = build_empty_execution_payload(spec, state)
yield from run_withdrawals_processing(spec, state, execution_payload, num_expected_withdrawals=0)

View File

@ -120,7 +120,7 @@ def prepare_pending_withdrawal(spec, state, validator_index,
)
withdrawal = spec.PendingPartialWithdrawal(
index=validator_index,
validator_index=validator_index,
amount=amount,
withdrawable_epoch=withdrawable_epoch,
)
@ -238,7 +238,7 @@ def run_withdrawals_processing(spec, state, execution_payload, num_expected_with
assert len(pending_withdrawal_requests) <= len(execution_payload.withdrawals)
for index, request in enumerate(pending_withdrawal_requests):
withdrawal = execution_payload.withdrawals[index]
assert withdrawal.validator_index == request.index
assert withdrawal.validator_index == request.validator_index
assert withdrawal.amount == request.amount
return expected_withdrawals