mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-02-26 15:47:21 +00:00
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:
parent
13b157a461
commit
074da25f66
1 changed files with 6 additions and 1 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue