From fa1aebe4ce307e6073c7b0af1fd1fae16e803e5f Mon Sep 17 00:00:00 2001 From: chonghe Date: Thu, 16 May 2024 10:43:20 +0800 Subject: [PATCH] Update events and types --- beacon_node/beacon_chain/src/events.rs | 7 +++++++ common/eth2/src/types.rs | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/beacon_node/beacon_chain/src/events.rs b/beacon_node/beacon_chain/src/events.rs index 8700675a66..077388b86c 100644 --- a/beacon_node/beacon_chain/src/events.rs +++ b/beacon_node/beacon_chain/src/events.rs @@ -22,6 +22,7 @@ pub struct ServerSentEventHandler { block_reward_tx: Sender>, proposer_slashing_tx: Sender>, attester_slashing_tx: Sender>, + bls_to_execution_change_tx: Sender>, log: Logger, } @@ -49,6 +50,7 @@ impl ServerSentEventHandler { 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 ServerSentEventHandler { block_reward_tx, proposer_slashing_tx, attester_slashing_tx, + bls_to_execution_change_tx, log, } } @@ -140,6 +143,10 @@ impl ServerSentEventHandler { .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); diff --git a/common/eth2/src/types.rs b/common/eth2/src/types.rs index b15246e7fd..5b62177c0f 100644 --- a/common/eth2/src/types.rs +++ b/common/eth2/src/types.rs @@ -1082,6 +1082,7 @@ pub enum EventKind { PayloadAttributes(VersionedSsePayloadAttributes), ProposerSlashing(Box), AttesterSlashing(Box>), + BlsToExecutionChange(Box), } impl EventKind { @@ -1103,6 +1104,7 @@ impl EventKind { EventKind::BlockReward(_) => "block_reward", EventKind::ProposerSlashing(_) => "proposer_slashing", EventKind::AttesterSlashing(_) => "attester_slashing", + EventKind::BlsToExecutionChange(_) => "bls_to_execution_change", } } @@ -1193,6 +1195,11 @@ impl EventKind { ServerError::InvalidServerSentEvent(format!("Proposer Slashing: {:?}", e)) })?, )), + "bls_to_execution_change" => Ok(EventKind::BlsToExecutionChange( + serde_json::from_str(data).map_err(|e| { + ServerError::InvalidServerSentEvent(format!("Bls To Execution Change: {:?}", e)) + })?, + )), _ => Err(ServerError::InvalidServerSentEvent( "Could not parse event tag".to_string(), )), @@ -1226,6 +1233,7 @@ pub enum EventTopic { BlockReward, AttesterSlashing, ProposerSlashing, + BlsToExecutionChange, } impl FromStr for EventTopic { @@ -1249,6 +1257,7 @@ impl FromStr for EventTopic { "block_reward" => Ok(EventTopic::BlockReward), "attester_slashing" => Ok(EventTopic::AttesterSlashing), "proposer_slashing" => Ok(EventTopic::ProposerSlashing), + "bls_to_execution_change" => Ok(EventTopic::BlsToExecutionChange), _ => Err("event topic cannot be parsed.".to_string()), } } @@ -1273,6 +1282,7 @@ impl fmt::Display for EventTopic { EventTopic::BlockReward => write!(f, "block_reward"), EventTopic::AttesterSlashing => write!(f, "attester_slashing"), EventTopic::ProposerSlashing => write!(f, "proposer_slashing"), + EventTopic::BlsToExecutionChange => write!(f, "bls_to_execution_change"), } } }