Use Correct Math Library (#10742)

* use correct math lib

* one more case
This commit is contained in:
Nishant Das
2022-05-24 15:22:46 +08:00
committed by GitHub
parent 6910460173
commit 5d4078305a
4 changed files with 11 additions and 11 deletions

View File

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

View File

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