diff --git a/src/air/public_input.cairo b/src/air/public_input.cairo index 623a1146f..db824ffc1 100644 --- a/src/air/public_input.cairo +++ b/src/air/public_input.cairo @@ -86,25 +86,8 @@ impl PublicInputImpl of PublicInputTrait { let program_end_pc = initial_fp - 2; let program_len = program_end_pc - initial_pc; + memory.extract_range(initial_pc, program_len); (0, 0) } } - -fn extract_range(memory: Page, addr: felt252, length: felt252) -> Span { - let mut arr = ArrayTrait::new(); - let mut i = 0; - - loop { - if i == length { - break arr.span(); - } - - let current = *memory.at((addr + i).try_into().unwrap()); - - // TODO is this needed? If not we can just use slice directly - assert(current.address == addr + i, 'Invalid address'); - arr.append(current.value); - i += 1; - } -} diff --git a/src/air/public_memory.cairo b/src/air/public_memory.cairo index 96d10f534..a3034db08 100644 --- a/src/air/public_memory.cairo +++ b/src/air/public_memory.cairo @@ -4,7 +4,7 @@ struct AddrValue { value: felt252 } -#[derive(Drop)] +//#[derive(Drop)] type Page = Array; // Information about a continuous page (a consecutive section of the public memory).. @@ -44,6 +44,24 @@ impl PageImpl of PageTrait { i += 1; } } + + fn extract_range(self: @Page, addr: felt252, len: felt252) -> Span { + let mut arr = ArrayTrait::new(); + let mut i = 0; + + loop { + if i == len { + break arr.span(); + } + + let current = *self.at((addr + i).try_into().unwrap()); + + // TODO is this needed? If not we can just use slice directly + assert(current.address == addr + i, 'Invalid address'); + arr.append(current.value); + i += 1; + } + } } fn get_continuous_pages_product(page_headers: Span) -> (felt252, felt252) {