diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 9fd38d7db..013d002c9 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -493,7 +493,7 @@ class BeaconState(Container): slot: Slot fork: Fork # History - block_header: BeaconBlockHeader + parent_block_header: BeaconBlockHeader block_roots: Vector[Hash, SLOTS_PER_HISTORICAL_ROOT] state_roots: Vector[Hash, SLOTS_PER_HISTORICAL_ROOT] historical_roots: List[Hash] @@ -511,8 +511,8 @@ class BeaconState(Container): # Slashings slashed_balances: Vector[Gwei, SLASHED_EXIT_LENGTH] # Attestations - previous_attestations: List[PendingAttestation] - current_attestations: List[PendingAttestation] + previous_epoch_attestations: List[PendingAttestation] + current_epoch_attestations: List[PendingAttestation] # Crosslinks previous_crosslinks: Vector[Crosslink, SHARD_COUNT] current_crosslinks: Vector[Crosslink, SHARD_COUNT] @@ -1126,7 +1126,7 @@ def get_genesis_beacon_state(deposits: List[Deposit], genesis_time: int, genesis state = BeaconState( genesis_time=genesis_time, eth1_data=genesis_eth1_data, - block_header=BeaconBlockHeader(body_root=hash_tree_root(BeaconBlockBody())), + parent_block_header=BeaconBlockHeader(body_root=hash_tree_root(BeaconBlockBody())), ) # Process genesis deposits @@ -1186,11 +1186,11 @@ def process_slot(state: BeaconState) -> None: state.state_roots[state.slot % SLOTS_PER_HISTORICAL_ROOT] = previous_state_root # Cache latest block header state root - if state.block_header.state_root == ZERO_HASH: - state.block_header.state_root = previous_state_root + if state.parent_block_header.state_root == ZERO_HASH: + state.parent_block_header.state_root = previous_state_root # Cache block root - previous_block_root = signing_root(state.block_header) + previous_block_root = signing_root(state.parent_block_header) state.block_roots[state.slot % SLOTS_PER_HISTORICAL_ROOT] = previous_block_root ``` @@ -1221,7 +1221,7 @@ def get_total_active_balance(state: BeaconState) -> Gwei: ```python def get_matching_source_attestations(state: BeaconState, epoch: Epoch) -> List[PendingAttestation]: assert epoch in (get_current_epoch(state), get_previous_epoch(state)) - return state.current_attestations if epoch == get_current_epoch(state) else state.previous_attestations + return state.current_epoch_attestations if epoch == get_current_epoch(state) else state.previous_epoch_attestations ``` ```python @@ -1509,8 +1509,8 @@ def process_final_updates(state: BeaconState) -> None: ) state.historical_roots.append(hash_tree_root(historical_batch)) # Rotate current/previous epoch attestations - state.previous_attestations = state.current_attestations - state.current_attestations = [] + state.previous_epoch_attestations = state.current_epoch_attestations + state.current_epoch_attestations = [] ``` ### Block processing @@ -1530,9 +1530,9 @@ def process_block_header(state: BeaconState, block: BeaconBlock) -> None: # Verify that the slots match assert block.slot == state.slot # Verify that the parent matches - assert block.parent_root == signing_root(state.block_header) + assert block.parent_root == signing_root(state.parent_block_header) # Save current block as the new latest block - state.block_header = BeaconBlockHeader( + state.parent_block_header = BeaconBlockHeader( slot=block.slot, parent_root=block.parent_root, body_root=hash_tree_root(block.body), @@ -1661,11 +1661,11 @@ def process_attestation(state: BeaconState, attestation: Attestation) -> None: if data.target_epoch == get_current_epoch(state): ffg_data = (state.current_justified_epoch, state.current_justified_root, get_current_epoch(state)) parent_crosslink = state.current_crosslinks[data.crosslink.shard] - state.current_attestations.append(pending_attestation) + state.current_epoch_attestations.append(pending_attestation) else: ffg_data = (state.previous_justified_epoch, state.previous_justified_root, get_previous_epoch(state)) parent_crosslink = state.previous_crosslinks[data.crosslink.shard] - state.previous_attestations.append(pending_attestation) + state.previous_epoch_attestations.append(pending_attestation) # Check FFG data, crosslink data, and signature assert ffg_data == (data.source_epoch, data.source_root, data.target_epoch) diff --git a/specs/test_formats/operations/README.md b/specs/test_formats/operations/README.md index 32cf880b3..dead3722b 100644 --- a/specs/test_formats/operations/README.md +++ b/specs/test_formats/operations/README.md @@ -14,7 +14,7 @@ post: BeaconState -- state after applying the operation. No ## Condition -A handler of the `operations` test-runner should process these cases, +A handler of the `operations` test-runner should process these cases, calling the corresponding processing implementation. Operations: @@ -23,13 +23,13 @@ Operations: |-------------------------|----------------------|----------------------|--------------------------------------------------------| | `attestation` | `Attestation` | `attestation` | `process_attestation(state, attestation)` | | `attester_slashing` | `AttesterSlashing` | `attester_slashing` | `process_attester_slashing(state, attester_slashing)` | -| `block_header` | `Block` | `block` | `process_block_header(state, block)` | +| `parent_block_header` | `Block` | `block` | `process_block_header(state, block)` | | `deposit` | `Deposit` | `deposit` | `process_deposit(state, deposit)` | | `proposer_slashing` | `ProposerSlashing` | `proposer_slashing` | `process_proposer_slashing(state, proposer_slashing)` | | `transfer` | `Transfer` | `transfer` | `process_transfer(state, transfer)` | | `voluntary_exit` | `VoluntaryExit` | `voluntary_exit` | `process_voluntary_exit(state, voluntary_exit)` | -Note that `block_header` is not strictly an operation (and is a full `Block`), but processed in the same manner, and hence included here. +Note that `parent_block_header` is not strictly an operation (and is a full `Block`), but processed in the same manner, and hence included here. The resulting state should match the expected `post` state, or if the `post` state is left blank, the handler should reject the input operation as invalid. diff --git a/test_generators/operations/main.py b/test_generators/operations/main.py index 82e05b307..70089ebe8 100644 --- a/test_generators/operations/main.py +++ b/test_generators/operations/main.py @@ -42,8 +42,8 @@ if __name__ == "__main__": create_suite('attestation', 'mainnet', lambda: generate_from_tests(test_process_attestation)), create_suite('attester_slashing', 'minimal', lambda: generate_from_tests(test_process_attester_slashing)), create_suite('attester_slashing', 'mainnet', lambda: generate_from_tests(test_process_attester_slashing)), - create_suite('block_header', 'minimal', lambda: generate_from_tests(test_process_block_header)), - create_suite('block_header', 'mainnet', lambda: generate_from_tests(test_process_block_header)), + create_suite('parent_block_header', 'minimal', lambda: generate_from_tests(test_process_block_header)), + create_suite('parent_block_header', 'mainnet', lambda: generate_from_tests(test_process_block_header)), create_suite('deposit', 'minimal', lambda: generate_from_tests(test_process_deposit)), create_suite('deposit', 'mainnet', lambda: generate_from_tests(test_process_deposit)), create_suite('proposer_slashing', 'minimal', lambda: generate_from_tests(test_process_proposer_slashing)), diff --git a/test_libs/pyspec/eth2spec/test/helpers/block.py b/test_libs/pyspec/eth2spec/test/helpers/block.py index ebd20f1b5..03f8d5b7e 100644 --- a/test_libs/pyspec/eth2spec/test/helpers/block.py +++ b/test_libs/pyspec/eth2spec/test/helpers/block.py @@ -58,7 +58,7 @@ def build_empty_block(spec, state, slot=None, signed=False): empty_block = spec.BeaconBlock() empty_block.slot = slot empty_block.body.eth1_data.deposit_count = state.eth1_deposit_index - previous_block_header = deepcopy(state.block_header) + previous_block_header = deepcopy(state.parent_block_header) if previous_block_header.state_root == spec.ZERO_HASH: previous_block_header.state_root = state.hash_tree_root() empty_block.parent_root = signing_root(previous_block_header) diff --git a/test_libs/pyspec/eth2spec/test/helpers/proposer_slashings.py b/test_libs/pyspec/eth2spec/test/helpers/proposer_slashings.py index d5b7f7b7f..d725f3316 100644 --- a/test_libs/pyspec/eth2spec/test/helpers/proposer_slashings.py +++ b/test_libs/pyspec/eth2spec/test/helpers/proposer_slashings.py @@ -1,6 +1,6 @@ from copy import deepcopy -from eth2spec.test.helpers.block_header import sign_block_header +from eth2spec.test.helpers.parent_block_header import sign_block_header from eth2spec.test.helpers.keys import pubkey_to_privkey diff --git a/test_libs/pyspec/eth2spec/test/phase_0/block_processing/test_process_attestation.py b/test_libs/pyspec/eth2spec/test/phase_0/block_processing/test_process_attestation.py index 6cd2d1194..2b34ab405 100644 --- a/test_libs/pyspec/eth2spec/test/phase_0/block_processing/test_process_attestation.py +++ b/test_libs/pyspec/eth2spec/test/phase_0/block_processing/test_process_attestation.py @@ -31,17 +31,17 @@ def run_attestation_processing(spec, state, attestation, valid=True): yield 'post', None return - current_epoch_count = len(state.current_attestations) - previous_epoch_count = len(state.previous_attestations) + current_epoch_count = len(state.current_epoch_attestations) + previous_epoch_count = len(state.previous_epoch_attestations) # process attestation spec.process_attestation(state, attestation) # Make sure the attestation has been processed if attestation.data.target_epoch == spec.get_current_epoch(state): - assert len(state.current_attestations) == current_epoch_count + 1 + assert len(state.current_epoch_attestations) == current_epoch_count + 1 else: - assert len(state.previous_attestations) == previous_epoch_count + 1 + assert len(state.previous_epoch_attestations) == previous_epoch_count + 1 # yield post-state yield 'post', state diff --git a/test_libs/pyspec/eth2spec/test/phase_0/block_processing/test_process_proposer_slashing.py b/test_libs/pyspec/eth2spec/test/phase_0/block_processing/test_process_proposer_slashing.py index af34ea709..41039ab06 100644 --- a/test_libs/pyspec/eth2spec/test/phase_0/block_processing/test_process_proposer_slashing.py +++ b/test_libs/pyspec/eth2spec/test/phase_0/block_processing/test_process_proposer_slashing.py @@ -1,5 +1,5 @@ from eth2spec.test.context import spec_state_test, expect_assertion_error, always_bls, with_all_phases -from eth2spec.test.helpers.block_header import sign_block_header +from eth2spec.test.helpers.parent_block_header import sign_block_header from eth2spec.test.helpers.keys import privkeys from eth2spec.test.helpers.proposer_slashings import get_valid_proposer_slashing from eth2spec.test.helpers.state import get_balance diff --git a/test_libs/pyspec/eth2spec/test/phase_0/epoch_processing/test_process_crosslinks.py b/test_libs/pyspec/eth2spec/test/phase_0/epoch_processing/test_process_crosslinks.py index cd4532457..65d958678 100644 --- a/test_libs/pyspec/eth2spec/test/phase_0/epoch_processing/test_process_crosslinks.py +++ b/test_libs/pyspec/eth2spec/test/phase_0/epoch_processing/test_process_crosslinks.py @@ -56,7 +56,7 @@ def test_single_crosslink_update_from_current_epoch(spec, state): fill_aggregate_attestation(spec, state, attestation) add_attestation_to_state(spec, state, attestation, state.slot + spec.MIN_ATTESTATION_INCLUSION_DELAY) - assert len(state.current_attestations) == 1 + assert len(state.current_epoch_attestations) == 1 shard = attestation.data.crosslink.shard pre_crosslink = deepcopy(state.current_crosslinks[shard]) @@ -77,7 +77,7 @@ def test_single_crosslink_update_from_previous_epoch(spec, state): fill_aggregate_attestation(spec, state, attestation) add_attestation_to_state(spec, state, attestation, state.slot + spec.SLOTS_PER_EPOCH) - assert len(state.previous_attestations) == 1 + assert len(state.previous_epoch_attestations) == 1 shard = attestation.data.crosslink.shard pre_crosslink = deepcopy(state.current_crosslinks[shard]) @@ -130,8 +130,8 @@ def test_double_late_crosslink(spec, state): next_epoch(spec, state) add_attestation_to_state(spec, state, attestation_2, state.slot + 1) - assert len(state.previous_attestations) == 1 - assert len(state.current_attestations) == 0 + assert len(state.previous_epoch_attestations) == 1 + assert len(state.current_epoch_attestations) == 0 crosslink_deltas = spec.get_crosslink_deltas(state) diff --git a/test_libs/pyspec/eth2spec/test/sanity/test_blocks.py b/test_libs/pyspec/eth2spec/test/sanity/test_blocks.py index a5079b901..967846cb7 100644 --- a/test_libs/pyspec/eth2spec/test/sanity/test_blocks.py +++ b/test_libs/pyspec/eth2spec/test/sanity/test_blocks.py @@ -233,17 +233,17 @@ def test_attestation(spec, state): attestation = get_valid_attestation(spec, state, signed=True) # Add to state via block transition - pre_current_attestations_len = len(state.current_attestations) + pre_current_attestations_len = len(state.current_epoch_attestations) attestation_block = build_empty_block_for_next_slot(spec, state) attestation_block.slot += spec.MIN_ATTESTATION_INCLUSION_DELAY attestation_block.body.attestations.append(attestation) sign_block(spec, state, attestation_block) spec.state_transition(state, attestation_block) - assert len(state.current_attestations) == pre_current_attestations_len + 1 + assert len(state.current_epoch_attestations) == pre_current_attestations_len + 1 - # Epoch transition should move to previous_attestations - pre_current_attestations_root = spec.hash_tree_root(state.current_attestations) + # Epoch transition should move to previous_epoch_attestations + pre_current_attestations_root = spec.hash_tree_root(state.current_epoch_attestations) epoch_block = build_empty_block_for_next_slot(spec, state) epoch_block.slot += spec.SLOTS_PER_EPOCH @@ -253,8 +253,8 @@ def test_attestation(spec, state): yield 'blocks', [attestation_block, epoch_block], List[spec.BeaconBlock] yield 'post', state - assert len(state.current_attestations) == 0 - assert spec.hash_tree_root(state.previous_attestations) == pre_current_attestations_root + assert len(state.current_epoch_attestations) == 0 + assert spec.hash_tree_root(state.previous_epoch_attestations) == pre_current_attestations_root @with_all_phases