You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We need high-level type signatures for linking and cross-context calls to generate lifting and lowering functions for the Miden ABI.
Let's consider the following example:
We need to generate lowering and lifting functions for the cross-context calls when process-list-felt
is called from a different package(context).
The process should look like this:
Store the bytes from the caller's memory (pointed by arg0) into the advice provider;
Allocate in the callee memory via callee's exported cabi_realloc and load bytes from the advice
provider into the callee's(export_process_list_felt_cabi) memory;
Call callee's export function (export_process_list_felt_cabi) passing the pointer to the bytes loaded
from the advice provider in step 2;
Store the results (returned via a pointer ptr2) into the advice provider;
Release the callee memory allocated for the result by calling post_return_process_list_felt(ptr2);
Allocate and load the bytes from the advice provider into the caller's memory;
Return the pointer to the bytes loaded from the advice provider in step 5 to the caller.
Suggested solution
To store and load bytes to/from the advice provider, we need to provide a high-level type signatures to calculate the byte size of the data to be stored and loaded.
Since we only can do both allocation (step and 6) when linking the caller (we have callee's cabi_realloc exported from their component) we cannot generate the lowering and lifting functions at the time of the caller's compilation.
Alternatives
We will have WIT binary stored in Miden package to use it as a dependency in a Rust project. We could try to parse high-level type signatures from the WIT binary, but we would need to find corresponding low-level Miden package exports and imports (which we don't have BTW) by name, which is error-prone.
Discovered in #353
Ref #346
Why
We need high-level type signatures for linking and cross-context calls to generate lifting and lowering functions for the Miden ABI.
Let's consider the following example:
WIT:
Which generates the following Rust bindings:
We need to generate lowering and lifting functions for the cross-context calls when
process-list-felt
is called from a different package(context).
The process should look like this:
arg0
) into the advice provider;cabi_realloc
and load bytes from the adviceprovider into the callee's(
export_process_list_felt_cabi
) memory;export_process_list_felt_cabi
) passing the pointer to the bytes loadedfrom the advice provider in step 2;
ptr2
) into the advice provider;post_return_process_list_felt(ptr2)
;Suggested solution
To store and load bytes to/from the advice provider, we need to provide a high-level type signatures to calculate the byte size of the data to be stored and loaded.
Since we only can do both allocation (step and 6) when linking the caller (we have callee's
cabi_realloc
exported from their component) we cannot generate the lowering and lifting functions at the time of the caller's compilation.Alternatives
We will have WIT binary stored in Miden package to use it as a dependency in a Rust project. We could try to parse high-level type signatures from the WIT binary, but we would need to find corresponding low-level Miden package exports and imports (which we don't have BTW) by name, which is error-prone.
Pinging @bitwalker
The text was updated successfully, but these errors were encountered: