From 19b0db2cdff34897f1bd3c2b4baf787aacdd341d Mon Sep 17 00:00:00 2001 From: chonghe <44791194+chong-he@users.noreply.github.com> Date: Sun, 24 Mar 2024 05:30:36 +0800 Subject: [PATCH] Delete PRE_CAPELLA_ENGINE_CAPABILITIES (#5406) * Adjust width * Commit changes * Delete PRE_CAPELLA_ENGINE_CAPABILITIES * Revert "Adjust width" This reverts commit 6fea81b897ce4a346c90902f1c95190875afc2d9. * Revert "Commit changes" This reverts commit d00859a63e526c791e0fec25acdaa2557da2fb95. * Simplify * Merge branch 'delete-pre-capella' of https://github.com/chong-he/lighthouse into delete-pre-capella --- .../execution_layer/src/engine_api/http.rs | 60 ++++++------------- 1 file changed, 17 insertions(+), 43 deletions(-) diff --git a/beacon_node/execution_layer/src/engine_api/http.rs b/beacon_node/execution_layer/src/engine_api/http.rs index 7fafeadb8..0604f15c4 100644 --- a/beacon_node/execution_layer/src/engine_api/http.rs +++ b/beacon_node/execution_layer/src/engine_api/http.rs @@ -71,23 +71,6 @@ pub static LIGHTHOUSE_CAPABILITIES: &[&str] = &[ ENGINE_GET_PAYLOAD_BODIES_BY_RANGE_V1, ]; -/// This is necessary because a user might run a capella-enabled version of -/// lighthouse before they update to a capella-enabled execution engine. -// TODO (mark): rip this out once we are post-capella on mainnet -pub static PRE_CAPELLA_ENGINE_CAPABILITIES: EngineCapabilities = EngineCapabilities { - new_payload_v1: true, - new_payload_v2: false, - new_payload_v3: false, - forkchoice_updated_v1: true, - forkchoice_updated_v2: false, - forkchoice_updated_v3: false, - get_payload_bodies_by_hash_v1: false, - get_payload_bodies_by_range_v1: false, - get_payload_v1: true, - get_payload_v2: false, - get_payload_v3: false, -}; - /// Contains methods to convert arbitrary bytes to an ETH2 deposit contract object. pub mod deposit_log { use ssz::Decode; @@ -1012,38 +995,29 @@ impl HttpJsonRpc { pub async fn exchange_capabilities(&self) -> Result { let params = json!([LIGHTHOUSE_CAPABILITIES]); - let response: Result, _> = self + let capabilities: HashSet = self .rpc_request( ENGINE_EXCHANGE_CAPABILITIES, params, ENGINE_EXCHANGE_CAPABILITIES_TIMEOUT * self.execution_timeout_multiplier, ) - .await; + .await?; - match response { - // TODO (mark): rip this out once we are post capella on mainnet - Err(error) => match error { - Error::ServerMessage { code, message: _ } if code == METHOD_NOT_FOUND_CODE => { - Ok(PRE_CAPELLA_ENGINE_CAPABILITIES) - } - _ => Err(error), - }, - Ok(capabilities) => Ok(EngineCapabilities { - new_payload_v1: capabilities.contains(ENGINE_NEW_PAYLOAD_V1), - new_payload_v2: capabilities.contains(ENGINE_NEW_PAYLOAD_V2), - new_payload_v3: capabilities.contains(ENGINE_NEW_PAYLOAD_V3), - forkchoice_updated_v1: capabilities.contains(ENGINE_FORKCHOICE_UPDATED_V1), - forkchoice_updated_v2: capabilities.contains(ENGINE_FORKCHOICE_UPDATED_V2), - forkchoice_updated_v3: capabilities.contains(ENGINE_FORKCHOICE_UPDATED_V3), - get_payload_bodies_by_hash_v1: capabilities - .contains(ENGINE_GET_PAYLOAD_BODIES_BY_HASH_V1), - get_payload_bodies_by_range_v1: capabilities - .contains(ENGINE_GET_PAYLOAD_BODIES_BY_RANGE_V1), - get_payload_v1: capabilities.contains(ENGINE_GET_PAYLOAD_V1), - get_payload_v2: capabilities.contains(ENGINE_GET_PAYLOAD_V2), - get_payload_v3: capabilities.contains(ENGINE_GET_PAYLOAD_V3), - }), - } + Ok(EngineCapabilities { + new_payload_v1: capabilities.contains(ENGINE_NEW_PAYLOAD_V1), + new_payload_v2: capabilities.contains(ENGINE_NEW_PAYLOAD_V2), + new_payload_v3: capabilities.contains(ENGINE_NEW_PAYLOAD_V3), + forkchoice_updated_v1: capabilities.contains(ENGINE_FORKCHOICE_UPDATED_V1), + forkchoice_updated_v2: capabilities.contains(ENGINE_FORKCHOICE_UPDATED_V2), + forkchoice_updated_v3: capabilities.contains(ENGINE_FORKCHOICE_UPDATED_V3), + get_payload_bodies_by_hash_v1: capabilities + .contains(ENGINE_GET_PAYLOAD_BODIES_BY_HASH_V1), + get_payload_bodies_by_range_v1: capabilities + .contains(ENGINE_GET_PAYLOAD_BODIES_BY_RANGE_V1), + get_payload_v1: capabilities.contains(ENGINE_GET_PAYLOAD_V1), + get_payload_v2: capabilities.contains(ENGINE_GET_PAYLOAD_V2), + get_payload_v3: capabilities.contains(ENGINE_GET_PAYLOAD_V3), + }) } pub async fn clear_exchange_capabilties_cache(&self) {