From 7505e09b21f8940a2277067beac77d9ea090d179 Mon Sep 17 00:00:00 2001 From: Centaur AI Date: Thu, 7 May 2026 18:55:38 +0000 Subject: [PATCH] fix(storage): update debug assertions in gen_array_impl and gen_struct_array_impl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow-up to #3840 — align the remaining debug_assert_eq!(ctx, FULL) checks in gen_array_impl and gen_struct_array_impl with the new LayoutCtx::INIT sentinel by switching to debug_assert!(ctx.is_full()). Amp-Thread-ID: https://ampcode.com/threads/T-019e03a5-11cc-719c-8ca9-539a6b4b8277 --- .../src/storable_primitives.rs | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/crates/precompiles-macros/src/storable_primitives.rs b/crates/precompiles-macros/src/storable_primitives.rs index a4dc32d7e0..10624e91ec 100644 --- a/crates/precompiles-macros/src/storable_primitives.rs +++ b/crates/precompiles-macros/src/storable_primitives.rs @@ -375,7 +375,7 @@ fn gen_array_impl(config: &ArrayConfig) -> TokenStream { type Handler = crate::storage::types::array::ArrayHandler<#elem_type, #array_size>; fn handle(slot: ::alloy::primitives::U256, ctx: crate::storage::LayoutCtx, address: ::alloy::primitives::Address) -> Self::Handler { - debug_assert_eq!(ctx, crate::storage::LayoutCtx::FULL, "Arrays cannot be packed"); + debug_assert!(ctx.is_full(), "Arrays can only use full-slot LayoutCtx (FULL or INIT)"); Self::Handler::new(slot, address) } } @@ -384,9 +384,9 @@ fn gen_array_impl(config: &ArrayConfig) -> TokenStream { impl crate::storage::Storable for [#elem_type; #array_size] { #[inline] fn load(storage: &S, slot: ::alloy::primitives::U256, ctx: crate::storage::LayoutCtx) -> crate::error::Result { - debug_assert_eq!( - ctx, crate::storage::LayoutCtx::FULL, - "Arrays can only be loaded with LayoutCtx::FULL" + debug_assert!( + ctx.is_full(), + "Arrays can only be loaded with a full-slot LayoutCtx (FULL or INIT)" ); use crate::storage::packing::{calc_element_slot, calc_element_offset, extract_from_word}; @@ -396,9 +396,9 @@ fn gen_array_impl(config: &ArrayConfig) -> TokenStream { #[inline] fn store(&self, storage: &mut S, slot: ::alloy::primitives::U256, ctx: crate::storage::LayoutCtx) -> crate::error::Result<()> { - debug_assert_eq!( - ctx, crate::storage::LayoutCtx::FULL, - "Arrays can only be stored with LayoutCtx::FULL" + debug_assert!( + ctx.is_full(), + "Arrays can only be stored with a full-slot LayoutCtx (FULL or INIT)" ); use crate::storage::packing::{calc_element_slot, calc_element_offset, insert_into_word}; @@ -674,9 +674,9 @@ fn gen_struct_array_impl(struct_type: &TokenStream, array_size: usize) -> TokenS impl crate::storage::Storable for [#struct_type; #array_size] { #[inline] fn load(storage: &S, slot: ::alloy::primitives::U256, ctx: crate::storage::LayoutCtx) -> crate::error::Result { - debug_assert_eq!( - ctx, crate::storage::LayoutCtx::FULL, - "Struct arrays can only be loaded with LayoutCtx::FULL" + debug_assert!( + ctx.is_full(), + "Struct arrays can only be loaded with a full-slot LayoutCtx (FULL or INIT)" ); let base_slot = slot; #load_impl @@ -684,9 +684,9 @@ fn gen_struct_array_impl(struct_type: &TokenStream, array_size: usize) -> TokenS #[inline] fn store(&self, storage: &mut S, slot: ::alloy::primitives::U256, ctx: crate::storage::LayoutCtx) -> crate::error::Result<()> { - debug_assert_eq!( - ctx, crate::storage::LayoutCtx::FULL, - "Struct arrays can only be stored with LayoutCtx::FULL" + debug_assert!( + ctx.is_full(), + "Struct arrays can only be stored with a full-slot LayoutCtx (FULL or INIT)" ); let base_slot = slot; #store_impl