Skip to content

fix: use SLOT_DURATION_MS instead of deprecated SECONDS_PER_SLOT#148

Open
barnabasbusa wants to merge 1 commit intomasterfrom
bbusa/fix-seconds-per-slot-panic
Open

fix: use SLOT_DURATION_MS instead of deprecated SECONDS_PER_SLOT#148
barnabasbusa wants to merge 1 commit intomasterfrom
bbusa/fix-seconds-per-slot-panic

Conversation

@barnabasbusa
Copy link
Contributor

@barnabasbusa barnabasbusa commented Mar 25, 2026

Fix:

panic: runtime error: integer divide by zero
  
  goroutine 178 [running]:
  github.com/ethpandaops/ethwallclock.(*DefaultSlotCreator).FromTime(0xc0015b4b00, {0x0?, 0x0?, 0x2e54ba0?})
  	/home/runner/go/pkg/mod/github.com/ethpandaops/ethwallclock@v0.4.0/slot_creator.go:28 +0x70
  github.com/ethpandaops/ethwallclock.(*DefaultSlotCreator).Current(0xc0015b4b00)
  	/home/runner/go/pkg/mod/github.com/ethpandaops/ethwallclock@v0.4.0/slot_creator.go:24 +0x2b
  github.com/ethpandaops/ethwallclock.NewEthereumBeaconChain.func1()
  	/home/runner/go/pkg/mod/github.com/ethpandaops/ethwallclock@v0.4.0/beacon_chain.go:44 +0x86
  created by github.com/ethpandaops/ethwallclock.NewEthereumBeaconChain in goroutine 47
  	/home/runner/go/pkg/mod/github.com/ethpandaops/ethwallclock@v0.4.0/beacon_chain.go:36 +0x207
  

Summary

  • Replace SecondsPerSlot (time.Duration, yaml:"SECONDS_PER_SLOT") with SlotDurationMs (uint64, yaml:"SLOT_DURATION_MS") in ChainSpec to match the new consensus spec field
  • Fall back to SECONDS_PER_SLOT for backwards compatibility with older genesis configs that haven't migrated yet
  • Add a guard in InitWallclock to prevent divide-by-zero panic if neither value is available

Context

SECONDS_PER_SLOT has been deprecated and removed from the consensus spec config (ethereum/consensus-specs#4926) in favor of SLOT_DURATION_MS. The ethereum-genesis-generator is removing it in ethpandaops/ethereum-genesis-generator#268. When CL nodes stop returning SECONDS_PER_SLOT, the ChainSpec field stays at zero, causing a divide-by-zero panic in ethwallclock when computing the current slot.

Similar change was made in dora: ethpandaops/dora#612

Test plan

  • Verify assertoor starts correctly with genesis configs that include SLOT_DURATION_MS but not SECONDS_PER_SLOT
  • Verify backwards compat with configs that still include SECONDS_PER_SLOT

🤖 Generated with Claude Code

SECONDS_PER_SLOT has been deprecated and removed from the consensus spec
config (ethereum/consensus-specs#4926) in favor of SLOT_DURATION_MS.
When CL nodes stop returning SECONDS_PER_SLOT, the ChainSpec field stays
at zero, causing a divide-by-zero panic in ethwallclock when computing
the current slot.

Replace SecondsPerSlot (time.Duration) with SlotDurationMs (uint64) in
ChainSpec to match the new spec field directly. Fall back to
SECONDS_PER_SLOT for backwards compatibility with older genesis configs.
Add a guard in InitWallclock to prevent the panic if neither value is
available.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

1 participant