1
- use openvm_instructions:: riscv:: RV32_IMM_AS ;
1
+ use openvm_instructions:: riscv:: {
2
+ RV32_IMM_AS , RV32_NUM_REGISTERS , RV32_REGISTER_AS , RV32_REGISTER_NUM_LIMBS ,
3
+ } ;
2
4
3
5
use super :: {
4
6
memory_ctx:: MemoryCtx ,
@@ -27,7 +29,7 @@ impl<const PAGE_BITS: usize> MeteredCtx<PAGE_BITS> {
27
29
widths : Vec < usize > ,
28
30
interactions : Vec < usize > ,
29
31
) -> Self {
30
- let ( trace_heights, is_trace_height_constant) : ( Vec < u32 > , Vec < bool > ) =
32
+ let ( mut trace_heights, is_trace_height_constant) : ( Vec < u32 > , Vec < bool > ) =
31
33
constant_trace_heights
32
34
. iter ( )
33
35
. map ( |& constant_height| {
@@ -39,7 +41,7 @@ impl<const PAGE_BITS: usize> MeteredCtx<PAGE_BITS> {
39
41
} )
40
42
. unzip ( ) ;
41
43
42
- let memory_ctx = MemoryCtx :: new (
44
+ let mut memory_ctx = MemoryCtx :: new (
43
45
has_public_values_chip,
44
46
continuations_enabled,
45
47
as_byte_alignment_bits,
@@ -55,6 +57,16 @@ impl<const PAGE_BITS: usize> MeteredCtx<PAGE_BITS> {
55
57
56
58
let segmentation_ctx = SegmentationCtx :: new ( air_names, widths, interactions) ;
57
59
60
+ // Add merkle height contributions for all registers
61
+ if continuations_enabled {
62
+ memory_ctx. update_boundary_merkle_heights (
63
+ & mut trace_heights,
64
+ RV32_REGISTER_AS ,
65
+ 0 ,
66
+ ( RV32_NUM_REGISTERS * RV32_REGISTER_NUM_LIMBS ) as u32 ,
67
+ ) ;
68
+ }
69
+
58
70
Self {
59
71
trace_heights,
60
72
is_trace_height_constant,
@@ -115,6 +127,7 @@ impl<const PAGE_BITS: usize> MeteredCtx<PAGE_BITS> {
115
127
}
116
128
117
129
impl < const PAGE_BITS : usize > E1E2ExecutionCtx for MeteredCtx < PAGE_BITS > {
130
+ #[ inline( always) ]
118
131
fn on_memory_operation ( & mut self , address_space : u32 , ptr : u32 , size : u32 ) {
119
132
debug_assert ! (
120
133
address_space != RV32_IMM_AS ,
@@ -132,11 +145,13 @@ impl<const PAGE_BITS: usize> E1E2ExecutionCtx for MeteredCtx<PAGE_BITS> {
132
145
. update_adapter_heights ( & mut self . trace_heights , address_space, size_bits) ;
133
146
134
147
// Handle merkle tree updates
135
- self . memory_ctx . update_boundary_merkle_heights (
136
- & mut self . trace_heights ,
137
- address_space,
138
- ptr,
139
- size,
140
- ) ;
148
+ if address_space != RV32_REGISTER_AS {
149
+ self . memory_ctx . update_boundary_merkle_heights (
150
+ & mut self . trace_heights ,
151
+ address_space,
152
+ ptr,
153
+ size,
154
+ ) ;
155
+ }
141
156
}
142
157
}
0 commit comments