Move slot epoch from core to time pkg (#9714)

* Move slot epoch from core to time pkg

* Fix fuzz

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
terence tsao
2021-09-30 12:00:14 -07:00
committed by GitHub
parent f5234634d6
commit 8219af46e4
200 changed files with 739 additions and 757 deletions

View File

@@ -11,8 +11,8 @@ import (
"github.com/pkg/errors"
types "github.com/prysmaticlabs/eth2-types"
"github.com/prysmaticlabs/prysm/beacon-chain/core"
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
"github.com/prysmaticlabs/prysm/beacon-chain/core/time"
"github.com/prysmaticlabs/prysm/beacon-chain/core/validators"
"github.com/prysmaticlabs/prysm/beacon-chain/state"
"github.com/prysmaticlabs/prysm/config/features"
@@ -88,11 +88,11 @@ func AttestingBalance(ctx context.Context, state state.ReadOnlyBeaconState, atts
// validator = state.validators[index]
// validator.activation_epoch = compute_activation_exit_epoch(get_current_epoch(state))
func ProcessRegistryUpdates(ctx context.Context, state state.BeaconState) (state.BeaconState, error) {
currentEpoch := core.CurrentEpoch(state)
currentEpoch := time.CurrentEpoch(state)
vals := state.Validators()
var err error
ejectionBal := params.BeaconConfig().EjectionBalance
activationEligibilityEpoch := core.CurrentEpoch(state) + 1
activationEligibilityEpoch := time.CurrentEpoch(state) + 1
for idx, validator := range vals {
// Process the validators for activation eligibility.
if helpers.IsEligibleForActivationQueue(validator) {
@@ -167,7 +167,7 @@ func ProcessRegistryUpdates(ctx context.Context, state state.BeaconState) (state
// penalty = penalty_numerator // total_balance * increment
// decrease_balance(state, ValidatorIndex(index), penalty)
func ProcessSlashings(state state.BeaconState, slashingMultiplier uint64) (state.BeaconState, error) {
currentEpoch := core.CurrentEpoch(state)
currentEpoch := time.CurrentEpoch(state)
totalBalance, err := helpers.TotalActiveBalance(state)
if err != nil {
return nil, errors.Wrap(err, "could not get total active balance")
@@ -214,7 +214,7 @@ func ProcessSlashings(state state.BeaconState, slashingMultiplier uint64) (state
// if next_epoch % EPOCHS_PER_ETH1_VOTING_PERIOD == 0:
// state.eth1_data_votes = []
func ProcessEth1DataReset(state state.BeaconState) (state.BeaconState, error) {
currentEpoch := core.CurrentEpoch(state)
currentEpoch := time.CurrentEpoch(state)
nextEpoch := currentEpoch + 1
// Reset ETH1 data votes.
@@ -312,7 +312,7 @@ func ProcessEffectiveBalanceUpdates(state state.BeaconState) (state.BeaconState,
// # Reset slashings
// state.slashings[next_epoch % EPOCHS_PER_SLASHINGS_VECTOR] = Gwei(0)
func ProcessSlashingsReset(state state.BeaconState) (state.BeaconState, error) {
currentEpoch := core.CurrentEpoch(state)
currentEpoch := time.CurrentEpoch(state)
nextEpoch := currentEpoch + 1
// Set total slashed balances.
@@ -342,7 +342,7 @@ func ProcessSlashingsReset(state state.BeaconState) (state.BeaconState, error) {
// # Set randao mix
// state.randao_mixes[next_epoch % EPOCHS_PER_HISTORICAL_VECTOR] = get_randao_mix(state, current_epoch)
func ProcessRandaoMixesReset(state state.BeaconState) (state.BeaconState, error) {
currentEpoch := core.CurrentEpoch(state)
currentEpoch := time.CurrentEpoch(state)
nextEpoch := currentEpoch + 1
// Set RANDAO mix.
@@ -375,7 +375,7 @@ func ProcessRandaoMixesReset(state state.BeaconState) (state.BeaconState, error)
// historical_batch = HistoricalBatch(block_roots=state.block_roots, state_roots=state.state_roots)
// state.historical_roots.append(hash_tree_root(historical_batch))
func ProcessHistoricalRootsUpdate(state state.BeaconState) (state.BeaconState, error) {
currentEpoch := core.CurrentEpoch(state)
currentEpoch := time.CurrentEpoch(state)
nextEpoch := currentEpoch + 1
// Set historical root accumulator.