Skip to content

Commit

Permalink
Initialize side_effect_counter based on the initial value passed to the
Browse files Browse the repository at this point in the history
builder
  • Loading branch information
jeanmon committed Jun 11, 2024
1 parent 42a4b1c commit cbfdeee
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ AvmTraceBuilder::AvmTraceBuilder(VmPublicInputs public_inputs,
// NOTE: we initialise the environment builder here as it requires public inputs
: kernel_trace_builder(std::move(public_inputs))
, side_effect_counter(side_effect_counter)
, initial_side_effect_counter(side_effect_counter)
, execution_hints(std::move(execution_hints))
{
main_trace.reserve(AVM_TRACE_SIZE);
Expand Down Expand Up @@ -4387,6 +4388,8 @@ std::vector<Row> AvmTraceBuilder::finalize(uint32_t min_trace_size, bool range_c
// check the clock and iterate through the main trace until we hit the clock
auto clk = src.clk;

main_trace.at(1).avm_kernel_side_effect_counter = initial_side_effect_counter;

// Until the next kernel changing instruction is encountered we set all of the values of the offset arrays
// to be the same as the previous row This satisfies the `offset' - (offset + operation_selector) = 0`
// constraints
Expand Down
3 changes: 2 additions & 1 deletion barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,10 @@ class AvmTraceBuilder {
0; // After a nested call, it should be initialized with MAX_SIZE_INTERNAL_STACK * call_ptr
uint8_t call_ptr = 0;

// Side effect counter will incremenent when any state writing values are
// Side effect counter will increment when any state writing values are
// encountered
uint32_t side_effect_counter = 0;
uint32_t initial_side_effect_counter; // This one is constant.
uint32_t external_call_counter = 0;

// Execution hints aid witness solving for instructions that require auxiliary information to construct
Expand Down

0 comments on commit cbfdeee

Please sign in to comment.