swap parent_root for il_committee_root and introduce timing logic#6
swap parent_root for il_committee_root and introduce timing logic#6terencechain merged 3 commits intoterencechain:focilfrom
Conversation
| store: Store, signed_inclusion_list: SignedInclusionList) -> None: | ||
| store: Store, | ||
| signed_inclusion_list: SignedInclusionList, | ||
| inclusion_list_committee: Vector[ValidatorIndex, IL_COMMITTEE_SIZE]]) -> None: |
There was a problem hiding this comment.
| inclusion_list_committee: Vector[ValidatorIndex, IL_COMMITTEE_SIZE]]) -> None: | |
| inclusion_list_committee: List[ValidatorIndex, IL_COMMITTEE_SIZE]]) -> None: |
There was a problem hiding this comment.
I believe Vector is right here
There was a problem hiding this comment.
What's difference between Vector and List? Is the Vector from Numpy?
There was a problem hiding this comment.
nope, these are ssz types: https://github.com/ethereum/consensus-specs/blob/dev/ssz/simple-serialize.md
we want a fixed list here
| | Name | Value | Unit | Duration | | ||
| | - | - | :-: | :-: | | ||
| | `inclusion_list_CUT_OFF` | `uint64(9)` | seconds | 9 seconds | | ||
| | `attestation_deadline` | `uint64(4)` | seconds | 4 seconds | |
There was a problem hiding this comment.
Is this better to be capitalized? Besides, do we want to rename PROPOSER_INCLUSION_LIST_CUT_OFF using DEADLINE for better consistency?
| if validator_index in [il.validator_index for il in inclusion_lists[(message.slot, root)]] | ||
| il = [il for il in inclusion_lists[(message.slot, root)] if il.validator_index == validator_index][0] | ||
| if not il == message: | ||
| # We have equivocation evidence for `validator_index`, record it as equivocator |
There was a problem hiding this comment.
Do we want to remove il from inclusion_lists[(message.slot, root)] following the description at L72?
There was a problem hiding this comment.
The comment is outdated, as that's the old design. This new design uses inclusion_list_equivocators so no longer required to remove inclusion_lists
| # Verify inclusion list slot is bounded to the current slot | ||
| assert get_current_slot(store) == message.slot | ||
| # Verify inclusion list slot is either from the current or previous slot | ||
| assert get_current_slot(store) in [message.slot, message.slot + 1] |
There was a problem hiding this comment.
wouldn't it be message.slot - 1 if it's from either the current or the previous slot?
There was a problem hiding this comment.
If message is from previous slot, message.slot + 1 == get_current_slot(store).
| process_slots(state, message.slot) | ||
| inclusion_list_committee = get_inclusion_list_committee(state, message.slot) | ||
| time_into_slot = (store.time - store.genesis_time) % SECONDS_PER_SLOT | ||
| is_before_attesting_interval = time_into_slot < SECONDS_PER_SLOT // INTERVALS_PER_SLOT |
There was a problem hiding this comment.
wouldn't it be easier to define the attestation deadline like this?
ATTESTATION_DEADLINE = uint64(4) # seconds
is_before_attestation_deadline = time_into_slot < ATTESTATION_DEADLINE
# 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_attestation_deadline
There was a problem hiding this comment.
I dont think we want to hard code uint64(4), we want to use INTERVALS_PER_SLOT so it's not a breaking change to the spec if we were to adjust the interval deadlines later
| 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 inclusion_list_equivocators[(message.slot, root)]: |
There was a problem hiding this comment.
I think here you might need to introduce a time window, so you only record equivocation evidence only if before the attestation deadline (t=4s)?
if validator_index not in inclusion_list_equivocators[(message.slot, root)]:
if validator_index in [il.validator_index for il in inclusion_lists[(message.slot, root)]]:
il = next(
il for il in inclusion_lists[(message.slot, root)] if il.validator_index == validator_index
)
if il != message:
# Record equivocation evidence if within the allowed time window
if get_current_slot(store) <= message.slot + 1 and (
get_current_slot(store) != message.slot + 1 or is_before_attestation_deadline
):
inclusion_list_equivocators[(message.slot, root)].add(validator_index)
else:
# This inclusion list is not an equivocation. Store it if prior to the view freeze deadline
if is_before_freeze_deadline:
inclusion_lists[(message.slot, root)].append(message)
There was a problem hiding this comment.
If it's after the attestation deadline, we won't even get here because of line 82
No description provided.