Skip to content

Commit 714c6a5

Browse files
jwasingerMariusVanDerWijdengballetfjl
authored andcommitted
eth/catalyst: sanitize simulated beacon period to avoid overflowing time.Duration (ethereum#31407)
closes ethereum#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>
1 parent 3ae2a10 commit 714c6a5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

eth/catalyst/simulated_beacon.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"crypto/sha256"
2222
"errors"
2323
"fmt"
24+
"math"
2425
"sync"
2526
"time"
2627

@@ -124,9 +125,13 @@ func NewSimulatedBeacon(period uint64, feeRecipient common.Address, eth *eth.Eth
124125
return nil, err
125126
}
126127
}
128+
129+
// cap the dev mode period to a reasonable maximum value to avoid
130+
// overflowing the time.Duration (int64) that it will occupy
131+
const maxPeriod = uint64(math.MaxInt64 / time.Second)
127132
return &SimulatedBeacon{
128133
eth: eth,
129-
period: period,
134+
period: min(period, maxPeriod),
130135
shutdownCh: make(chan struct{}),
131136
engineAPI: engineAPI,
132137
lastBlockTime: block.Time,

0 commit comments

Comments
 (0)