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

closes #31401

---------

Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
Co-authored-by: Guillaume Ballet <3272758+gballet@users.noreply.github.com>
Co-authored-by: Felix Lange <fjl@twurst.com>
This commit is contained in:
jwasinger 2025-04-17 20:23:31 +08:00 committed by GitHub
parent 13b157a461
commit 074da25f66
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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,