-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
removes the merkle root from shreds binary #29427
Conversation
f639e75
to
49c523d
Compare
6c1626f
to
346be25
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
I think it may make it easier to read if you expose shred::OFFSET_OF_SHRED_VARIANT
and use that in place of SIZE_OF_SIGNATURE
.
let index = self.erasure_shard_index()?; | ||
let proof_offset = Self::proof_offset(proof_size)?; | ||
let proof = get_merkle_proof(&self.payload, proof_offset, proof_size)?; | ||
let node = get_merkle_node(&self.payload, SIZE_OF_SIGNATURE..proof_offset)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/SIZE_OF_SIGNATURE/OFFSET_OF_SHRED_VARIANT/ for clarity?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ledger/src/shred/merkle.rs
Outdated
Ok(verify_merkle_proof(index, node, &self.merkle_branch()?)) | ||
fn merkle_node(&self) -> Result<Hash, Error> { | ||
let proof_size = self.proof_size()?; | ||
let offsets = SIZE_OF_SIGNATURE..Self::proof_offset(proof_size)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/SIZE_OF_SIGNATURE/OFFSET_OF_SHRED_VARIANT/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_merkle_root(shred, proof_size, index, offset) | ||
let proof_offset = Self::proof_offset(proof_size).ok()?; | ||
let proof = get_merkle_proof(shred, proof_offset, proof_size).ok()?; | ||
let node = get_merkle_node(shred, SIZE_OF_SIGNATURE..proof_offset).ok()?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/SIZE_OF_SIGNATURE/OFFSET_OF_SHRED_VARIANT/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok(<&MerkleRoot>::try_from(root).unwrap()) | ||
// Where the merkle proof starts in the shred binary. | ||
fn proof_offset(proof_size: u8) -> Result<usize, Error> { | ||
Ok(Self::SIZE_OF_HEADERS + Self::capacity(proof_size)?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/SIZE_OF_SIGNATURE/OFFSET_OF_SHRED_VARIANT/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a SIZE_OF_SIGNATURE
here.
let index = self.erasure_shard_index()?; | ||
let proof_offset = Self::proof_offset(proof_size)?; | ||
let proof = get_merkle_proof(&self.payload, proof_offset, proof_size)?; | ||
let node = get_merkle_node(&self.payload, SIZE_OF_SIGNATURE..proof_offset)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/SIZE_OF_SIGNATURE/OFFSET_OF_SHRED_VARIANT/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ledger/src/shred/merkle.rs
Outdated
Some(offset..offset + SIZE_OF_MERKLE_ROOT) | ||
fn merkle_node(&self) -> Result<Hash, Error> { | ||
let proof_size = self.proof_size()?; | ||
let offsets = SIZE_OF_SIGNATURE..Self::proof_offset(proof_size)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/SIZE_OF_SIGNATURE/OFFSET_OF_SHRED_VARIANT/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_merkle_root(shred, proof_size, index, offset) | ||
let proof_offset = Self::proof_offset(proof_size).ok()?; | ||
let proof = get_merkle_proof(shred, proof_offset, proof_size).ok()?; | ||
let node = get_merkle_node(shred, SIZE_OF_SIGNATURE..proof_offset).ok()?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/SIZE_OF_SIGNATURE/OFFSET_OF_SHRED_VARIANT/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.payload | ||
.get(SIZE_OF_SIGNATURE..Self::SIZE_OF_HEADERS + data_buffer_size) | ||
.get(SIZE_OF_SIGNATURE..proof_offset) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/SIZE_OF_SIGNATURE/OFFSET_OF_SHRED_VARIANT/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.payload | ||
.get(Self::SIZE_OF_HEADERS..Self::SIZE_OF_HEADERS + shard_size) | ||
.get(Self::SIZE_OF_HEADERS..proof_offset) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/SIZE_OF_SIGNATURE/OFFSET_OF_SHRED_VARIANT/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a SIZE_OF_SIGNATURE
here.
I believe that skipping over signature bytes is better indicated in the code by |
346be25
to
ef9815c
Compare
Ok, I'm fine with |
solana-labs#29445 makes it unnecessary to embed merkle roots into shreds binary. This commit removes the merkle root from shreds binary. This adds 20 bytes to shreds capacity to store more data. Additionally since we no longer need to truncate the merkle root, the signature would be on the full 32 bytes of hash as opposed to the truncated one. Also signature verification would now effectively verify merkle proof as well, so we no longer need to verify merkle proof in the sanitize implementation.
ef9815c
to
75b0430
Compare
#29445 makes it unnecessary to embed merkle roots into shreds binary. This commit removes the merkle root from shreds binary. This adds 20 bytes to shreds capacity to store more data. Additionally since we no longer need to truncate the merkle root, the signature would be on the full 32 bytes of hash as opposed to the truncated one. Also signature verification would now effectively verify merkle proof as well, so we no longer need to verify merkle proof in the sanitize implementation. (cherry picked from commit cf0a149)
#30344) removes the merkle root from shreds binary (#29427) #29445 makes it unnecessary to embed merkle roots into shreds binary. This commit removes the merkle root from shreds binary. This adds 20 bytes to shreds capacity to store more data. Additionally since we no longer need to truncate the merkle root, the signature would be on the full 32 bytes of hash as opposed to the truncated one. Also signature verification would now effectively verify merkle proof as well, so we no longer need to verify merkle proof in the sanitize implementation. (cherry picked from commit cf0a149) Co-authored-by: behzad nouri <[email protected]>
#29445 makes it unnecessary to embed merkle roots into shreds binary. This commit removes the merkle root from shreds binary. This adds 20 bytes to shreds capacity to store more data. Additionally since we no longer need to truncate the merkle root, the signature would be on the full 32 bytes of hash as opposed to the truncated one. Also signature verification would now effectively verify merkle proof as well, so we no longer need to verify merkle proof in the sanitize implementation. (cherry picked from commit cf0a149) # Conflicts: # ledger/src/shred.rs
#30613) * removes the merkle root from shreds binary (#29427) #29445 makes it unnecessary to embed merkle roots into shreds binary. This commit removes the merkle root from shreds binary. This adds 20 bytes to shreds capacity to store more data. Additionally since we no longer need to truncate the merkle root, the signature would be on the full 32 bytes of hash as opposed to the truncated one. Also signature verification would now effectively verify merkle proof as well, so we no longer need to verify merkle proof in the sanitize implementation. (cherry picked from commit cf0a149) # Conflicts: # ledger/src/shred.rs * resolves mergify merge conflicts --------- Co-authored-by: behzad nouri <[email protected]>
solana-labs#29445 makes it unnecessary to embed merkle roots into shreds binary. This commit removes the merkle root from shreds binary. This adds 20 bytes to shreds capacity to store more data. Additionally since we no longer need to truncate the merkle root, the signature would be on the full 32 bytes of hash as opposed to the truncated one. Also signature verification would now effectively verify merkle proof as well, so we no longer need to verify merkle proof in the sanitize implementation.
Problem
Summary of Changes
#29445 makes it unnecessary to embed merkle roots into shreds binary. This commit removes the merkle root from shreds binary.
This adds 20 bytes to shreds capacity to store more data.
Additionally since we no longer need to truncate the merkle root, the signature would be on the full 32 bytes of hash as opposed to the truncated one.
Also signature verification would now effectively verify merkle proof as well, so we no longer need to verify merkle proof in the sanitize implementation.