Skip to content

Commit

Permalink
Remove RelativeRelationDecodable for Path
Browse files Browse the repository at this point in the history
  • Loading branch information
sgwilym committed Sep 16, 2024
1 parent 1acf046 commit 7ea01ff
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 22 deletions.
27 changes: 11 additions & 16 deletions data-model/src/relative_encodings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,6 @@ pub(super) mod encoding {
}
}

impl<const MCL: usize, const MCC: usize, const MPL: usize>
RelativeRelationDecodable<Path<MCL, MCC, MPL>> for Path<MCL, MCC, MPL>
{
}

// Entry <> Entry

impl<const MCL: usize, const MCC: usize, const MPL: usize, N, S, PD>
Expand Down Expand Up @@ -382,8 +377,8 @@ pub(super) mod encoding {
reference.subspace_id().clone()
};

let path =
Path::<MCL, MCC, MPL>::relative_decode_relation(reference.path(), producer).await?;
let path = Path::<MCL, MCC, MPL>::relative_decode_canonical(reference.path(), producer)
.await?;

let time_diff =
decode_compact_width_be_relation(compact_width_time_diff, producer).await?;
Expand Down Expand Up @@ -619,7 +614,7 @@ pub(super) mod encoding {
}
};

let path = Path::relative_decode_relation(out.path(), producer).await?;
let path = Path::relative_decode_canonical(out.path(), producer).await?;

if !path.is_prefixed_by(out.path()) {
return Err(DecodeError::InvalidInput);
Expand Down Expand Up @@ -944,11 +939,11 @@ pub(super) mod encoding {
}

let path = if decode_path_relative_to_start {
Path::relative_decode_relation(&out.paths().start, producer).await?
Path::relative_decode_canonical(&out.paths().start, producer).await?
} else {
match &out.paths().end {
RangeEnd::Closed(end_path) => {
Path::relative_decode_relation(end_path, producer).await?
Path::relative_decode_canonical(end_path, producer).await?
}
RangeEnd::Open => return Err(DecodeError::InvalidInput),
}
Expand Down Expand Up @@ -1297,7 +1292,7 @@ pub(super) mod encoding {
}
}

let path = Path::relative_decode_relation(out.path(), producer).await?;
let path = Path::relative_decode_canonical(out.path(), producer).await?;

// Verify the decoded path is prefixed by the reference path
if !path.is_prefixed_by(out.path()) {
Expand Down Expand Up @@ -1922,13 +1917,13 @@ pub(super) mod encoding {

let path_start = match (is_path_start_rel_to_start, &reference.paths().end) {
(true, RangeEnd::Closed(_)) => {
Path::relative_decode_relation(&reference.paths().start, producer).await?
Path::relative_decode_canonical(&reference.paths().start, producer).await?
}
(true, RangeEnd::Open) => {
Path::relative_decode_relation(&reference.paths().start, producer).await?
Path::relative_decode_canonical(&reference.paths().start, producer).await?
}
(false, RangeEnd::Closed(path_end)) => {
Path::relative_decode_relation(path_end, producer).await?
Path::relative_decode_canonical(path_end, producer).await?
}
(false, RangeEnd::Open) => Err(DecodeError::InvalidInput)?,
};
Expand All @@ -1937,12 +1932,12 @@ pub(super) mod encoding {
RangeEnd::Open
} else if is_path_end_rel_to_start {
RangeEnd::Closed(
Path::relative_decode_relation(&reference.paths().start, producer).await?,
Path::relative_decode_canonical(&reference.paths().start, producer).await?,
)
} else {
match &reference.paths().end {
RangeEnd::Closed(end) => {
RangeEnd::Closed(Path::relative_decode_relation(end, producer).await?)
RangeEnd::Closed(Path::relative_decode_canonical(end, producer).await?)
}
RangeEnd::Open => Err(DecodeError::InvalidInput)?,
}
Expand Down
7 changes: 5 additions & 2 deletions fuzz/fuzz_targets/path_rel_path_encoding_random.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use libfuzzer_sys::fuzz_target;
use willow_data_model::Path;
use willow_fuzz::encode::relative_encoding_random;
use willow_fuzz::encode::relative_encoding_canonical_random;

const MCL: usize = 300;
const MCC: usize = 300;
Expand All @@ -11,5 +11,8 @@ const MPL: usize = 300;
fuzz_target!(|data: (&[u8], Path<MCL, MCC, MPL>)| {
let (random_bytes, ref_path) = data;

relative_encoding_random::<Path<MCL, MCC, MPL>, Path<MCL, MCC, MPL>>(&ref_path, random_bytes)
relative_encoding_canonical_random::<Path<MCL, MCC, MPL>, Path<MCL, MCC, MPL>>(
&ref_path,
random_bytes,
);
});
7 changes: 5 additions & 2 deletions fuzz/fuzz_targets/path_rel_path_encoding_random2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use libfuzzer_sys::fuzz_target;
use willow_data_model::Path;
use willow_fuzz::encode::relative_encoding_random;
use willow_fuzz::encode::relative_encoding_canonical_random;

const MCL: usize = 2;
const MCC: usize = 3;
Expand All @@ -11,5 +11,8 @@ const MPL: usize = 3;
fuzz_target!(|data: (&[u8], Path<MCL, MCC, MPL>)| {
let (random_bytes, ref_path) = data;

relative_encoding_random::<Path<MCL, MCC, MPL>, Path<MCL, MCC, MPL>>(&ref_path, random_bytes)
relative_encoding_canonical_random::<Path<MCL, MCC, MPL>, Path<MCL, MCC, MPL>>(
&ref_path,
random_bytes,
);
});
7 changes: 5 additions & 2 deletions fuzz/fuzz_targets/path_rel_path_encoding_random3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use libfuzzer_sys::fuzz_target;
use willow_data_model::Path;
use willow_fuzz::encode::relative_encoding_random;
use willow_fuzz::encode::relative_encoding_canonical_random;

const MCL: usize = 4;
const MCC: usize = 4;
Expand All @@ -11,5 +11,8 @@ const MPL: usize = 16;
fuzz_target!(|data: (&[u8], Path<MCL, MCC, MPL>)| {
let (random_bytes, ref_path) = data;

relative_encoding_random::<Path<MCL, MCC, MPL>, Path<MCL, MCC, MPL>>(&ref_path, random_bytes)
relative_encoding_canonical_random::<Path<MCL, MCC, MPL>, Path<MCL, MCC, MPL>>(
&ref_path,
random_bytes,
);
});

0 comments on commit 7ea01ff

Please sign in to comment.