Replies: 1 comment 5 replies
-
Great writeup! Thank you! A few preliminary questions/comments: To be able to run Not for now, but maybe later, do we envision projects that would have accounts and notes together (in different crates)? In the current setup, do we put anything into the Are Also, regarding dependencies: I think it makes sense for accounts to depend on other accounts, and for notes to depend on accounts, but it probably doesn't make sense for accounts to depend on notes, or for notes to depend on notes. Is this something we'd want to enforce? In general, how do we specify library dependencies (i.e., not note or account dependencies)? What exactly would account package contain? I've written up some thoughts in 0xPolygonMiden/miden-base#550 (comment) - but there are more questions than answer there. I think the main thing is figuring out how to describe the "shape" or the storage and how it should be initialized on deployment. In general, I'm wondering if deployment should be handled separately. That is, the job of |
Beta Was this translation helpful? Give feedback.
-
Creating a new project
To create a new account project:
with
--account
implied, or specifying it explicitly:To create a new note script project:
WIT bindings and
rust-analyzer
rust-analyzer
depends oncargo check
to check for errors. To ensure thatrust-analyzer
can discover the latest bindings (generated from the WIT file),rust-analyzer
must be configured to usecargo miden check
as the check command. Thecargo miden check
will re-generate the bindings if the WIT file is changed.By default,
cargo miden new
will configure Visual Studio Code to usecargo miden check
by creating a.vscode/settings.json
file for you.Specifying the project's Miden package dependencies
The project dependencies on Miden package(s) are specified in the
Cargo.toml
file of the project in a separate tablepackage.metadata.miden
. For example, to specify the dependency on the specific account package in the note script project:Where
SOME_PATH
is either a path to the Miden package file or a Rust project from which the Miden package can be built.For the MVP we only support local dependencies (
path
field) with package repository support coming later.Compiling the Miden package
To compile the Miden package with
dev
(debug) profile:Which builds the Miden package and puts it in the
target/miden/debug
directory.To compile the Miden package with
release
profile:Which builds the Miden package and puts it in the
target/miden/release
directory.Running/debugging the Miden package
The account does not have an entry point, so it is not possible to run it directly. We could specify an entry point and inputs via the command line, but I believe such use cases would be easier for the MVP to cover with our testing infrastructure.
The note script can be run directly, but it requires an account, in most cases pre-populated with some state (assets, etc.) which is cumbersome to do via the command line and would be easier to cover with our testing infrastructure.
Testing the Miden package
Since the account API is called only from the note script (for now at least), we can focus on providing enough glue (test infrastructure) to let note scripts interact with the account and make assertions of its state.
Building on the ideas of the Smart contracts testing discussion and
miden-base
testing infrastructure, we can simulate the rollup and run the compiled Miden packages for account and note scripts on the VM and assert the state of the account after the execution.The simplest test for the basic wallet account would look like this:
Where
compile
compiles the Miden package (equivalent tocargo miden build
) and returns it wrapped in some test harness.This way we only simulate the rollup parts and running the Miden packages under test on the VM.
The tests are regular Rust integration tests and can be run with
cargo miden test
which will runcargo test
under the hood.To debug the account and note scripts in the MVP we can control the debugger from the test code. For example, to stop on entering the
receive_asset
function of the basic wallet account put in the test code:Which will stop the execution on the first call to the
receive_asset
function of thebasic_wallet
and open the debugger TUI.Later, we can utilize the DAP protocol and expose the debugger to the IDE/editor and utilize the debugging capabilities of the IDE/editor.
Deploying the Miden package
To deploy the Miden package to a Miden node use the
deploy
command:@bitwalker @bobbinth
Beta Was this translation helpful? Give feedback.
All reactions