Skip to content

Commit

Permalink
track only unique block hashes when writing to DB (polkadot-evm#1087)
Browse files Browse the repository at this point in the history
Seems like import notifications is sending the block hash multiple times and everytime its called, even the same hash gets written to DB event though the DB has already seen it. This change should ensure we only write unique fork hashes
  • Loading branch information
vedhavyas authored and koushiro committed Jul 12, 2023
1 parent 301da2a commit 23edeff
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions client/db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,15 @@ impl<Block: BlockT> MappingDb<Block> {

let substrate_hashes = match self.block_hash(&commitment.ethereum_block_hash) {
Ok(Some(mut data)) => {
data.push(commitment.block_hash);
log::warn!(
target: "fc-db",
"Possible equivocation at ethereum block hash {} {:?}",
&commitment.ethereum_block_hash,
&data
);
if !data.contains(&commitment.block_hash) {
data.push(commitment.block_hash);
log::warn!(
target: "fc-db",
"Possible equivocation at ethereum block hash {} {:?}",
&commitment.ethereum_block_hash,
&data
);
}
data
}
_ => vec![commitment.block_hash],
Expand Down

0 comments on commit 23edeff

Please sign in to comment.