Repository: ethereum/go-ethereum (language: go)

Issue:
dev.period should be clamped to max int64 / time.Second
#### System information

Geth
Version: 1.15.3-stable
Git Commit: 612c9e0f4ae483f180ef96ace86effec6dc9bb0e
Git Commit Date: 20250225
Architecture: arm64
Go Version: go1.24.1
Operating System: darwin

#### Expected behaviour
`--dev.period` will only accept valid values

#### Actual behaviour
If `--dev.period` is passed a value greater than `max int64 / time.Second`, go-ethereum dev mode will mine as fast as it can. The overflow happens because  although `--dev.period` is `uint64` in seconds, it backends into a `time.Timer` which takes a `time.Duration`, an `int64`.

max dev.period = 9223372036, go-ethereum works
over dev.period = 9223372037, go-ethereum mines as fast as it can

Trivial Go code to compute these values: https://go.dev/play/p/yoyue1iVsAD



Discussion / hints:

Fix patch:
diff --git a/eth/catalyst/simulated_beacon.go b/eth/catalyst/simulated_beacon.go
index dd9d8f90629e..b84df9a4d6c0 100644
--- a/eth/catalyst/simulated_beacon.go
+++ b/eth/catalyst/simulated_beacon.go
@@ -21,6 +21,7 @@ import (
 	"crypto/sha256"
 	"errors"
 	"fmt"
+	"math"
 	"sync"
 	"time"
 
@@ -124,9 +125,13 @@ func NewSimulatedBeacon(period uint64, feeRecipient common.Address, eth *eth.Eth
 			return nil, err
 		}
 	}
+
+	// cap the dev mode period to a reasonable maximum value to avoid
+	// overflowing the time.Duration (int64) that it will occupy
+	const maxPeriod = uint64(math.MaxInt64 / time.Second)
 	return &SimulatedBeacon{
 		eth:                eth,
-		period:             period,
+		period:             min(period, maxPeriod),
 		shutdownCh:         make(chan struct{}),
 		engineAPI:          engineAPI,
 		lastBlockTime:      block.Time,


Test patch: