Skip to content

Commit

Permalink
Fail gracefully if we are unable to parse a gossipsub message (#1448)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesHinshelwood authored Sep 12, 2024
1 parent a8f1f0b commit 3094673
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

Unreleased changes, in reverse chronological order. New entries are added at the top of this list.

- [#1448](https://github.com/Zilliqa/zq2/pull/1448): Fail gracefully if we are unable to parse a gossipsub message.
- [#1423](https://github.com/Zilliqa/zq2/pull/1423): Fix invalid value returned by calling `_balance` in a scilla transition.

## [0.3.0] - 2024-09-12
Expand Down
9 changes: 8 additions & 1 deletion zilliqa/src/p2p_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,14 @@ impl P2pNode {
}, ..
})) => {
let source = source.expect("message should have a source");
let message = cbor4ii::serde::from_slice::<ExternalMessage>(&data).unwrap();
let message = match cbor4ii::serde::from_slice::<ExternalMessage>(&data) {
Ok(m) => m,
Err(e) => {
let data = hex::encode(&data);
error!(?e, data, "message parsing failed");
continue;
}
};
let to = self.peer_id;
debug!(%source, %to, %message, "broadcast recieved");
self.send_to(&topic_hash, |c| c.broadcasts.send((source, message)))?;
Expand Down

0 comments on commit 3094673

Please sign in to comment.