Integrate tracing (#6339)

Tracing Integration
- [reference](5bbf1859e9/projects/project-ideas.md (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
This commit is contained in:
ThreeHrSleep
2025-03-13 04:01:05 +05:30
committed by GitHub
parent f23f984f85
commit d60c24ef1c
241 changed files with 9485 additions and 9328 deletions

View File

@@ -4,7 +4,7 @@ use eth1::{Config, Eth1Endpoint, Service};
use eth1::{DepositCache, DEFAULT_CHAIN_ID};
use eth1_test_rig::{AnvilEth1Instance, Http, Middleware, Provider};
use execution_layer::http::{deposit_methods::*, HttpJsonRpc, Log};
use logging::test_logger;
use logging::create_test_tracing_subscriber;
use merkle_proof::verify_merkle_proof;
use sensitive_url::SensitiveUrl;
use std::ops::Range;
@@ -19,11 +19,10 @@ use types::{
const DEPOSIT_CONTRACT_TREE_DEPTH: usize = 32;
pub fn new_env() -> Environment<MinimalEthSpec> {
create_test_tracing_subscriber();
EnvironmentBuilder::minimal()
.multi_threaded_tokio_runtime()
.expect("should start tokio runtime")
.test_logger()
.expect("should start null logger")
.build()
.expect("should build env")
}
@@ -100,9 +99,8 @@ mod eth1_cache {
#[tokio::test]
async fn simple_scenario() {
create_test_tracing_subscriber();
async {
let log = test_logger();
for follow_distance in 0..3 {
let eth1 = new_anvil_instance()
.await
@@ -123,12 +121,8 @@ mod eth1_cache {
};
let cache_follow_distance = config.cache_follow_distance();
let service = Service::new(
config,
log.clone(),
Arc::new(MainnetEthSpec::default_spec()),
)
.unwrap();
let service =
Service::new(config, Arc::new(MainnetEthSpec::default_spec())).unwrap();
// Create some blocks and then consume them, performing the test `rounds` times.
for round in 0..2 {
@@ -186,9 +180,8 @@ mod eth1_cache {
#[tokio::test]
async fn big_skip() {
create_test_tracing_subscriber();
async {
let log = test_logger();
let eth1 = new_anvil_instance()
.await
.expect("should start eth1 environment");
@@ -208,7 +201,6 @@ mod eth1_cache {
block_cache_truncation: Some(cache_len),
..Config::default()
},
log,
Arc::new(MainnetEthSpec::default_spec()),
)
.unwrap();
@@ -241,9 +233,8 @@ mod eth1_cache {
/// cache size.
#[tokio::test]
async fn pruning() {
create_test_tracing_subscriber();
async {
let log = test_logger();
let eth1 = new_anvil_instance()
.await
.expect("should start eth1 environment");
@@ -263,7 +254,6 @@ mod eth1_cache {
block_cache_truncation: Some(cache_len),
..Config::default()
},
log,
Arc::new(MainnetEthSpec::default_spec()),
)
.unwrap();
@@ -293,9 +283,8 @@ mod eth1_cache {
#[tokio::test]
async fn double_update() {
create_test_tracing_subscriber();
async {
let log = test_logger();
let n = 16;
let eth1 = new_anvil_instance()
@@ -314,7 +303,6 @@ mod eth1_cache {
follow_distance: 0,
..Config::default()
},
log,
Arc::new(MainnetEthSpec::default_spec()),
)
.unwrap();
@@ -346,9 +334,8 @@ mod deposit_tree {
#[tokio::test]
async fn updating() {
create_test_tracing_subscriber();
async {
let log = test_logger();
let n = 4;
let eth1 = new_anvil_instance()
@@ -369,7 +356,6 @@ mod deposit_tree {
follow_distance: 0,
..Config::default()
},
log,
Arc::new(MainnetEthSpec::default_spec()),
)
.unwrap();
@@ -427,9 +413,8 @@ mod deposit_tree {
#[tokio::test]
async fn double_update() {
create_test_tracing_subscriber();
async {
let log = test_logger();
let n = 8;
let eth1 = new_anvil_instance()
@@ -451,7 +436,6 @@ mod deposit_tree {
follow_distance: 0,
..Config::default()
},
log,
Arc::new(MainnetEthSpec::default_spec()),
)
.unwrap();
@@ -689,9 +673,8 @@ mod fast {
// with the deposit count and root computed from the deposit cache.
#[tokio::test]
async fn deposit_cache_query() {
create_test_tracing_subscriber();
async {
let log = test_logger();
let eth1 = new_anvil_instance()
.await
.expect("should start eth1 environment");
@@ -712,7 +695,6 @@ mod fast {
block_cache_truncation: None,
..Config::default()
},
log,
spec.clone(),
)
.unwrap();
@@ -772,9 +754,8 @@ mod persist {
use super::*;
#[tokio::test]
async fn test_persist_caches() {
create_test_tracing_subscriber();
async {
let log = test_logger();
let eth1 = new_anvil_instance()
.await
.expect("should start eth1 environment");
@@ -793,12 +774,8 @@ mod persist {
block_cache_truncation: None,
..Config::default()
};
let service = Service::new(
config.clone(),
log.clone(),
Arc::new(MainnetEthSpec::default_spec()),
)
.unwrap();
let service =
Service::new(config.clone(), Arc::new(MainnetEthSpec::default_spec())).unwrap();
let n = 10;
let deposits: Vec<_> = (0..n).map(|_| random_deposit_data()).collect();
for deposit in &deposits {
@@ -840,7 +817,6 @@ mod persist {
let recovered_service = Service::from_bytes(
&eth1_bytes,
config,
log,
Arc::new(MainnetEthSpec::default_spec()),
)
.unwrap();