Skip to content

Commit

Permalink
patches code accessing shred payload as slice
Browse files Browse the repository at this point in the history
anza-xyz/agave#4690
encapsulates the type of shred payload, and this code should use

    shred.payload().as_ref()

instead of

    shred.payload().as_slice()
  • Loading branch information
behzadnouri committed Jan 29, 2025
1 parent b57408f commit 4796ba3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions program/src/duplicate_block_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,8 @@ mod tests {
};
(
DuplicateBlockProofData {
shred1: shred1.payload().as_slice(),
shred2: shred2.payload().as_slice(),
shred1: shred1.payload().as_ref(),
shred2: shred2.payload().as_ref(),
},
context,
)
Expand Down
4 changes: 2 additions & 2 deletions program/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ mod tests {
shred_2_signature: shred2.signature().as_ref().try_into().unwrap(),
};
let proof_data = DuplicateBlockProofData {
shred1: shred1.payload().as_slice(),
shred2: shred2.payload().as_slice(),
shred1: shred1.payload().as_ref(),
shred2: shred2.payload().as_ref(),
};
(sigverify_data, proof_data.pack())
}
Expand Down
2 changes: 1 addition & 1 deletion program/src/shred.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ pub(crate) mod tests {
.into_iter()
.chain(coding_solana_shreds.into_iter())
{
let payload = solana_shred.payload().as_slice();
let payload = solana_shred.payload().as_ref();
let shred = Shred::new_from_payload(payload).unwrap();

assert_eq!(shred.slot().unwrap(), solana_shred.slot());
Expand Down
24 changes: 12 additions & 12 deletions program/tests/duplicate_block_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ async fn valid_proof_data() {
);

let duplicate_proof = DuplicateBlockProofData {
shred1: shred1.payload().as_slice(),
shred2: shred2.payload().as_slice(),
shred1: shred1.payload().as_ref(),
shred2: shred2.payload().as_ref(),
};
let data = duplicate_proof.pack();

Expand Down Expand Up @@ -281,8 +281,8 @@ async fn valid_proof_coding() {
);

let duplicate_proof = DuplicateBlockProofData {
shred1: shred1.payload().as_slice(),
shred2: shred2.payload().as_slice(),
shred1: shred1.payload().as_ref(),
shred2: shred2.payload().as_ref(),
};
let data = duplicate_proof.pack();

Expand Down Expand Up @@ -319,8 +319,8 @@ async fn invalid_proof_data() {
let shred2 = shred1.clone();

let duplicate_proof = DuplicateBlockProofData {
shred1: shred1.payload().as_slice(),
shred2: shred2.payload().as_slice(),
shred1: shred1.payload().as_ref(),
shred2: shred2.payload().as_ref(),
};
let data = duplicate_proof.pack();

Expand Down Expand Up @@ -368,8 +368,8 @@ async fn invalid_proof_coding() {
"Expecting no erasure conflict"
);
let duplicate_proof = DuplicateBlockProofData {
shred1: shred1.payload().as_slice(),
shred2: shred2.payload().as_slice(),
shred1: shred1.payload().as_ref(),
shred2: shred2.payload().as_ref(),
};
let data = duplicate_proof.pack();

Expand Down Expand Up @@ -414,8 +414,8 @@ async fn missing_sigverify() {
new_rand_coding_shreds(&mut rng, next_shred_index, 10, &shredder, &leader)[1].clone();

let duplicate_proof = DuplicateBlockProofData {
shred1: shred1.payload().as_slice(),
shred2: shred2.payload().as_slice(),
shred1: shred1.payload().as_ref(),
shred2: shred2.payload().as_ref(),
};
let data = duplicate_proof.pack();

Expand Down Expand Up @@ -489,8 +489,8 @@ async fn improper_sigverify() {
new_rand_coding_shreds(&mut rng, next_shred_index, 10, &shredder, &leader)[1].clone();

let duplicate_proof = DuplicateBlockProofData {
shred1: shred1.payload().as_slice(),
shred2: shred2.payload().as_slice(),
shred1: shred1.payload().as_ref(),
shred2: shred2.payload().as_ref(),
};
let data = duplicate_proof.pack();

Expand Down

0 comments on commit 4796ba3

Please sign in to comment.