mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-23 23:04:53 +00:00
Allow per validator fee recipient via flag or file in validator client (similar to graffiti / graffiti-file) (#2924)
## Issue Addressed #2883 ## Proposed Changes * Added `suggested-fee-recipient` & `suggested-fee-recipient-file` flags to validator client (similar to graffiti / graffiti-file implementation). * Added proposer preparation service to VC, which sends the fee-recipient of all known validators to the BN via [/eth/v1/validator/prepare_beacon_proposer](https://github.com/ethereum/beacon-APIs/pull/178) api once per slot * Added [/eth/v1/validator/prepare_beacon_proposer](https://github.com/ethereum/beacon-APIs/pull/178) api endpoint and preparation data caching * Added cleanup routine to remove cached proposer preparations when not updated for 2 epochs ## Additional Info Changed the Implementation following the discussion in #2883. Co-authored-by: pk910 <philipp@pk910.de> Co-authored-by: Paul Hauner <paul@paulhauner.com> Co-authored-by: Philipp K <philipp@pk910.de>
This commit is contained in:
@@ -45,9 +45,9 @@ use tokio::sync::mpsc::UnboundedSender;
|
||||
use tokio_stream::{wrappers::BroadcastStream, StreamExt};
|
||||
use types::{
|
||||
Attestation, AttesterSlashing, BeaconStateError, CommitteeCache, ConfigAndPreset, Epoch,
|
||||
EthSpec, ForkName, ProposerSlashing, RelativeEpoch, SignedAggregateAndProof, SignedBeaconBlock,
|
||||
SignedContributionAndProof, SignedVoluntaryExit, Slot, SyncCommitteeMessage,
|
||||
SyncContributionData,
|
||||
EthSpec, ForkName, ProposerPreparationData, ProposerSlashing, RelativeEpoch,
|
||||
SignedAggregateAndProof, SignedBeaconBlock, SignedContributionAndProof, SignedVoluntaryExit,
|
||||
Slot, SyncCommitteeMessage, SyncContributionData,
|
||||
};
|
||||
use version::{
|
||||
add_consensus_version_header, fork_versioned_response, inconsistent_fork_rejection,
|
||||
@@ -2186,6 +2186,53 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
},
|
||||
);
|
||||
|
||||
// POST validator/prepare_beacon_proposer
|
||||
let post_validator_prepare_beacon_proposer = eth1_v1
|
||||
.and(warp::path("validator"))
|
||||
.and(warp::path("prepare_beacon_proposer"))
|
||||
.and(warp::path::end())
|
||||
.and(not_while_syncing_filter.clone())
|
||||
.and(chain_filter.clone())
|
||||
.and(warp::addr::remote())
|
||||
.and(log_filter.clone())
|
||||
.and(warp::body::json())
|
||||
.and_then(
|
||||
|chain: Arc<BeaconChain<T>>,
|
||||
client_addr: Option<SocketAddr>,
|
||||
log: Logger,
|
||||
preparation_data: Vec<ProposerPreparationData>| {
|
||||
blocking_json_task(move || {
|
||||
let execution_layer = chain
|
||||
.execution_layer
|
||||
.as_ref()
|
||||
.ok_or(BeaconChainError::ExecutionLayerMissing)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
let current_epoch = chain
|
||||
.epoch()
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
|
||||
debug!(
|
||||
log,
|
||||
"Received proposer preparation data";
|
||||
"count" => preparation_data.len(),
|
||||
"client" => client_addr
|
||||
.map(|a| a.to_string())
|
||||
.unwrap_or_else(|| "unknown".to_string()),
|
||||
);
|
||||
|
||||
execution_layer
|
||||
.update_proposer_preparation_blocking(current_epoch, &preparation_data)
|
||||
.map_err(|_e| {
|
||||
warp_utils::reject::custom_bad_request(
|
||||
"error processing proposer preparations".to_string(),
|
||||
)
|
||||
})?;
|
||||
|
||||
Ok(())
|
||||
})
|
||||
},
|
||||
);
|
||||
|
||||
// POST validator/sync_committee_subscriptions
|
||||
let post_validator_sync_committee_subscriptions = eth1_v1
|
||||
.and(warp::path("validator"))
|
||||
@@ -2710,6 +2757,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
.or(post_validator_contribution_and_proofs.boxed())
|
||||
.or(post_validator_beacon_committee_subscriptions.boxed())
|
||||
.or(post_validator_sync_committee_subscriptions.boxed())
|
||||
.or(post_validator_prepare_beacon_proposer.boxed())
|
||||
.or(post_lighthouse_liveness.boxed())
|
||||
.or(post_lighthouse_database_reconstruct.boxed())
|
||||
.or(post_lighthouse_database_historical_blocks.boxed()),
|
||||
|
||||
Reference in New Issue
Block a user