예제 #1
0
def test_initiate_validator_exit(n_validators_state):
    state = n_validators_state
    index = 1
    assert state.validator_registry[index].initiated_exit is False

    result_state = initiate_validator_exit(
        state,
        index,
    )
    assert result_state.validator_registry[index].initiated_exit is True
def test_initiate_validator_exit(n_validators_state):
    state = n_validators_state
    index = 1
    assert not (state.validator_registry[index].status_flags
                & ValidatorStatusFlags.INITIATED_EXIT)
    old_validator_status_flags = state.validator_registry[index].status_flags
    result_state = initiate_validator_exit(
        state,
        index,
    )

    assert result_state.validator_registry[index].status_flags == (
        old_validator_status_flags | ValidatorStatusFlags.INITIATED_EXIT)
예제 #3
0
def process_voluntary_exits(state: BeaconState, block: BaseBeaconBlock,
                            config: Eth2Config) -> BeaconState:
    if len(block.body.voluntary_exits) > config.MAX_VOLUNTARY_EXITS:
        raise ValidationError(
            f"The block ({block}) has too many voluntary exits:\n"
            f"\tFound {len(block.body.voluntary_exits)} voluntary exits, "
            f"maximum: {config.MAX_VOLUNTARY_EXITS}")

    for voluntary_exit in block.body.voluntary_exits:
        validate_voluntary_exit(
            state,
            voluntary_exit,
            config.SLOTS_PER_EPOCH,
            config.PERSISTENT_COMMITTEE_PERIOD,
        )
        state = initiate_validator_exit(state, voluntary_exit.validator_index,
                                        config)

    return state
def process_voluntary_exits(state: BeaconState, block: BaseBeaconBlock,
                            config: BeaconConfig) -> BeaconState:
    if len(block.body.voluntary_exits) > config.MAX_VOLUNTARY_EXITS:
        raise ValidationError(
            f"The block ({block}) has too many voluntary exits:\n"
            f"\tFound {len(block.body.voluntary_exits)} voluntary exits, "
            f"maximum: {config.MAX_VOLUNTARY_EXITS}")

    for voluntary_exit in block.body.voluntary_exits:
        validate_voluntary_exit(
            state,
            voluntary_exit,
            config.SLOTS_PER_EPOCH,
            config.ACTIVATION_EXIT_DELAY,
        )
        # Run the exit
        state = initiate_validator_exit(state, voluntary_exit.validator_index)

    return state