import { Fr } from '@aztec/foundation/curves/bn254'; import { type LoggerBindings } from '@aztec/foundation/log'; import { AvmCircuitPublicInputs, RevertCode } from '@aztec/stdlib/avm'; import type { AztecAddress } from '@aztec/stdlib/aztec-address'; import { type ContractDeploymentData } from '@aztec/stdlib/contract'; import type { SimulationError } from '@aztec/stdlib/errors'; import { Gas } from '@aztec/stdlib/gas'; import { PrivateToPublicAccumulatedData } from '@aztec/stdlib/kernel'; import { type GlobalVariables, ProtocolContracts, PublicCallRequestWithCalldata, type Tx, TxExecutionPhase, type TxHash } from '@aztec/stdlib/tx'; import type { PublicContractsDBInterface } from '../db_interfaces.js'; import type { PublicTreesDB } from '../public_db_sources.js'; import { PublicPersistableStateManager } from '../state_manager/state_manager.js'; /** * The transaction-level context for public execution. */ export declare class PublicTxContext { readonly txHash: TxHash; readonly state: PhaseStateManager; private readonly startTreeSnapshots; private readonly globalVariables; private readonly protocolContracts; private readonly proverId; private readonly gasSettings; private readonly gasUsedByPrivate; private readonly gasAllocatedToPublic; private readonly gasAllocatedToPublicTeardown; private readonly setupCallRequests; private readonly appLogicCallRequests; private readonly teardownCallRequests; readonly nonRevertibleContractDeploymentData: ContractDeploymentData; readonly revertibleContractDeploymentData: ContractDeploymentData; readonly nonRevertibleAccumulatedDataFromPrivate: PrivateToPublicAccumulatedData; readonly revertibleAccumulatedDataFromPrivate: PrivateToPublicAccumulatedData; readonly feePayer: AztecAddress; private readonly trace; private log; private gasUsedByPublic; teardownGasUsed: Gas; private halted; private revertCode; revertReason: SimulationError | undefined; private constructor(); static create(treesDB: PublicTreesDB, contractsDB: PublicContractsDBInterface, tx: Tx, globalVariables: GlobalVariables, protocolContracts: ProtocolContracts, proverId: Fr, bindings?: LoggerBindings): Promise; /** * Signal that the entire transaction execution is done. * All phases have been processed. * Actual transaction fee and actual total consumed gas can now be queried. */ halt(): void; /** * Revert execution a phase. Populate revertReason & revertCode. * If in setup, throw an error (transaction will be thrown out). * NOTE: this does not "halt" the entire transaction execution. */ revert(phase: TxExecutionPhase, revertReason?: SimulationError | undefined, culprit?: string): void; /** * Get the revert code. * @returns The revert code. */ getFinalRevertCode(): RevertCode; /** * Are there any call requests for the speciiied phase? */ hasPhase(phase: TxExecutionPhase): boolean; /** * Get the call requests for the specified phase (including args hashes). */ getCallRequestsForPhase(phase: TxExecutionPhase): PublicCallRequestWithCalldata[]; /** * How much gas is left as of the specified phase? */ getGasLeftAtPhase(phase: TxExecutionPhase): Gas; /** * Consume gas. Track gas for teardown phase separately. */ consumeGas(phase: TxExecutionPhase, gas: Gas): void; /** * The gasUsed by public and private, as if the entire teardown gas limit was consumed. * * This is intentional: teardown is used for gas accounting and refunds, so the transaction * fee must be deterministic _before_ teardown executes. If fees depended on teardown's actual * consumption there would be a circular dependency. Billing the full teardown gas limit * (set by the user) makes the fee known in advance and available to the teardown function. */ getTotalGasUsed(): Gas; /** * Compute the gas used using the actual gas used during teardown instead * of the teardown gas limit. * Note that this.gasUsed is initialized from private's gasUsed which includes * teardown gas limit. */ getActualGasUsed(): Gas; /** * Compute the public gas used using the actual gas used during teardown instead * of the teardown gas limit. */ getActualPublicGasUsed(): Gas; /** * Get the transaction fee as is available to the specified phase. * Only teardown should have access to the actual transaction fee. */ getTransactionFee(phase: TxExecutionPhase): Fr; /** * Compute the transaction fee. * Should only be called during or after teardown. */ private getTransactionFeeUnsafe; /** * Generate the public inputs for the AVM circuit. */ generateAvmCircuitPublicInputs(): Promise; } /** * Thin wrapper around the state manager to handle forking and merging for phases. * * This lets us keep track of whether the state has already been forked * so that we can conditionally fork at the start of a phase. * * There is a state manager that lives at the level of the entire transaction, * but for app logic and teardown the active state manager will be a fork of the * transaction level one. */ declare class PhaseStateManager { private readonly txStateManager; private log; private currentlyActiveStateManager; constructor(txStateManager: PublicPersistableStateManager, bindings?: LoggerBindings); fork(): Promise; getActiveStateManager(): PublicPersistableStateManager; isForked(): boolean; mergeForkedState(): Promise; discardForkedState(): Promise; } export {}; //# sourceMappingURL=data:application/json;base64,eyJ2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