From 7bcb070c711d67bc50d9093940c2272ed179622c Mon Sep 17 00:00:00 2001 From: Pawan Dhananjay Date: Tue, 18 Feb 2025 15:44:06 -0800 Subject: [PATCH 1/8] Set the accept header on submit_blinded_blocks --- beacon_node/builder_client/src/lib.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/beacon_node/builder_client/src/lib.rs b/beacon_node/builder_client/src/lib.rs index 5f64ac7e43c..620381e1e29 100644 --- a/beacon_node/builder_client/src/lib.rs +++ b/beacon_node/builder_client/src/lib.rs @@ -7,8 +7,7 @@ use eth2::types::{ use eth2::types::{FullPayloadContents, SignedBlindedBeaconBlock}; pub use eth2::Error; use eth2::{ - ok_or_error, StatusCode, CONSENSUS_VERSION_HEADER, CONTENT_TYPE_HEADER, - JSON_CONTENT_TYPE_HEADER, SSZ_CONTENT_TYPE_HEADER, + ok_or_error, StatusCode, CONSENSUS_VERSION_HEADER, CONTENT_TYPE_HEADER, SSZ_CONTENT_TYPE_HEADER, }; use reqwest::header::{HeaderMap, HeaderValue, ACCEPT}; use reqwest::{IntoUrl, Response}; @@ -29,6 +28,9 @@ pub const DEFAULT_GET_HEADER_TIMEOUT_MILLIS: u64 = 1000; /// Default user agent for HTTP requests. pub const DEFAULT_USER_AGENT: &str = lighthouse_version::VERSION; +/// The value we set on the `ACCEPT` http header to indicate a preference for ssz response. +pub const PREFERENCE_ACCEPT_VALUE: &str = "application/octet-stream;q=1.0,application/json;q=0.9"; + #[derive(Clone)] pub struct Timeouts { get_header: Duration, @@ -226,6 +228,8 @@ impl BuilderHttpClient { HeaderValue::from_static(SSZ_CONTENT_TYPE_HEADER), ); + headers.insert(ACCEPT, HeaderValue::from_static(PREFERENCE_ACCEPT_VALUE)); + let response = builder .headers(headers) .body(ssz_body) @@ -362,12 +366,8 @@ impl BuilderHttpClient { .push(pubkey.as_hex_string().as_str()); let mut headers = HeaderMap::new(); - if let Ok(ssz_content_type_header) = HeaderValue::from_str(&format!( - "{}; q=1.0,{}; q=0.9", - SSZ_CONTENT_TYPE_HEADER, JSON_CONTENT_TYPE_HEADER - )) { - headers.insert(ACCEPT, ssz_content_type_header); - }; + // We accept ssz responses by default so indicate that in the accept header + headers.insert(ACCEPT, HeaderValue::from_static(PREFERENCE_ACCEPT_VALUE)); let resp = self .get_with_header(path, self.timeouts.get_header, headers) From 950d55fcdc60e2bb4cec5de84b5f12cc00f6d764 Mon Sep 17 00:00:00 2001 From: Pawan Dhananjay Date: Tue, 18 Feb 2025 16:55:18 -0800 Subject: [PATCH 2/8] Add a disable-ssz flag on the builder --- beacon_node/beacon_chain/src/test_utils.rs | 1 + beacon_node/builder_client/src/lib.rs | 32 ++++++++++++++++------ beacon_node/execution_layer/src/lib.rs | 12 +++++++- beacon_node/src/cli.rs | 9 ++++++ beacon_node/src/config.rs | 2 ++ 5 files changed, 46 insertions(+), 10 deletions(-) diff --git a/beacon_node/beacon_chain/src/test_utils.rs b/beacon_node/beacon_chain/src/test_utils.rs index 8c9e3929f6b..24c85b3e070 100644 --- a/beacon_node/beacon_chain/src/test_utils.rs +++ b/beacon_node/beacon_chain/src/test_utils.rs @@ -779,6 +779,7 @@ where SensitiveUrl::parse(format!("http://127.0.0.1:{port}").as_str()).unwrap(), None, None, + false, ) .unwrap(); diff --git a/beacon_node/builder_client/src/lib.rs b/beacon_node/builder_client/src/lib.rs index 620381e1e29..ded2620262b 100644 --- a/beacon_node/builder_client/src/lib.rs +++ b/beacon_node/builder_client/src/lib.rs @@ -7,7 +7,8 @@ use eth2::types::{ use eth2::types::{FullPayloadContents, SignedBlindedBeaconBlock}; pub use eth2::Error; use eth2::{ - ok_or_error, StatusCode, CONSENSUS_VERSION_HEADER, CONTENT_TYPE_HEADER, SSZ_CONTENT_TYPE_HEADER, + ok_or_error, StatusCode, CONSENSUS_VERSION_HEADER, CONTENT_TYPE_HEADER, + JSON_CONTENT_TYPE_HEADER, SSZ_CONTENT_TYPE_HEADER, }; use reqwest::header::{HeaderMap, HeaderValue, ACCEPT}; use reqwest::{IntoUrl, Response}; @@ -59,7 +60,12 @@ pub struct BuilderHttpClient { server: SensitiveUrl, timeouts: Timeouts, user_agent: String, - ssz_enabled: Arc, + /// Only use json for all requests/responses types. + disable_ssz: bool, + /// Indicates that the `get_header`` response had content-type ssz + /// so we can set content-type header to ssz to make the `submit_blinded_blocks` + /// request. + ssz_used: Arc, } impl BuilderHttpClient { @@ -67,6 +73,7 @@ impl BuilderHttpClient { server: SensitiveUrl, user_agent: Option, builder_header_timeout: Option, + disable_ssz: bool, ) -> Result { let user_agent = user_agent.unwrap_or(DEFAULT_USER_AGENT.to_string()); let client = reqwest::Client::builder().user_agent(&user_agent).build()?; @@ -75,7 +82,8 @@ impl BuilderHttpClient { server, timeouts: Timeouts::new(builder_header_timeout), user_agent, - ssz_enabled: Arc::new(false.into()), + disable_ssz, + ssz_used: Arc::new(false.into()), }) } @@ -126,7 +134,7 @@ impl BuilderHttpClient { let Ok(Some(fork_name)) = self.fork_name_from_header(&headers) else { // if no fork version specified, attempt to fallback to JSON - self.ssz_enabled.store(false, Ordering::SeqCst); + self.ssz_used.store(false, Ordering::SeqCst); return serde_json::from_slice(&response_bytes).map_err(Error::InvalidJson); }; @@ -134,7 +142,7 @@ impl BuilderHttpClient { match content_type { ContentType::Ssz => { - self.ssz_enabled.store(true, Ordering::SeqCst); + self.ssz_used.store(true, Ordering::SeqCst); T::from_ssz_bytes_by_fork(&response_bytes, fork_name) .map(|data| ForkVersionedResponse { version: Some(fork_name), @@ -144,15 +152,17 @@ impl BuilderHttpClient { .map_err(Error::InvalidSsz) } ContentType::Json => { - self.ssz_enabled.store(false, Ordering::SeqCst); + self.ssz_used.store(false, Ordering::SeqCst); serde_json::from_slice(&response_bytes).map_err(Error::InvalidJson) } } } /// Return `true` if the most recently received response from the builder had SSZ Content-Type. + /// + /// Also returns `false` if we have explicitly disabled ssz. pub fn is_ssz_enabled(&self) -> bool { - self.ssz_enabled.load(Ordering::SeqCst) + self.disable_ssz && self.ssz_used.load(Ordering::SeqCst) } async fn get_with_timeout( @@ -366,8 +376,12 @@ impl BuilderHttpClient { .push(pubkey.as_hex_string().as_str()); let mut headers = HeaderMap::new(); - // We accept ssz responses by default so indicate that in the accept header - headers.insert(ACCEPT, HeaderValue::from_static(PREFERENCE_ACCEPT_VALUE)); + if self.disable_ssz { + headers.insert(ACCEPT, HeaderValue::from_static(JSON_CONTENT_TYPE_HEADER)); + } else { + // We accept ssz responses by default so indicate that in the accept header + headers.insert(ACCEPT, HeaderValue::from_static(PREFERENCE_ACCEPT_VALUE)); + } let resp = self .get_with_header(path, self.timeouts.get_header, headers) diff --git a/beacon_node/execution_layer/src/lib.rs b/beacon_node/execution_layer/src/lib.rs index 6e5e4fca01e..9af4eb2c5a0 100644 --- a/beacon_node/execution_layer/src/lib.rs +++ b/beacon_node/execution_layer/src/lib.rs @@ -441,6 +441,8 @@ pub struct Config { pub builder_header_timeout: Option, /// User agent to send with requests to the builder API. pub builder_user_agent: Option, + /// Disable ssz requests on builder. Only use json. + pub disable_builder_ssz_requests: bool, /// JWT secret for the above endpoint running the engine api. pub secret_file: Option, /// The default fee recipient to use on the beacon node if none if provided from @@ -470,6 +472,7 @@ impl ExecutionLayer { builder_url, builder_user_agent, builder_header_timeout, + disable_builder_ssz_requests, secret_file, suggested_fee_recipient, jwt_id, @@ -539,7 +542,12 @@ impl ExecutionLayer { }; if let Some(builder_url) = builder_url { - el.set_builder_url(builder_url, builder_user_agent, builder_header_timeout)?; + el.set_builder_url( + builder_url, + builder_user_agent, + builder_header_timeout, + disable_builder_ssz_requests, + )?; } Ok(el) @@ -562,11 +570,13 @@ impl ExecutionLayer { builder_url: SensitiveUrl, builder_user_agent: Option, builder_header_timeout: Option, + disable_ssz: bool, ) -> Result<(), Error> { let builder_client = BuilderHttpClient::new( builder_url.clone(), builder_user_agent, builder_header_timeout, + disable_ssz, ) .map_err(Error::Builder)?; info!( diff --git a/beacon_node/src/cli.rs b/beacon_node/src/cli.rs index 4c2daecdd34..03a2b0d41e6 100644 --- a/beacon_node/src/cli.rs +++ b/beacon_node/src/cli.rs @@ -1460,6 +1460,15 @@ pub fn cli_app() -> Command { .action(ArgAction::Set) .display_order(0) ) + .arg( + Arg::new("builder-disable-ssz") + .long("builder-disable-ssz") + .value_name("BOOLEAN") + .help("Disables sending requests using ssz over the builder api") + .requires("builder") + .action(ArgAction::SetTrue) + .display_order(0) + ) .arg( Arg::new("reset-payload-statuses") .long("reset-payload-statuses") diff --git a/beacon_node/src/config.rs b/beacon_node/src/config.rs index 24d569bea22..84320762d6c 100644 --- a/beacon_node/src/config.rs +++ b/beacon_node/src/config.rs @@ -346,6 +346,8 @@ pub fn get_config( el_config.builder_header_timeout = clap_utils::parse_optional(cli_args, "builder-header-timeout")? .map(Duration::from_millis); + + el_config.disable_builder_ssz_requests = cli_args.get_flag("builder-disable-ssz"); } // Set config values from parse values. From 8adaeae902232f98e30d54bf50f9d7ea182ba3d0 Mon Sep 17 00:00:00 2001 From: Pawan Dhananjay Date: Tue, 18 Feb 2025 19:32:50 -0800 Subject: [PATCH 3/8] Fix is_ssz_enabled condition --- beacon_node/builder_client/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/beacon_node/builder_client/src/lib.rs b/beacon_node/builder_client/src/lib.rs index ded2620262b..3ec6194cf5e 100644 --- a/beacon_node/builder_client/src/lib.rs +++ b/beacon_node/builder_client/src/lib.rs @@ -159,10 +159,10 @@ impl BuilderHttpClient { } /// Return `true` if the most recently received response from the builder had SSZ Content-Type. - /// + /// Return `false` otherwise. /// Also returns `false` if we have explicitly disabled ssz. pub fn is_ssz_enabled(&self) -> bool { - self.disable_ssz && self.ssz_used.load(Ordering::SeqCst) + !self.disable_ssz && self.ssz_used.load(Ordering::SeqCst) } async fn get_with_timeout( From 6672f4b75028e4c4f370d22b1ff245caf7df92be Mon Sep 17 00:00:00 2001 From: Pawan Dhananjay Date: Wed, 19 Feb 2025 17:33:30 -0800 Subject: [PATCH 4/8] Cleanup; add logs --- beacon_node/builder_client/src/lib.rs | 76 ++++++++++++++++++++------ beacon_node/execution_layer/src/lib.rs | 6 ++ 2 files changed, 65 insertions(+), 17 deletions(-) diff --git a/beacon_node/builder_client/src/lib.rs b/beacon_node/builder_client/src/lib.rs index 3ec6194cf5e..a7a61d2a743 100644 --- a/beacon_node/builder_client/src/lib.rs +++ b/beacon_node/builder_client/src/lib.rs @@ -31,6 +31,8 @@ pub const DEFAULT_USER_AGENT: &str = lighthouse_version::VERSION; /// The value we set on the `ACCEPT` http header to indicate a preference for ssz response. pub const PREFERENCE_ACCEPT_VALUE: &str = "application/octet-stream;q=1.0,application/json;q=0.9"; +/// Only accept json responses. +pub const JSON_ACCEPT_VALUE: &str = "application/json"; #[derive(Clone)] pub struct Timeouts { @@ -225,7 +227,7 @@ impl BuilderHttpClient { &self, url: U, ssz_body: Vec, - mut headers: HeaderMap, + headers: HeaderMap, timeout: Option, ) -> Result { let mut builder = self.client.post(url); @@ -233,13 +235,6 @@ impl BuilderHttpClient { builder = builder.timeout(timeout); } - headers.insert( - CONTENT_TYPE_HEADER, - HeaderValue::from_static(SSZ_CONTENT_TYPE_HEADER), - ); - - headers.insert(ACCEPT, HeaderValue::from_static(PREFERENCE_ACCEPT_VALUE)); - let response = builder .headers(headers) .body(ssz_body) @@ -306,9 +301,21 @@ impl BuilderHttpClient { .push("blinded_blocks"); let mut headers = HeaderMap::new(); - if let Ok(value) = HeaderValue::from_str(&blinded_block.fork_name_unchecked().to_string()) { - headers.insert(CONSENSUS_VERSION_HEADER, value); - } + headers.insert( + CONSENSUS_VERSION_HEADER, + HeaderValue::from_str(&blinded_block.fork_name_unchecked().to_string()) + .map_err(|e| Error::InvalidHeaders(format!("{}", e)))?, + ); + headers.insert( + CONTENT_TYPE_HEADER, + HeaderValue::from_str(SSZ_CONTENT_TYPE_HEADER) + .map_err(|e| Error::InvalidHeaders(format!("{}", e)))?, + ); + headers.insert( + ACCEPT, + HeaderValue::from_str(PREFERENCE_ACCEPT_VALUE) + .map_err(|e| Error::InvalidHeaders(format!("{}", e)))?, + ); let result = self .post_ssz_with_raw_response( @@ -340,9 +347,21 @@ impl BuilderHttpClient { .push("blinded_blocks"); let mut headers = HeaderMap::new(); - if let Ok(value) = HeaderValue::from_str(&blinded_block.fork_name_unchecked().to_string()) { - headers.insert(CONSENSUS_VERSION_HEADER, value); - } + headers.insert( + CONSENSUS_VERSION_HEADER, + HeaderValue::from_str(&blinded_block.fork_name_unchecked().to_string()) + .map_err(|e| Error::InvalidHeaders(format!("{}", e)))?, + ); + headers.insert( + CONTENT_TYPE_HEADER, + HeaderValue::from_str(JSON_CONTENT_TYPE_HEADER) + .map_err(|e| Error::InvalidHeaders(format!("{}", e)))?, + ); + headers.insert( + ACCEPT, + HeaderValue::from_str(JSON_ACCEPT_VALUE) + .map_err(|e| Error::InvalidHeaders(format!("{}", e)))?, + ); Ok(self .post_with_raw_response( @@ -377,10 +396,18 @@ impl BuilderHttpClient { let mut headers = HeaderMap::new(); if self.disable_ssz { - headers.insert(ACCEPT, HeaderValue::from_static(JSON_CONTENT_TYPE_HEADER)); + headers.insert( + ACCEPT, + HeaderValue::from_str(JSON_CONTENT_TYPE_HEADER) + .map_err(|e| Error::InvalidHeaders(format!("{}", e)))?, + ); } else { - // We accept ssz responses by default so indicate that in the accept header - headers.insert(ACCEPT, HeaderValue::from_static(PREFERENCE_ACCEPT_VALUE)); + // Indicate preference for ssz response in the accept header + headers.insert( + ACCEPT, + HeaderValue::from_str(PREFERENCE_ACCEPT_VALUE) + .map_err(|e| Error::InvalidHeaders(format!("{}", e)))?, + ); } let resp = self @@ -409,3 +436,18 @@ impl BuilderHttpClient { .await } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_headers_no_panic() { + for fork in ForkName::list_all() { + assert!(HeaderValue::from_str(&fork.to_string()).is_ok()); + } + assert!(HeaderValue::from_str(PREFERENCE_ACCEPT_VALUE).is_ok()); + assert!(HeaderValue::from_str(JSON_ACCEPT_VALUE).is_ok()); + assert!(HeaderValue::from_str(JSON_CONTENT_TYPE_HEADER).is_ok()); + } +} diff --git a/beacon_node/execution_layer/src/lib.rs b/beacon_node/execution_layer/src/lib.rs index 9af4eb2c5a0..6298a6a97c5 100644 --- a/beacon_node/execution_layer/src/lib.rs +++ b/beacon_node/execution_layer/src/lib.rs @@ -584,6 +584,7 @@ impl ExecutionLayer { "Using external block builder"; "builder_url" => ?builder_url, "local_user_agent" => builder_client.get_user_agent(), + "ssz_disabled" => disable_ssz ); self.inner.builder.swap(Some(Arc::new(builder_client))); Ok(()) @@ -1912,6 +1913,11 @@ impl ExecutionLayer { let (payload_result, duration) = timed_future(metrics::POST_BLINDED_PAYLOAD_BUILDER, async { if builder.is_ssz_enabled() { + debug!( + self.log(), + "Sending submit_blinded_block"; + "ssz" => "true" + ); builder .post_builder_blinded_blocks_ssz(block) .await From 54b2f70482ac65e365c259057503c3d020490287 Mon Sep 17 00:00:00 2001 From: Pawan Dhananjay Date: Wed, 19 Feb 2025 17:46:14 -0800 Subject: [PATCH 5/8] Add cli tests; update book --- book/src/help_bn.md | 2 ++ lighthouse/tests/beacon_node.rs | 34 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/book/src/help_bn.md b/book/src/help_bn.md index cbcb1ec5a3d..c508dd8f242 100644 --- a/book/src/help_bn.md +++ b/book/src/help_bn.md @@ -28,6 +28,8 @@ Options: network. Multiaddr is also supported. --builder The URL of a service compatible with the MEV-boost API. + --builder-disable-ssz + Disables sending requests using ssz over the builder api --builder-fallback-epochs-since-finalization If this node is proposing a block and the chain has not finalized within this number of epochs, it will NOT query any connected diff --git a/lighthouse/tests/beacon_node.rs b/lighthouse/tests/beacon_node.rs index 03314930b9b..da10c2c4bd9 100644 --- a/lighthouse/tests/beacon_node.rs +++ b/lighthouse/tests/beacon_node.rs @@ -720,6 +720,40 @@ fn builder_user_agent() { ); } +#[test] +fn test_builder_disable_ssz_flag() { + run_payload_builder_flag_test_with_config( + "builder", + "http://meow.cats", + None, + None, + |config| { + assert!( + !config + .execution_layer + .as_ref() + .unwrap() + .disable_builder_ssz_requests, + ); + }, + ); + run_payload_builder_flag_test_with_config( + "builder", + "http://meow.cats", + Some("builder-disable-ssz"), + None, + |config| { + assert!( + config + .execution_layer + .as_ref() + .unwrap() + .disable_builder_ssz_requests, + ); + }, + ); +} + fn run_jwt_optional_flags_test(jwt_flag: &str, jwt_id_flag: &str, jwt_version_flag: &str) { use sensitive_url::SensitiveUrl; From f931c1604b7cb2f2d09f1e68aebd642e59eec60f Mon Sep 17 00:00:00 2001 From: Pawan Dhananjay Date: Wed, 19 Feb 2025 18:06:19 -0800 Subject: [PATCH 6/8] Change log --- beacon_node/execution_layer/src/lib.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/beacon_node/execution_layer/src/lib.rs b/beacon_node/execution_layer/src/lib.rs index 6298a6a97c5..07a424193cb 100644 --- a/beacon_node/execution_layer/src/lib.rs +++ b/beacon_node/execution_layer/src/lib.rs @@ -1912,12 +1912,14 @@ impl ExecutionLayer { if let Some(builder) = self.builder() { let (payload_result, duration) = timed_future(metrics::POST_BLINDED_PAYLOAD_BUILDER, async { - if builder.is_ssz_enabled() { - debug!( - self.log(), - "Sending submit_blinded_block"; - "ssz" => "true" - ); + let ssz_enabled = builder.is_ssz_enabled(); + debug!( + self.log(), + "Calling submit_blinded_block on builder"; + "block_root" => ?block_root, + "ssz" => ssz_enabled + ); + if ssz_enabled { builder .post_builder_blinded_blocks_ssz(block) .await From d368d982204a76df02c82f8a6f4b5252f44ddd4c Mon Sep 17 00:00:00 2001 From: Pawan Dhananjay Date: Thu, 20 Feb 2025 10:59:52 -0800 Subject: [PATCH 7/8] Apply suggestions from michael's review Co-authored-by: Michael Sproul --- beacon_node/src/cli.rs | 2 +- book/src/help_bn.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/beacon_node/src/cli.rs b/beacon_node/src/cli.rs index 03a2b0d41e6..2c8b271bd25 100644 --- a/beacon_node/src/cli.rs +++ b/beacon_node/src/cli.rs @@ -1464,7 +1464,7 @@ pub fn cli_app() -> Command { Arg::new("builder-disable-ssz") .long("builder-disable-ssz") .value_name("BOOLEAN") - .help("Disables sending requests using ssz over the builder api") + .help("Disables sending requests using SSZ over the builder API.") .requires("builder") .action(ArgAction::SetTrue) .display_order(0) diff --git a/book/src/help_bn.md b/book/src/help_bn.md index c508dd8f242..79c8d8ead85 100644 --- a/book/src/help_bn.md +++ b/book/src/help_bn.md @@ -29,7 +29,7 @@ Options: --builder The URL of a service compatible with the MEV-boost API. --builder-disable-ssz - Disables sending requests using ssz over the builder api + Disables sending requests using SSZ over the builder API. --builder-fallback-epochs-since-finalization If this node is proposing a block and the chain has not finalized within this number of epochs, it will NOT query any connected From 1332704eaa62ac91f5b2b54374c2cc1e8cb92522 Mon Sep 17 00:00:00 2001 From: Pawan Dhananjay Date: Thu, 20 Feb 2025 11:10:12 -0800 Subject: [PATCH 8/8] Rename --- beacon_node/builder_client/src/lib.rs | 16 ++++++++-------- beacon_node/execution_layer/src/lib.rs | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/beacon_node/builder_client/src/lib.rs b/beacon_node/builder_client/src/lib.rs index a7a61d2a743..6d82542cefc 100644 --- a/beacon_node/builder_client/src/lib.rs +++ b/beacon_node/builder_client/src/lib.rs @@ -64,10 +64,10 @@ pub struct BuilderHttpClient { user_agent: String, /// Only use json for all requests/responses types. disable_ssz: bool, - /// Indicates that the `get_header`` response had content-type ssz + /// Indicates that the `get_header` response had content-type ssz /// so we can set content-type header to ssz to make the `submit_blinded_blocks` /// request. - ssz_used: Arc, + ssz_available: Arc, } impl BuilderHttpClient { @@ -85,7 +85,7 @@ impl BuilderHttpClient { timeouts: Timeouts::new(builder_header_timeout), user_agent, disable_ssz, - ssz_used: Arc::new(false.into()), + ssz_available: Arc::new(false.into()), }) } @@ -136,7 +136,7 @@ impl BuilderHttpClient { let Ok(Some(fork_name)) = self.fork_name_from_header(&headers) else { // if no fork version specified, attempt to fallback to JSON - self.ssz_used.store(false, Ordering::SeqCst); + self.ssz_available.store(false, Ordering::SeqCst); return serde_json::from_slice(&response_bytes).map_err(Error::InvalidJson); }; @@ -144,7 +144,7 @@ impl BuilderHttpClient { match content_type { ContentType::Ssz => { - self.ssz_used.store(true, Ordering::SeqCst); + self.ssz_available.store(true, Ordering::SeqCst); T::from_ssz_bytes_by_fork(&response_bytes, fork_name) .map(|data| ForkVersionedResponse { version: Some(fork_name), @@ -154,7 +154,7 @@ impl BuilderHttpClient { .map_err(Error::InvalidSsz) } ContentType::Json => { - self.ssz_used.store(false, Ordering::SeqCst); + self.ssz_available.store(false, Ordering::SeqCst); serde_json::from_slice(&response_bytes).map_err(Error::InvalidJson) } } @@ -163,8 +163,8 @@ impl BuilderHttpClient { /// Return `true` if the most recently received response from the builder had SSZ Content-Type. /// Return `false` otherwise. /// Also returns `false` if we have explicitly disabled ssz. - pub fn is_ssz_enabled(&self) -> bool { - !self.disable_ssz && self.ssz_used.load(Ordering::SeqCst) + pub fn is_ssz_available(&self) -> bool { + !self.disable_ssz && self.ssz_available.load(Ordering::SeqCst) } async fn get_with_timeout( diff --git a/beacon_node/execution_layer/src/lib.rs b/beacon_node/execution_layer/src/lib.rs index 07a424193cb..4fd7188c206 100644 --- a/beacon_node/execution_layer/src/lib.rs +++ b/beacon_node/execution_layer/src/lib.rs @@ -1912,7 +1912,7 @@ impl ExecutionLayer { if let Some(builder) = self.builder() { let (payload_result, duration) = timed_future(metrics::POST_BLINDED_PAYLOAD_BUILDER, async { - let ssz_enabled = builder.is_ssz_enabled(); + let ssz_enabled = builder.is_ssz_available(); debug!( self.log(), "Calling submit_blinded_block on builder";