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

Introduce cashu to host the shared types, traits and other common code #519

Merged
merged 15 commits into from
Jan 12, 2025

Conversation

crodas
Copy link
Contributor

@crodas crodas commented Dec 31, 2024

Description

Introduce a new crate, cdk-common, to host all the shared types and common functions and allow extensibility without having to include the cdk to avoid circular dependencies.

No major refactor has been done; only code has been moved to this new crate.

This will allow significant extensibility, making PRs like #509 and other similar initiatives much cleaner and easier to implement.


Suggested CHANGELOG Updates

CHANGED

Introduced cdk-common, a new internal crate to host all shared types, traits, and common functions to extend the cdk without having to depend on it.

ADDED

REMOVED

FIXED


Checklist

@crodas crodas changed the title Feature/cdk common Introduce cdk-common to host the shared types, traits and other common code Jan 2, 2025
Copy link
Collaborator

@thesimplekid thesimplekid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR, it makes sense to split this up.

Just left a few comments/questions.

More generally we have the option of naming cdk_common cashu and using the cashu name space on crates.io do you think that makes more sense then cdk_common? Just a naming thing really, but as what is called cdk_common in this PR is the basics of the cashu protocol I think it makes sense.

@crodas
Copy link
Contributor Author

crodas commented Jan 3, 2025

More generally we have the option of naming cdk_common cashu and using the cashu name space on crates.io do you think that makes more sense then cdk_common? Just a naming thing really, but as what is called cdk_common in this PR is the basics of the cashu protocol I think it makes sense.

I'll rename it to cashu

@crodas crodas force-pushed the feature/cdk-common branch from 5f5ec1e to cf0f99f Compare January 3, 2025 17:34
@crodas crodas changed the title Introduce cdk-common to host the shared types, traits and other common code Introduce cashu to host the shared types, traits and other common code Jan 3, 2025
@thesimplekid
Copy link
Collaborator

I can do this so just as a reminder to myself.

  • Add cashu crate to ci.

@crodas crodas force-pushed the feature/cdk-common branch from 2a4e598 to 1b95398 Compare January 6, 2025 13:14
@ok300
Copy link
Contributor

ok300 commented Jan 7, 2025

do you think cashu makes more sense then cdk_common?

Isn't that misleading?

The name gives no hint that it's a commons package for the CDK. Also, nobody will be able to use it without the CDK, as the structs and utils in it are "glue" for the other logic implented in the CDK mint and wallet.

For example, the bdk crate contains the actual BDK SDK, so it can be used on its own.

IMO cdk_common is more appropriate, as its only meant for CDK to use internally.

@ok300
Copy link
Contributor

ok300 commented Jan 7, 2025

Side note: I find it curious that the PR is extracting common code, i.e. moving code or removing duplicates, and yet the diff is +1,326 −743. I didn't review in detail, but I think I saw a bunch of new things like signatory.rs.

Maybe it makes sense to add the new things in a separate PR on top of this, and keep this exclusively about consolidating existing code into the commons crate? Would make reviews easier. What do you guys think?

@crodas
Copy link
Contributor Author

crodas commented Jan 7, 2025

@ok300 I need to rebase better, but all the signatory code is from #509

@crodas
Copy link
Contributor Author

crodas commented Jan 7, 2025

I'll remove the signatory bits now and I'll add the features flags /cc @thesimplekid

crodas and others added 6 commits January 7, 2025 22:05
- Created a new internal crate, `cdk-common`, to centralize shared types and
  trait definitions.
- The goal is to enable CDK extensions without requiring CDK as a direct
  dependency.
Co-authored-by: thesimplekid <tsk@thesimplekid.com>
@crodas crodas force-pushed the feature/cdk-common branch 3 times, most recently from 3cbad5e to ec3abfb Compare January 9, 2025 15:52
The `cashu` crates have all the types belonging to the protocol, allowing
anyone to implement a compatible Cashu server if they so wish.

The `cdk-common` has all the common types needed in the cdk and their
sub-crates
@crodas crodas force-pushed the feature/cdk-common branch from ec3abfb to 76755c5 Compare January 9, 2025 17:16
@crodas crodas force-pushed the feature/cdk-common branch from 053feef to e5f97f3 Compare January 10, 2025 01:58
@crodas
Copy link
Contributor Author

crodas commented Jan 10, 2025

@thesimplekid this is ready for review now

Copy link
Collaborator

@thesimplekid thesimplekid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updates the ci to include the new crates and some structs behind feature flags that are only needed for one of the feature.

@thesimplekid
Copy link
Collaborator

do you think cashu makes more sense then cdk_common?

Isn't that misleading?

The name gives no hint that it's a commons package for the CDK. Also, nobody will be able to use it without the CDK, as the structs and utils in it are "glue" for the other logic implented in the CDK mint and wallet.

For example, the bdk crate contains the actual BDK SDK, so it can be used on its own.

IMO cdk_common is more appropriate, as its only meant for CDK to use internally.

I think splitting it into cash and cdk-common addresses this concern. The cashu crate can be used without cdk it is just the core structs and functions that are defined in the spec. Someone could us this if they do not want a full cdk wallet or mint and only want to implement part of the protocol. Having this crate small and only what is defined in the spec also makes it easier to make it nostd so that it could be used on embedded devices. Then cdk-common is the cdk specific stuff that is not defined in the protocol (db traits, ln trait etc) but is used across cdk crates.

I think this is similar to rust-bitcoin and bdk split, just in a mono repo.

@crodas crodas force-pushed the feature/cdk-common branch from ac622d8 to a3f8add Compare January 11, 2025 14:16
Copy link
Collaborator

@thesimplekid thesimplekid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 94a4c87

@thesimplekid thesimplekid merged commit 8fe0982 into cashubtc:main Jan 12, 2025
59 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants