Struct miden_tx::TransactionExecutor

source ·
pub struct TransactionExecutor<D, A> { /* private fields */ }
Expand description

The transaction executor is responsible for executing Miden rollup transactions.

Transaction execution consists of the following steps:

The transaction executor is generic over the DataStore which allows it to be used with different data backend implementations.

The TransactionExecutor::execute_transaction() method is the main entry point for the executor and produces an ExecutedTransaction for the transaction. The executed transaction can then be used to by the prover to generate a proof transaction execution.

Implementations§

source§

impl<D: DataStore, A: TransactionAuthenticator> TransactionExecutor<D, A>

source

pub fn new(data_store: D, authenticator: Option<Rc<A>>) -> Self

Creates a new TransactionExecutor instance with the specified DataStore and TransactionAuthenticator.

source

pub fn with_debug_mode(self, in_debug_mode: bool) -> Self

Puts the TransactionExecutor into debug mode.

When transaction executor is in debug mode, all transaction-related code (note scripts, account code) will be compiled and executed in debug mode. This will ensure that all debug instructions present in the original source code are executed.

source

pub fn with_tracing(self) -> Self

Enables tracing for the created instance of TransactionExecutor.

When tracing is enabled, the executor will receive tracing events as various stages of the transaction kernel complete. This enables collecting basic stats about how long different stages of transaction execution take.

source

pub fn load_account( &mut self, account_id: AccountId, ) -> Result<AccountCode, TransactionExecutorError>

Fetches the account code from the DataStore, compiles it, and loads the compiled code into the internal cache.

This also returns the AccountCode object built from the loaded account code.

§Errors:

Returns an error if:

  • If the account code cannot be fetched from the DataStore.
  • If the account code fails to be loaded into the compiler.
source

pub fn load_account_interface( &mut self, account_id: AccountId, procedures: Vec<Digest>, ) -> Option<Vec<Digest>>

Loads the provided account interface (vector of procedure digests) into the compiler.

Returns the old interface for the specified account ID if it previously existed.

source

pub fn compile_note_script( &self, note_script_ast: ProgramAst, target_account_procs: Vec<ScriptTarget>, ) -> Result<NoteScript, TransactionExecutorError>

Compiles the provided program into a NoteScript and checks (to the extent possible) if the specified note program could be executed against all accounts with the specified interfaces.

source

pub fn compile_tx_script<T>( &self, tx_script_ast: ProgramAst, inputs: T, target_account_procs: Vec<ScriptTarget>, ) -> Result<TransactionScript, TransactionExecutorError>
where T: IntoIterator<Item = (Word, Vec<Felt>)>,

Compiles the provided transaction script source and inputs into a TransactionScript and checks (to the extent possible) that the transaction script can be executed against all accounts with the specified interfaces.

source

pub fn execute_transaction( &self, account_id: AccountId, block_ref: u32, notes: &[NoteId], tx_args: TransactionArgs, ) -> Result<ExecutedTransaction, TransactionExecutorError>

Prepares and executes a transaction specified by the provided arguments and returns an ExecutedTransaction.

The method first fetches the data required to execute the transaction from the DataStore and compile the transaction into an executable program. Then, it executes the transaction program and creates an ExecutedTransaction object.

§Errors:

Returns an error if:

  • If required data can not be fetched from the DataStore.
  • If the transaction program can not be compiled.
  • If the transaction program can not be executed.
source

pub fn prepare_transaction( &self, account_id: AccountId, block_ref: u32, notes: &[NoteId], tx_args: TransactionArgs, ) -> Result<PreparedTransaction, TransactionExecutorError>

Fetches the data required to execute the transaction from the DataStore, compiles the transaction into an executable program using the TransactionCompiler, and returns a PreparedTransaction.

§Errors:

Returns an error if:

  • If required data can not be fetched from the DataStore.
  • If the transaction can not be compiled.

Auto Trait Implementations§

§

impl<D, A> !Freeze for TransactionExecutor<D, A>

§

impl<D, A> !RefUnwindSafe for TransactionExecutor<D, A>

§

impl<D, A> !Send for TransactionExecutor<D, A>

§

impl<D, A> !Sync for TransactionExecutor<D, A>

§

impl<D, A> Unpin for TransactionExecutor<D, A>
where D: Unpin,

§

impl<D, A> UnwindSafe for TransactionExecutor<D, A>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more