Skip to content

Commit

Permalink
Use safe add
Browse files Browse the repository at this point in the history
  • Loading branch information
terencechain committed Nov 2, 2024
1 parent 386424c commit 599805f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion beacon-chain/core/electra/consolidations.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"fmt"

"github.com/ethereum/go-ethereum/common/math"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v5/beacon-chain/core/helpers"
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state"
Expand Down Expand Up @@ -265,7 +266,12 @@ func ProcessConsolidationRequests(ctx context.Context, st state.BeaconState, req
continue
}

if curEpoch < srcV.ActivationEpoch+params.BeaconConfig().ShardCommitteePeriod {
e, ok := math.SafeAdd(uint64(srcV.ActivationEpoch), uint64(params.BeaconConfig().ShardCommitteePeriod))
if !ok {
log.Error("Overflow when adding activation epoch and shard committee period")
continue
}
if uint64(curEpoch) < e {
continue
}
bal, err := st.PendingBalanceToWithdraw(srcIdx)
Expand Down

0 comments on commit 599805f

Please sign in to comment.