62 Gas gas_limit =
tx.gasSettings.gasLimits;
63 Gas teardown_gas_limit =
tx.gasSettings.teardownGasLimits;
68 .gas_limit = gas_limit,
69 .teardown_gas_limit = teardown_gas_limit,
72 info(
"Simulating tx ",
75 tx.setupEnqueuedCalls.size(),
76 " setup enqueued calls, ",
77 tx.appLogicEnqueuedCalls.size(),
78 " app logic enqueued calls, and ",
79 tx.teardownEnqueuedCall ?
"1 teardown enqueued call" :
"no teardown enqueued call");
86 for (
const auto& call :
tx.setupEnqueuedCalls) {
87 info(
"[SETUP] Executing enqueued call to ", call.request.contractAddress);
91 call.request.msgSender,
94 call.request.isStaticCall,
113 throw TxExecutionException(
114 format(
"[SETUP] UNRECOVERABLE ERROR! Enqueued call to ", call.request.contractAddress,
" failed"));
128 for (
const auto& call :
tx.appLogicEnqueuedCalls) {
129 info(
"[APP_LOGIC] Executing enqueued call to ", call.request.contractAddress);
133 call.request.msgSender,
136 call.request.isStaticCall,
155 throw TxExecutionException(
156 format(
"[APP_LOGIC] Enqueued call to ", call.request.contractAddress,
" failed"));
159 }
catch (
const TxExecutionException& e) {
160 info(
"Revertible failure while simulating tx ",
tx.hash,
": ", e.what());
163 tx_context.side_effect_states = end_setup_side_effect_states;
171 uint128_t fee_per_da_gas =
tx.effectiveGasFees.feePerDaGas;
172 uint128_t fee_per_l2_gas =
tx.effectiveGasFees.feePerL2Gas;
173 FF fee =
FF(fee_per_da_gas) *
FF(gas_used_before_teardown.
daGas) +
174 FF(fee_per_l2_gas) *
FF(gas_used_before_teardown.
l2Gas);
178 if (
tx.teardownEnqueuedCall) {
179 info(
"[TEARDOWN] Executing enqueued call to ",
tx.teardownEnqueuedCall->request.contractAddress);
181 Gas start_gas = { 0, 0 };
182 gas_limit = teardown_gas_limit;
185 tx.teardownEnqueuedCall->request.msgSender,
187 tx.teardownEnqueuedCall->calldata,
188 tx.teardownEnqueuedCall->request.isStaticCall,
207 throw TxExecutionException(
format(
208 "[TEARDOWN] Enqueued call to ",
tx.teardownEnqueuedCall->request.contractAddress,
" failed"));
214 }
catch (
const TxExecutionException& e) {
215 info(
"Teardown failure while simulating tx ",
tx.hash,
": ", e.what());
221 pay_fee(
tx.feePayer, fee, fee_per_da_gas, fee_per_l2_gas);
302 throw TxExecutionException(
"Maximum number of L2 to L1 messages reached");
306 tx_context.side_effect_states.numL2ToL1Messages++;
308 .state_before = state_before,
309 .state_after =
tx_context.serialize_tx_context_event(),
311 }
catch (
const TxExecutionException& e) {
313 .state_before = state_before,
314 .state_after =
tx_context.serialize_tx_context_event(),
327 info(
"[NON_REVERTIBLE] Inserting ",
328 tx.nonRevertibleAccumulatedData.nullifiers.size(),
330 tx.nonRevertibleAccumulatedData.noteHashes.size(),
331 " note hashes, and ",
332 tx.nonRevertibleAccumulatedData.l2ToL1Messages.size(),
333 " L2 to L1 messages for tx ",
337 for (
const auto&
nullifier :
tx.nonRevertibleAccumulatedData.nullifiers) {
342 for (
const auto& unique_note_hash :
tx.nonRevertibleAccumulatedData.noteHashes) {
347 for (
const auto& l2_to_l1_msg :
tx.nonRevertibleAccumulatedData.l2ToL1Messages) {
355 info(
"[REVERTIBLE] Inserting ",
356 tx.revertibleAccumulatedData.nullifiers.size(),
358 tx.revertibleAccumulatedData.noteHashes.size(),
359 " note hashes, and ",
360 tx.revertibleAccumulatedData.l2ToL1Messages.size(),
361 " L2 to L1 messages for tx ",
365 for (
const auto& siloed_nullifier :
tx.revertibleAccumulatedData.nullifiers) {
370 for (
const auto& siloed_note_hash :
tx.revertibleAccumulatedData.noteHashes) {
375 for (
const auto& l2_to_l1_msg :
tx.revertibleAccumulatedData.l2ToL1Messages) {
393 throw TxExecutionException(
"Not enough balance for fee payer to pay for transaction");
399 .state_before = state_before,
400 .state_after =
tx_context.serialize_tx_context_event(),
403 .effective_fee_per_l2_gas = fee_per_l2_gas,
404 .fee_payer = fee_payer,
405 .fee_payer_balance = fee_payer_balance,
406 .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)