diff --git a/docker-compose-config-a.yaml b/docker-compose-config-a.yaml index a393df6..afec3a0 100644 --- a/docker-compose-config-a.yaml +++ b/docker-compose-config-a.yaml @@ -62,7 +62,7 @@ services: labels: logging: "config-a" image: template-provider-builder-image - entrypoint: ["/bin/sh", "-c", "./scripts/update-mainnet-chainstate.sh ${NETWORK} && /bitcoin/bin/bitcoind -sv2 -sv2port=8442 -sv2interval=${SV2_INTERVAL} -sv2feedelta=0 -debug=sv2 -loglevel=sv2:trace -sv2bind=0.0.0.0 -${NETWORK}"] + entrypoint: ["/bin/sh", "-c", "./scripts/update-mainnet-chainstate.sh ${NETWORK} && /bitcoin/bin/bitcoind -sv2 -sv2port=8442 -sv2interval=${SV2_INTERVAL} -sv2feedelta=0 -debug=sv2 -loglevel=sv2:debug -sv2bind=0.0.0.0 -${NETWORK}"] ports: - "8442:8442" - "18333:48333" @@ -91,7 +91,7 @@ services: labels: logging: "config-a" image: template-provider-builder-image - entrypoint: ["/bin/sh", "-c", "./scripts/update-mainnet-chainstate.sh ${NETWORK} && /bitcoin/bin/bitcoind -sv2 -sv2port=8443 -sv2interval=${SV2_INTERVAL} -sv2feedelta=0 -debug=sv2 -loglevel=sv2:trace -sv2bind=0.0.0.0 -${NETWORK}"] + entrypoint: ["/bin/sh", "-c", "./scripts/update-mainnet-chainstate.sh ${NETWORK} && /bitcoin/bin/bitcoind -sv2 -sv2port=8443 -sv2interval=${SV2_INTERVAL} -sv2feedelta=0 -debug=sv2 -loglevel=sv2:debug -sv2bind=0.0.0.0 -${NETWORK}"] ports: - "8443:8443" - "28333:18333" @@ -543,7 +543,7 @@ services: ipv4_address: 10.5.0.18 loki: - image: grafana/loki + image: grafana/loki:2.9.8 container_name: loki ports: - "3100:3100" diff --git a/docker-compose-config-c.yaml b/docker-compose-config-c.yaml index cd1c210..95c5393 100644 --- a/docker-compose-config-c.yaml +++ b/docker-compose-config-c.yaml @@ -61,7 +61,7 @@ services: labels: logging: "config-c" image: template-provider-builder-image - entrypoint: ["/bin/sh", "-c", "./scripts/update-mainnet-chainstate.sh ${NETWORK} && /bitcoin/bin/bitcoind -sv2 -sv2port=8442 -sv2interval=${SV2_INTERVAL} -sv2feedelta=0 -debug=sv2 -loglevel=sv2:trace -sv2bind=0.0.0.0 -${NETWORK}"] + entrypoint: ["/bin/sh", "-c", "./scripts/update-mainnet-chainstate.sh ${NETWORK} && /bitcoin/bin/bitcoind -sv2 -sv2port=8442 -sv2interval=${SV2_INTERVAL} -sv2feedelta=0 -debug=sv2 -loglevel=sv2:debug -sv2bind=0.0.0.0 -${NETWORK}"] ports: - "8442:8442" - "18333:48333" @@ -473,7 +473,7 @@ services: ipv4_address: 10.5.0.18 loki: - image: grafana/loki + image: grafana/loki:2.9.8 container_name: loki ports: - "3100:3100" diff --git a/sv1-custom-proxy/src/main.rs b/sv1-custom-proxy/src/main.rs index 3f0763e..fe8bd6d 100644 --- a/sv1-custom-proxy/src/main.rs +++ b/sv1-custom-proxy/src/main.rs @@ -41,7 +41,6 @@ async fn transfer( while let Some(pos) = client_buf.iter().position(|&b| b == b'\n') { let line = client_buf.drain(..=pos).collect::>(); if let Ok(json) = serde_json::from_slice::(&line) { - println!("Client to Server: {}", json); if json["method"] == "mining.submit" { submitted_shares.inc(); if let Some(params) = json["params"].as_array() { @@ -65,14 +64,14 @@ async fn transfer( .remove_label_values(&[&nonce_string]); }); } else { + println!("Client to Server: {:?}", line); println!("Nonce not found in params"); } } else { + println!("Client to Server: {:?}", line); println!("Params is not an array"); } } - } else { - println!("Client to Server: {:?}", line); } wo.write_all(&line).await?; } @@ -93,7 +92,6 @@ async fn transfer( while let Some(pos) = server_buf.iter().position(|&b| b == b'\n') { let line = server_buf.drain(..=pos).collect::>(); if let Ok(json) = serde_json::from_slice::(&line) { - println!("Server to Client: {}", json); if json["method"] == "mining.notify" { if let Some(params) = json["params"].as_array() { if let Some(_prevhash) = params.get(1) { @@ -107,7 +105,6 @@ async fn transfer( if let Ok(response) = client.get(prometheus_url).send().await { if let Ok(body) = response.text().await { for line in body.lines() { - println!("Line: {:?}", line); if let Some(start_index) = line.find("flag=") { let start = start_index + "flag=\"".len(); if let Some(value) = line.chars().nth(start) { @@ -128,6 +125,7 @@ async fn transfer( new_job_prev_hash_gauge.set(delta); new_job_gauge.set(delta); } else { + println!("Line: {:?}", line); println!("No timestamp value found."); } } else if let Some((_, timestamp)) = @@ -145,6 +143,7 @@ async fn transfer( current_timestamp - new_job_timestamp; new_job_gauge.set(delta); } else { + println!("Line: {:?}", line); println!("No timestamp value found."); } } @@ -153,6 +152,7 @@ async fn transfer( } } } else { + println!("Server to Client: {}", json); println!("Prevhash not found in params"); } } @@ -168,9 +168,9 @@ async fn transfer( stale_shares.inc(); } } else { - // println!("Server to Client: {:?}", line); + println!("Server to Client: {:?}", line); + println!("Error in getting json from line") } - wi.write_all(&line).await?; } } @@ -190,14 +190,11 @@ async fn handle_rpc_request( sv1_new_job_vec: GaugeVec, prev_hash_mutex: Arc>>, ) -> Result, hyper::Error> { - let uri = req.uri().clone(); let method = req.method().clone(); let headers = req.headers().clone(); let body_bytes = hyper::body::to_bytes(req.into_body()).await?; let body_str = String::from_utf8_lossy(&body_bytes); let mut is_get_block_template: bool = false; - println!("Incoming request: {} {} {:?}", method, uri, headers); - println!("Request body: {}", body_str); if let Ok(json) = serde_json::from_slice::(&body_bytes) { if let Some(method) = json.get("method") { @@ -247,13 +244,7 @@ async fn handle_rpc_request( if let Some(timestamp_str) = parts.get(1) { if let Ok(previous_timestamp) = timestamp_str.parse::() { - println!( - "Previous timestamp: {:?}", - previous_timestamp - ); - println!("Current timestamp: {:?}", current_timestamp); let latency = current_timestamp - previous_timestamp; - println!("Computed latency: {:?}", latency); block_propagation_time.set(latency); mined_blocks.inc(); } @@ -291,16 +282,6 @@ async fn handle_rpc_request( .insert("authorization", auth_value.parse().unwrap()); } - // Log the forwarded request - let forwarded_headers = new_req.headers().clone(); - println!( - "Forwarded request: {} {} {:?}", - new_req.method(), - new_req.uri(), - forwarded_headers - ); - println!("Forwarded request body: {}", body_str); - let res = match client.request(new_req).await { Ok(res) => res, Err(err) => { @@ -310,11 +291,7 @@ async fn handle_rpc_request( }; let status = res.status(); - let headers = res.headers().clone(); let body_bytes = hyper::body::to_bytes(res.into_body()).await?; - let body_str = String::from_utf8_lossy(&body_bytes); - println!("Response: {} {:?}", status, headers); - println!("Response body: {}", body_str); if let Ok(json) = serde_json::from_slice::(&body_bytes) { if is_get_block_template { @@ -346,7 +323,6 @@ async fn handle_rpc_request( // Take the coinbase value and set the block template value metric if let Some(coinbasevalue) = result.get("coinbasevalue") { if let Some(block_value) = coinbasevalue.as_i64() { - println!("Block Template Value: {}", block_value); sv1_block_template_value.set(block_value as f64); } } @@ -638,14 +614,6 @@ async fn transfer_new_job( { let new_job_timestamp = timestamp.trim().parse::().unwrap(); - println!( - "Current timestamp: {:?}", - current_timestamp - ); - println!( - "New job timestamp: {:?}", - new_job_timestamp - ); let delta = current_timestamp - new_job_timestamp; new_job_prev_hash_throught_sv2_jdc.set(delta); @@ -657,11 +625,6 @@ async fn transfer_new_job( if line.contains("id=") { if let Some((_, timestamp)) = line.rsplit_once(' ') { - println!( - "Current timestamp: {:?}", - current_timestamp - ); - println!("Read Timestamp: {:?}", timestamp); let new_job_timestamp = timestamp.trim().parse::().unwrap(); let delta = diff --git a/sv2-custom-proxy/src/main.rs b/sv2-custom-proxy/src/main.rs index ae6d63c..18499b6 100644 --- a/sv2-custom-proxy/src/main.rs +++ b/sv2-custom-proxy/src/main.rs @@ -334,7 +334,6 @@ async fn fetch_block_reward(hash: &str) -> Result { let height = json["height"] .as_u64() .ok_or("Failed to parse height from response")?; - println!("Height: {:?}", height); let reward_stats_url = match network.as_str() { "" => "https://mempool.space/api/v1/mining/reward-stats/1", @@ -358,7 +357,6 @@ async fn fetch_block_reward(hash: &str) -> Result { let start_block = reward_stats_json["startBlock"] .as_u64() .ok_or("Failed to parse startBlock from reward stats")?; - println!("start_block: {:?}", start_block); let end_block = reward_stats_json["endBlock"] .as_u64() .ok_or("Failed to parse endBlock from reward stats")?; @@ -402,11 +400,8 @@ async fn fetch_metric_from_prometheus( "{}/api/v1/query?query={} &time={}", prometheus_address, metric_name, timestamp ); - println!("Fetching from URL: {}", url); // Logging dell'URL let response = client.get(&url).send().await.map_err(|e| e.to_string())?; let body = response.text().await.map_err(|e| e.to_string())?; - println!("Received response body: {}", body); // Logging della risposta - let json: Value = serde_json::from_str(&body).map_err(|e| format!("Error parsing JSON: {}", e))?; @@ -438,7 +433,6 @@ async fn intercept_prev_hash( m, ))) = r.recv().await { - println!("Set prev hash received --> {:?}", m); let mut id = m.prev_hash; let d = id.inner_as_mut(); let prev_hash_hex = encode_hex(d); @@ -483,7 +477,6 @@ async fn intercept_prev_hash( // Set the fetched metric value for last_sv2_block_template_value if let Ok(value) = fetch_metric_result { - println!("Fetched metric value: {}", value); last_sv2_block_template_value_clone.set(value); } else { eprintln!("Error fetching metric"); @@ -504,7 +497,6 @@ async fn intercept_new_template( while let Some(PoolMessages::TemplateDistribution(TemplateDistribution::NewTemplate(m))) = r.recv().await { - println!("Set new template received --> {:?}", m); let id = m.template_id; let current_time = std::time::SystemTime::now() .duration_since(std::time::UNIX_EPOCH) @@ -522,7 +514,6 @@ async fn intercept_new_template( // Take the coinbase value and set the block template value metric let sv2_block_template_value_clone = sv2_block_template_value.clone(); let block_value = m.coinbase_tx_value_remaining; - println!("Block Template Value: {}", block_value); sv2_block_template_value_clone.set(block_value as f64); } }); @@ -536,7 +527,6 @@ async fn intercept_submit_share_extended( let mut r = builder.add_handler(Remote::Client, MESSAGE_TYPE_SUBMIT_SHARES_EXTENDED); tokio::spawn(async move { while let Some(PoolMessages::Mining(Mining::SubmitSharesExtended(m))) = r.recv().await { - println!("SubmitSharesExtended received --> {:?}", m); submitted_shares.inc(); let id = m.nonce; @@ -562,8 +552,7 @@ async fn intercept_submit_share_extended( async fn intercept_submit_share_success(builder: &mut ProxyBuilder, valid_shares: Counter) { let mut r = builder.add_handler(Remote::Server, MESSAGE_TYPE_SUBMIT_SHARES_SUCCESS); tokio::spawn(async move { - while let Some(PoolMessages::Mining(Mining::SubmitSharesSuccess(m))) = r.recv().await { - println!("SubmitSharesSuccess received --> {:?}", m); + while let Some(PoolMessages::Mining(Mining::SubmitSharesSuccess(_m))) = r.recv().await { valid_shares.inc(); } }); @@ -592,7 +581,6 @@ async fn intercept_submit_solution( m, ))) = r.recv().await { - println!("SubmitSolution received --> {:?}", m); let current_timestamp = std::time::SystemTime::now() .duration_since(std::time::UNIX_EPOCH) .expect("Time went backwards") @@ -609,10 +597,7 @@ async fn intercept_submit_solution( let parts: Vec<&str> = line.split_whitespace().collect(); if let Some(timestamp_str) = parts.get(1) { if let Ok(previous_timestamp) = timestamp_str.parse::() { - println!("Previous timestamp: {:?}", previous_timestamp); - println!("Current timestamp: {:?}", current_timestamp); let latency = current_timestamp - previous_timestamp; - println!("Computed latency: {:?}", latency); block_propagation_time.set(latency); mined_blocks.inc(); }