Skip to content

Commit

Permalink
Do not process zero or hashed_null_node pair trie roots.
Browse files Browse the repository at this point in the history
Log the case when these are received from other nodes.
#807
  • Loading branch information
artemii235 committed Feb 16, 2021
1 parent 0f36d9b commit 375bb56
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion mm2src/lp_ordermatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,9 @@ fn remove_and_purge_pubkey_pair_orders(orderbook: &mut Orderbook, pubkey: &str,
}

if orderbook.memory_db.remove_and_purge(&pair_root, EMPTY_PREFIX).is_none() {
log::warn!("Warning: couldn't find {:?} hash root in memory_db", pair_root);
if pair_root != H64::default() && pair_root != hashed_null_node::<Layout>() {
log::warn!("Warning: couldn't find {:?} hash root in memory_db", pair_root);
}
}
}

Expand Down Expand Up @@ -1999,6 +2001,15 @@ impl Orderbook {
continue;
}

if trie_root == H64::default() || trie_root == hashed_null_node::<Layout>() {
log::warn!(
"Received zero or hashed_null_node pair {} trie root from pub {}",
alb_pair,
from_pubkey
);

continue;
}
let actual_trie_root = order_pair_root_mut(&mut pubkey_state.trie_roots, &alb_pair);
if *actual_trie_root != trie_root {
trie_roots_to_request.insert(alb_pair, trie_root);
Expand Down

0 comments on commit 375bb56

Please sign in to comment.