Skip to content
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

Merged
merged 28 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
6f5d782
refactor: split into workspace
tomyrd Jun 28, 2024
83421cc
Update CHANGELOG
tomyrd Jun 28, 2024
6b37542
refactor: separate directories for binaries and crates
tomyrd Jun 28, 2024
4e07a0c
feat: add workspace dependencies
tomyrd Jun 28, 2024
8b5a8ec
refactor: enable integration tests as separate crate
tomyrd Jun 28, 2024
49ad991
fix: workspace features
tomyrd Jun 28, 2024
19fb973
fix: address suggestions
tomyrd Jun 28, 2024
c9a763c
fix: makefile descriptions
tomyrd Jun 28, 2024
6349fd6
fix: add build step before tests
tomyrd Jun 28, 2024
f715555
Rebase
igamigo Jun 30, 2024
23c8ede
fix: Integration tests
igamigo Jun 30, 2024
1131acf
fix: Go back to next for integration tests
igamigo Jul 1, 2024
6aaa2f9
Change docs make target
igamigo Jul 1, 2024
256128b
fix: address suggestions for miden-cli Cargo.toml
tomyrd Jul 1, 2024
a6d4a63
fix: remove unnecessary exports in miden-client
tomyrd Jul 1, 2024
be199e2
fix: remove unnecessary dependency from tests
tomyrd Jul 1, 2024
9183699
fix: remove patch versions from all dependencies
tomyrd Jul 1, 2024
72a1619
refactor: rename `miden-client` directory to `rust-client`
tomyrd Jul 1, 2024
a9661b9
refactor: create `commands` sub-module for miden-cli
tomyrd Jul 1, 2024
dacf7a6
refactor: distribute sections of workspace README to the crate/bin
tomyrd Jul 1, 2024
49b2c6e
fix: add general workspace information and links to READMEs
tomyrd Jul 1, 2024
44b268b
fix: cli name in README
tomyrd Jul 1, 2024
6a44628
fix: alphabetize dependencies in tests crate
tomyrd Jul 1, 2024
76e35e7
fix: improve miden-cli README
tomyrd Jul 1, 2024
e844b0d
fix: add more information about the rust-client features
tomyrd Jul 1, 2024
b8520ae
refactor: remove `client` sub-module
tomyrd Jul 1, 2024
afd268a
fix: tonic generated file builder
tomyrd Jul 2, 2024
c73d780
fix: remove optional dependencies in cli
tomyrd Jul 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Changelog

