-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: split cli and client into workspace #407
Conversation
ca7cef7
to
27c4a59
Compare
btw, how is this PR different from #400? |
27c4a59
to
40e4b6a
Compare
b673fcb
to
8b5a8ec
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work! Left tiny fixes and with that I think we're ok to merge
We debugged offline for a while on why the integration tests were failing (assert_cmd wasn't finding the CLI binary). We noticed the CLI binary was not being built. As a fast fix we noticed that you can just run UPDATE: including it as a dependency didn't work so we'll go with building before running the test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thank you. I left a few comments inline.
Also, we should update the docs to make sure they are up to date.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to above comments, I'm not sure we need the client
submodule any more. Contents of this file should probably go into lib.rs
and all other files brought up one level.
ced1195
to
23c8ede
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a few more comments inline. Also, a couple of additional comments:
- We should rename
crates/miden-client
intocrates/rust-client
. - we should create
README.md
files for each crate (i.e.,bin/miden-cli/README.md
andcrates/rust-client/README.md
). - Looking at files in
bin/miden-cli/src
now, it seems like we've made the structure "too flat". Maybe we should havecommands
sub-module to contain one file per command (e.g.,bin/miden-cli/src/commands/account.rs
).
crates/miden-client/src/errors.rs
Outdated
pub use miden_objects::{ | ||
accounts::AccountId, crypto::merkle::MmrError, notes::NoteId, AccountError, AssetError, | ||
AssetVaultError, Digest, NoteError, TransactionScriptError, Word, | ||
}; | ||
use miden_tx::{ | ||
pub use miden_tx::{ | ||
utils::{DeserializationError, HexParseError}, | ||
DataStoreError, TransactionExecutorError, TransactionProverError, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to re-export things like AccountId
, NoteId
, Word
, and Digest
from here.
Also, Some error are re-exports from other places too - e.g., DataStoreError
, TransactionExecutorError
, and DeserializationError
exported from sub-modules defined at the root. We should have a consistent methodology and either export all errors from here - or all errors from corresponding sub-modules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would leave re-exports from other crates in lib.rs
. Also, in #374 I move around errors a bit maybe I can rebase once we merge this PR and deal with inconsistencies then
cargo nextest run --release --test=integration --features $(FEATURES_INTEGRATION_TESTING) --no-default-features | ||
|
||
.PHONY: integration-test-full | ||
integration-test-full: ## Run the integration test binary with ignored tests included | ||
integration-test-full: build ## Run the integration test binary with ignored tests included |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's create an issue to move the CLI integration tests to the CLI crate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, created issue #411
README.md
Outdated
``` | ||
The workspace is organized as follows: | ||
- The `bin` folder contains crates that are meant to be compiled into binaries (like the CLI). | ||
- The `crates` folder contains the library crates that are meant to be used as dependencies (like the rust client library). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
- The `crates` folder contains the library crates that are meant to be used as dependencies (like the rust client library). | |
- The `crates` folder contains the library crates that are meant to be used as dependencies (like the Rust client library). |
tests/Cargo.toml
Outdated
figment = { version = "0.10", features = ["toml", "env"] } | ||
miden-client = { path = "../crates/rust-client", features = ["testing"] } | ||
miden-objects = { package = "miden-objects", git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "next", default-features = false, features = ["serde"] } | ||
assert_cmd = { version = "2.0" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: let's make sure these are sorted in alphabetical order.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thank you. I left a few more comments inline.
Also, I think e should still get rid of the client
sub-module in miden-client
.
bin/miden-cli/README.md
Outdated
Before you can use the Miden client, you'll need to make sure you have both | ||
[Rust](https://www.rust-lang.org/tools/install) and sqlite3 installed. Miden | ||
client requires rust version **1.78** or higher. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we usually don't manually wrap lines in markdown files.
bin/miden-cli/README.md
Outdated
You can either build from source with: | ||
|
||
```bash | ||
cargo build --release | ||
``` | ||
|
||
Once the binary is built, you can find it on `./target/release/miden-client`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should mention building with testing
feature enabled.
Also, is the target directory correct here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, the target directory is ok but the binary name isn't
bin/miden-cli/README.md
Outdated
```bash | ||
cargo install miden-client | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be miden-cli
, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is the old binary name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a "License" section to this file (as we have in the main file).
bin/miden-cli/README.md
Outdated
@@ -0,0 +1,27 @@ | |||
# Miden Client CLI | |||
|
|||
This binary is a wrapper around the library exposing its functionality via a simple command-line interface (CLI). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would make this description a bit more informative (i.e., that this is for interacting with the Miden rollup). This fill will be the main file on crates.io for the miden-cli
crate.
crates/rust-client/Cargo.toml
Outdated
miden-lib = { package = "miden-lib", git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "next", default-features = false, features = ["testing"] } | ||
miden-objects = { package = "miden-objects", git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "next", default-features = false, features = ["serde", "testing"] } | ||
uuid = { version = "1.6", features = ["serde", "v4"] } | ||
miden-client = { path = ".", features = ["testing", "concurrent", "sqlite", "tonic", "tokio"]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: let's alphabetize this list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add the "License" section to this file.
crates/rust-client/README.md
Outdated
- `concurrent`: used to enable concurrency during execution and proof generation. | ||
- `testing`: useful feature that lowers PoW difficulty when enabled, meant to be used during development and not on production. | ||
- `sqlite`: includes `SqliteStore`, a SQLite implementation of the `Store` trait that can be used as a component of `Client`. | ||
- `async`: enables async traits. Disabled by default. | ||
- `tonic`: includes `TonicRpcClient`, a Tonic client to communicate with Miden node, that can be used as a component of `Client`. | ||
- `executable`: builds the CLI, based on `SqliteStore` and `TonicRpcClient`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have executable
feature any more, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch, we removed it and I forgot to delete it from the list
crates/rust-client/README.md
Outdated
By default, the library is `no_std` compatible. | ||
|
||
### Features |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would try to do something more similar to how we describe features in other places (e.g., here.
For example, I would name the section "Crate features", would describe how to use --no-default-features
flag etc.
crates/rust-client/src/lib.rs
Outdated
@@ -47,16 +53,16 @@ pub mod crypto { | |||
}, | |||
rand::{FeltRng, RpoRandomCoin}, | |||
}, | |||
Digest, | |||
Digest, ONE, ZERO, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would probably move ONE
and ZERO
exports to the root level (i.e., to line 60 below).
Co-authored-by: igamigo <ignacio.amigo@lambdaclass.com>
bin/miden-cli/Cargo.toml
Outdated
path = "src/main.rs" | ||
|
||
[features] | ||
default = ["dep:clap", "dep:comfy-table", "dep:figment", "dep:tokio", "dep:toml"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should be able to leave default
as empty, and remove optional dependencies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible that tonic files are not being generated? I tried deleting the crates/rust-client/src/client/rpc/tonic_client
directory and building and the files didn't get generated. Perhaps I'm missing something
we'll probably need to update the getting-started documentation in miden base.
edition.workspace = true | ||
|
||
[features] | ||
integration = ["miden-client/integration"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm. wondering if an integration
feature is necessary in the client still. We don't have to change it in this PR, but I'd try removing it and checking if integration tests are not being ran during make test
and the appropiate integration tests are being ran during make integration-test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we remove it we'll also need to update the readme
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should definitely be able to remove it on #411
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a comment referencing this change in the issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this PR has been merged already, but I left a few comments below. Would be good to address them in a follow-up PR.
These actions can also be executed when inside the repository via the Makefile with `make build` or `make install`. | ||
|
||
## License | ||
This project is [MIT licensed](./LICENSE). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this link is broken. Probably should refer to the parent directory.
@@ -0,0 +1,30 @@ | |||
# Miden Client CLI | |||
|
|||
This binary allows the user to interact with the Miden rollup via a simple command-line interface (CLI). It's a wrapper around the Miden client library exposing its functionality in order to create accounts, create and consume notes, all executed and proved using the Miden VM. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would make the "Miden client" reference in the second sentence a link to the miden-client
crate on crates.io.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to release it first as miden-client?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can put in the link now assuming it will be published at the time miden-cli
crate is published.
The `sqlite` and `tonic` features provide implementations for these traits using [Rusqlite](https://github.com/rusqlite/rusqlite) and [Tonic](https://github.com/hyperium/tonic) respectively. | ||
|
||
## License | ||
This project is [MIT licensed](./LICENSE). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this link is broken. Probably should refer to the parent directory.
pub use miden_objects::assets::{Asset, AssetVault, FungibleAsset, TokenSymbol}; | ||
} | ||
|
||
mod store_authenticator; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this line should probably be moved up to the top section of the file.
pub mod accounts; | ||
pub mod config; | ||
pub mod errors; | ||
pub(crate) mod note_screener; | ||
pub mod notes; | ||
pub mod rpc; | ||
pub mod store; | ||
pub mod sync; | ||
pub mod transactions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure any of these modules need to be pub
any more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We moved the re-exports to each of the relevant submodules so we should make them (the modules) public for them to be accesible. I'll try moving the re-exports back to lib.rs
and renaming the modules so that they dont cause conflicts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this and notes.rs
file go into src/notes
directory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would probably move this file into its own directory (i.e., src/sync/mod.rs
) and split it up into several files.
* refactor: split into workspace * Update CHANGELOG * refactor: separate directories for binaries and crates * feat: add workspace dependencies * refactor: enable integration tests as separate crate * fix: workspace features * fix: address suggestions * fix: makefile descriptions * fix: add build step before tests * fix: Integration tests * fix: Go back to next for integration tests * Change docs make target * fix: address suggestions for miden-cli Cargo.toml * fix: remove unnecessary exports in miden-client * fix: remove unnecessary dependency from tests * fix: remove patch versions from all dependencies * refactor: rename `miden-client` directory to `rust-client` * refactor: create `commands` sub-module for miden-cli * refactor: distribute sections of workspace README to the crate/bin * fix: add general workspace information and links to READMEs * fix: cli name in README Co-authored-by: igamigo <ignacio.amigo@lambdaclass.com> * fix: alphabetize dependencies in tests crate * fix: improve miden-cli README * fix: add more information about the rust-client features * refactor: remove `client` sub-module * fix: tonic generated file builder * fix: remove optional dependencies in cli --------- Co-authored-by: Ignacio Amigo <ignacio.amigo@lambdaclass.com>
* refactor: split into workspace * Update CHANGELOG * refactor: separate directories for binaries and crates * feat: add workspace dependencies * refactor: enable integration tests as separate crate * fix: workspace features * fix: address suggestions * fix: makefile descriptions * fix: add build step before tests * fix: Integration tests * fix: Go back to next for integration tests * Change docs make target * fix: address suggestions for miden-cli Cargo.toml * fix: remove unnecessary exports in miden-client * fix: remove unnecessary dependency from tests * fix: remove patch versions from all dependencies * refactor: rename `miden-client` directory to `rust-client` * refactor: create `commands` sub-module for miden-cli * refactor: distribute sections of workspace README to the crate/bin * fix: add general workspace information and links to READMEs * fix: cli name in README Co-authored-by: igamigo <ignacio.amigo@lambdaclass.com> * fix: alphabetize dependencies in tests crate * fix: improve miden-cli README * fix: add more information about the rust-client features * refactor: remove `client` sub-module * fix: tonic generated file builder * fix: remove optional dependencies in cli --------- Co-authored-by: Ignacio Amigo <ignacio.amigo@lambdaclass.com>
This PR restructures the repo to separate the client and cli in separate crates sharing a workspace.