Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fork choice: on inclusion list #9100

Open
mehdi-aouadi opened this issue Feb 11, 2025 · 0 comments
Open

Fork choice: on inclusion list #9100

mehdi-aouadi opened this issue Feb 11, 2025 · 0 comments
Labels

Comments

@mehdi-aouadi
Copy link
Contributor

mehdi-aouadi commented Feb 11, 2025

New on_inclusion_list

on_inclusion_list is called to import signed_inclusion_list to the fork choice store.

def on_inclusion_list(
        store: Store,
        state: BeaconState,
        signed_inclusion_list: SignedInclusionList,
        inclusion_list_committee: Vector[ValidatorIndex, INCLUSION_LIST_COMMITTEE_SIZE]) -> None:
    """
    Verify the inclusion list and import it into the fork choice store. If there exists more than
    one inclusion list in the store with the same slot and validator index, add the equivocator to
    the ``inclusion_list_equivocators`` cache. Otherwise, add the inclusion list to the
    ``inclusion_lists` cache.
    """
    message = signed_inclusion_list.message

    # Verify inclusion list slot is either from the current or previous slot
    assert get_current_slot(store) in [message.slot, message.slot + 1]

    time_into_slot = (store.time - store.genesis_time) % SECONDS_PER_SLOT
    is_before_attesting_interval = time_into_slot < SECONDS_PER_SLOT // INTERVALS_PER_SLOT

    # If the inclusion list is from the previous slot, ignore it if already past the attestation deadline
    if get_current_slot(store) == message.slot + 1:
        assert is_before_attesting_interval

    # Sanity check that the given `inclusion_list_committee` matches the root in the inclusion list
    root = message.inclusion_list_committee_root
    assert hash_tree_root(inclusion_list_committee) == root

    # Verify inclusion list validator is part of the committee
    validator_index = message.validator_index
    assert validator_index in inclusion_list_committee

    # Verify inclusion list signature
    assert is_valid_inclusion_list_signature(state, signed_inclusion_list)

    is_before_freeze_deadline = get_current_slot(store) == message.slot and time_into_slot < VIEW_FREEZE_DEADLINE

    # Do not process inclusion lists from known equivocators
    if validator_index not in store.inclusion_list_equivocators[(message.slot, root)]:
        if validator_index in [il.validator_index for il in store.inclusion_lists[(message.slot, root)]]:
            validator_inclusion_list = [
                il for il in store.inclusion_lists[(message.slot, root)]
                if il.validator_index == validator_index
            ][0]
            if validator_inclusion_list != message:
                # We have equivocation evidence for `validator_index`, record it as equivocator
                store.inclusion_list_equivocators[(message.slot, root)].add(validator_index)
        # This inclusion list is not an equivocation. Store it if prior to the view freeze deadline
        elif is_before_freeze_deadline:
            store.inclusion_lists[(message.slot, root)].append(message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant