Skip to content

add attestation validation#315

Merged
g11tech merged 5 commits intoblockblaz:mainfrom
bomanaps:feat/Attestation
Oct 23, 2025
Merged

add attestation validation#315
g11tech merged 5 commits intoblockblaz:mainfrom
bomanaps:feat/Attestation

Conversation

@bomanaps
Copy link
Copy Markdown
Contributor

Add attestation validation matching leanSpec specification with tests

@bomanaps bomanaps requested a review from g11tech October 15, 2025 14:48
// Validate attestation before processing
self.validateAttestation(signed_vote) catch |err| {
self.module_logger.debug("Gossip attestation validation failed: {any}", .{err});
return; // Drop invalid gossip attestations
Copy link
Copy Markdown
Member

@g11tech g11tech Oct 20, 2025

Choose a reason for hiding this comment

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

add a task to add it to add the head block to be pulled via req/resp if the validation fails because of the head root missing in forkchoice

@noopur23

// Validate attestation before processing
self.validateAttestation(signed_vote) catch |e| {
self.module_logger.err("invalid attestation in block: validator={d} error={any}", .{ signed_vote.validator_id, e });
// Skip invalid attestations but continue processing the block
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

add a task to determine and implement what to do if the attestation validation fails for the block attestations

@noopur23

};

const head_idx = self.forkChoice.protoArray.indices.get(vote.head.root) orelse {
self.module_logger.debug("Attestation validation failed: unknown head block root=0x{s}", .{
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

check if the spec validates if head is in forkchoice, do a PR in the python spec for this change and put it up for discussion @bomanaps

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +551 to +555
const current_slot = self.forkChoice.fcStore.timeSlots;
const max_allowed_slot = if (is_from_block)
current_slot + constants.MAX_FUTURE_SLOT_TOLERANCE // Block attestations: allow +1
else
current_slot; // Gossip attestations: no future slots allowed
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

where is this check in specs? can you share the link

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

General check: leanSpec/src/lean_spec/subspecs/forkchoice/store.py#L140
Gossip-specific check: leanSpec/src/lean_spec/subspecs/forkchoice/store.py#L177

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

seems incorrect to me (L140 one), raising it with others

// Block attestations can be more lenient since the block itself was validated.
const current_slot = self.forkChoice.fcStore.timeSlots;
const max_allowed_slot = if (is_from_block)
current_slot + constants.MAX_FUTURE_SLOT_TOLERANCE // Block attestations: allow +1
Copy link
Copy Markdown
Member

@g11tech g11tech Oct 22, 2025

Choose a reason for hiding this comment

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

Suggested change
current_slot + constants.MAX_FUTURE_SLOT_TOLERANCE // Block attestations: allow +1
current_slot - constants.MAX_FUTURE_SLOT_TOLERANCE // Block attestations: allow +1

this is the correct condition, i.e. an attestation/vote packed in a proposal block at a slot can't be any later than the previous slot

can you also do the PR in the spec to fix this if thats there

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In the spec where have this assert vote.slot <= Slot(current_slot + Slot(1)), "Attestation too far in future" which means it should be assert vote.slot <= Slot(current_slot - Slot(1)), "Attestation from current or future slot" Line https://github.com/leanEthereum/leanSpec/blob/161c0493e980c4f26b70c3f873d0f17b378f6268/src/lean_spec/subspecs/forkchoice/store.py#L178 gossip check would become redundant after this fix (since -1 is stricter than <= current_slot), so should I leave it as a redundant safety check?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ok lets leave this here right now, @noopur23 create an issue to clarify and if needed patch the attestation validation slot condition

@g11tech g11tech merged commit f6e52a4 into blockblaz:main Oct 23, 2025
7 checks passed
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.

2 participants