mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-11 10:36:37 +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"
|
"crypto/sha256"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -124,9 +125,13 @@ func NewSimulatedBeacon(period uint64, feeRecipient common.Address, eth *eth.Eth
|
||||||
return nil, err
|
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{
|
return &SimulatedBeacon{
|
||||||
eth: eth,
|
eth: eth,
|
||||||
period: period,
|
period: min(period, maxPeriod),
|
||||||
shutdownCh: make(chan struct{}),
|
shutdownCh: make(chan struct{}),
|
||||||
engineAPI: engineAPI,
|
engineAPI: engineAPI,
|
||||||
lastBlockTime: block.Time,
|
lastBlockTime: block.Time,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue