mirror of
https://github.com/sigp/lighthouse.git
synced 2026-06-17 02:38:34 +00:00
Manual finalization endpoint (#7059)
* Load block roots from fork choice where possible to avoid loading state from disk when serving block by range requests. * Check if the start slot is newer than finalization (`start_slot >= finalized_slot`), and use fork choice in that case. * force finalization endpoint * cleanup * Remove ds store * Don't import blocks that conflict with the split * Disconnect and ban peer if we get blocks conflicting manual checkpoint * immediately commit state to cold db * revert * Fix descent from split check * Add safety check to checkpoint when doing manual finalization. --------- Co-authored-by: Jimmy Chen <jchen.tc@gmail.com> Co-authored-by: Michael Sproul <michael@sigmaprime.io> Co-authored-by: Pawan Dhananjay <pawandhananjay@gmail.com>
This commit is contained in:
@@ -86,11 +86,11 @@ use tokio_stream::{
|
||||
};
|
||||
use types::{
|
||||
fork_versioned_response::EmptyMetadata, Attestation, AttestationData, AttestationShufflingId,
|
||||
AttesterSlashing, BeaconStateError, ChainSpec, CommitteeCache, ConfigAndPreset, Epoch, EthSpec,
|
||||
ForkName, ForkVersionedResponse, Hash256, ProposerPreparationData, ProposerSlashing,
|
||||
RelativeEpoch, SignedAggregateAndProof, SignedBlindedBeaconBlock, SignedBlsToExecutionChange,
|
||||
SignedContributionAndProof, SignedValidatorRegistrationData, SignedVoluntaryExit, Slot,
|
||||
SyncCommitteeMessage, SyncContributionData,
|
||||
AttesterSlashing, BeaconStateError, ChainSpec, Checkpoint, CommitteeCache, ConfigAndPreset,
|
||||
Epoch, EthSpec, ForkName, ForkVersionedResponse, Hash256, ProposerPreparationData,
|
||||
ProposerSlashing, RelativeEpoch, SignedAggregateAndProof, SignedBlindedBeaconBlock,
|
||||
SignedBlsToExecutionChange, SignedContributionAndProof, SignedValidatorRegistrationData,
|
||||
SignedVoluntaryExit, Slot, SyncCommitteeMessage, SyncContributionData,
|
||||
};
|
||||
use validator::pubkey_to_validator_index;
|
||||
use version::{
|
||||
@@ -4133,6 +4133,35 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
},
|
||||
);
|
||||
|
||||
// POST lighthouse/finalize
|
||||
let post_lighthouse_finalize = warp::path("lighthouse")
|
||||
.and(warp::path("finalize"))
|
||||
.and(warp::path::end())
|
||||
.and(warp_utils::json::json())
|
||||
.and(task_spawner_filter.clone())
|
||||
.and(chain_filter.clone())
|
||||
.then(
|
||||
|request_data: api_types::ManualFinalizationRequestData,
|
||||
task_spawner: TaskSpawner<T::EthSpec>,
|
||||
chain: Arc<BeaconChain<T>>| {
|
||||
task_spawner.blocking_json_task(Priority::P0, move || {
|
||||
let checkpoint = Checkpoint {
|
||||
epoch: request_data.epoch,
|
||||
root: request_data.block_root,
|
||||
};
|
||||
|
||||
chain
|
||||
.manually_finalize_state(request_data.state_root, checkpoint)
|
||||
.map(|_| api_types::GenericResponse::from(request_data))
|
||||
.map_err(|e| {
|
||||
warp_utils::reject::custom_bad_request(format!(
|
||||
"Failed to finalize state due to error: {e:?}"
|
||||
))
|
||||
})
|
||||
})
|
||||
},
|
||||
);
|
||||
|
||||
// POST lighthouse/liveness
|
||||
let post_lighthouse_liveness = warp::path("lighthouse")
|
||||
.and(warp::path("liveness"))
|
||||
@@ -4932,6 +4961,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
.uor(post_lighthouse_block_rewards)
|
||||
.uor(post_lighthouse_ui_validator_metrics)
|
||||
.uor(post_lighthouse_ui_validator_info)
|
||||
.uor(post_lighthouse_finalize)
|
||||
.recover(warp_utils::reject::handle_rejection),
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user