Skip to content

Commit 21c761f

Browse files
author
AztecBot
committed
Merge branch 'next' into merge-train/barretenberg
2 parents 05cebda + c13d950 commit 21c761f

7 files changed

Lines changed: 70 additions & 11 deletions

File tree

avm-transpiler/Cargo.lock

Lines changed: 16 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

barretenberg/cpp/src/barretenberg/vm2/simulation/gadgets/execution.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,7 @@ void Execution::ret(ContextInterface& context, MemoryAddress ret_size_offset, Me
793793
.gas_used = context.get_gas_used(),
794794
.success = true,
795795
.halting_pc = context.get_pc(),
796+
.halting_mode = HaltingMode::RETURN,
796797
.halting_message = std::nullopt });
797798

798799
context.halt();
@@ -826,6 +827,7 @@ void Execution::revert(ContextInterface& context, MemoryAddress rev_size_offset,
826827
.gas_used = context.get_gas_used(),
827828
.success = false,
828829
.halting_pc = context.get_pc(),
830+
.halting_mode = HaltingMode::REVERT,
829831
.halting_message = "Assertion failed: " });
830832

831833
context.halt();
@@ -1849,9 +1851,11 @@ EnqueuedCallResult Execution::execute(std::unique_ptr<ContextInterface> enqueued
18491851
}
18501852

18511853
const ExecutionResult& result = get_execution_result();
1852-
return {
1854+
return EnqueuedCallResult{
18531855
.success = result.success,
18541856
.gas_used = result.gas_used,
1857+
.halting_mode = result.halting_mode,
1858+
.halting_message = result.halting_message,
18551859
};
18561860
}
18571861

@@ -1969,6 +1973,7 @@ void Execution::handle_exceptional_halt(ContextInterface& context, const std::st
19691973
.gas_used = context.get_gas_used(),
19701974
.success = false,
19711975
.halting_pc = context.get_pc(),
1976+
.halting_mode = HaltingMode::EXCEPTIONAL_HALT,
19721977
.halting_message = halting_message,
19731978
});
19741979
}

barretenberg/cpp/src/barretenberg/vm2/simulation/gadgets/execution.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ class Execution : public ExecutionInterface {
213213
MemoryAddress rd_size;
214214
Gas gas_used;
215215
bool success;
216-
PC halting_pc = 0; // PC at which the context halted.
216+
PC halting_pc = 0; // PC at which the context halted.
217+
HaltingMode halting_mode = HaltingMode::UNDEFINED;
217218
std::optional<std::string> halting_message; // If reverted.
218219
};
219220

barretenberg/cpp/src/barretenberg/vm2/simulation/gadgets/tx_execution.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,23 @@ class TxExecutionException : public std::runtime_error {
1818
{}
1919
};
2020

21+
std::string get_halting_information(const EnqueuedCallResult& result)
22+
{
23+
std::string halting_message =
24+
result.halting_message.has_value() ? " with message: " + result.halting_message.value() : "";
25+
26+
switch (result.halting_mode) {
27+
case HaltingMode::RETURN:
28+
return "RETURN" + halting_message;
29+
case HaltingMode::REVERT:
30+
return "REVERT" + halting_message;
31+
case HaltingMode::EXCEPTIONAL_HALT:
32+
return "EXCEPTIONAL_HALT";
33+
default:
34+
return "UNKNOWN" + halting_message;
35+
}
36+
}
37+
2138
} // namespace
2239

2340
/**
@@ -115,6 +132,11 @@ TxExecutionResult TxExecution::simulate(const Tx& tx)
115132
// This call should not throw unless it's an unexpected unrecoverable failure.
116133
EnqueuedCallResult result = call_execution.execute(std::move(context));
117134
tx_context.gas_used = result.gas_used;
135+
vinfo("[SETUP] Enqueued call to ",
136+
call.request.contract_address,
137+
" halted via ",
138+
get_halting_information(result));
139+
118140
emit_public_call_request(call,
119141
TransactionPhase::SETUP,
120142
/*transaction_fee=*/FF(0),
@@ -175,6 +197,10 @@ TxExecutionResult TxExecution::simulate(const Tx& tx)
175197
// This call should not throw unless it's an unexpected unrecoverable failure.
176198
EnqueuedCallResult result = call_execution.execute(std::move(context));
177199
tx_context.gas_used = result.gas_used;
200+
vinfo("[APP_LOGIC] Enqueued call to ",
201+
call.request.contract_address,
202+
" halted via ",
203+
get_halting_information(result));
178204

179205
emit_public_call_request(call,
180206
TransactionPhase::APP_LOGIC,
@@ -239,6 +265,11 @@ TxExecutionResult TxExecution::simulate(const Tx& tx)
239265
// This call should not throw unless it's an unexpected unrecoverable failure.
240266
EnqueuedCallResult result = call_execution.execute(std::move(context));
241267
gas_used_by_teardown = result.gas_used;
268+
vinfo("[TEARDOWN] Enqueued call to ",
269+
teardown_enqueued_call.request.contract_address,
270+
" halted via ",
271+
get_halting_information(result));
272+
242273
emit_public_call_request(teardown_enqueued_call,
243274
TransactionPhase::TEARDOWN,
244275
fee,

barretenberg/cpp/src/barretenberg/vm2/simulation/interfaces/execution.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,19 @@ namespace bb::avm2::simulation {
1515
// Forward declarations
1616
class ContextInterface;
1717

18+
enum HaltingMode : uint8_t {
19+
UNDEFINED,
20+
RETURN,
21+
REVERT,
22+
EXCEPTIONAL_HALT,
23+
};
24+
1825
struct EnqueuedCallResult {
1926
bool success;
2027
Gas gas_used;
28+
// For debugging.
29+
HaltingMode halting_mode;
30+
std::optional<std::string> halting_message;
2131
};
2232

2333
class ExecutionInterface {

barretenberg/cpp/src/barretenberg/vm2/simulation/standalone/hybrid_execution.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,12 @@ EnqueuedCallResult HybridExecution::execute(std::unique_ptr<ContextInterface> en
103103
}
104104
}
105105

106-
ExecutionResult result = get_execution_result();
107-
return {
106+
const ExecutionResult& result = get_execution_result();
107+
return EnqueuedCallResult{
108108
.success = result.success,
109109
.gas_used = result.gas_used,
110+
.halting_mode = result.halting_mode,
111+
.halting_message = result.halting_message,
110112
};
111113
}
112114

noir/noir-repo

Submodule noir-repo updated 142 files

0 commit comments

Comments
 (0)