-
Notifications
You must be signed in to change notification settings - Fork 34
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: library api reorganization #367
Conversation
90bc912
to
40b6cf4
Compare
82bbe7f
to
6c323cb
Compare
The changes in |
6c323cb
to
ff56c79
Compare
done! Rebased and pushed |
1f96117
to
52d1ac7
Compare
The fixes can be separated into 2: - compilation errors (most of them were because the old `Account::new` became `Account::from_parts` and the addition of `OutputNote::Partial` which needed to be handled in some pattern matchings. - start storing the partial output notes (currently being discarded), this also came with small refactors.
1f96117
to
5a4091c
Compare
8e2e258
to
95c1f97
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.
Looks good! Thank you! I left some comments inline. Also, a few comments about the errors
module:
IdPrefixFetchError
seems like CLI-specific error. I think we should remove it from the public library interface.InvalidNoteInputsError
seems like an internal-only error which doesn't appear in the public interface. If so, we should hide it (e.g., usepub(crate)
).- Should we rename
NodeRpcClientError
into justRpcError
? I think having wordsNode
andClient
there is making things more confusing. - We should probably rename
ScreenerError
intoNoteScreenerError
.
In general, I'm wondering if we need this module at all or maybe we should just move (or just re-export) error types into relevant modules (e.g., RPC error would be in the rpc
module).
While it does not appear in the public interface directly, it is used in 1 warning: type `InvalidNoteInputsError` is more private than the item `NoteScreenerE
rror::InvalidNoteInputsError::0`
--> src/errors.rs:398:28
|
398 | InvalidNoteInputsError(InvalidNoteInputsError),
| ^^^^^^^^^^^^^^^^^^^^^^ field `NoteScreenerError::Inva
lidNoteInputsError::0` is reachable at visibility `pub`
|
note: but type `InvalidNoteInputsError` is only usable at visibility `pub(crate)`
--> src/errors.rs:428:1
|
428 | pub(crate) enum InvalidNoteInputsError {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: `#[warn(private_interfaces)]` on by default |
Ah - I see! Let's keep it as is then. |
This allows implementors of other kinds of store to specify their own configuration, provided they implement `Default` and serialization/deserialization traits.
…lient into mFragaBA-library-api-reorganization
…/miden-client into mFragaBA-next-0.4
…lient into mFragaBA-library-api-reorganization
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/questions inline (in addition to the ones above). But overall, I think this is good to be merged.
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 one small comment regarding the config file - but other than that, I think this PR can be merged.
* feat: point to miden base's next and fix errors The fixes can be separated into 2: - compilation errors (most of them were because the old `Account::new` became `Account::from_parts` and the addition of `OutputNote::Partial` which needed to be handled in some pattern matchings. - start storing the partial output notes (currently being discarded), this also came with small refactors. * fix: point node to custom branch on integration tests also * fix: filter out partial notes * fix: only store in scripts table if output note record has a script * fix: add new storage type to node config file from #365 * fix: pull from custom branch instead of main * Update the `TransactionAuthenticator` imports * Remove duplicate `get_falcon_signature` * fix: update note script root hashes * refactor: flatten refactors * refactor: make `StoreConfig` an associated type of the `Store` trait. This allows implementors of other kinds of store to specify their own configuration, provided they implement `Default` and serialization/deserialization traits. * refactor: put sqlite store behind feature flag * refactor: put tonic rpc client behind a feature flag * refactor: make concurrent feature imply std * refactor: remove tests in cli module files - we remove some tests that got duplicated during the refactor of the CLI - the remaining tests will be moved into the integration tests added in #353 * refactor: invert dependency between ClientConfig and CliConfig and move CliConfig to CLI binary. * refactor: stop exposing optional dependencies as features * fix: fix compilation errors after rebase * fix CHANGELOG * address some review comments * refactor: rename error types * refactor: remove old client config struct * feat: point to miden base's next and fix errors The fixes can be separated into 2: - compilation errors (most of them were because the old `Account::new` became `Account::from_parts` and the addition of `OutputNote::Partial` which needed to be handled in some pattern matchings. - start storing the partial output notes (currently being discarded), this also came with small refactors. * fix: point node to custom branch on integration tests also * fix: filter out partial notes * fix: only store in scripts table if output note record has a script * fix: add new storage type to node config file from #365 * fix: pull from custom branch instead of main * Update the `TransactionAuthenticator` imports * Remove duplicate `get_falcon_signature` * fix: update note script root hashes * Use `&mut rng` for note creation in transactions * Fix usage of new `InputNote` * fix: fix after rebase * feat: point to miden base's next and fix errors The fixes can be separated into 2: - compilation errors (most of them were because the old `Account::new` became `Account::from_parts` and the addition of `OutputNote::Partial` which needed to be handled in some pattern matchings. - start storing the partial output notes (currently being discarded), this also came with small refactors. * fix: filter out partial notes * fix: only store in scripts table if output note record has a script * fix: add new storage type to node config file from #365 * Update the `TransactionAuthenticator` imports * Remove duplicate `get_falcon_signature` * fix: update note script root hashes * Use `&mut rng` for note creation in transactions * Fix usage of new `InputNote` * fix: fix after rebase * cargo: point to node's next branch * Change node ref * test: avoid reruns on genesis cli tests test will fail on retry anyways since the genesis account stays is the same every time. * add looser sleep times to ensure blocks are included * test: add helper to wait until notes get committed/consumed * test: add helper to wait until notes get committed/consumed * deps: point to miden-node's next branch and fix compilation errors * Test transaction ordering * make: remove dependency for node to avoid duplication on CI * Rollback node branch * fix: fix breaking change from base * fix: update swap note script root * feat: point to miden base's next and fix errors The fixes can be separated into 2: - compilation errors (most of them were because the old `Account::new` became `Account::from_parts` and the addition of `OutputNote::Partial` which needed to be handled in some pattern matchings. - start storing the partial output notes (currently being discarded), this also came with small refactors. * fix: filter out partial notes * fix: only store in scripts table if output note record has a script * fix: add new storage type to node config file from #365 * Update the `TransactionAuthenticator` imports * Remove duplicate `get_falcon_signature` * fix: update note script root hashes * Use `&mut rng` for note creation in transactions * Fix usage of new `InputNote` * fix: fix after rebase * cargo: point to node's next branch * Change node ref * test: avoid reruns on genesis cli tests test will fail on retry anyways since the genesis account stays is the same every time. * add looser sleep times to ensure blocks are included * test: add helper to wait until notes get committed/consumed * deps: point to miden-node's next branch and fix compilation errors * Test transaction ordering * Rollback node branch * make: remove dependency for node to avoid duplication on CI * fix: fix breaking change from base * fix: update swap note script root * fix: add new aux field to updated note creation functions from base * chore: increment crate version to v0.3.1 * Handle aux parameter * MASM fix * Correct script root * Update CHANGELOG.md for WASM changes * Aux param on custom note * Remove wasm feature in favor of being compatible by default * Clean up testing targets * Clean up lint targets * Fix typo * Undo async call in CLI * Update Cargo.toml * Undo async call in CLI * Cargo fmt * Remove getrandom * Re-add getrandom, but under asyhnc * Reviews --------- Co-authored-by: tomyrd <[email protected]> Co-authored-by: Ignacio Amigo <[email protected]> Co-authored-by: Bobbin Threadbare <[email protected]>
closes #362.
closes #284.
I tried to have each commit as self contained as possible:
StoreConfig
an associated type ofStore
. This allows the consumers of the library to re-use theClientConfig
struct when providing their own store implementation. Not only that but we expect it to satisfy a few trait bounds (usually they can be derived) such asDebug
,Default
,Eq
,PartialEq
,Serialize
,DeserializeOwned
.std
in base so we should add it here as well to be explicit about it.uuid
andtest_utils
. This comes at a bit of a cost. Unless we're on unit tests of the client, we can't use anything under#[cfg(test)]
because in those cases (like the CLI and integration tests) the client gets compiled but not in test mode. I couldn't find a built in way to do so and the workaround is what we had withtest_utils
which is to define a custom feature flag, but the problem is that it cannot be hidden. In order to removeuuid
andtest_utils
I also had to remove some tests fromsrc/cli/...
, but considering we're adding very similar tests on feat: add CLI integration tests using assert_cmd #353 it's not a big deal.CliConfig
frommiden_client
. The way to do so was by inverting the dependency between it and theClientConfig
struct. So we go from "AClientConfig
can have aCliConfig
defined" to "AllCliConfig
has aClientConfig
defined"rusqlite
andrusqlite_migration
as features by prepending them with adep:
onCargo.toml
Discussion