63 Gas gas_limit =
tx.gasSettings.gasLimits;
64 Gas teardown_gas_limit =
tx.gasSettings.teardownGasLimits;
69 .gas_limit = gas_limit,
70 .teardown_gas_limit = teardown_gas_limit,
74 info(
"Simulating tx ",
77 tx.setupEnqueuedCalls.size(),
78 " setup enqueued calls, ",
79 tx.appLogicEnqueuedCalls.size(),
80 " app logic enqueued calls, and ",
81 tx.teardownEnqueuedCall ?
"1 teardown enqueued call" :
"no teardown enqueued call");
88 if (
tx.setupEnqueuedCalls.empty()) {
91 for (
const auto& call :
tx.setupEnqueuedCalls) {
92 vinfo(
"[SETUP] Executing enqueued call to ", call.request.contractAddress);
96 call.request.msgSender,
99 call.request.isStaticCall,
118 throw TxExecutionException(
119 format(
"[SETUP] UNRECOVERABLE ERROR! Enqueued call to ", call.request.contractAddress,
" failed"));
134 if (
tx.appLogicEnqueuedCalls.empty()) {
137 for (
const auto& call :
tx.appLogicEnqueuedCalls) {
138 vinfo(
"[APP_LOGIC] Executing enqueued call to ", call.request.contractAddress);
142 call.request.msgSender,
145 call.request.isStaticCall,
164 throw TxExecutionException(
165 format(
"[APP_LOGIC] Enqueued call to ", call.request.contractAddress,
" failed"));
169 }
catch (
const TxExecutionException& e) {
170 info(
"Revertible failure while simulating tx ",
tx.hash,
": ", e.what());
173 tx_context.side_effect_states = end_setup_side_effect_states;
181 uint128_t fee_per_da_gas =
tx.effectiveGasFees.feePerDaGas;
182 uint128_t fee_per_l2_gas =
tx.effectiveGasFees.feePerL2Gas;
183 FF fee =
FF(fee_per_da_gas) *
FF(gas_used_before_teardown.
daGas) +
184 FF(fee_per_l2_gas) *
FF(gas_used_before_teardown.
l2Gas);
188 if (!
tx.teardownEnqueuedCall) {
191 vinfo(
"[TEARDOWN] Executing enqueued call to ",
tx.teardownEnqueuedCall->request.contractAddress);
193 Gas start_gas = { 0, 0 };
194 gas_limit = teardown_gas_limit;
197 tx.teardownEnqueuedCall->request.msgSender,
199 tx.teardownEnqueuedCall->calldata,
200 tx.teardownEnqueuedCall->request.isStaticCall,
219 throw TxExecutionException(
format(
220 "[TEARDOWN] Enqueued call to ",
tx.teardownEnqueuedCall->request.contractAddress,
" failed"));
226 }
catch (
const TxExecutionException& e) {
227 info(
"Teardown failure while simulating tx ",
tx.hash,
": ", e.what());
233 pay_fee(
tx.feePayer, fee, fee_per_da_gas, fee_per_l2_gas);
249 throw TxExecutionException(
"Maximum number of nullifiers reached");
255 throw TxExecutionException(e.what());
259 .state_before = state_before,
260 .state_after =
tx_context.serialize_tx_context_event(),
263 }
catch (
const TxExecutionException& e) {
266 .state_before = state_before,
267 .state_after =
tx_context.serialize_tx_context_event(),
316 throw TxExecutionException(
"Maximum number of L2 to L1 messages reached");
320 tx_context.side_effect_states.numL2ToL1Messages++;
322 .state_before = state_before,
323 .state_after =
tx_context.serialize_tx_context_event(),
325 }
catch (
const TxExecutionException& e) {
327 .state_before = state_before,
328 .state_after =
tx_context.serialize_tx_context_event(),
341 vinfo(
"[NON_REVERTIBLE] Inserting ",
342 tx.nonRevertibleAccumulatedData.nullifiers.size(),
344 tx.nonRevertibleAccumulatedData.noteHashes.size(),
345 " note hashes, and ",
346 tx.nonRevertibleAccumulatedData.l2ToL1Messages.size(),
347 " L2 to L1 messages for tx ",
351 if (
tx.nonRevertibleAccumulatedData.nullifiers.empty()) {
354 for (
const auto&
nullifier :
tx.nonRevertibleAccumulatedData.nullifiers) {
360 if (
tx.nonRevertibleAccumulatedData.noteHashes.empty()) {
363 for (
const auto& unique_note_hash :
tx.nonRevertibleAccumulatedData.noteHashes) {
369 if (
tx.nonRevertibleAccumulatedData.l2ToL1Messages.empty()) {
372 for (
const auto& l2_to_l1_msg :
tx.nonRevertibleAccumulatedData.l2ToL1Messages) {
381 vinfo(
"[REVERTIBLE] Inserting ",
382 tx.revertibleAccumulatedData.nullifiers.size(),
384 tx.revertibleAccumulatedData.noteHashes.size(),
385 " note hashes, and ",
386 tx.revertibleAccumulatedData.l2ToL1Messages.size(),
387 " L2 to L1 messages for tx ",
391 if (
tx.revertibleAccumulatedData.nullifiers.empty()) {
394 for (
const auto& siloed_nullifier :
tx.revertibleAccumulatedData.nullifiers) {
400 if (
tx.revertibleAccumulatedData.noteHashes.empty()) {
403 for (
const auto& siloed_note_hash :
tx.revertibleAccumulatedData.noteHashes) {
409 if (
tx.revertibleAccumulatedData.l2ToL1Messages.empty()) {
412 for (
const auto& l2_to_l1_msg :
tx.revertibleAccumulatedData.l2ToL1Messages) {
431 throw TxExecutionException(
"Not enough balance for fee payer to pay for transaction");
437 .state_before = state_before,
438 .state_after =
tx_context.serialize_tx_context_event(),
441 .effective_fee_per_l2_gas = fee_per_l2_gas,
442 .fee_payer = fee_payer,
443 .fee_payer_balance = fee_payer_balance,
444 .fee_juice_balance_slot = fee_juice_balance_slot,
virtual std::unique_ptr< ContextInterface > make_enqueued_context(AztecAddress address, AztecAddress msg_sender, FF transaction_fee, std::span< const FF > calldata, bool is_static, Gas gas_limit, Gas gas_used, SideEffectStates side_effect_states, TransactionPhase phase)=0
void emit_public_call_request(const PublicCallRequestWithCalldata &call, TransactionPhase phase, const FF &transaction_fee, bool success, const Gas &start_gas, const Gas &end_gas, const TxContextEvent &state_before, const TxContextEvent &state_after)