diff --git a/beacon_node/http_api/Cargo.toml b/beacon_node/http_api/Cargo.toml index 2fb3ec06bf..7bd4807cc9 100644 --- a/beacon_node/http_api/Cargo.toml +++ b/beacon_node/http_api/Cargo.toml @@ -46,11 +46,11 @@ tree_hash = { workspace = true } types = { workspace = true } warp = { workspace = true } warp_utils = { workspace = true } +proto_array = { workspace = true } [dev-dependencies] genesis = { workspace = true } logging = { workspace = true } -proto_array = { workspace = true } serde_json = { workspace = true } [[test]] diff --git a/beacon_node/http_api/src/lib.rs b/beacon_node/http_api/src/lib.rs index ff2474531d..47a1557e90 100644 --- a/beacon_node/http_api/src/lib.rs +++ b/beacon_node/http_api/src/lib.rs @@ -4543,6 +4543,34 @@ pub fn serve( }, ); + let post_lighthouse_fork_choice_invalidate = warp::path("lighthouse") + .and(warp::path("fork_choice")) + .and(warp::path("invalidate")) + .and(warp::path::end()) + .and(task_spawner_filter.clone()) + .and(chain_filter.clone()) + .and(warp_utils::json::json()) + .then( + |task_spawner: TaskSpawner, + chain: Arc>, + block_root: Hash256| { + task_spawner.blocking_json_task(Priority::P0, move || { + let invalidation = + proto_array::InvalidationOperation::InvalidateOne { block_root }; + chain + .canonical_head + .fork_choice_write_lock() + .on_invalid_execution_payload(&invalidation) + .map_err(|e| { + warp_utils::reject::custom_server_error(format!( + "not invalidated due to error: {e:?}" + )) + })?; + Ok("invalidated") + }) + }, + ); + // GET lighthouse/analysis/block_rewards let get_lighthouse_block_rewards = warp::path("lighthouse") .and(warp::path("analysis")) @@ -4904,6 +4932,7 @@ pub fn serve( .uor(post_validator_liveness_epoch) .uor(post_lighthouse_liveness) .uor(post_lighthouse_database_reconstruct) + .uor(post_lighthouse_fork_choice_invalidate) .uor(post_lighthouse_block_rewards) .uor(post_lighthouse_ui_validator_metrics) .uor(post_lighthouse_ui_validator_info)