Skip to content

Conversation

@bomanaps
Copy link
Contributor

πŸ—’οΈ Description

Add skip slot flag to state transition filler and implement consensus test rejecting blocks with mismatched slots.

πŸ”— Related Issues or PRs

#120

βœ… Checklist

  • Ran tox checks to avoid unnecessary CI fails:
    uvx tox
  • Considered adding appropriate tests for the changes.
  • Considered updating the online docs in the ./docs/ directory.

Comment on lines 63 to 64
This is a private attribute not part of the model schema.
Tests cannot set this. The framework populates it during make_fixture().
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think there is no change here, can we revert this to minimize git diff? I guess this is the same at other places in this PR :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry about this I got a Ruff’s line-length lint so had to split to a new line

Comment on lines 116 to 117
Builds blocks from BlockSpec if needed, then processes them through
state_transition.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comment about minimizing git diff

Comment on lines 197 to 199
TODO: If the spec implements a State.produce_block() method in the
future, we should use that instead of manually computing fields here.
Until then, this manual approach is necessary.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same message about minimizing git diff

Comment on lines 145 to 151
if getattr(block_spec, "skip_slot_processing", False):
state = state.process_block(block)
else:
state = state.state_transition(
block=block,
valid_signatures=True,
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure why we need all this here and why we need this new skip_slot_processing, looks like confusing and I guess we want to test the classical state_transition processing here because the block processing is the first step of it

# First, process any intermediate slots.
state = self.process_slots(block.slot)

so that we should see the exact same error that if we do state.process_block(block) because the only additional step which happens before this in the state transition processing is to check that valid_signatures is true but this is the case here in this call so there should be no problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only reason the skip_slot_processing flag exists is to make the new β€œwrong slot” vector possible. state_transition() always advances through process_slots(block.slot) before running process_block, so by the time the header check runs the state slot already equals the block slot and assert block.slot == self.slot can never trip. The flag simply lets an individual test opt out of that automatic advancement so we can feed the block to process_block while the state is still at the earlier slot. Everything else continues through the normal state_transition path; no existing tests are touched. If you’d prefer an alternative hook (e.g., a dedicated helper to run process_block directly), I’m happy to rework it the key requirement is just some way to bypass that initial process_slots call for this negative test.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah yes true I get it, can you solve conflicts?

@tcoratger
Copy link
Collaborator

Hey @bomanaps I think that we have some conflicts with recent updates and then looks good, we should just try to minimize git diff here especially with the comments if possible.

@bomanaps bomanaps force-pushed the add-test_block_with_wrong_slot-vector branch from b572062 to 12810de Compare December 17, 2025 06:22
@bomanaps bomanaps requested a review from tcoratger December 17, 2025 06:39
@tcoratger tcoratger merged commit e2781a1 into leanEthereum:main Dec 17, 2025
10 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