Skip to content

eth/catalyst: sanitize simulated beacon period to avoid overflowing time.Duration #31407

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/era_backend.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package core
9 changes: 9 additions & 0 deletions eth/catalyst/simulated_beacon.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"crypto/sha256"
"errors"
"fmt"
"math"
"sync"
"time"

Expand Down Expand Up @@ -124,6 +125,14 @@ 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
maxPeriod := uint64(math.MaxInt64 / time.Second)
if period > maxPeriod {
log.Warn(fmt.Sprintf("period exceeds maximum possible value (have: %d, max: %d). Sanitizing period to maximum possible value.", period, maxPeriod))
period = maxPeriod
}

return &SimulatedBeacon{
eth: eth,
period: period,
Expand Down