Skip to content

Enable lazy loading for tests using TransactionContext::execute_code #1872

@PhilippGackstatter

Description

@PhilippGackstatter

We currently have lazy loading enabled only for a handful of tests. One primary blocker is that we cannot easily enable lazy loading when executing arbitrary code with TransactionContext::execute_code, because MockHost does not support it. As it is now, we would have to integrate lazy loading into MockHost which seems like an unnecessary maintenance burden. Ideally, we can use the TransactionExecutorHost instead and remove MockHost entirely.

In execute_code this could look something like this:

let account_procedure_index_map = AccountProcedureIndexMap::new(
    [self.tx_inputs().account().code().commitment()],
    advice_inputs.as_advice_inputs(),
)
.expect("TODO");

let host = TransactionExecutorHost::<'_, '_, _, UnreachableAuth>::new(
    self.tx_inputs.account(),
    self.input_notes().clone(),
    self,
    ScriptMastForestStore::default(),
    account_procedure_index_map,
    None,
    self.tx_inputs().block_header().block_num(),
    self.source_manager.clone(),
);

The above works, but trying to pass it to CodeExecutor doesn't because it requires a SyncHost but TransactionExecutorHost implements AsyncHost. We could instead make CodeExecutor use the FastProcessor, but it does not currently let us access the process state after execute, like Process does. This is already implemented done through 0xMiden/miden-vm#2052, and so we should be able to do this after we have upgraded to the next VM.

At that point, we should ideally be able to enable lazy loading throughout the codebase, and independent of whether TransactionContext::execute or execute_code is used. This means removing TransactionContextBuilder::enable_partial_loading and everything that depends on it.

Once we have this, we can also remove the foreign_account_inputs parameter from TransactionArgs::new, i.e. close #1473. Until then, we still need it to load foreign account code for execute_code tests (a couple of tests in test_fpi.rs).

This is a follow-up to #401.

Metadata

Metadata

Labels

blockedSomething prevents working on thistestsImprovements to testing

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions