Skip to content

Commit d60c24e

Browse files
authored
Integrate tracing (#6339)
Tracing Integration - [reference](https://github.com/eth-protocol-fellows/cohort-five/blob/5bbf1859e921065bd69f8671038ed16643465b86/projects/project-ideas.md?plain=1#L297) - [x] replace slog & log with tracing throughout the codebase - [x] implement custom crit log - [x] make relevant changes in the formatter - [x] replace sloggers - [x] re-write SSE logging components cc: @macladson @eserilev
1 parent f23f984 commit d60c24e

File tree

241 files changed

+9477
-9320
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

241 files changed

+9477
-9320
lines changed

Cargo.lock

Lines changed: 147 additions & 339 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ members = [
8484
"testing/node_test_rig",
8585
"testing/simulator",
8686
"testing/state_transition_vectors",
87-
"testing/test-test_logger",
8887
"testing/validator_test_rig",
8988
"testing/web3signer_tests",
9089

@@ -151,6 +150,7 @@ hyper = "1"
151150
itertools = "0.10"
152151
libsecp256k1 = "0.7"
153152
log = "0.4"
153+
logroller = "0.1.4"
154154
lru = "0.12"
155155
maplit = "1"
156156
milhouse = "0.5"
@@ -181,14 +181,6 @@ serde_json = "1"
181181
serde_repr = "0.1"
182182
serde_yaml = "0.9"
183183
sha2 = "0.9"
184-
slog = { version = "2", features = [
185-
"max_level_debug",
186-
"release_max_level_debug",
187-
"nested-values",
188-
] }
189-
slog-async = "2"
190-
slog-term = "2"
191-
sloggers = { version = "2", features = ["json"] }
192184
smallvec = { version = "1.11.2", features = ["arbitrary"] }
193185
snap = "1"
194186
ssz_types = "0.10"
@@ -209,7 +201,7 @@ tracing = "0.1.40"
209201
tracing-appender = "0.2"
210202
tracing-core = "0.1"
211203
tracing-log = "0.2"
212-
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
204+
tracing-subscriber = { version = "0.3", features = ["env-filter", "json"] }
213205
tree_hash = "0.9"
214206
tree_hash_derive = "0.9"
215207
url = "2"

beacon_node/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ monitoring_api = { workspace = true }
3939
sensitive_url = { workspace = true }
4040
serde_json = { workspace = true }
4141
slasher = { workspace = true }
42-
slog = { workspace = true }
4342
store = { workspace = true }
4443
strum = { workspace = true }
4544
task_executor = { workspace = true }
45+
tracing = { workspace = true }
4646
types = { workspace = true }
4747
unused_port = { workspace = true }

beacon_node/beacon_chain/Cargo.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ sensitive_url = { workspace = true }
5858
serde = { workspace = true }
5959
serde_json = { workspace = true }
6060
slasher = { workspace = true }
61-
slog = { workspace = true }
62-
slog-async = { workspace = true }
63-
slog-term = { workspace = true }
64-
sloggers = { workspace = true }
6561
slot_clock = { workspace = true }
6662
smallvec = { workspace = true }
6763
ssz_types = { workspace = true }
@@ -73,6 +69,7 @@ task_executor = { workspace = true }
7369
tempfile = { workspace = true }
7470
tokio = { workspace = true }
7571
tokio-stream = { workspace = true }
72+
tracing = { workspace = true }
7673
tree_hash = { workspace = true }
7774
tree_hash_derive = { workspace = true }
7875
types = { workspace = true }

beacon_node/beacon_chain/src/attestation_rewards.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use eth2::lighthouse::StandardAttestationRewards;
44
use eth2::types::ValidatorId;
55
use safe_arith::SafeArith;
66
use serde_utils::quoted_u64::Quoted;
7-
use slog::debug;
87
use state_processing::common::base::{self, SqrtTotalActiveBalance};
98
use state_processing::per_epoch_processing::altair::{
109
process_inactivity_updates_slow, process_justification_and_finalization,
@@ -29,6 +28,7 @@ use store::consts::altair::{
2928
PARTICIPATION_FLAG_WEIGHTS, TIMELY_HEAD_FLAG_INDEX, TIMELY_SOURCE_FLAG_INDEX,
3029
TIMELY_TARGET_FLAG_INDEX,
3130
};
31+
use tracing::debug;
3232
use types::consts::altair::WEIGHT_DENOMINATOR;
3333
use types::{BeaconState, Epoch, EthSpec, RelativeEpoch};
3434

@@ -38,7 +38,11 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
3838
epoch: Epoch,
3939
validators: Vec<ValidatorId>,
4040
) -> Result<StandardAttestationRewards, BeaconChainError> {
41-
debug!(self.log, "computing attestation rewards"; "epoch" => epoch, "validator_count" => validators.len());
41+
debug!(
42+
%epoch,
43+
validator_count = validators.len(),
44+
"computing attestation rewards"
45+
);
4246

4347
// Get state
4448
let state_slot = (epoch + 1).end_slot(T::EthSpec::slots_per_epoch());
@@ -214,10 +218,9 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
214218
// Return 0s for unknown/inactive validator indices.
215219
let Ok(validator) = state.get_validator(validator_index) else {
216220
debug!(
217-
self.log,
218-
"No rewards for inactive/unknown validator";
219-
"index" => validator_index,
220-
"epoch" => previous_epoch
221+
index = validator_index,
222+
epoch = %previous_epoch,
223+
"No rewards for inactive/unknown validator"
221224
);
222225
total_rewards.push(TotalAttestationRewards {
223226
validator_index: validator_index as u64,

beacon_node/beacon_chain/src/attestation_simulator.rs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use crate::{BeaconChain, BeaconChainTypes};
2-
use slog::{debug, error};
32
use slot_clock::SlotClock;
43
use std::sync::Arc;
54
use task_executor::TaskExecutor;
65
use tokio::time::sleep;
6+
use tracing::{debug, error};
77
use types::{EthSpec, Slot};
88

99
/// Don't run the attestation simulator if the head slot is this many epochs
@@ -36,10 +36,7 @@ async fn attestation_simulator_service<T: BeaconChainTypes>(
3636
Some(duration) => {
3737
sleep(duration + additional_delay).await;
3838

39-
debug!(
40-
chain.log,
41-
"Simulating unagg. attestation production";
42-
);
39+
debug!("Simulating unagg. attestation production");
4340

4441
// Run the task in the executor
4542
let inner_chain = chain.clone();
@@ -53,7 +50,7 @@ async fn attestation_simulator_service<T: BeaconChainTypes>(
5350
);
5451
}
5552
None => {
56-
error!(chain.log, "Failed to read slot clock");
53+
error!("Failed to read slot clock");
5754
// If we can't read the slot clock, just wait another slot.
5855
sleep(slot_duration).await;
5956
}
@@ -85,10 +82,9 @@ pub fn produce_unaggregated_attestation<T: BeaconChainTypes>(
8582
let data = unaggregated_attestation.data();
8683

8784
debug!(
88-
chain.log,
89-
"Produce unagg. attestation";
90-
"attestation_source" => data.source.root.to_string(),
91-
"attestation_target" => data.target.root.to_string(),
85+
attestation_source = data.source.root.to_string(),
86+
attestation_target = data.target.root.to_string(),
87+
"Produce unagg. attestation"
9288
);
9389

9490
chain
@@ -98,9 +94,8 @@ pub fn produce_unaggregated_attestation<T: BeaconChainTypes>(
9894
}
9995
Err(e) => {
10096
debug!(
101-
chain.log,
102-
"Failed to simulate attestation";
103-
"error" => ?e
97+
error = ?e,
98+
"Failed to simulate attestation"
10499
);
105100
}
106101
}

beacon_node/beacon_chain/src/attestation_verification.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ use crate::{
4343
use bls::verify_signature_sets;
4444
use itertools::Itertools;
4545
use proto_array::Block as ProtoBlock;
46-
use slog::debug;
4746
use slot_clock::SlotClock;
4847
use state_processing::{
4948
common::{
@@ -58,6 +57,7 @@ use state_processing::{
5857
};
5958
use std::borrow::Cow;
6059
use strum::AsRefStr;
60+
use tracing::debug;
6161
use tree_hash::TreeHash;
6262
use types::{
6363
Attestation, AttestationData, AttestationRef, BeaconCommittee,
@@ -430,10 +430,9 @@ fn process_slash_info<T: BeaconChainTypes>(
430430
Ok((indexed, _)) => (indexed, true, err),
431431
Err(e) => {
432432
debug!(
433-
chain.log,
434-
"Unable to obtain indexed form of attestation for slasher";
435-
"attestation_root" => format!("{:?}", attestation.tree_hash_root()),
436-
"error" => format!("{:?}", e)
433+
attestation_root = ?attestation.tree_hash_root(),
434+
error = ?e,
435+
"Unable to obtain indexed form of attestation for slasher"
437436
);
438437
return err;
439438
}
@@ -447,9 +446,8 @@ fn process_slash_info<T: BeaconChainTypes>(
447446
if check_signature {
448447
if let Err(e) = verify_attestation_signature(chain, &indexed_attestation) {
449448
debug!(
450-
chain.log,
451-
"Signature verification for slasher failed";
452-
"error" => format!("{:?}", e),
449+
error = ?e,
450+
"Signature verification for slasher failed"
453451
);
454452
return err;
455453
}

beacon_node/beacon_chain/src/beacon_block_reward.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use crate::{BeaconChain, BeaconChainError, BeaconChainTypes, StateSkipConfig};
22
use attesting_indices_base::get_attesting_indices;
33
use eth2::lighthouse::StandardBlockReward;
44
use safe_arith::SafeArith;
5-
use slog::error;
65
use state_processing::common::attesting_indices_base;
76
use state_processing::{
87
common::{
@@ -19,6 +18,7 @@ use store::{
1918
consts::altair::{PARTICIPATION_FLAG_WEIGHTS, PROPOSER_WEIGHT, WEIGHT_DENOMINATOR},
2019
RelativeEpoch,
2120
};
21+
use tracing::error;
2222
use types::{AbstractExecPayload, BeaconBlockRef, BeaconState, BeaconStateError, EthSpec};
2323

2424
type BeaconBlockSubRewardValue = u64;
@@ -56,9 +56,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
5656
.compute_beacon_block_proposer_slashing_reward(block, state)
5757
.map_err(|e| {
5858
error!(
59-
self.log,
60-
"Error calculating proposer slashing reward";
61-
"error" => ?e
59+
error = ?e,
60+
"Error calculating proposer slashing reward"
6261
);
6362
BeaconChainError::BlockRewardError
6463
})?;
@@ -67,9 +66,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
6766
.compute_beacon_block_attester_slashing_reward(block, state)
6867
.map_err(|e| {
6968
error!(
70-
self.log,
71-
"Error calculating attester slashing reward";
72-
"error" => ?e
69+
error = ?e,
70+
"Error calculating attester slashing reward"
7371
);
7472
BeaconChainError::BlockRewardError
7573
})?;
@@ -78,19 +76,17 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
7876
self.compute_beacon_block_attestation_reward_base(block, state)
7977
.map_err(|e| {
8078
error!(
81-
self.log,
82-
"Error calculating base block attestation reward";
83-
"error" => ?e
79+
error = ?e,
80+
"Error calculating base block attestation reward"
8481
);
8582
BeaconChainError::BlockRewardAttestationError
8683
})?
8784
} else {
8885
self.compute_beacon_block_attestation_reward_altair_deneb(block, state)
8986
.map_err(|e| {
9087
error!(
91-
self.log,
92-
"Error calculating altair block attestation reward";
93-
"error" => ?e
88+
error = ?e,
89+
"Error calculating altair block attestation reward"
9490
);
9591
BeaconChainError::BlockRewardAttestationError
9692
})?

0 commit comments

Comments
 (0)