* Split cli and client into workspace (#407).
* Note importing in client now uses the `NoteFile` type (#375).
* Added build script to import Miden node protobuf files to generate types for `tonic_client` and removed `miden-node-proto` dependency (#395).
* Implemented retrieval of executed transaction info (id, commit height, account_id) from sync state RPC endpoint (#387).
Expand Down
90 changes: 15 additions & 75 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,80 +1,20 @@
[package]
name = "miden-client"
version = "0.3.1"
description = "Client library that facilitates interaction with the Miden rollup"
authors = ["miden contributors"]
readme = "README.md"
license = "MIT"
repository = "https://github.com/0xPolygonMiden/miden-client"
documentation = "https://docs.rs/miden-client/0.3.1"
keywords = ["miden", "client"]
edition = "2021"
rust-version = "1.78"
default-run = "miden"

[lib]
crate-type = ["lib"]
[workspace]
resolver = "2"

[[bin]]
name = "miden"
path = "src/main.rs"
required-features = ["executable"]
members = [
"bin/miden-cli",
"crates/miden-client",
"tests"
]

[[test]]
name = "integration"
path = "tests/integration/main.rs"
required-features = ["integration"]

[features]
async = ["miden-tx/async"]
concurrent = ["miden-lib/concurrent", "miden-objects/concurrent", "miden-tx/concurrent", "std"]
default = ["std"]
executable = ["std", "sqlite", "tonic", "dep:clap", "dep:comfy-table", "dep:figment", "dep:tokio", "dep:toml"]
integration = ["concurrent", "executable", "testing"]
sqlite = ["dep:rusqlite", "dep:rusqlite_migration", "dep:lazy_static"]
std = ["miden-objects/std"]
testing = ["miden-objects/testing", "miden-lib/testing"]
tonic = ["dep:hex", "dep:prost","dep:tonic"]
[workspace.package]
edition = "2021"
rust-version = "1.78"
license = "MIT"
authors = ["miden contributors"]
repository = "https://github.com/0xPolygonMiden/miden-client"

[dependencies]
chrono = { version = "0.4", optional = false }
clap = { version = "4.3", features = ["derive"], optional = true }
comfy-table = { version = "7.1.0", optional = true }
figment = { version = "0.10", features = ["toml", "env"], optional = true }
hex = { version = "0.4" , optional = true}
lazy_static = { version = "1.4.0", optional = true }
miden-lib = { package = "miden-lib", git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "next", default-features = false }
miden-tx = { package = "miden-tx", git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "next", default-features = false }
miden-objects = { package = "miden-objects", git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "next", default-features = false, features = ["serde"] }
prost = { version = "0.12", optional = true }
[workspace.dependencies]
rand = { version = "0.8.5" }
rusqlite = { version = "0.30.0", features = ["vtab", "array", "bundled"], optional = true }
rusqlite_migration = { version = "1.0", optional = true }
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0", features = ["raw_value"] }
tokio = { version = "1.29", features = ["rt-multi-thread", "net", "macros"], optional = true }
tonic = { version = "0.11", optional = true }
toml = { version = "0.8", optional = true }
thiserror = { version = "1.0", optional = true }
tokio = { version = "1.29", features = ["rt-multi-thread", "net", "macros"] }
tracing = { version = "0.1" }
tracing-subscriber = { version = "0.3" }
winter-maybe-async = "0.10.0"

[target.'wasm32-unknown-unknown'.dependencies]
getrandom = { version = "0.2", features = ["js"] }

[dev-dependencies]
# To enable testing feature during tests
assert_cmd = { version = "2.0" }
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"] }
proptest = { version = "1.2" }
uuid = { version = "1.6.1", features = ["serde", "v4"] }

[build-dependencies]
miden-rpc-proto = { package = "miden-rpc-proto", git = "https://github.com/0xPolygonMiden/miden-node.git", branch = "next" }
miette = { version = "7.0", features = ["fancy"] }
prost = { version = "0.12" }
prost-build = { version = "0.12" }
protox = { version = "0.6" }
tonic-build = { version = "0.11" }
2 changes: 1 addition & 1 deletion Makefile
mFragaBA marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ start-node: ## Run node. This requires the node repo to be present at `miden-nod
# --- Installing ----------------------------------------------------------------------------------

install: ## Installs the CLI binary using the current dir
cargo install --features $(FEATURES_CLI) --path .
cargo install --path miden-cli

# --- Building ------------------------------------------------------------------------------------

Expand Down
35 changes: 35 additions & 0 deletions bin/miden-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[package]
name = "miden-client-cli"
bobbinth marked this conversation as resolved.
Show resolved Hide resolved
version = "0.3.1"
description = "CLI binary application that facilitates interaction with the Miden rollup"
readme = "README.md"
documentation = "https://docs.rs/miden-client/0.3.1"
bobbinth marked this conversation as resolved.
Show resolved Hide resolved
keywords = ["miden", "client"]
bobbinth marked this conversation as resolved.
Show resolved Hide resolved
license.workspace = true
authors.workspace = true
repository.workspace = true
rust-version.workspace = true
edition.workspace = true

[[bin]]
name = "miden"
path = "src/main.rs"

[features]
default = ["dep:clap", "dep:comfy-table", "dep:figment", "dep:tokio", "dep:toml"]
igamigo marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Collaborator

@igamigo igamigo Jul 2, 2024

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.


[dependencies]
clap = { version = "4.3", features = ["derive"], optional = true }
comfy-table = { version = "7.1.0", optional = true }
figment = { version = "0.10", features = ["toml", "env"], optional = true }
miden-client = { path = "../../crates/miden-client", features = ["sqlite", "tonic", "testing", "concurrent"] }
miden-tx = { package = "miden-tx", git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "next", default-features = false }
miden-objects = { package = "miden-objects", git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "next", default-features = false, features = ["serde"] }
bobbinth marked this conversation as resolved.
Show resolved Hide resolved
rand = { version = "0.8.5" }
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0", features = ["raw_value"] }
tokio = { version = "1.29", features = ["rt-multi-thread", "net", "macros"], optional = true }
tonic = { version = "0.11", optional = true }
toml = { version = "0.8", optional = true }
tracing = { version = "0.1" }
tracing-subscriber = { version = "0.3" }
bobbinth marked this conversation as resolved.
Show resolved Hide resolved
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
bobbinth marked this conversation as resolved.
Show resolved Hide resolved
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
15 changes: 15 additions & 0 deletions bin/miden-cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
extern crate alloc;

mod cli;

#[tokio::main]
async fn main() -> Result<(), String> {
use clap::Parser;

tracing_subscriber::fmt::init();
// read command-line args
let cli = cli::Cli::parse();

// execute cli action
cli.execute().await
}
62 changes: 62 additions & 0 deletions crates/miden-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
[package]
name = "miden-client"
version = "0.3.1"
description = "Client library that facilitates interaction with the Miden rollup"
readme = "README.md"
documentation = "https://docs.rs/miden-client/0.3.1"
keywords = ["miden", "client"]
license.workspace = true
authors.workspace = true
repository.workspace = true
rust-version.workspace = true
edition.workspace = true

[lib]
crate-type = ["lib"]

[features]
async = ["miden-tx/async"]
concurrent = ["miden-lib/concurrent", "miden-objects/concurrent", "miden-tx/concurrent", "std"]
default = ["std"]
executable = ["std", "sqlite", "tonic", "dep:tokio"]
integration = ["concurrent", "executable", "testing"]
sqlite = ["dep:rusqlite", "dep:rusqlite_migration", "dep:lazy_static"]
std = ["miden-objects/std"]
testing = ["miden-objects/testing", "miden-lib/testing"]
tonic = ["dep:hex", "dep:prost","dep:tonic"]

[dependencies]
chrono = { version = "0.4", optional = false }
hex = { version = "0.4" , optional = true}
lazy_static = { version = "1.4.0", optional = true }
miden-lib = { package = "miden-lib", git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "next", default-features = false }
miden-tx = { package = "miden-tx", git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "next", default-features = false }
miden-objects = { package = "miden-objects", git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "next", default-features = false, features = ["serde"] }
prost = { version = "0.12", optional = true }
rand = { workspace = true }
rusqlite = { version = "0.30.0", features = ["vtab", "array", "bundled"], optional = true }
rusqlite_migration = { version = "1.0", optional = true }
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0", features = ["raw_value"] }
tokio = { workspace = true , optional = true }
tonic = { version = "0.11", optional = true }
thiserror = { version = "1.0", optional = true }
tracing = { workspace = true }
winter-maybe-async = "0.10.0"

[target.'wasm32-unknown-unknown'.dependencies]
getrandom = { version = "0.2", features = ["js"] }

[dev-dependencies]
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"] }
proptest = { version = "1.2" }
mFragaBA marked this conversation as resolved.
Show resolved Hide resolved
uuid = { version = "1.6.1", features = ["serde", "v4"] }

[build-dependencies]
miden-rpc-proto = { package = "miden-rpc-proto", git = "https://github.com/0xPolygonMiden/miden-node.git", branch = "next" }
miette = { version = "7.0", features = ["fancy"] }
prost = { version = "0.12" }
prost-build = { version = "0.12" }
protox = { version = "0.6" }
tonic-build = { version = "0.11" }
File renamed without changes.
Copy link
Contributor

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.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use clap::error::Result;
use miden_lib::transaction::TransactionKernel;
use miden_objects::{
accounts::{Account, AccountCode, AccountId, AccountStorage, AccountStub, AuthSecretKey},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use alloc::{collections::BTreeMap, rc::Rc};
use std::num::NonZeroUsize;

use clap::error::Result;
use miden_objects::{
crypto::merkle::{InOrderIndex, MmrPeaks},
BlockHeader, Digest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ impl Store for SqliteStore {
fn get_unspent_input_note_nullifiers(&self) -> Result<Vec<Nullifier>, StoreError> {
self.get_unspent_input_note_nullifiers()
}

fn update_note_inclusion_proof(
&self,
note_id: miden_objects::notes::NoteId,
Expand All @@ -277,7 +278,7 @@ impl Store for SqliteStore {
&self,
note_id: miden_objects::notes::NoteId,
metadata: miden_objects::notes::NoteMetadata,
) -> clap::error::Result<(), StoreError> {
) -> Result<(), StoreError> {
self.update_note_metadata(note_id, metadata)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use alloc::rc::Rc;
use std::fmt;

use chrono::Utc;
use clap::error::Result;
use miden_objects::{
accounts::AccountId,
crypto::utils::{Deserializable, Serializable},
Expand Down
File renamed without changes.
18 changes: 0 additions & 18 deletions src/main.rs

This file was deleted.

25 changes: 25 additions & 0 deletions tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[package]
name = "miden-client-tests"
version = "0.3.1"
description = "Integration Tests for the miden client library and CLI"
readme = "README.md"
publish = false
license.workspace = true
authors.workspace = true
repository.workspace = true
rust-version.workspace = true
edition.workspace = true

[dev-dependencies]
figment = { version = "0.10", features = ["toml", "env"] }
miden-client = { path = "../crates/miden-client", features = ["executable", "testing"] }
miden-tx = { package = "miden-tx", git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "next", default-features = false }
miden-objects = { package = "miden-objects", git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "next", default-features = false, features = ["serde"] }
bobbinth marked this conversation as resolved.
Show resolved Hide resolved
assert_cmd = { version = "2.0" }
Copy link
Contributor

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.

uuid = { version = "1.6.1", features = ["serde", "v4"] }
rand = { workspace = true }
tokio = { workspace = true }

[[test]]
name = "integration"
path = "integration/main.rs"
Loading