-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Rebase EIP-4844 on Capella #3052
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
Changes from all commits
242e1b7
f6f2474
2ac57c7
0488c0c
459310f
6d270cd
ca538f5
3172095
e460005
60187e5
95ee291
e3e73a8
a59dd37
a04f06b
bed1df0
2fbb1ed
fcafdc1
67ba28c
104cba0
6327ffa
cd1e113
3df1371
3714446
f1d4c90
ee0e2a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,13 +33,14 @@ | |
- [`process_execution_payload`](#process_execution_payload) | ||
- [Blob KZG commitments](#blob-kzg-commitments) | ||
- [Testing](#testing) | ||
- [Disabling Withdrawals](#disabling-withdrawals) | ||
|
||
<!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- /TOC --> | ||
|
||
## Introduction | ||
|
||
This upgrade adds blobs to the beacon chain as part of EIP-4844. | ||
This upgrade adds blobs to the beacon chain as part of EIP-4844. This is an extension of the Capella upgrade. | ||
|
||
## Custom types | ||
|
||
|
@@ -89,6 +90,7 @@ class BeaconBlockBody(Container): | |
sync_aggregate: SyncAggregate | ||
# Execution | ||
execution_payload: ExecutionPayload | ||
bls_to_execution_changes: List[SignedBLSToExecutionChange, MAX_BLS_TO_EXECUTION_CHANGES] | ||
blob_kzg_commitments: List[KZGCommitment, MAX_BLOBS_PER_BLOCK] # [New in EIP-4844] | ||
``` | ||
|
||
|
@@ -109,10 +111,11 @@ class ExecutionPayload(Container): | |
timestamp: uint64 | ||
extra_data: ByteList[MAX_EXTRA_DATA_BYTES] | ||
base_fee_per_gas: uint256 | ||
excess_blobs: uint64 # [New in EIP-4844] | ||
excess_data_gas: uint256 # [New in EIP-4844] | ||
# Extra payload fields | ||
block_hash: Hash32 # Hash of execution block | ||
transactions: List[Transaction, MAX_TRANSACTIONS_PER_PAYLOAD] | ||
withdrawals: List[Withdrawal, MAX_WITHDRAWALS_PER_PAYLOAD] | ||
``` | ||
|
||
#### `ExecutionPayloadHeader` | ||
|
@@ -132,10 +135,11 @@ class ExecutionPayloadHeader(Container): | |
timestamp: uint64 | ||
extra_data: ByteList[MAX_EXTRA_DATA_BYTES] | ||
base_fee_per_gas: uint256 | ||
excess_blobs: uint64 # [New in EIP-4844] | ||
excess_data_gas: uint256 # [New in EIP-4844] | ||
# Extra payload fields | ||
djrtwo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
block_hash: Hash32 # Hash of execution block | ||
transactions_root: Root | ||
withdrawals_root: Root | ||
``` | ||
|
||
## Helper functions | ||
|
@@ -227,7 +231,8 @@ def verify_kzg_commitments_against_transactions(transactions: Sequence[Transacti | |
def process_block(state: BeaconState, block: BeaconBlock) -> None: | ||
process_block_header(state, block) | ||
if is_execution_enabled(state, block.body): | ||
process_execution_payload(state, block.body.execution_payload, EXECUTION_ENGINE) | ||
process_withdrawals(state, block.body.execution_payload) | ||
process_execution_payload(state, block.body.execution_payload, EXECUTION_ENGINE) # [Modified in EIP-4844] | ||
process_randao(state, block.body) | ||
process_eth1_data(state, block.body) | ||
process_operations(state, block.body) | ||
|
@@ -253,6 +258,7 @@ def process_execution_payload(state: BeaconState, payload: ExecutionPayload, exe | |
assert payload.timestamp == compute_timestamp_at_slot(state, state.slot) | ||
# Verify the execution payload is valid | ||
assert execution_engine.notify_new_payload(payload) | ||
|
||
# Cache execution payload header | ||
state.latest_execution_payload_header = ExecutionPayloadHeader( | ||
parent_hash=payload.parent_hash, | ||
|
@@ -267,9 +273,10 @@ def process_execution_payload(state: BeaconState, payload: ExecutionPayload, exe | |
timestamp=payload.timestamp, | ||
extra_data=payload.extra_data, | ||
base_fee_per_gas=payload.base_fee_per_gas, | ||
excess_blobs=payload.excess_blobs, # [New in EIP-4844] | ||
excess_data_gas=payload.excess_data_gas, # [New in EIP-4844] | ||
block_hash=payload.block_hash, | ||
transactions_root=hash_tree_root(payload.transactions), | ||
withdrawals_root=hash_tree_root(payload.withdrawals), | ||
) | ||
``` | ||
|
||
|
@@ -335,3 +342,10 @@ def initialize_beacon_state_from_eth1(eth1_block_hash: Hash32, | |
|
||
return state | ||
``` | ||
|
||
### Disabling Withdrawals | ||
During testing we avoid Capella-specific updates to the state transition. We do this by replacing the following functions with a no-op implementation: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This no-op works fine for clients? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We want to avoid submitted withdrawals from interfering with the testnet. By no-op'ing these functions, withdrawals won't have any effect. |
||
- `process_withdrawals` | ||
- `process_bls_to_execution_change` | ||
|
||
The `get_expected_withdrawals` function is also modified to return an empty withdrawals list. As such, the PayloadAttributes used to update forkchoice does not contain withdrawals. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,7 +67,7 @@ Some gossip meshes are upgraded in the fork of EIP4844 to support upgraded types | |
Topics follow the same specification as in prior upgrades. | ||
All topics remain stable except the beacon block topic which is updated with the modified type. | ||
|
||
The specification around the creation, validation, and dissemination of messages has not changed from the Bellatrix document unless explicitly noted here. | ||
The specification around the creation, validation, and dissemination of messages has not changed from the Capella document unless explicitly noted here. | ||
|
||
The derivation of the `message-id` remains stable. | ||
|
||
|
@@ -124,6 +124,7 @@ Per `context = compute_fork_digest(fork_version, genesis_validators_root)`: | |
| `GENESIS_FORK_VERSION` | `phase0.SignedBeaconBlock` | | ||
| `ALTAIR_FORK_VERSION` | `altair.SignedBeaconBlock` | | ||
| `BELLATRIX_FORK_VERSION` | `bellatrix.SignedBeaconBlock` | | ||
| `CAPELLA_FORK_VERSION` | `capella.SignedBeaconBlock` | | ||
| `EIP4844_FORK_VERSION` | `eip4844.SignedBeaconBlock` | | ||
|
||
#### BeaconBlocksByRoot v2 | ||
|
@@ -142,6 +143,7 @@ Per `context = compute_fork_digest(fork_version, genesis_validators_root)`: | |
| `GENESIS_FORK_VERSION` | `phase0.SignedBeaconBlock` | | ||
| `ALTAIR_FORK_VERSION` | `altair.SignedBeaconBlock` | | ||
| `BELLATRIX_FORK_VERSION` | `bellatrix.SignedBeaconBlock` | | ||
| `CAPELLA_FORK_VERSION` | `capella.SignedBeaconBlock` | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potential merge conflict with #3089. I can fix that after this is merged There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed in f1d4c90 |
||
|
||
#### BeaconBlockAndBlobsSidecarByRoot v1 | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
from eth2spec.test.helpers.constants import CAPELLA | ||
from eth2spec.test.helpers.keys import pubkeys | ||
from eth2spec.test.helpers.bls_to_execution_changes import get_signed_address_change | ||
|
||
from eth2spec.test.context import spec_state_test, expect_assertion_error, with_capella_and_later, always_bls | ||
from eth2spec.test.context import spec_state_test, expect_assertion_error, with_phases, always_bls | ||
|
||
|
||
def run_bls_to_execution_change_processing(spec, state, signed_address_change, valid=True): | ||
|
@@ -37,14 +38,14 @@ def run_bls_to_execution_change_processing(spec, state, signed_address_change, v | |
yield 'post', state | ||
|
||
|
||
@with_capella_and_later | ||
@with_phases([CAPELLA]) | ||
@spec_state_test | ||
def test_success(spec, state): | ||
signed_address_change = get_signed_address_change(spec, state) | ||
yield from run_bls_to_execution_change_processing(spec, state, signed_address_change) | ||
|
||
|
||
@with_capella_and_later | ||
@with_phases([CAPELLA]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be capella and later, no? Ah, the no-op change will break this test... If we do this, we need to remember to go back and change these all :/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My understanding is to prevent random semi-public testnet users/validators from invoking any withdrawals? Agreed with this complicating testing but given that we have 3-4 in-discussion changes on Capella, it makes sense that EIP-4844 devs want to disable Capella now... 😭 Btw I also added the tests to test the Capella no-op. So we must undo it altogether. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes it's exactly this. |
||
@spec_state_test | ||
def test_success_not_activated(spec, state): | ||
validator_index = 3 | ||
|
@@ -62,7 +63,7 @@ def test_success_not_activated(spec, state): | |
assert not spec.is_fully_withdrawable_validator(validator, balance, spec.get_current_epoch(state)) | ||
|
||
|
||
@with_capella_and_later | ||
@with_phases([CAPELLA]) | ||
@spec_state_test | ||
def test_success_in_activation_queue(spec, state): | ||
validator_index = 3 | ||
|
@@ -80,7 +81,7 @@ def test_success_in_activation_queue(spec, state): | |
assert not spec.is_fully_withdrawable_validator(validator, balance, spec.get_current_epoch(state)) | ||
|
||
|
||
@with_capella_and_later | ||
@with_phases([CAPELLA]) | ||
@spec_state_test | ||
def test_success_in_exit_queue(spec, state): | ||
validator_index = 3 | ||
|
@@ -93,7 +94,7 @@ def test_success_in_exit_queue(spec, state): | |
yield from run_bls_to_execution_change_processing(spec, state, signed_address_change) | ||
|
||
|
||
@with_capella_and_later | ||
@with_phases([CAPELLA]) | ||
@spec_state_test | ||
def test_success_exited(spec, state): | ||
validator_index = 4 | ||
|
@@ -110,7 +111,7 @@ def test_success_exited(spec, state): | |
assert not spec.is_fully_withdrawable_validator(validator, balance, spec.get_current_epoch(state)) | ||
|
||
|
||
@with_capella_and_later | ||
@with_phases([CAPELLA]) | ||
@spec_state_test | ||
def test_success_withdrawable(spec, state): | ||
validator_index = 4 | ||
|
@@ -128,7 +129,7 @@ def test_success_withdrawable(spec, state): | |
assert spec.is_fully_withdrawable_validator(validator, balance, spec.get_current_epoch(state)) | ||
|
||
|
||
@with_capella_and_later | ||
@with_phases([CAPELLA]) | ||
@spec_state_test | ||
def test_fail_val_index_out_of_range(spec, state): | ||
# Create for one validator beyond the validator list length | ||
|
@@ -137,7 +138,7 @@ def test_fail_val_index_out_of_range(spec, state): | |
yield from run_bls_to_execution_change_processing(spec, state, signed_address_change, valid=False) | ||
|
||
|
||
@with_capella_and_later | ||
@with_phases([CAPELLA]) | ||
@spec_state_test | ||
def test_fail_already_0x01(spec, state): | ||
# Create for one validator beyond the validator list length | ||
|
@@ -149,7 +150,7 @@ def test_fail_already_0x01(spec, state): | |
yield from run_bls_to_execution_change_processing(spec, state, signed_address_change, valid=False) | ||
|
||
|
||
@with_capella_and_later | ||
@with_phases([CAPELLA]) | ||
@spec_state_test | ||
def test_fail_incorrect_from_bls_pubkey(spec, state): | ||
# Create for one validator beyond the validator list length | ||
|
@@ -163,7 +164,7 @@ def test_fail_incorrect_from_bls_pubkey(spec, state): | |
yield from run_bls_to_execution_change_processing(spec, state, signed_address_change, valid=False) | ||
|
||
|
||
@with_capella_and_later | ||
@with_phases([CAPELLA]) | ||
@spec_state_test | ||
@always_bls | ||
def test_fail_bad_signature(spec, state): | ||
|
Uh oh!
There was an error while loading. Please reload this page.