Skip to content

Validator Pool (κ)

Bases: StateComponent

Source code in pyjamaz/state/components.py
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
class ValidatorPool(StateComponent):
    component_id = 8

    @log_execution_time
    def state_transition(
            self,
            header: Header,
            pre_state_timeslot: TimeslotState,
            pre_state_validator_pool: ValidatorPoolState,
            pre_state_safrole: SafroleState
    ) -> ValidatorPoolOutput:
        """
        GP-0.7.2-eq:6.13 (κ') | State transition function for the state's current validator set. Occurs on epoch change.

        Parameters
        ----------
        header: Header
            GP-0.7.2-eq:4.9 (bold_H)
        pre_state_timeslot: TimeslotState
            GP-0.7.2-eq:4.9 (τ)
        pre_state_validator_pool: ValidatorPoolState
            GP-0.7.2-eq:4.9 (κ)
        pre_state_safrole: SafroleState
            GP-0.7.2-eq:4.9 (γ)

        Returns
        -------
        ValidatorPoolOutput
            Output containing: posterior state of ValidatorPoolState (κ')
        """
        post_state_validator_pool = deepcopy(pre_state_validator_pool)

        if self.is_epoch_change(pre_state_timeslot.number, header.timeslot):
            post_state_validator_pool.validators = pre_state_safrole.validators

        return ValidatorPoolOutput(
            post_state=post_state_validator_pool
        )

    def retrieve_state(self) -> ValidatorPoolState:
        value = self.retrieve()
        return ValidatorPoolState.from_jam_bytes(JamBytes(value))

state_transition(header: Header, pre_state_timeslot: TimeslotState, pre_state_validator_pool: ValidatorPoolState, pre_state_safrole: SafroleState) -> ValidatorPoolOutput

GP-0.7.2-eq:6.13 (κ') | State transition function for the state's current validator set. Occurs on epoch change.

Parameters:

Name Type Description Default
header Header

GP-0.7.2-eq:4.9 (bold_H)

required
pre_state_timeslot TimeslotState

GP-0.7.2-eq:4.9 (τ)

required
pre_state_validator_pool ValidatorPoolState

GP-0.7.2-eq:4.9 (κ)

required
pre_state_safrole SafroleState

GP-0.7.2-eq:4.9 (γ)

required

Returns:

Type Description
ValidatorPoolOutput

Output containing: posterior state of ValidatorPoolState (κ')

Source code in pyjamaz/state/components.py
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
@log_execution_time
def state_transition(
        self,
        header: Header,
        pre_state_timeslot: TimeslotState,
        pre_state_validator_pool: ValidatorPoolState,
        pre_state_safrole: SafroleState
) -> ValidatorPoolOutput:
    """
    GP-0.7.2-eq:6.13 (κ') | State transition function for the state's current validator set. Occurs on epoch change.

    Parameters
    ----------
    header: Header
        GP-0.7.2-eq:4.9 (bold_H)
    pre_state_timeslot: TimeslotState
        GP-0.7.2-eq:4.9 (τ)
    pre_state_validator_pool: ValidatorPoolState
        GP-0.7.2-eq:4.9 (κ)
    pre_state_safrole: SafroleState
        GP-0.7.2-eq:4.9 (γ)

    Returns
    -------
    ValidatorPoolOutput
        Output containing: posterior state of ValidatorPoolState (κ')
    """
    post_state_validator_pool = deepcopy(pre_state_validator_pool)

    if self.is_epoch_change(pre_state_timeslot.number, header.timeslot):
        post_state_validator_pool.validators = pre_state_safrole.validators

    return ValidatorPoolOutput(
        post_state=post_state_validator_pool
    )