|
3711 | 3711 | - file: ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/capella/withdrawals/WithdrawalsHelpersCapella.java |
3712 | 3712 | search: public ExpectedWithdrawals getExpectedWithdrawals( |
3713 | 3713 | spec: | |
3714 | | - <spec fn="get_expected_withdrawals" fork="capella" hash="d6a98c14"> |
3715 | | - def get_expected_withdrawals(state: BeaconState) -> Tuple[Sequence[Withdrawal], uint64]: |
| 3714 | + <spec fn="get_expected_withdrawals" fork="capella" hash="12088347"> |
| 3715 | + def get_expected_withdrawals(state: BeaconState) -> ExpectedWithdrawals: |
3716 | 3716 | withdrawal_index = state.next_withdrawal_index |
3717 | 3717 | withdrawals: List[Withdrawal] = [] |
3718 | 3718 |
|
|
3722 | 3722 | ) |
3723 | 3723 | withdrawals.extend(validators_sweep_withdrawals) |
3724 | 3724 |
|
3725 | | - return withdrawals, processed_validators_sweep_count |
| 3725 | + return ExpectedWithdrawals( |
| 3726 | + withdrawals, |
| 3727 | + processed_validators_sweep_count, |
| 3728 | + ) |
3726 | 3729 | </spec> |
3727 | 3730 |
|
3728 | 3731 | - name: get_expected_withdrawals#electra |
3729 | 3732 | sources: |
3730 | 3733 | - file: ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/capella/withdrawals/WithdrawalsHelpersCapella.java |
3731 | 3734 | search: public ExpectedWithdrawals getExpectedWithdrawals( |
3732 | 3735 | spec: | |
3733 | | - <spec fn="get_expected_withdrawals" fork="electra" hash="cfce862b"> |
3734 | | - def get_expected_withdrawals(state: BeaconState) -> Tuple[Sequence[Withdrawal], uint64, uint64]: |
| 3736 | + <spec fn="get_expected_withdrawals" fork="electra" hash="254541e3"> |
| 3737 | + def get_expected_withdrawals(state: BeaconState) -> ExpectedWithdrawals: |
3735 | 3738 | withdrawal_index = state.next_withdrawal_index |
3736 | 3739 | withdrawals: List[Withdrawal] = [] |
3737 | 3740 |
|
|
3748 | 3751 | ) |
3749 | 3752 | withdrawals.extend(validators_sweep_withdrawals) |
3750 | 3753 |
|
3751 | | - # [Modified in Electra:EIP7251] |
3752 | | - return withdrawals, processed_partial_withdrawals_count, processed_validators_sweep_count |
| 3754 | + return ExpectedWithdrawals( |
| 3755 | + withdrawals, |
| 3756 | + # [New in Electra:EIP7251] |
| 3757 | + processed_partial_withdrawals_count, |
| 3758 | + processed_validators_sweep_count, |
| 3759 | + ) |
3753 | 3760 | </spec> |
3754 | 3761 |
|
3755 | 3762 | - name: get_expected_withdrawals#gloas |
3756 | 3763 | sources: [] |
3757 | 3764 | spec: | |
3758 | | - <spec fn="get_expected_withdrawals" fork="gloas" hash="950fb815"> |
3759 | | - def get_expected_withdrawals( |
3760 | | - state: BeaconState, |
3761 | | - ) -> Tuple[Sequence[Withdrawal], uint64, uint64, uint64, uint64]: |
| 3765 | + <spec fn="get_expected_withdrawals" fork="gloas" hash="8d0675cb"> |
| 3766 | + def get_expected_withdrawals(state: BeaconState) -> ExpectedWithdrawals: |
3762 | 3767 | withdrawal_index = state.next_withdrawal_index |
3763 | 3768 | withdrawals: List[Withdrawal] = [] |
3764 | 3769 |
|
|
3788 | 3793 | ) |
3789 | 3794 | withdrawals.extend(validators_sweep_withdrawals) |
3790 | 3795 |
|
3791 | | - # [Modified in Gloas:EIP7732] |
3792 | | - return ( |
| 3796 | + return ExpectedWithdrawals( |
3793 | 3797 | withdrawals, |
| 3798 | + # [New in Gloas:EIP7732] |
3794 | 3799 | processed_builder_withdrawals_count, |
3795 | 3800 | processed_partial_withdrawals_count, |
| 3801 | + # [New in Gloas:EIP7732] |
3796 | 3802 | processed_builders_sweep_count, |
3797 | 3803 | processed_validators_sweep_count, |
3798 | 3804 | ) |
|
7314 | 7320 | - name: prepare_execution_payload#capella |
7315 | 7321 | sources: [] |
7316 | 7322 | spec: | |
7317 | | - <spec fn="prepare_execution_payload" fork="capella" style="diff" hash="c258893e"> |
| 7323 | + <spec fn="prepare_execution_payload" fork="capella" style="diff" hash="998e8b92"> |
7318 | 7324 | --- bellatrix |
7319 | 7325 | +++ capella |
7320 | | - @@ -4,28 +4,16 @@ |
| 7326 | + @@ -4,28 +4,14 @@ |
7321 | 7327 | finalized_block_hash: Hash32, |
7322 | 7328 | suggested_fee_recipient: ExecutionAddress, |
7323 | 7329 | execution_engine: ExecutionEngine, |
|
7331 | 7337 | - ) |
7332 | 7338 | - if is_terminal_block_hash_set and not is_activation_epoch_reached: |
7333 | 7339 | - return None |
7334 | | - + parent_hash = state.latest_execution_payload_header.block_hash |
7335 | | - |
| 7340 | + - |
7336 | 7341 | - terminal_pow_block = get_terminal_pow_block(pow_chain) |
7337 | 7342 | - if terminal_pow_block is None: |
7338 | 7343 | - return None |
7339 | 7344 | - parent_hash = terminal_pow_block.block_hash |
7340 | 7345 | - else: |
7341 | 7346 | - parent_hash = state.latest_execution_payload_header.block_hash |
7342 | | - + withdrawals, _ = get_expected_withdrawals(state) |
| 7347 | + + parent_hash = state.latest_execution_payload_header.block_hash |
7343 | 7348 |
|
7344 | 7349 | payload_attributes = PayloadAttributes( |
7345 | 7350 | timestamp=compute_time_at_slot(state, state.slot), |
7346 | 7351 | prev_randao=get_randao_mix(state, get_current_epoch(state)), |
7347 | 7352 | suggested_fee_recipient=suggested_fee_recipient, |
7348 | | - + withdrawals=withdrawals, |
| 7353 | + + withdrawals=get_expected_withdrawals(state).withdrawals, |
7349 | 7354 | ) |
7350 | 7355 | return execution_engine.notify_forkchoice_updated( |
7351 | 7356 | head_block_hash=parent_hash, |
|
7354 | 7359 | - name: prepare_execution_payload#deneb |
7355 | 7360 | sources: [] |
7356 | 7361 | spec: | |
7357 | | - <spec fn="prepare_execution_payload" fork="deneb" style="diff" hash="59f61f3a"> |
| 7362 | + <spec fn="prepare_execution_payload" fork="deneb" style="diff" hash="c617aa1b"> |
7358 | 7363 | --- capella |
7359 | 7364 | +++ deneb |
7360 | | - @@ -14,6 +14,7 @@ |
| 7365 | + @@ -12,6 +12,7 @@ |
7361 | 7366 | prev_randao=get_randao_mix(state, get_current_epoch(state)), |
7362 | 7367 | suggested_fee_recipient=suggested_fee_recipient, |
7363 | | - withdrawals=withdrawals, |
| 7368 | + withdrawals=get_expected_withdrawals(state).withdrawals, |
7364 | 7369 | + parent_beacon_block_root=hash_tree_root(state.latest_block_header), |
7365 | 7370 | ) |
7366 | 7371 | return execution_engine.notify_forkchoice_updated( |
|
7370 | 7375 | - name: prepare_execution_payload#electra |
7371 | 7376 | sources: [] |
7372 | 7377 | spec: | |
7373 | | - <spec fn="prepare_execution_payload" fork="electra" style="diff" hash="5414b883"> |
7374 | | - --- deneb |
| 7378 | + <spec fn="prepare_execution_payload" fork="electra" style="diff" hash="c617aa1b"> |
| 7379 | + --- capella |
7375 | 7380 | +++ electra |
7376 | | - @@ -7,7 +7,7 @@ |
7377 | | - ) -> Optional[PayloadId]: |
7378 | | - parent_hash = state.latest_execution_payload_header.block_hash |
7379 | | - |
7380 | | - - withdrawals, _ = get_expected_withdrawals(state) |
7381 | | - + withdrawals, _, _ = get_expected_withdrawals(state) |
7382 | | - |
7383 | | - payload_attributes = PayloadAttributes( |
7384 | | - timestamp=compute_time_at_slot(state, state.slot), |
| 7381 | + @@ -12,6 +12,7 @@ |
| 7382 | + prev_randao=get_randao_mix(state, get_current_epoch(state)), |
| 7383 | + suggested_fee_recipient=suggested_fee_recipient, |
| 7384 | + withdrawals=get_expected_withdrawals(state).withdrawals, |
| 7385 | + + parent_beacon_block_root=hash_tree_root(state.latest_block_header), |
| 7386 | + ) |
| 7387 | + return execution_engine.notify_forkchoice_updated( |
| 7388 | + head_block_hash=parent_hash, |
7385 | 7389 | </spec> |
7386 | 7390 |
|
7387 | 7391 | - name: prepare_execution_payload#gloas |
7388 | 7392 | sources: [] |
7389 | 7393 | spec: | |
7390 | | - <spec fn="prepare_execution_payload" fork="gloas" hash="8fdad5cf"> |
| 7394 | + <spec fn="prepare_execution_payload" fork="gloas" hash="c617aa1b"> |
7391 | 7395 | def prepare_execution_payload( |
7392 | 7396 | state: BeaconState, |
7393 | 7397 | safe_block_hash: Hash32, |
7394 | 7398 | finalized_block_hash: Hash32, |
7395 | 7399 | suggested_fee_recipient: ExecutionAddress, |
7396 | 7400 | execution_engine: ExecutionEngine, |
7397 | 7401 | ) -> Optional[PayloadId]: |
7398 | | - # Verify consistency of the parent hash with respect to the previous execution payload bid |
7399 | | - parent_hash = state.latest_execution_payload_bid.block_hash |
| 7402 | + # Verify consistency of the parent hash with respect to the previous execution payload header |
| 7403 | + parent_hash = state.latest_execution_payload_header.block_hash |
7400 | 7404 |
|
7401 | | - # [Modified in Gloas:EIP7732] |
7402 | 7405 | # Set the forkchoice head and initiate the payload build process |
7403 | | - withdrawals, _, _, _, _ = get_expected_withdrawals(state) |
7404 | | - |
7405 | 7406 | payload_attributes = PayloadAttributes( |
7406 | 7407 | timestamp=compute_time_at_slot(state, state.slot), |
7407 | 7408 | prev_randao=get_randao_mix(state, get_current_epoch(state)), |
7408 | 7409 | suggested_fee_recipient=suggested_fee_recipient, |
7409 | | - withdrawals=withdrawals, |
| 7410 | + withdrawals=get_expected_withdrawals(state).withdrawals, |
| 7411 | + # [New in Deneb:EIP4788] |
7410 | 7412 | parent_beacon_block_root=hash_tree_root(state.latest_block_header), |
7411 | 7413 | ) |
7412 | 7414 | return execution_engine.notify_forkchoice_updated( |
|
9912 | 9914 | - file: ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/capella/block/BlockProcessorCapella.java |
9913 | 9915 | search: public void processWithdrawals( |
9914 | 9916 | spec: | |
9915 | | - <spec fn="process_withdrawals" fork="capella" hash="901f9fc4"> |
| 9917 | + <spec fn="process_withdrawals" fork="capella" hash="47327ef6"> |
9916 | 9918 | def process_withdrawals(state: BeaconState, payload: ExecutionPayload) -> None: |
9917 | 9919 | # Get expected withdrawals |
9918 | | - withdrawals, processed_validators_sweep_count = get_expected_withdrawals(state) |
9919 | | - assert payload.withdrawals == withdrawals |
| 9920 | + expected = get_expected_withdrawals(state) |
| 9921 | + assert payload.withdrawals == expected.withdrawals |
9920 | 9922 |
|
9921 | 9923 | # Apply expected withdrawals |
9922 | | - apply_withdrawals(state, withdrawals) |
| 9924 | + apply_withdrawals(state, expected.withdrawals) |
9923 | 9925 |
|
9924 | 9926 | # Update withdrawals fields in the state |
9925 | | - update_next_withdrawal_index(state, withdrawals) |
9926 | | - update_next_withdrawal_validator_index(state, processed_validators_sweep_count) |
| 9927 | + update_next_withdrawal_index(state, expected.withdrawals) |
| 9928 | + update_next_withdrawal_validator_index(state, expected.withdrawals) |
9927 | 9929 | </spec> |
9928 | 9930 |
|
9929 | 9931 | - name: process_withdrawals#electra |
9930 | 9932 | sources: |
9931 | 9933 | - file: ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/capella/block/BlockProcessorCapella.java |
9932 | 9934 | search: public void processWithdrawals( |
9933 | 9935 | spec: | |
9934 | | - <spec fn="process_withdrawals" fork="electra" hash="67870972"> |
| 9936 | + <spec fn="process_withdrawals" fork="electra" hash="24a50daa"> |
9935 | 9937 | def process_withdrawals(state: BeaconState, payload: ExecutionPayload) -> None: |
9936 | | - # [Modified in Electra:EIP7251] |
9937 | 9938 | # Get expected withdrawals |
9938 | | - withdrawals, processed_partial_withdrawals_count, processed_validators_sweep_count = ( |
9939 | | - get_expected_withdrawals(state) |
9940 | | - ) |
9941 | | - assert payload.withdrawals == withdrawals |
| 9939 | + expected = get_expected_withdrawals(state) |
| 9940 | + assert payload.withdrawals == expected.withdrawals |
9942 | 9941 |
|
9943 | 9942 | # Apply expected withdrawals |
9944 | | - apply_withdrawals(state, withdrawals) |
| 9943 | + apply_withdrawals(state, expected.withdrawals) |
9945 | 9944 |
|
9946 | 9945 | # Update withdrawals fields in the state |
9947 | | - update_next_withdrawal_index(state, withdrawals) |
| 9946 | + update_next_withdrawal_index(state, expected.withdrawals) |
9948 | 9947 | # [New in Electra:EIP7251] |
9949 | | - update_pending_partial_withdrawals(state, processed_partial_withdrawals_count) |
9950 | | - update_next_withdrawal_validator_index(state, processed_validators_sweep_count) |
| 9948 | + update_pending_partial_withdrawals(state, expected.processed_partial_withdrawals_count) |
| 9949 | + update_next_withdrawal_validator_index(state, expected.withdrawals) |
9951 | 9950 | </spec> |
9952 | 9951 |
|
9953 | 9952 | - name: process_withdrawals#gloas |
9954 | 9953 | sources: |
9955 | 9954 | - file: ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/gloas/withdrawals/WithdrawalsHelpersGloas.java |
9956 | 9955 | search: public void processWithdrawals( |
9957 | 9956 | spec: | |
9958 | | - <spec fn="process_withdrawals" fork="gloas" hash="3caee596"> |
| 9957 | + <spec fn="process_withdrawals" fork="gloas" hash="16d9ad2a"> |
9959 | 9958 | def process_withdrawals( |
9960 | 9959 | state: BeaconState, |
9961 | 9960 | # [Modified in Gloas:EIP7732] |
|
9966 | 9965 | if not is_parent_block_full(state): |
9967 | 9966 | return |
9968 | 9967 |
|
9969 | | - # [Modified in Gloas:EIP7732] |
9970 | 9968 | # Get expected withdrawals |
9971 | | - ( |
9972 | | - withdrawals, |
9973 | | - processed_builder_withdrawals_count, |
9974 | | - processed_partial_withdrawals_count, |
9975 | | - processed_builders_sweep_count, |
9976 | | - processed_validators_sweep_count, |
9977 | | - ) = get_expected_withdrawals(state) |
| 9969 | + expected = get_expected_withdrawals(state) |
9978 | 9970 |
|
9979 | 9971 | # Apply expected withdrawals |
9980 | | - apply_withdrawals(state, withdrawals) |
| 9972 | + apply_withdrawals(state, expected.withdrawals) |
9981 | 9973 |
|
9982 | 9974 | # Update withdrawals fields in the state |
9983 | | - update_next_withdrawal_index(state, withdrawals) |
| 9975 | + update_next_withdrawal_index(state, expected.withdrawals) |
9984 | 9976 | # [New in Gloas:EIP7732] |
9985 | | - update_payload_expected_withdrawals(state, withdrawals) |
| 9977 | + update_payload_expected_withdrawals(state, expected.withdrawals) |
9986 | 9978 | # [New in Gloas:EIP7732] |
9987 | | - update_builder_pending_withdrawals(state, processed_builder_withdrawals_count) |
9988 | | - update_pending_partial_withdrawals(state, processed_partial_withdrawals_count) |
| 9979 | + update_builder_pending_withdrawals(state, expected.processed_builder_withdrawals_count) |
| 9980 | + update_pending_partial_withdrawals(state, expected.processed_partial_withdrawals_count) |
9989 | 9981 | # [New in Gloas:EIP7732] |
9990 | | - update_next_withdrawal_builder_index(state, processed_builders_sweep_count) |
9991 | | - update_next_withdrawal_validator_index(state, processed_validators_sweep_count) |
| 9982 | + update_next_withdrawal_builder_index(state, expected.processed_builders_sweep_count) |
| 9983 | + update_next_withdrawal_validator_index(state, expected.withdrawals) |
9992 | 9984 | </spec> |
9993 | 9985 |
|
9994 | 9986 | - name: queue_excess_active_balance#electra |
@@ -10690,14 +10682,22 @@ |
10690 | 10682 | - file: ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/capella/withdrawals/WithdrawalsHelpersCapella.java |
10691 | 10683 | search: protected void updateNextWithdrawalValidatorIndex( |
10692 | 10684 | spec: | |
10693 | | - <spec fn="update_next_withdrawal_validator_index" fork="capella" hash="98095ea6"> |
| 10685 | + <spec fn="update_next_withdrawal_validator_index" fork="capella" hash="4a3ee635"> |
10694 | 10686 | def update_next_withdrawal_validator_index( |
10695 | | - state: BeaconState, processed_validators_sweep_count: uint64 |
| 10687 | + state: BeaconState, withdrawals: Sequence[Withdrawal] |
10696 | 10688 | ) -> None: |
10697 | 10689 | # Update the next validator index to start the next withdrawal sweep |
10698 | | - next_index = state.next_withdrawal_validator_index + processed_validators_sweep_count |
10699 | | - next_validator_index = ValidatorIndex(next_index % len(state.validators)) |
10700 | | - state.next_withdrawal_validator_index = next_validator_index |
| 10690 | + if len(withdrawals) == MAX_WITHDRAWALS_PER_PAYLOAD: |
| 10691 | + # Next sweep starts after the latest withdrawal's validator index |
| 10692 | + next_validator_index = ValidatorIndex( |
| 10693 | + (withdrawals[-1].validator_index + 1) % len(state.validators) |
| 10694 | + ) |
| 10695 | + state.next_withdrawal_validator_index = next_validator_index |
| 10696 | + else: |
| 10697 | + # Advance sweep by the max length of the sweep if there was not a full set of withdrawals |
| 10698 | + next_index = state.next_withdrawal_validator_index + MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP |
| 10699 | + next_validator_index = ValidatorIndex(next_index % len(state.validators)) |
| 10700 | + state.next_withdrawal_validator_index = next_validator_index |
10701 | 10701 | </spec> |
10702 | 10702 |
|
10703 | 10703 | - name: update_payload_expected_withdrawals#gloas |
|
0 commit comments