mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 15:37:56 -05:00
Use Correct Math Library (#10742)
* use correct math lib * one more case
This commit is contained in:
@@ -12,8 +12,8 @@ go_library(
|
||||
deps = [
|
||||
"//config/params:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//math:go_default_library",
|
||||
"//time:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//common/math:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
"@com_github_sirupsen_logrus//:go_default_library",
|
||||
],
|
||||
|
||||
@@ -5,10 +5,10 @@ import (
|
||||
"math"
|
||||
"time"
|
||||
|
||||
commonMath "github.com/ethereum/go-ethereum/common/math"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/config/params"
|
||||
types "github.com/prysmaticlabs/prysm/consensus-types/primitives"
|
||||
mathutil "github.com/prysmaticlabs/prysm/math"
|
||||
prysmTime "github.com/prysmaticlabs/prysm/time"
|
||||
)
|
||||
|
||||
@@ -222,9 +222,9 @@ func SyncCommitteePeriod(e types.Epoch) uint64 {
|
||||
// SyncCommitteePeriodStartEpoch returns the start epoch of a sync committee period.
|
||||
func SyncCommitteePeriodStartEpoch(e types.Epoch) (types.Epoch, error) {
|
||||
// Overflow is impossible here because of division of `EPOCHS_PER_SYNC_COMMITTEE_PERIOD`.
|
||||
startEpoch, overflow := commonMath.SafeMul(SyncCommitteePeriod(e), uint64(params.BeaconConfig().EpochsPerSyncCommitteePeriod))
|
||||
if overflow {
|
||||
return 0, errors.New("start epoch calculation overflow")
|
||||
startEpoch, err := mathutil.Mul64(SyncCommitteePeriod(e), uint64(params.BeaconConfig().EpochsPerSyncCommitteePeriod))
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return types.Epoch(startEpoch), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user