From a8de94ad05ceda7456622baa3c9f844d7e8604bd Mon Sep 17 00:00:00 2001 From: Dustin Brody Date: Mon, 25 Nov 2019 09:22:16 +0100 Subject: [PATCH] add validator_leaving logging at debug chronicles level for all call paths to initiate_validator_exit(...) --- beacon_chain/spec/beaconstate.nim | 22 ++++++++++++++++++-- beacon_chain/spec/state_transition_block.nim | 9 ++++++++ tests/simulation/tmux_demo.sh | 1 + 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/beacon_chain/spec/beaconstate.nim b/beacon_chain/spec/beaconstate.nim index a2ec22448..c0de8db6e 100644 --- a/beacon_chain/spec/beaconstate.nim +++ b/beacon_chain/spec/beaconstate.nim @@ -147,12 +147,22 @@ func initiate_validator_exit*(state: var BeaconState, 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 -func slash_validator*(state: var BeaconState, slashed_index: ValidatorIndex, +proc slash_validator*(state: var BeaconState, slashed_index: ValidatorIndex, stateCache: var StateCache) = # Slash the validator with index ``index``. let epoch = get_current_epoch(state) initiate_validator_exit(state, 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.withdrawable_epoch = 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? # 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 ## 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 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) ## Queue validators eligible for activation and not dequeued for activation diff --git a/beacon_chain/spec/state_transition_block.nim b/beacon_chain/spec/state_transition_block.nim index 09162dad0..9fa050389 100644 --- a/beacon_chain/spec/state_transition_block.nim +++ b/beacon_chain/spec/state_transition_block.nim @@ -353,6 +353,15 @@ proc process_voluntary_exit*( return false # 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) true diff --git a/tests/simulation/tmux_demo.sh b/tests/simulation/tmux_demo.sh index ca290804b..5866e550d 100755 --- a/tests/simulation/tmux_demo.sh +++ b/tests/simulation/tmux_demo.sh @@ -2,6 +2,7 @@ # Read in variables set -a +# shellcheck source=/dev/null source "$(dirname "$0")/vars.sh" cd $(dirname "$0")