Skip to content

Commit

Permalink
removes merkle root comparison in erasure_mismatch (solana-labs#29447)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
behzadnouri authored Dec 31, 2022
1 parent 50afb80 commit 70c9017
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
6 changes: 0 additions & 6 deletions ledger/src/shred/merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 9 additions & 2 deletions ledger/src/shred/shred_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
}
Expand Down

0 comments on commit 70c9017

Please sign in to comment.