Skip to content

Conversation

shariqnaiyer
Copy link
Contributor

@shariqnaiyer shariqnaiyer commented Oct 19, 2025

What was wrong?

Fixes: #834

This is a test that was left out from earlier. I was debugging on why the exact implementation was failing. I think going foward we will not be duplicating logic and will use test vectors when released in leanSpec.

How was it fixed?

Ok so the 1:1 implementation from the spec of this test fails as we perform additional validations performed in 3SF mini but not in leanSpec. These validations prohibit us from processing attestations for a slot till a block for the next slot has been processed.

In the case of this test, we can not process attestations for slot 4 if block for slot 5 has not been processed.

# Validate that this is a reasonable vote (source comes before target).
if source.slot.as_int() >= target.slot.as_int():
    continue  # Skip invalid votes

# Check if source checkpoint is justified.
source_slot_int = source.slot.as_int()
target_slot_int = target.slot.as_int()

# Ensure we have enough justified slots history.
if source_slot_int < len(justified_slots):
    source_is_justified = justified_slots[source_slot_int]
else:
    continue  # Source is too far in the past

https://github.com/leanEthereum/leanSpec/blob/main/src/lean_spec/subspecs/containers/state/state.py#L437-L439

The leanSpec does not validate the following:

if vote.source.root
!= *self
.historical_block_hashes
.get(vote.source.slot as usize)
.ok_or(anyhow!("Source slot not found in historical_block_hashes"))?
{
info!(
reason = "Source block not in historical block hashes",
source_slot = vote.source.slot,
target_slot = vote.target.slot,
"Skipping vote by Validator {}",
signed_vote.validator_id,
);
continue;
}
if vote.target.root
!= *self
.historical_block_hashes
.get(vote.target.slot as usize)
.ok_or(anyhow!("Target slot not found in historical_block_hashes"))?
{
info!(
reason = "Target block not in historical block hashes",
source_slot = vote.source.slot,
target_slot = vote.target.slot,
"Skipping vote by Validator {}",
signed_vote.validator_id,
);
continue;
}

I believe this deviation is justified as we're implementing validations from 3SF mini but I wonder if leanSpec should also implement all validations for process_attestation from 3SF mini.

To-Do

Copy link
Contributor

@Kayden-ML Kayden-ML left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

@Kayden-ML Kayden-ML added this pull request to the merge queue Oct 19, 2025
Merged via the queue into ReamLabs:master with commit d08c02a Oct 19, 2025
16 checks passed
@KolbyML
Copy link
Contributor

KolbyML commented Oct 19, 2025

for future reference this PR would be test: not feat: as this PR is not adding new functionality, it is adding a test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add leanState test for process_attestations_justification_and_finalization as per the leanSpec

3 participants