Skip to content

Validator Archive (λ)

Bases: StateComponent

Source code in pyjamaz/state/components.py
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
class ValidatorArchive(StateComponent):
    component_id = 9

    @log_execution_time
    def state_transition(
            self,
            header: Header,
            pre_state_timeslot: TimeslotState,
            pre_state_validator_archive: ValidatorArchiveState,
            pre_state_validator_pool: ValidatorPoolState
    ) -> ValidatorArchiveOutput:
        """
        GP-0.7.2-eq:6.13 (λ') | State transition function for the state's archived validator set. Occurs on epoch
        change.

        Parameters
        ----------
        header: Header
            GP-0.7.2-eq:4.10 (bold_H)
        pre_state_timeslot: TimeslotState
            GP-0.7.2-eq:4.10 (τ)
        pre_state_validator_archive: ValidatorArchiveState
            GP-0.7.2-eq:4.10 (λ)
        pre_state_validator_pool: ValidatorPoolState
            GP-0.7.2-eq:4.10 (κ)

        Returns
        -------
        ValidatorArchiveOutput
            Output containing: posterior state of ValidatorArchiveState (λ')
        """
        post_state_validator_archive = deepcopy(pre_state_validator_archive)

        if self.is_epoch_change(pre_state_timeslot.number, header.timeslot):
            # Update prior epoch validators GP-0.7.2-eq:6.13
            post_state_validator_archive.validators = pre_state_validator_pool.validators

        return ValidatorArchiveOutput(
            post_state=post_state_validator_archive
        )

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

state_transition(header: Header, pre_state_timeslot: TimeslotState, pre_state_validator_archive: ValidatorArchiveState, pre_state_validator_pool: ValidatorPoolState) -> ValidatorArchiveOutput

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

Parameters:

Name Type Description Default
header Header

GP-0.7.2-eq:4.10 (bold_H)

required
pre_state_timeslot TimeslotState

GP-0.7.2-eq:4.10 (τ)

required
pre_state_validator_archive ValidatorArchiveState

GP-0.7.2-eq:4.10 (λ)

required
pre_state_validator_pool ValidatorPoolState

GP-0.7.2-eq:4.10 (κ)

required

Returns:

Type Description
ValidatorArchiveOutput

Output containing: posterior state of ValidatorArchiveState (λ')

Source code in pyjamaz/state/components.py
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
@log_execution_time
def state_transition(
        self,
        header: Header,
        pre_state_timeslot: TimeslotState,
        pre_state_validator_archive: ValidatorArchiveState,
        pre_state_validator_pool: ValidatorPoolState
) -> ValidatorArchiveOutput:
    """
    GP-0.7.2-eq:6.13 (λ') | State transition function for the state's archived validator set. Occurs on epoch
    change.

    Parameters
    ----------
    header: Header
        GP-0.7.2-eq:4.10 (bold_H)
    pre_state_timeslot: TimeslotState
        GP-0.7.2-eq:4.10 (τ)
    pre_state_validator_archive: ValidatorArchiveState
        GP-0.7.2-eq:4.10 (λ)
    pre_state_validator_pool: ValidatorPoolState
        GP-0.7.2-eq:4.10 (κ)

    Returns
    -------
    ValidatorArchiveOutput
        Output containing: posterior state of ValidatorArchiveState (λ')
    """
    post_state_validator_archive = deepcopy(pre_state_validator_archive)

    if self.is_epoch_change(pre_state_timeslot.number, header.timeslot):
        # Update prior epoch validators GP-0.7.2-eq:6.13
        post_state_validator_archive.validators = pre_state_validator_pool.validators

    return ValidatorArchiveOutput(
        post_state=post_state_validator_archive
    )