Skip to content

refactor: represent slot intervals with enum#496

Merged
MegaRedHand merged 7 commits into
lambdaclass:mainfrom
dicethedev:refactor/slot-interval-enum
Jul 6, 2026
Merged

refactor: represent slot intervals with enum#496
MegaRedHand merged 7 commits into
lambdaclass:mainfrom
dicethedev:refactor/slot-interval-enum

Conversation

@dicethedev

Copy link
Copy Markdown
Contributor

🗒️ Description / Motivation

  • Replaces raw 0..4 interval dispatch in blockchain tick handling with a typed SlotInterval enum.
  • This makes interval duties self-documenting and lets Rust enforce exhaustive handling when intervals change.
  • Closes the gap where interval-specific behavior was matched using integer literals.

What Changed

  • crates/blockchain/src/lib.rs

    • Added SlotInterval with from_slot_index as the integer slot-to-enum constructor.
    • Updated BlockChainServer::on_tick to compare and match on SlotInterval variants.
    • Kept interval logging as numeric output through Display.
  • crates/blockchain/src/store.rs

    • Reused SlotInterval for the store-level tick interval match.

Correctness / Behavior Guarantees

  • No behavior change intended.
  • The same interval indices map to the same duties:
    • 0 → block publication
    • 1 → attestation production
    • 2 → aggregation
    • 3 → safe target update
    • 4 → end of slot
  • Interval matches are now exhaustive, so adding/removing interval variants requires updating all dispatch sites at compile time.

Tests Added / Run

  • No tests added; this is a refactor with no intended behavior change.
  • Ran:
    • cargo fmt
    • cargo check -p ethlambda-blockchain

Related Issues / PRs

✅ Verification Checklist

  • Ran make fmt — clean
  • Ran make lint (clippy with -D warnings) — clean
  • Ran cargo test --workspace --release — all passing

@greptile-apps

greptile-apps Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

No reviewable files after applying ignore patterns.

Comment thread crates/blockchain/src/lib.rs Outdated
Comment thread crates/blockchain/src/lib.rs Outdated
Comment thread crates/blockchain/src/lib.rs Outdated
Comment thread crates/blockchain/src/store.rs Outdated

@MegaRedHand MegaRedHand left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Left some comments. The direction is good, but there are some improvements I think are necessary before we merge this

dicethedev and others added 2 commits July 6, 2026 11:49
Co-authored-by: Tomás Grüner <47506558+MegaRedHand@users.noreply.github.com>
Co-authored-by: Tomás Grüner <47506558+MegaRedHand@users.noreply.github.com>
@dicethedev

Copy link
Copy Markdown
Contributor Author

Left some comments. The direction is good, but there are some improvements I think are necessary before we merge this

Alright Mega. I will push a fix a few minutes with your suggestions.

@MegaRedHand MegaRedHand left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Good stuff!

@MegaRedHand MegaRedHand merged commit d7a7199 into lambdaclass:main Jul 6, 2026
2 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.

Use an enum to represent the different intervals in BlockChainServer::on_tick

2 participants