Skip to content

Commit

Permalink
staking: tweak tracing events (review)
Browse files Browse the repository at this point in the history
  • Loading branch information
cratelyn authored and erwanor committed Feb 23, 2024
1 parent 148a882 commit 615de3c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
4 changes: 4 additions & 0 deletions crates/core/component/stake/src/component/epoch_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,10 @@ pub trait EpochHandler: StateWriteExt + ConsensusIndexRead {
// be in the CS index. We should replace the union set approach with a merged
// stream that tags items with their source. See #3874.
if !self.belongs_in_index(&validator.identity_key).await {
tracing::debug!(
validator_id = %validator.identity_key,
"removing validator from consensus set"
);
self.remove_consensus_set_index(&validator.identity_key);
}

Expand Down
26 changes: 12 additions & 14 deletions crates/core/component/stake/src/component/stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,29 +489,27 @@ pub trait ConsensusIndexRead: StateRead {
}

/// Returns whether the given validator should be indexed in the consensus set.
#[instrument(level = "error", skip(self))]
async fn belongs_in_index(&self, validator_id: &IdentityKey) -> bool {
let Some(state) = self
.get_validator_state(validator_id)
.await
.expect("no deserialization error")
else {
tracing::error!(
%validator_id,
"consensus set index check returned false because validator state was not found");
tracing::error!("validator state was not found");
return false;
};

let belongs_in_index =
matches!(state, validator::State::Active | validator::State::Inactive);

tracing::debug!(
%validator_id,
?belongs_in_index,
?state,
"does not belong in consensus set"
);

belongs_in_index
match state {
validator::State::Active | validator::State::Inactive => {
tracing::debug!(?state, "validator belongs in consensus set");
true
}
_ => {
tracing::debug!(?state, "validator does not belong in consensus set");
false
}
}
}
}

Expand Down

0 comments on commit 615de3c

Please sign in to comment.