Skip to content

Commit

Permalink
New validator nonce (#430)
Browse files Browse the repository at this point in the history
  • Loading branch information
WuBruno authored Feb 9, 2024
1 parent a0ebf62 commit 2236b0b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion products/bridge/bridge-validators/src/bridge_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use crate::{
#[derive(Debug)]
pub struct BridgeNode {
event_signatures: HashMap<U256, RelayEventSignatures>,
relay_nonces: HashSet<U256>,
outbound_message_sender: UnboundedSender<OutboundBridgeMessage>,
inbound_message_receiver: UnboundedReceiverStream<InboundBridgeMessage>,
inbound_message_sender: UnboundedSender<InboundBridgeMessage>,
Expand All @@ -53,6 +54,7 @@ impl BridgeNode {
inbound_message_receiver,
inbound_message_sender,
is_leader,
relay_nonces: HashSet::new(),
};

bridge_node.update_validators().await?;
Expand Down Expand Up @@ -199,7 +201,15 @@ impl BridgeNode {
Ok(())
}

fn handle_relay_event(&self, event: RelayedFilter) -> Result<()> {
fn handle_relay_event(&mut self, event: RelayedFilter) -> Result<()> {
if self.relay_nonces.contains(&event.nonce) {
info!(
"Chain: {} event duplicated {}",
self.chain_client.chain_id, event
);
return Ok(());
}

info!(
"Chain: {} event found to be broadcasted: {}",
self.chain_client.chain_id, event
Expand All @@ -215,6 +225,8 @@ impl BridgeNode {

let relay_event = RelayEvent::from(event, self.chain_client.chain_id);

self.relay_nonces.insert(relay_event.nonce);

self.broadcast_message(Relay {
signature: relay_event.sign(&self.chain_client.wallet)?,
event: relay_event,
Expand Down

0 comments on commit 2236b0b

Please sign in to comment.