removes merkle root comparison in erasure_mismatch (#29447)

Merkle shreds within the same erasure batch have the same merkle root.
The root of the merkle tree is signed. So either the signatures match
or one fails sigverify, and the comparison of merkle roots is redundant.
This commit is contained in:
behzad nouri 2022-12-31 14:21:05 +00:00 committed by GitHub
parent 50afb80f52
commit 70c901792e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 8 deletions

View File

@ -336,12 +336,6 @@ impl ShredCode {
Some(offset..offset + SIZE_OF_MERKLE_ROOT)
}
pub(super) fn erasure_mismatch(&self, other: &ShredCode) -> bool {
shred_code::erasure_mismatch(self, other)
|| self.merkle_root().ok() != other.merkle_root().ok()
|| self.common_header.signature != other.common_header.signature
}
fn from_recovered_shard(
common_header: ShredCommonHeader,
coding_header: CodingShredHeader,

View File

@ -79,8 +79,15 @@ impl ShredCode {
pub(super) fn erasure_mismatch(&self, other: &ShredCode) -> bool {
match (self, other) {
(Self::Legacy(shred), Self::Legacy(other)) => erasure_mismatch(shred, other),
(Self::Merkle(shred), Self::Merkle(other)) => shred.erasure_mismatch(other),
_ => true,
(Self::Legacy(_), Self::Merkle(_)) => true,
(Self::Merkle(_), Self::Legacy(_)) => true,
(Self::Merkle(shred), Self::Merkle(other)) => {
// Merkle shreds within the same erasure batch have the same
// merkle root. The root of the merkle tree is signed. So
// either the signatures match or one fails sigverify.
erasure_mismatch(shred, other)
|| shred.common_header().signature != other.common_header().signature
}
}
}
}