Manual compaction endpoint backport (#7104)

Backports:
- https://github.com/sigp/lighthouse/pull/7072

To:
- https://github.com/sigp/lighthouse/issues/7039

#7103 should be merged first


  This PR introduces an endpoint that allows users to manually trigger background compaction.
This commit is contained in:
Eitan Seri-Levi
2025-03-18 00:29:12 -06:00
committed by GitHub
parent 27aabe8159
commit ed1b7689ae
3 changed files with 46 additions and 0 deletions

View File

@@ -4105,6 +4105,23 @@ pub fn serve<T: BeaconChainTypes>(
},
);
// POST lighthouse/compaction
let post_lighthouse_compaction = warp::path("lighthouse")
.and(warp::path("compaction"))
.and(warp::path::end())
.and(task_spawner_filter.clone())
.and(chain_filter.clone())
.then(
|task_spawner: TaskSpawner<T::EthSpec>, chain: Arc<BeaconChain<T>>| {
task_spawner.blocking_json_task(Priority::P0, move || {
chain.manually_compact_database();
Ok(api_types::GenericResponse::from(String::from(
"Triggered manual compaction",
)))
})
},
);
// POST lighthouse/liveness
let post_lighthouse_liveness = warp::path("lighthouse")
.and(warp::path("liveness"))
@@ -4878,6 +4895,7 @@ pub fn serve<T: BeaconChainTypes>(
.uor(post_lighthouse_ui_validator_metrics)
.uor(post_lighthouse_ui_validator_info)
.uor(post_lighthouse_finalize)
.uor(post_lighthouse_compaction)
.recover(warp_utils::reject::handle_rejection),
),
)