Skip to content

Commit 907aa6f

Browse files
authored
Merge branch 'next' into gd/acir-serialization-changes
2 parents 0b5ddae + 395632f commit 907aa6f

File tree

115 files changed

+2381
-601
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+2381
-601
lines changed

.github/workflows/deploy-aztec-infra.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ on:
100100
description: Whether to use an external ingress for the rpc
101101
required: true
102102
type: boolean
103+
otel_collector_url:
104+
description: The OpenTelemetry collector that will receive metrics from this deployment. Optional
105+
required: false
106+
type: string
103107
secrets:
104108
GCP_SA_KEY:
105109
description: The GCP service account key
@@ -207,6 +211,10 @@ on:
207211
description: Whether to use an external ingress for the rpc
208212
required: true
209213
type: boolean
214+
otel_collector_url:
215+
description: The OpenTelemetry collector that will receive metrics from this deployment. Optional
216+
required: false
217+
type: string
210218

211219
jobs:
212220
deploy_aztec_infra:
@@ -237,6 +245,7 @@ jobs:
237245
TF_VAR_PROVER_RESOURCE_PROFILE: ${{ inputs.prover_resource_profile }}
238246
TF_VAR_RPC_RESOURCE_PROFILE: ${{ inputs.rpc_resource_profile }}
239247
TF_VAR_RPC_EXTERNAL_INGRESS: ${{ inputs.rpc_external_ingress }}
248+
TF_VAR_OTEL_COLLECTOR_URL: ${{ inputs.otel_collector_url }}
240249

241250
steps:
242251
- name: Debug inputs

