Пример #1
0
    def process_block(
        cls,
        crystallized_state: CrystallizedState,
        active_state: ActiveState,
        block: BaseBeaconBlock,
        chaindb: BaseBeaconChainDB,
        is_validating_signatures: bool = True
    ) -> Tuple[BaseBeaconBlock, CrystallizedState, ActiveState]:
        """
        Process ``block`` and return the new crystallized state and active state.
        """
        # Process per block state changes (ActiveState)
        processing_active_state = cls.compute_per_block_transition(
            crystallized_state,
            active_state,
            block,
            chaindb,
            is_validating_signatures=is_validating_signatures,
        )

        # Process per cycle state changes (CrystallizedState and ActiveState)
        processed_crystallized_state, processed_active_state = cls.compute_cycle_transitions(
            crystallized_state,
            processing_active_state,
            block,
        )

        # Return the copy
        result_block = block.copy()
        return result_block, processed_crystallized_state, processed_active_state
Пример #2
0
def test_update_attestations(sample_attestation_record_params,
                             sample_beacon_block_params):
    block = BaseBeaconBlock(**sample_beacon_block_params)
    attestations = block.attestations
    attestations = list(attestations)
    attestations.append(AttestationRecord(**sample_attestation_record_params))
    block2 = block.copy(attestations=attestations)
    assert block2.num_attestations == 1
Пример #3
0
def test_update_attestations(sample_attestation_params, sample_beacon_block_params):
    block = BaseBeaconBlock(**sample_beacon_block_params)
    attestations = block.body.attestations
    attestations = list(attestations)
    attestations.append(Attestation(**sample_attestation_params))
    body2 = block.body.copy(
        attestations=attestations
    )
    block2 = block.copy(
        body=body2
    )
    assert block2.num_attestations == 1