Part 3: Annotated Specification

Helper Functions

Participation flags

These two simple utilities were added in the Altair upgrade.

add_flag

def add_flag(flags: ParticipationFlags, flag_index: int) -> ParticipationFlags:
    """
    Return a new ``ParticipationFlags`` adding ``flag_index`` to ``flags``.
    """
    flag = ParticipationFlags(2**flag_index)
    return flags | flag

This is simple and self-explanatory. The 2**flag_index is a bit Pythonic. In a C-like language we would use a bit-shift:

    1 << flag_index
Used byprocess_attestation()
See alsoParticipationFlags

has_flag

def has_flag(flags: ParticipationFlags, flag_index: int) -> bool:
    """
    Return whether ``flags`` has ``flag_index`` set.
    """
    flag = ParticipationFlags(2**flag_index)
    return flags & flag == flag

Move along now, nothing to see here.

Used byget_unslashed_participating_indices(), process_attestation()
See alsoParticipationFlags

Created by Ben Edgington. Licensed under CC BY-SA 4.0. Published 2025-09-01 08:19 UTC. Commit d013cb9.