barretenberg/cpp/pil/vm2/alu.pil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ pol EXPECTED_C_TAG = (sel_op_add + sel_op_sub + sel_op_mul + sel_op_div + sel_op
119119
// Gating with (1 - sel_tag_err) is necessary because when an error occurs, we have to set the tag to 0,
120120
// which might not be equal to EXPECTED_C_TAG.
121121
#[C_TAG_CHECK]
122-
(1 - sel_tag_err) * (EXPECTED_C_TAG - ic_tag) = 0;
122+
(1 - sel_err) * (EXPECTED_C_TAG - ic_tag) = 0;
123123

124124
pol commit sel_tag_err;
125125
sel_tag_err * (1 - sel_tag_err) = 0;

barretenberg/cpp/pil/vm2/context.pil

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ namespace execution;
1212
#[skippable_if]
1313
sel = 0;
1414

15+
// TODO: make sure that all uses of `sel_error` here really should be "error" only
16+
// since `sel_error` will not be ` for the REVERT opcode. If we need "error or REVERT",
17+
// use `sel_failure`.
18+
1519
// Guaranteed to be boolean because sel_execute_call & sel_execute_static_call are mutually exclusive
1620
pol commit sel_enter_call;
1721
// The following selectors will be 0 if there is an error during execution (before the opcode execution step).
@@ -33,7 +37,9 @@ namespace execution;
3337
pol commit contract_address;
3438
pol commit bytecode_id;
3539
pol commit transaction_fee;
36-
// Constrained boolean by tx trace (for enqueued call) and #[NEXT_IS_STATIC] for nested
40+
// Constrained boolean by tx trace for enqueued call, #[IS_STATIC_NEXT_ROW] during normal execution,
41+
// IS_STATIC_IF_STATIC_CALL+IS_STATIC_IF_CALL_FROM_STATIC_CONTEXT for nested calls,
42+
// and CTX_STACK_CALL for returns or failures.
3743
pol commit is_static;
3844

3945
pol commit parent_calldata_addr;
@@ -189,7 +195,12 @@ namespace execution;
189195
// otherwise = 0 ==> is_static' = is_static
190196
#[IS_STATIC_NEXT_ROW]
191197
NOT_LAST_EXEC * DEFAULT_CTX_ROW * (is_static' - is_static) = 0;
192-
NOT_LAST_EXEC * sel_enter_call * (is_static' - sel_execute_static_call) = 0;
198+
// An external call from a non-static context only creates a nested static context if the opcode is STATICCALL.
199+
#[IS_STATIC_IF_STATIC_CALL]
200+
NOT_LAST_EXEC * sel_enter_call * (1 - is_static) * (is_static' - sel_execute_static_call) = 0;
201+
// An external call from a static context always creates a nested static context.
202+
#[IS_STATIC_IF_CALL_FROM_STATIC_CONTEXT]
203+
NOT_LAST_EXEC * sel_enter_call * is_static * (is_static' - 1) = 0;
193204

194205
// nested_exit_call = 1 ==> constraints come from lookup
195206
// sel_enter_call = 1 ==> parent_calldata_addr' = rop[4] (resolved operand 5 from execution trace)

barretenberg/cpp/pil/vm2/execution.pil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ sel_bytecode_retrieval_success {
147147

148148
pol commit sel_instruction_fetching_success;
149149
// If sel = 0, we want sel_instruction_fetching_success = 0. We shouldn't be using it.
150-
sel_instruction_fetching_success = sel * (1 - sel_instruction_fetching_failure);
150+
sel_instruction_fetching_success = sel_bytecode_retrieval_success * (1 - sel_instruction_fetching_failure);
151151

152152
#[INSTRUCTION_FETCHING_BODY]
153153
sel_instruction_fetching_success {

barretenberg/cpp/pil/vm2/tx.pil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ namespace tx;
306306
execution.enqueued_call_end {
307307
execution.context_id,
308308
execution.next_context_id,
309-
execution.sel_error,
309+
execution.sel_failure,
310310
execution.discard,
311311
// Tree State
312312
execution.note_hash_tree_root,

barretenberg/cpp/src/barretenberg/vm2/constraining/relations/context.test.cpp

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,21 +61,25 @@ TEST(ContextConstrainingTest, ContextSwitchingCallReturn)
6161
{ C::execution_context_id, 1 },
6262
{ C::execution_next_context_id, 2 },
6363
{ C::execution_bytecode_id, top_bytecode_id },
64+
{ C::execution_is_static, 0 }, // Non-static context
6465
{ C::execution_parent_l2_gas_limit, 2000 },
6566
{ C::execution_parent_da_gas_limit, 4000 },
6667
{ C::execution_parent_l2_gas_used, 500 },
6768
{ C::execution_parent_da_gas_used, 1500 },
69+
{ C::execution_enqueued_call_start, 1 },
6870
},
6971
// CALL
7072
{
7173
{ C::execution_sel, 1 },
7274
{ C::execution_pc, 1 },
7375
{ C::execution_next_pc, 2 },
7476
{ C::execution_sel_execute_call, 1 },
77+
{ C::execution_sel_execute_static_call, 0 }, // Regular CALL, not STATICCALL
7578
{ C::execution_sel_enter_call, 1 },
7679
{ C::execution_context_id, 1 },
7780
{ C::execution_next_context_id, 2 },
7881
{ C::execution_bytecode_id, top_bytecode_id }, // Same as previous row (propagated)
82+
{ C::execution_is_static, 0 }, // Still non-static
7983
{ C::execution_rop_4_, /*cd offset=*/10 },
8084
{ C::execution_register_2_, /*contract address=*/0xdeadbeef },
8185
{ C::execution_register_3_, /*cd size=*/1 },
@@ -96,6 +100,7 @@ TEST(ContextConstrainingTest, ContextSwitchingCallReturn)
96100
{ C::execution_has_parent_ctx, 1 },
97101
{ C::execution_contract_address, 0xdeadbeef },
98102
{ C::execution_bytecode_id, nested_bytecode_id }, // New bytecode_id on entering new context
103+
{ C::execution_is_static, 0 }, // Remains non-static after regular CALL
99104
{ C::execution_parent_calldata_addr, 10 },
100105
{ C::execution_parent_calldata_size, 1 },
101106
},
@@ -633,6 +638,137 @@ TEST(ContextConstrainingTest, BytecodeIdPropagation)
633638
"BYTECODE_ID_NEXT_ROW"); // Should fail constraint
634639
}
635640

641+
TEST(ContextConstrainingTest, IsStaticRegularCallFromNonStaticContext)
642+
{
643+
// Non-static context making a regular CALL - should remain non-static
644+
TestTraceContainer trace({
645+
{ { C::precomputed_first_row, 1 } },
646+
{
647+
{ C::execution_sel, 1 },
648+
{ C::execution_context_id, 1 },
649+
{ C::execution_next_context_id, 2 },
650+
{ C::execution_is_static, 0 }, // Non-static context
651+
{ C::execution_sel_enter_call, 1 },
652+
{ C::execution_sel_execute_call, 1 }, // Regular CALL
653+
{ C::execution_sel_execute_static_call, 0 },
654+
},
655+
{
656+
{ C::execution_sel, 1 },
657+
{ C::execution_context_id, 2 },
658+
{ C::execution_next_context_id, 3 },
659+
{ C::execution_is_static, 0 }, // Should remain non-static
660+
},
661+
});
662+
check_relation<context>(
663+
trace, context::SR_IS_STATIC_IF_STATIC_CALL, context::SR_IS_STATIC_IF_CALL_FROM_STATIC_CONTEXT);
664+
665+
// Negative test: change is_static
666+
// regular call from non-static context cannot become static
667+
trace.set(C::execution_is_static, 2, 1);
668+
EXPECT_THROW_WITH_MESSAGE(check_relation<context>(trace, context::SR_IS_STATIC_IF_STATIC_CALL),
669+
"IS_STATIC_IF_STATIC_CALL");
670+
671+
// reset is_static
672+
trace.set(C::execution_is_static, 2, 0);
673+
}
674+
675+
TEST(ContextConstrainingTest, IsStaticStaticCallFromNonStaticContext)
676+
{
677+
// Non-static context making a STATICCALL - should become static
678+
TestTraceContainer trace({
679+
{ { C::precomputed_first_row, 1 } },
680+
{
681+
{ C::execution_sel, 1 },
682+
{ C::execution_context_id, 1 },
683+
{ C::execution_next_context_id, 2 },
684+
{ C::execution_is_static, 0 }, // Non-static context
685+
{ C::execution_sel_enter_call, 1 },
686+
{ C::execution_sel_execute_call, 0 },
687+
{ C::execution_sel_execute_static_call, 1 }, // STATICCALL
688+
},
689+
{
690+
{ C::execution_sel, 1 },
691+
{ C::execution_context_id, 2 },
692+
{ C::execution_next_context_id, 3 },
693+
{ C::execution_is_static, 1 }, // Should become static
694+
},
695+
});
696+
check_relation<context>(
697+
trace, context::SR_IS_STATIC_IF_STATIC_CALL, context::SR_IS_STATIC_IF_CALL_FROM_STATIC_CONTEXT);
698+
699+
// Negative test: change is_static
700+
// static call from non-static context MUST become static
701+
trace.set(C::execution_is_static, 2, 0);
702+
EXPECT_THROW_WITH_MESSAGE(check_relation<context>(trace, context::SR_IS_STATIC_IF_STATIC_CALL),
703+
"IS_STATIC_IF_STATIC_CALL");
704+
705+
// reset is_static
706+
trace.set(C::execution_is_static, 2, 1);
707+
}
708+
709+
TEST(ContextConstrainingTest, IsStaticCallFromStaticContext)
710+
{
711+
// Static context making any call - must remain static
712+
TestTraceContainer trace({
713+
{ { C::precomputed_first_row, 1 } },
714+
{
715+
{ C::execution_sel, 1 },
716+
{ C::execution_context_id, 1 },
717+
{ C::execution_next_context_id, 2 },
718+
{ C::execution_is_static, 1 }, // Static context
719+
{ C::execution_sel_enter_call, 1 },
720+
{ C::execution_sel_execute_call, 1 }, // Regular CALL
721+
{ C::execution_sel_execute_static_call, 0 },
722+
},
723+
{
724+
{ C::execution_sel, 1 },
725+
{ C::execution_context_id, 2 },
726+
{ C::execution_next_context_id, 3 },
727+
{ C::execution_is_static, 1 }, // Must remain static
728+
},
729+
});
730+
check_relation<context>(
731+
trace, context::SR_IS_STATIC_IF_STATIC_CALL, context::SR_IS_STATIC_IF_CALL_FROM_STATIC_CONTEXT);
732+
733+
// Negative test: change is_static
734+
// static call from static context MUST remain static
735+
trace.set(C::execution_is_static, 2, 0);
736+
EXPECT_THROW_WITH_MESSAGE(check_relation<context>(trace, context::SR_IS_STATIC_IF_CALL_FROM_STATIC_CONTEXT),
737+
"IS_STATIC_IF_CALL_FROM_STATIC_CONTEXT");
738+
739+
// reset is_static
740+
trace.set(C::execution_is_static, 2, 1);
741+
}
742+
743+
TEST(ContextConstrainingTest, IsStaticPropagationWithoutCalls)
744+
{
745+
// is_static propagation without calls
746+
TestTraceContainer trace({
747+
{ { C::precomputed_first_row, 1 } },
748+
{
749+
{ C::execution_sel, 1 },
750+
{ C::execution_context_id, 1 },
751+
{ C::execution_next_context_id, 1 },
752+
{ C::execution_is_static, 1 }, // Static context
753+
},
754+
{
755+
{ C::execution_sel, 1 },
756+
{ C::execution_context_id, 1 },
757+
{ C::execution_next_context_id, 1 },
758+
{ C::execution_is_static, 1 }, // Should propagate
759+
},
760+
});
761+
check_relation<context>(trace, context::SR_IS_STATIC_NEXT_ROW);
762+
763+
// Negative test: change is_static
764+
// staticness must propagate without calls
765+
trace.set(C::execution_is_static, 2, 0);
766+
EXPECT_THROW_WITH_MESSAGE(check_relation<context>(trace, context::SR_IS_STATIC_NEXT_ROW), "IS_STATIC_NEXT_ROW");
767+
768+
// reset is_static
769+
trace.set(C::execution_is_static, 2, 1);
770+
}
771+
636772
TEST(ContextConstrainingTest, ContextIdPropagation)
637773
{
638774
TestTraceContainer trace({

barretenberg/cpp/src/barretenberg/vm2/generated/relations/alu_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ void aluImpl<FF_>::accumulate(ContainerOverSubrelations& evals,
138138
}
139139
{ // C_TAG_CHECK
140140
using Accumulator = typename std::tuple_element_t<8, ContainerOverSubrelations>;
141-
auto tmp = (FF(1) - in.get(C::alu_sel_tag_err)) * (alu_EXPECTED_C_TAG - in.get(C::alu_ic_tag));
141+
auto tmp = (FF(1) - in.get(C::alu_sel_err)) * (alu_EXPECTED_C_TAG - in.get(C::alu_ic_tag));
142142
tmp *= scaling_factor;
143143
std::get<8>(evals) += typename Accumulator::View(tmp);
144144
}

0 commit comments

Comments
 (0)