Add bls_to_execution_change topic to eth1/v1/events (#5823)

* Add bls event

* Update events and types

* Add bls in event

* Event bls

* tests..rs

* change order

* another tests.rs

* Signed BLS

* Revert "another tests.rs"

This reverts commit 7f54e9c1ce.

* Revert "Signed BLS"

This reverts commit 1146bc734b.

* withdrawal_keyparis

* Fix genesis
This commit is contained in:
chonghe
2024-05-30 13:48:29 +08:00
committed by GitHub
parent 6daeec31e2
commit ffe29c087d
5 changed files with 58 additions and 0 deletions

View File

@@ -2589,6 +2589,14 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
bls_to_execution_change: SigVerifiedOp<SignedBlsToExecutionChange, T::EthSpec>,
received_pre_capella: ReceivedPreCapella,
) -> bool {
if let Some(event_handler) = self.event_handler.as_ref() {
if event_handler.has_bls_to_execution_change_subscribers() {
event_handler.register(EventKind::BlsToExecutionChange(Box::new(
bls_to_execution_change.clone().into_inner(),
)));
}
}
if self.eth1_chain.is_some() {
self.op_pool
.insert_bls_to_execution_change(bls_to_execution_change, received_pre_capella)

View File

@@ -22,6 +22,7 @@ pub struct ServerSentEventHandler<E: EthSpec> {
block_reward_tx: Sender<EventKind<E>>,
proposer_slashing_tx: Sender<EventKind<E>>,
attester_slashing_tx: Sender<EventKind<E>>,
bls_to_execution_change_tx: Sender<EventKind<E>>,
log: Logger,
}
@@ -49,6 +50,7 @@ impl<E: EthSpec> ServerSentEventHandler<E> {
let (block_reward_tx, _) = broadcast::channel(capacity);
let (proposer_slashing_tx, _) = broadcast::channel(capacity);
let (attester_slashing_tx, _) = broadcast::channel(capacity);
let (bls_to_execution_change_tx, _) = broadcast::channel(capacity);
Self {
attestation_tx,
@@ -66,6 +68,7 @@ impl<E: EthSpec> ServerSentEventHandler<E> {
block_reward_tx,
proposer_slashing_tx,
attester_slashing_tx,
bls_to_execution_change_tx,
log,
}
}
@@ -140,6 +143,10 @@ impl<E: EthSpec> ServerSentEventHandler<E> {
.attester_slashing_tx
.send(kind)
.map(|count| log_count("attester slashing", count)),
EventKind::BlsToExecutionChange(_) => self
.bls_to_execution_change_tx
.send(kind)
.map(|count| log_count("bls to execution change", count)),
};
if let Err(SendError(event)) = result {
trace!(self.log, "No receivers registered to listen for event"; "event" => ?event);
@@ -206,6 +213,10 @@ impl<E: EthSpec> ServerSentEventHandler<E> {
self.proposer_slashing_tx.subscribe()
}
pub fn subscribe_bls_to_execution_change(&self) -> Receiver<EventKind<E>> {
self.bls_to_execution_change_tx.subscribe()
}
pub fn has_attestation_subscribers(&self) -> bool {
self.attestation_tx.receiver_count() > 0
}
@@ -257,4 +268,8 @@ impl<E: EthSpec> ServerSentEventHandler<E> {
pub fn has_attester_slashing_subscribers(&self) -> bool {
self.attester_slashing_tx.receiver_count() > 0
}
pub fn has_bls_to_execution_change_subscribers(&self) -> bool {
self.bls_to_execution_change_tx.receiver_count() > 0
}
}