mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 18:32:42 +00:00
Op pool and gossip for BLS to execution changes (#3726)
This commit is contained in:
@@ -5,6 +5,9 @@ authors = ["Paul Hauner <paul@paulhauner.com>"]
|
||||
edition = "2021"
|
||||
autotests = false # using a single test binary compiles faster
|
||||
|
||||
[features]
|
||||
withdrawals-processing = []
|
||||
|
||||
[dependencies]
|
||||
warp = { version = "0.3.2", features = ["tls"] }
|
||||
serde = { version = "1.0.116", features = ["derive"] }
|
||||
|
||||
@@ -49,9 +49,9 @@ use types::{
|
||||
Attestation, AttestationData, AttesterSlashing, BeaconStateError, BlindedPayload,
|
||||
CommitteeCache, ConfigAndPreset, Epoch, EthSpec, ForkName, FullPayload,
|
||||
ProposerPreparationData, ProposerSlashing, RelativeEpoch, SignedAggregateAndProof,
|
||||
SignedBeaconBlock, SignedBlindedBeaconBlock, SignedContributionAndProof,
|
||||
SignedValidatorRegistrationData, SignedVoluntaryExit, Slot, SyncCommitteeMessage,
|
||||
SyncContributionData,
|
||||
SignedBeaconBlock, SignedBlindedBeaconBlock, SignedBlsToExecutionChange,
|
||||
SignedContributionAndProof, SignedValidatorRegistrationData, SignedVoluntaryExit, Slot,
|
||||
SyncCommitteeMessage, SyncContributionData,
|
||||
};
|
||||
use version::{
|
||||
add_consensus_version_header, execution_optimistic_fork_versioned_response,
|
||||
@@ -1536,6 +1536,59 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
},
|
||||
);
|
||||
|
||||
// GET beacon/pool/bls_to_execution_changes
|
||||
let get_beacon_pool_bls_to_execution_changes = beacon_pool_path
|
||||
.clone()
|
||||
.and(warp::path("bls_to_execution_changes"))
|
||||
.and(warp::path::end())
|
||||
.and_then(|chain: Arc<BeaconChain<T>>| {
|
||||
blocking_json_task(move || {
|
||||
let address_changes = chain.op_pool.get_all_bls_to_execution_changes();
|
||||
Ok(api_types::GenericResponse::from(address_changes))
|
||||
})
|
||||
});
|
||||
|
||||
// POST beacon/pool/bls_to_execution_changes
|
||||
let post_beacon_pool_bls_to_execution_changes = beacon_pool_path
|
||||
.clone()
|
||||
.and(warp::path("bls_to_execution_changes"))
|
||||
.and(warp::path::end())
|
||||
.and(warp::body::json())
|
||||
.and(network_tx_filter.clone())
|
||||
.and_then(
|
||||
|chain: Arc<BeaconChain<T>>,
|
||||
address_change: SignedBlsToExecutionChange,
|
||||
network_tx: UnboundedSender<NetworkMessage<T::EthSpec>>| {
|
||||
blocking_json_task(move || {
|
||||
let outcome = chain
|
||||
.verify_bls_to_execution_change_for_gossip(address_change)
|
||||
.map_err(|e| {
|
||||
warp_utils::reject::object_invalid(format!(
|
||||
"gossip verification failed: {:?}",
|
||||
e
|
||||
))
|
||||
})?;
|
||||
|
||||
if let ObservationOutcome::New(address_change) = outcome {
|
||||
#[cfg(feature = "withdrawals-processing")]
|
||||
{
|
||||
publish_pubsub_message(
|
||||
&network_tx,
|
||||
PubsubMessage::BlsToExecutionChange(Box::new(
|
||||
address_change.as_inner().clone(),
|
||||
)),
|
||||
)?;
|
||||
}
|
||||
drop(network_tx);
|
||||
|
||||
chain.import_bls_to_execution_change(address_change);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
})
|
||||
},
|
||||
);
|
||||
|
||||
// GET beacon/deposit_snapshot
|
||||
let get_beacon_deposit_snapshot = eth_v1
|
||||
.and(warp::path("beacon"))
|
||||
@@ -3170,6 +3223,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
.or(get_beacon_pool_attester_slashings.boxed())
|
||||
.or(get_beacon_pool_proposer_slashings.boxed())
|
||||
.or(get_beacon_pool_voluntary_exits.boxed())
|
||||
.or(get_beacon_pool_bls_to_execution_changes.boxed())
|
||||
.or(get_beacon_deposit_snapshot.boxed())
|
||||
.or(get_config_fork_schedule.boxed())
|
||||
.or(get_config_spec.boxed())
|
||||
@@ -3218,6 +3272,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
.or(post_beacon_pool_proposer_slashings.boxed())
|
||||
.or(post_beacon_pool_voluntary_exits.boxed())
|
||||
.or(post_beacon_pool_sync_committees.boxed())
|
||||
.or(post_beacon_pool_bls_to_execution_changes.boxed())
|
||||
.or(post_validator_duties_attester.boxed())
|
||||
.or(post_validator_duties_sync.boxed())
|
||||
.or(post_validator_aggregate_and_proofs.boxed())
|
||||
|
||||
Reference in New Issue
Block a user