wgpu_core/
pipeline_cache.rs

1use thiserror::Error;
2use wgt::{
3    error::{ErrorType, WebGpuError},
4    AdapterInfo,
5};
6
7pub const HEADER_LENGTH: usize = size_of::<PipelineCacheHeader>();
8
9#[derive(Debug, PartialEq, Eq, Clone, Error)]
10#[non_exhaustive]
11pub enum PipelineCacheValidationError {
12    #[error("The pipeline cache data was truncated")]
13    Truncated,
14    #[error("The pipeline cache data was longer than recorded")]
15    // TODO: Is it plausible that this would happen
16    Extended,
17    #[error("The pipeline cache data was corrupted (e.g. the hash didn't match)")]
18    Corrupted,
19    #[error("The pipeline cacha data was out of date and so cannot be safely used")]
20    Outdated,
21    #[error("The cache data was created for a different device")]
22    DeviceMismatch,
23    #[error("Pipeline cacha data was created for a future version of wgpu")]
24    Unsupported,
25}
26
27impl PipelineCacheValidationError {
28    /// Could the error have been avoided?
29    /// That is, is there a mistake in user code interacting with the cache
30    pub fn was_avoidable(&self) -> bool {
31        match self {
32            PipelineCacheValidationError::DeviceMismatch => true,
33            PipelineCacheValidationError::Truncated
34            | PipelineCacheValidationError::Unsupported
35            | PipelineCacheValidationError::Extended
36            // It's unusual, but not implausible, to be downgrading wgpu
37            | PipelineCacheValidationError::Outdated
38            | PipelineCacheValidationError::Corrupted => false,
39        }
40    }
41}
42
43impl WebGpuError for PipelineCacheValidationError {
44    fn webgpu_error_type(&self) -> ErrorType {
45        ErrorType::Validation
46    }
47}
48
49/// Validate the data in a pipeline cache
50pub fn validate_pipeline_cache<'d>(
51    cache_data: &'d [u8],
52    adapter: &AdapterInfo,
53    validation_key: [u8; 16],
54) -> Result<&'d [u8], PipelineCacheValidationError> {
55    let adapter_key = adapter_key(adapter)?;
56    let Some((header, remaining_data)) = PipelineCacheHeader::read(cache_data) else {
57        return Err(PipelineCacheValidationError::Truncated);
58    };
59    if header.magic != MAGIC {
60        return Err(PipelineCacheValidationError::Corrupted);
61    }
62    if header.header_version != HEADER_VERSION {
63        return Err(PipelineCacheValidationError::Outdated);
64    }
65    if header.cache_abi != ABI {
66        return Err(PipelineCacheValidationError::Outdated);
67    }
68    if header.backend != adapter.backend as u8 {
69        return Err(PipelineCacheValidationError::DeviceMismatch);
70    }
71    if header.adapter_key != adapter_key {
72        return Err(PipelineCacheValidationError::DeviceMismatch);
73    }
74    if header.validation_key != validation_key {
75        // If the validation key is wrong, that means that this device has changed
76        // in a way where the cache won't be compatible since the cache was made,
77        // so it is outdated
78        return Err(PipelineCacheValidationError::Outdated);
79    }
80    let data_size: usize = header
81        .data_size
82        .try_into()
83        // If the data was previously more than 4GiB, and we're still on a 32 bit system (ABI check, above)
84        // Then the data must be corrupted
85        .map_err(|_| PipelineCacheValidationError::Corrupted)?;
86    if remaining_data.len() < data_size {
87        return Err(PipelineCacheValidationError::Truncated);
88    }
89    if remaining_data.len() > data_size {
90        return Err(PipelineCacheValidationError::Extended);
91    }
92    if header.hash_space != HASH_SPACE_VALUE {
93        return Err(PipelineCacheValidationError::Corrupted);
94    }
95    Ok(remaining_data)
96}
97
98pub fn add_cache_header(
99    in_region: &mut [u8],
100    data: &[u8],
101    adapter: &AdapterInfo,
102    validation_key: [u8; 16],
103) {
104    assert_eq!(in_region.len(), HEADER_LENGTH);
105    let header = PipelineCacheHeader {
106        adapter_key: adapter_key(adapter)
107            .expect("Called add_cache_header for an adapter which doesn't support cache data. This is a wgpu internal bug"),
108        backend: adapter.backend as u8,
109        cache_abi: ABI,
110        magic: MAGIC,
111        header_version: HEADER_VERSION,
112        validation_key,
113        hash_space: HASH_SPACE_VALUE,
114        data_size: data
115            .len()
116            .try_into()
117            .expect("Cache larger than u64::MAX bytes"),
118    };
119    header.write(in_region);
120}
121
122const MAGIC: [u8; 8] = *b"WGPUPLCH";
123const HEADER_VERSION: u32 = 1;
124const ABI: u32 = size_of::<*const ()>() as u32;
125
126/// The value used to fill [`PipelineCacheHeader::hash_space`]
127///
128/// If we receive reports of pipeline cache data corruption which is not otherwise caught
129/// on a real device, it would be worth modifying this
130///
131/// Note that wgpu does not protect against malicious writes to e.g. a file used
132/// to store a pipeline cache.
133/// That is the responsibility of the end application, such as by using a
134/// private space.
135const HASH_SPACE_VALUE: u64 = 0xFEDCBA9_876543210;
136
137#[repr(C)]
138#[derive(PartialEq, Eq)]
139struct PipelineCacheHeader {
140    /// The magic header to ensure that we have the right file format
141    /// Has a value of MAGIC, as above
142    magic: [u8; 8],
143    // /// The total size of this header, in bytes
144    // header_size: u32,
145    /// The version of this wgpu header
146    /// Should be equal to HEADER_VERSION above
147    ///
148    /// This must always be the second item, after the value above
149    header_version: u32,
150    /// The number of bytes in the pointers of this ABI, because some drivers
151    /// have previously not distinguished between their 32 bit and 64 bit drivers
152    /// leading to Vulkan data corruption
153    cache_abi: u32,
154    /// The id for the backend in use, from [wgt::Backend]
155    backend: u8,
156    /// The key which identifiers the device/adapter.
157    /// This is used to validate that this pipeline cache (probably) was produced for
158    /// the expected device.
159    /// On Vulkan: it is a combination of vendor ID and device ID
160    adapter_key: [u8; 15],
161    /// A key used to validate that this device is still compatible with the cache
162    ///
163    /// This should e.g. contain driver version and/or intermediate compiler versions
164    validation_key: [u8; 16],
165    /// The length of the data which is sent to/recieved from the backend
166    data_size: u64,
167    /// Space reserved for a hash of the data in future
168    ///
169    /// We assume that your cache storage system will be relatively robust, and so
170    /// do not validate this hash
171    ///
172    /// Therefore, this will always have a value of [`HASH_SPACE_VALUE`]
173    hash_space: u64,
174}
175
176impl PipelineCacheHeader {
177    fn read(data: &[u8]) -> Option<(PipelineCacheHeader, &[u8])> {
178        let mut reader = Reader {
179            data,
180            total_read: 0,
181        };
182        let magic = reader.read_array()?;
183        let header_version = reader.read_u32()?;
184        let cache_abi = reader.read_u32()?;
185        let backend = reader.read_byte()?;
186        let adapter_key = reader.read_array()?;
187        let validation_key = reader.read_array()?;
188        let data_size = reader.read_u64()?;
189        let data_hash = reader.read_u64()?;
190
191        assert_eq!(reader.total_read, size_of::<PipelineCacheHeader>());
192
193        Some((
194            PipelineCacheHeader {
195                magic,
196                header_version,
197                cache_abi,
198                backend,
199                adapter_key,
200                validation_key,
201                data_size,
202                hash_space: data_hash,
203            },
204            reader.data,
205        ))
206    }
207
208    fn write(&self, into: &mut [u8]) -> Option<()> {
209        let mut writer = Writer { data: into };
210        writer.write_array(&self.magic)?;
211        writer.write_u32(self.header_version)?;
212        writer.write_u32(self.cache_abi)?;
213        writer.write_byte(self.backend)?;
214        writer.write_array(&self.adapter_key)?;
215        writer.write_array(&self.validation_key)?;
216        writer.write_u64(self.data_size)?;
217        writer.write_u64(self.hash_space)?;
218
219        assert_eq!(writer.data.len(), 0);
220        Some(())
221    }
222}
223
224fn adapter_key(adapter: &AdapterInfo) -> Result<[u8; 15], PipelineCacheValidationError> {
225    match adapter.backend {
226        wgt::Backend::Vulkan => {
227            // If these change size, the header format needs to change
228            // We set the type explicitly so this won't compile in that case
229            let v: [u8; 4] = adapter.vendor.to_be_bytes();
230            let d: [u8; 4] = adapter.device.to_be_bytes();
231            let adapter = [
232                255, 255, 255, v[0], v[1], v[2], v[3], d[0], d[1], d[2], d[3], 255, 255, 255, 255,
233            ];
234            Ok(adapter)
235        }
236        _ => Err(PipelineCacheValidationError::Unsupported),
237    }
238}
239
240struct Reader<'a> {
241    data: &'a [u8],
242    total_read: usize,
243}
244
245impl<'a> Reader<'a> {
246    fn read_byte(&mut self) -> Option<u8> {
247        let res = *self.data.first()?;
248        self.total_read += 1;
249        self.data = &self.data[1..];
250        Some(res)
251    }
252    fn read_array<const N: usize>(&mut self) -> Option<[u8; N]> {
253        // Only greater than because we're indexing fenceposts, not items
254        if N > self.data.len() {
255            return None;
256        }
257        let (start, data) = self.data.split_at(N);
258        self.total_read += N;
259        self.data = data;
260        Some(start.try_into().expect("off-by-one-error in array size"))
261    }
262
263    // fn read_u16(&mut self) -> Option<u16> {
264    //     self.read_array().map(u16::from_be_bytes)
265    // }
266    fn read_u32(&mut self) -> Option<u32> {
267        self.read_array().map(u32::from_be_bytes)
268    }
269    fn read_u64(&mut self) -> Option<u64> {
270        self.read_array().map(u64::from_be_bytes)
271    }
272}
273
274struct Writer<'a> {
275    data: &'a mut [u8],
276}
277
278impl<'a> Writer<'a> {
279    fn write_byte(&mut self, byte: u8) -> Option<()> {
280        self.write_array(&[byte])
281    }
282    fn write_array<const N: usize>(&mut self, array: &[u8; N]) -> Option<()> {
283        // Only greater than because we're indexing fenceposts, not items
284        if N > self.data.len() {
285            return None;
286        }
287        let data = core::mem::take(&mut self.data);
288        let (start, data) = data.split_at_mut(N);
289        self.data = data;
290        start.copy_from_slice(array);
291        Some(())
292    }
293
294    // fn write_u16(&mut self, value: u16) -> Option<()> {
295    //     self.write_array(&value.to_be_bytes())
296    // }
297    fn write_u32(&mut self, value: u32) -> Option<()> {
298        self.write_array(&value.to_be_bytes())
299    }
300    fn write_u64(&mut self, value: u64) -> Option<()> {
301        self.write_array(&value.to_be_bytes())
302    }
303}
304
305#[cfg(test)]
306mod tests {
307    use alloc::{string::String, vec::Vec};
308    use wgt::AdapterInfo;
309
310    use crate::pipeline_cache::{PipelineCacheValidationError as E, HEADER_LENGTH};
311
312    use super::ABI;
313
314    // Assert the correct size
315    const _: [(); HEADER_LENGTH] = [(); 64];
316
317    const ADAPTER: AdapterInfo = AdapterInfo {
318        name: String::new(),
319        vendor: 0x0002_FEED,
320        device: 0xFEFE_FEFE,
321        device_type: wgt::DeviceType::Other,
322        device_pci_bus_id: String::new(),
323        driver: String::new(),
324        driver_info: String::new(),
325        backend: wgt::Backend::Vulkan,
326        subgroup_min_size: 32,
327        subgroup_max_size: 32,
328        transient_saves_memory: true,
329    };
330
331    // IMPORTANT: If these tests fail, then you MUST increment HEADER_VERSION
332    const VALIDATION_KEY: [u8; 16] = u128::to_be_bytes(0xFFFFFFFF_FFFFFFFF_88888888_88888888);
333    #[test]
334    fn written_header() {
335        let mut result = [0; HEADER_LENGTH];
336        super::add_cache_header(&mut result, &[], &ADAPTER, VALIDATION_KEY);
337        let cache: [[u8; 8]; HEADER_LENGTH / 8] = [
338            *b"WGPUPLCH",                                 // MAGIC
339            [0, 0, 0, 1, 0, 0, 0, ABI as u8],             // Version and ABI
340            [1, 255, 255, 255, 0, 2, 0xFE, 0xED],         // Backend and Adapter key
341            [0xFE, 0xFE, 0xFE, 0xFE, 255, 255, 255, 255], // Backend and Adapter key
342            0xFFFFFFFF_FFFFFFFFu64.to_be_bytes(),         // Validation key
343            0x88888888_88888888u64.to_be_bytes(),         // Validation key
344            0x0u64.to_be_bytes(),                         // Data size
345            0xFEDCBA9_876543210u64.to_be_bytes(),         // Hash
346        ];
347        let expected = cache.into_iter().flatten().collect::<Vec<u8>>();
348
349        assert_eq!(result.as_slice(), expected.as_slice());
350    }
351
352    #[test]
353    fn valid_data() {
354        let cache: [[u8; 8]; HEADER_LENGTH / 8] = [
355            *b"WGPUPLCH",                                 // MAGIC
356            [0, 0, 0, 1, 0, 0, 0, ABI as u8],             // Version and ABI
357            [1, 255, 255, 255, 0, 2, 0xFE, 0xED],         // Backend and Adapter key
358            [0xFE, 0xFE, 0xFE, 0xFE, 255, 255, 255, 255], // Backend and Adapter key
359            0xFFFFFFFF_FFFFFFFFu64.to_be_bytes(),         // Validation key
360            0x88888888_88888888u64.to_be_bytes(),         // Validation key
361            0x0u64.to_be_bytes(),                         // Data size
362            0xFEDCBA9_876543210u64.to_be_bytes(),         // Hash
363        ];
364        let cache = cache.into_iter().flatten().collect::<Vec<u8>>();
365        let expected: &[u8] = &[];
366        let validation_result = super::validate_pipeline_cache(&cache, &ADAPTER, VALIDATION_KEY);
367        assert_eq!(validation_result, Ok(expected));
368    }
369    #[test]
370    fn invalid_magic() {
371        let cache: [[u8; 8]; HEADER_LENGTH / 8] = [
372            *b"NOT_WGPU",                                 // (Wrong) MAGIC
373            [0, 0, 0, 1, 0, 0, 0, ABI as u8],             // Version and ABI
374            [1, 255, 255, 255, 0, 2, 0xFE, 0xED],         // Backend and Adapter key
375            [0xFE, 0xFE, 0xFE, 0xFE, 255, 255, 255, 255], // Backend and Adapter key
376            0xFFFFFFFF_FFFFFFFFu64.to_be_bytes(),         // Validation key
377            0x88888888_88888888u64.to_be_bytes(),         // Validation key
378            0x0u64.to_be_bytes(),                         // Data size
379            0xFEDCBA9_876543210u64.to_be_bytes(),         // Hash
380        ];
381        let cache = cache.into_iter().flatten().collect::<Vec<u8>>();
382        let validation_result = super::validate_pipeline_cache(&cache, &ADAPTER, VALIDATION_KEY);
383        assert_eq!(validation_result, Err(E::Corrupted));
384    }
385
386    #[test]
387    fn wrong_version() {
388        let cache: [[u8; 8]; HEADER_LENGTH / 8] = [
389            *b"WGPUPLCH",                                 // MAGIC
390            [0, 0, 0, 2, 0, 0, 0, ABI as u8],             // (wrong) Version and ABI
391            [1, 255, 255, 255, 0, 2, 0xFE, 0xED],         // Backend and Adapter key
392            [0xFE, 0xFE, 0xFE, 0xFE, 255, 255, 255, 255], // Backend and Adapter key
393            0xFFFFFFFF_FFFFFFFFu64.to_be_bytes(),         // Validation key
394            0x88888888_88888888u64.to_be_bytes(),         // Validation key
395            0x0u64.to_be_bytes(),                         // Data size
396            0xFEDCBA9_876543210u64.to_be_bytes(),         // Hash
397        ];
398        let cache = cache.into_iter().flatten().collect::<Vec<u8>>();
399        let validation_result = super::validate_pipeline_cache(&cache, &ADAPTER, VALIDATION_KEY);
400        assert_eq!(validation_result, Err(E::Outdated));
401    }
402    #[test]
403    fn wrong_abi() {
404        let cache: [[u8; 8]; HEADER_LENGTH / 8] = [
405            *b"WGPUPLCH", // MAGIC
406            // a 14 bit ABI is improbable
407            [0, 0, 0, 1, 0, 0, 0, 14],            // Version and (wrong) ABI
408            [1, 255, 255, 255, 0, 2, 0xFE, 0xED], // Backend and Adapter key
409            [0xFE, 0xFE, 0xFE, 0xFE, 255, 255, 255, 255], // Backend and Adapter key
410            0xFFFFFFFF_FFFFFFFFu64.to_be_bytes(), // Validation key
411            0x88888888_88888888u64.to_be_bytes(), // Validation key
412            0x0u64.to_be_bytes(),                 // Data size
413            0xFEDCBA9_876543210u64.to_be_bytes(), // Header
414        ];
415        let cache = cache.into_iter().flatten().collect::<Vec<u8>>();
416        let validation_result = super::validate_pipeline_cache(&cache, &ADAPTER, VALIDATION_KEY);
417        assert_eq!(validation_result, Err(E::Outdated));
418    }
419
420    #[test]
421    fn wrong_backend() {
422        let cache: [[u8; 8]; HEADER_LENGTH / 8] = [
423            *b"WGPUPLCH",                                 // MAGIC
424            [0, 0, 0, 1, 0, 0, 0, ABI as u8],             // Version and ABI
425            [2, 255, 255, 255, 0, 2, 0xFE, 0xED],         // (wrong) Backend and Adapter key
426            [0xFE, 0xFE, 0xFE, 0xFE, 255, 255, 255, 255], // Backend and Adapter key
427            0xFFFFFFFF_FFFFFFFFu64.to_be_bytes(),         // Validation key
428            0x88888888_88888888u64.to_be_bytes(),         // Validation key
429            0x0u64.to_be_bytes(),                         // Data size
430            0xFEDCBA9_876543210u64.to_be_bytes(),         // Hash
431        ];
432        let cache = cache.into_iter().flatten().collect::<Vec<u8>>();
433        let validation_result = super::validate_pipeline_cache(&cache, &ADAPTER, VALIDATION_KEY);
434        assert_eq!(validation_result, Err(E::DeviceMismatch));
435    }
436    #[test]
437    fn wrong_adapter() {
438        let cache: [[u8; 8]; HEADER_LENGTH / 8] = [
439            *b"WGPUPLCH",                                 // MAGIC
440            [0, 0, 0, 1, 0, 0, 0, ABI as u8],             // Version and ABI
441            [1, 255, 255, 255, 0, 2, 0xFE, 0x00],         // Backend and (wrong) Adapter key
442            [0xFE, 0xFE, 0xFE, 0xFE, 255, 255, 255, 255], // Backend and Adapter key
443            0xFFFFFFFF_FFFFFFFFu64.to_be_bytes(),         // Validation key
444            0x88888888_88888888u64.to_be_bytes(),         // Validation key
445            0x0u64.to_be_bytes(),                         // Data size
446            0xFEDCBA9_876543210u64.to_be_bytes(),         // Hash
447        ];
448        let cache = cache.into_iter().flatten().collect::<Vec<u8>>();
449        let validation_result = super::validate_pipeline_cache(&cache, &ADAPTER, VALIDATION_KEY);
450        assert_eq!(validation_result, Err(E::DeviceMismatch));
451    }
452    #[test]
453    fn wrong_validation() {
454        let cache: [[u8; 8]; HEADER_LENGTH / 8] = [
455            *b"WGPUPLCH",                                 // MAGIC
456            [0, 0, 0, 1, 0, 0, 0, ABI as u8],             // Version and ABI
457            [1, 255, 255, 255, 0, 2, 0xFE, 0xED],         // Backend and Adapter key
458            [0xFE, 0xFE, 0xFE, 0xFE, 255, 255, 255, 255], // Backend and Adapter key
459            0xFFFFFFFF_FFFFFFFFu64.to_be_bytes(),         // Validation key
460            0x88888888_00000000u64.to_be_bytes(),         // (wrong) Validation key
461            0x0u64.to_be_bytes(),                         // Data size
462            0xFEDCBA9_876543210u64.to_be_bytes(),         // Hash
463        ];
464        let cache = cache.into_iter().flatten().collect::<Vec<u8>>();
465        let validation_result = super::validate_pipeline_cache(&cache, &ADAPTER, VALIDATION_KEY);
466        assert_eq!(validation_result, Err(E::Outdated));
467    }
468    #[test]
469    fn too_little_data() {
470        let cache: [[u8; 8]; HEADER_LENGTH / 8] = [
471            *b"WGPUPLCH",                                 // MAGIC
472            [0, 0, 0, 1, 0, 0, 0, ABI as u8],             // Version and ABI
473            [1, 255, 255, 255, 0, 2, 0xFE, 0xED],         // Backend and Adapter key
474            [0xFE, 0xFE, 0xFE, 0xFE, 255, 255, 255, 255], // Backend and Adapter key
475            0xFFFFFFFF_FFFFFFFFu64.to_be_bytes(),         // Validation key
476            0x88888888_88888888u64.to_be_bytes(),         // Validation key
477            0x064u64.to_be_bytes(),                       // Data size
478            0xFEDCBA9_876543210u64.to_be_bytes(),         // Hash
479        ];
480        let cache = cache.into_iter().flatten().collect::<Vec<u8>>();
481        let validation_result = super::validate_pipeline_cache(&cache, &ADAPTER, VALIDATION_KEY);
482        assert_eq!(validation_result, Err(E::Truncated));
483    }
484    #[test]
485    fn not_no_data() {
486        let cache: [[u8; 8]; HEADER_LENGTH / 8] = [
487            *b"WGPUPLCH",                                 // MAGIC
488            [0, 0, 0, 1, 0, 0, 0, ABI as u8],             // Version and ABI
489            [1, 255, 255, 255, 0, 2, 0xFE, 0xED],         // Backend and Adapter key
490            [0xFE, 0xFE, 0xFE, 0xFE, 255, 255, 255, 255], // Backend and Adapter key
491            0xFFFFFFFF_FFFFFFFFu64.to_be_bytes(),         // Validation key
492            0x88888888_88888888u64.to_be_bytes(),         // Validation key
493            100u64.to_be_bytes(),                         // Data size
494            0xFEDCBA9_876543210u64.to_be_bytes(),         // Hash
495        ];
496        let cache = cache
497            .into_iter()
498            .flatten()
499            .chain(core::iter::repeat_n(0u8, 100))
500            .collect::<Vec<u8>>();
501        let validation_result = super::validate_pipeline_cache(&cache, &ADAPTER, VALIDATION_KEY);
502        let expected: &[u8] = &[0; 100];
503        assert_eq!(validation_result, Ok(expected));
504    }
505    #[test]
506    fn too_much_data() {
507        let cache: [[u8; 8]; HEADER_LENGTH / 8] = [
508            *b"WGPUPLCH",                                 // MAGIC
509            [0, 0, 0, 1, 0, 0, 0, ABI as u8],             // Version and ABI
510            [1, 255, 255, 255, 0, 2, 0xFE, 0xED],         // Backend and Adapter key
511            [0xFE, 0xFE, 0xFE, 0xFE, 255, 255, 255, 255], // Backend and Adapter key
512            0xFFFFFFFF_FFFFFFFFu64.to_be_bytes(),         // Validation key
513            0x88888888_88888888u64.to_be_bytes(),         // Validation key
514            0x064u64.to_be_bytes(),                       // Data size
515            0xFEDCBA9_876543210u64.to_be_bytes(),         // Hash
516        ];
517        let cache = cache
518            .into_iter()
519            .flatten()
520            .chain(core::iter::repeat_n(0u8, 200))
521            .collect::<Vec<u8>>();
522        let validation_result = super::validate_pipeline_cache(&cache, &ADAPTER, VALIDATION_KEY);
523        assert_eq!(validation_result, Err(E::Extended));
524    }
525    #[test]
526    fn wrong_hash() {
527        let cache: [[u8; 8]; HEADER_LENGTH / 8] = [
528            *b"WGPUPLCH",                                 // MAGIC
529            [0, 0, 0, 1, 0, 0, 0, ABI as u8],             // Version and ABI
530            [1, 255, 255, 255, 0, 2, 0xFE, 0xED],         // Backend and Adapter key
531            [0xFE, 0xFE, 0xFE, 0xFE, 255, 255, 255, 255], // Backend and Adapter key
532            0xFFFFFFFF_FFFFFFFFu64.to_be_bytes(),         // Validation key
533            0x88888888_88888888u64.to_be_bytes(),         // Validation key
534            0x0u64.to_be_bytes(),                         // Data size
535            0x00000000_00000000u64.to_be_bytes(),         // Hash
536        ];
537        let cache = cache.into_iter().flatten().collect::<Vec<u8>>();
538        let validation_result = super::validate_pipeline_cache(&cache, &ADAPTER, VALIDATION_KEY);
539        assert_eq!(validation_result, Err(E::Corrupted));
540    }
541}