Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add range check to signature index #5157

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion crates/iroha_core/src/sumeragi/main_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,19 @@ impl Sumeragi {
);

if let Ok(signatory_idx) = usize::try_from(signature.0) {
let signatory = &self.topology.as_ref()[signatory_idx];
let signatory = if let Some(s) = self.topology.as_ref().get(signatory_idx) {
s
} else {
error!(
peer_id=%self.peer_id,
role=%self.role(),
?signatory_idx,
topology_size=%self.topology.as_ref().len(),
"Unknown signatory"
);

return;
};

match self.topology.role(signatory) {
Role::Leader => error!(
Expand Down
2 changes: 1 addition & 1 deletion crates/iroha_p2p/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ impl<T: Pload, K: Kex, E: Enc> NetworkBase<T, K, E> {
#[log(skip(self, shutdown_signal), fields(listen_addr=%self.listen_addr, public_key=%self.key_pair.public_key()))]
async fn run(mut self, shutdown_signal: ShutdownSignal) {
// TODO: probably should be configuration parameter
let mut update_topology_interval = tokio::time::interval(Duration::from_millis(100));
let mut update_topology_interval = tokio::time::interval(Duration::from_millis(1000));
loop {
tokio::select! {
// Select is biased because we want to service messages to take priority over data messages.
Expand Down
Loading