add validator_leaving logging at debug chronicles level for all call paths to initiate_validator_exit(...)

This commit is contained in:
Dustin Brody 2019-11-25 09:22:16 +01:00
parent 8d9fdb0afd
commit a8de94ad05
3 changed files with 30 additions and 2 deletions

View File

@ -147,12 +147,22 @@ func initiate_validator_exit*(state: var BeaconState,
validator.exit_epoch + MIN_VALIDATOR_WITHDRAWABILITY_DELAY validator.exit_epoch + MIN_VALIDATOR_WITHDRAWABILITY_DELAY
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.2/specs/core/0_beacon-chain.md#slash_validator # https://github.com/ethereum/eth2.0-specs/blob/v0.9.2/specs/core/0_beacon-chain.md#slash_validator
func slash_validator*(state: var BeaconState, slashed_index: ValidatorIndex, proc slash_validator*(state: var BeaconState, slashed_index: ValidatorIndex,
stateCache: var StateCache) = stateCache: var StateCache) =
# Slash the validator with index ``index``. # Slash the validator with index ``index``.
let epoch = get_current_epoch(state) let epoch = get_current_epoch(state)
initiate_validator_exit(state, slashed_index) initiate_validator_exit(state, slashed_index)
let validator = addr state.validators[slashed_index] let validator = addr state.validators[slashed_index]
debug "slash_validator: ejecting validator via slashing (validator_leaving)",
index = slashed_index,
num_validators = state.validators.len,
current_epoch = get_current_epoch(state),
validator_slashed = validator.slashed,
validator_withdrawable_epoch = validator.withdrawable_epoch,
validator_exit_epoch = validator.exit_epoch,
validator_effective_balance = validator.effective_balance
validator.slashed = true validator.slashed = true
validator.withdrawable_epoch = validator.withdrawable_epoch =
max(validator.withdrawable_epoch, epoch + EPOCHS_PER_SLASHINGS_VECTOR) max(validator.withdrawable_epoch, epoch + EPOCHS_PER_SLASHINGS_VECTOR)
@ -285,7 +295,7 @@ func get_total_balance*(state: BeaconState, validators: auto): Gwei =
# XXX: Move to state_transition_epoch.nim? # XXX: Move to state_transition_epoch.nim?
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.2/specs/core/0_beacon-chain.md#registry-updates # https://github.com/ethereum/eth2.0-specs/blob/v0.9.2/specs/core/0_beacon-chain.md#registry-updates
func process_registry_updates*(state: var BeaconState) = proc process_registry_updates*(state: var BeaconState) =
## Process activation eligibility and ejections ## Process activation eligibility and ejections
## Try to avoid caching here, since this could easily become undefined ## Try to avoid caching here, since this could easily become undefined
@ -297,6 +307,14 @@ func process_registry_updates*(state: var BeaconState) =
if is_active_validator(validator, get_current_epoch(state)) and if is_active_validator(validator, get_current_epoch(state)) and
validator.effective_balance <= EJECTION_BALANCE: validator.effective_balance <= EJECTION_BALANCE:
debug "Registry updating: ejecting validator due to low balance (validator_leaving)",
index = index,
num_validators = state.validators.len,
current_epoch = get_current_epoch(state),
validator_slashed = validator.slashed,
validator_withdrawable_epoch = validator.withdrawable_epoch,
validator_exit_epoch = validator.exit_epoch,
validator_effective_balance = validator.effective_balance
initiate_validator_exit(state, index.ValidatorIndex) initiate_validator_exit(state, index.ValidatorIndex)
## Queue validators eligible for activation and not dequeued for activation ## Queue validators eligible for activation and not dequeued for activation

View File

@ -353,6 +353,15 @@ proc process_voluntary_exit*(
return false return false
# Initiate exit # Initiate exit
debug "Exit: processing voluntary exit (validator_leaving)",
index = exit.validator_index,
num_validators = state.validators.len,
epoch = exit.epoch,
current_epoch = get_current_epoch(state),
validator_slashed = validator.slashed,
validator_withdrawable_epoch = validator.withdrawable_epoch,
validator_exit_epoch = validator.exit_epoch,
validator_effective_balance = validator.effective_balance
initiate_validator_exit(state, exit.validator_index.ValidatorIndex) initiate_validator_exit(state, exit.validator_index.ValidatorIndex)
true true

View File

@ -2,6 +2,7 @@
# Read in variables # Read in variables
set -a set -a
# shellcheck source=/dev/null
source "$(dirname "$0")/vars.sh" source "$(dirname "$0")/vars.sh"
cd $(dirname "$0") cd $(dirname "$0")