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

feat: cbindings - allowing libwaku.so (dynamic) library #1730

Merged
merged 1 commit into from
May 19, 2023

Conversation

Ivansete-status
Copy link
Collaborator

@Ivansete-status Ivansete-status commented May 15, 2023

Description

This PR aims for adding the option to create a dynamic linking library (libwaku.so.)

To change the type of library just pass STATIC=true to the Makefile command, and it will generate a libwaku.a. If nothing is passed, it builds dynamic library by default.

How to use it

Create cwaku_example

  1. To generate a static library (libwaku.a) and cwaku_example binary with the libwaku embbeded into it:
    make cwaku_example STATIC=true -j8
  2. To generate a dynamic library (libwaku.so) and cwaku_example binary with the libwaku embbeded into it:
    make cwaku_example -j8

Generate the library itself:

  1. dynamic library: make libwaku -j8.
    `-> produces: build/libwaku.so
  2. static library: make libwaku STATIC=true -j8
    `-> produces: build/libwaku.a

Issue

#1632

@Ivansete-status Ivansete-status changed the title feat(cbindings) allowing libwaku.so (dynamic) library and setupNat reorganization for libwaku feat: cbindings - allowing libwaku.so (dynamic) library and setupNat reorganization for libwaku May 15, 2023
@vpavlin
Copy link
Member

vpavlin commented May 15, 2023

Do you know why is the confutils imported in the nat.nim? It seems like a pretty low-level library? Would it make sense to take a look at that and try to remove the dependency on confutils (if possible/feasible), rather than copy over the file?

@Ivansete-status
Copy link
Collaborator Author

Do you know why is the confutils imported in the nat.nim? It seems like a pretty low-level library? Would it make sense to take a look at that and try to remove the dependency on confutils (if possible/feasible), rather than copy over the file?

Yes, it imports confutils because the ConfigurationError is used in the next proc:
https://github.com/status-im/nim-eth/blob/72c98589278aec949c13435d9bcacdb306faa5a8/eth/net/nat.nim#L326

Actually, I think the parseCmdArg should be out of the nat.nim's responsability. I don't know if we can modify this eth/net/nat.nim ourselves.

@vpavlin
Copy link
Member

vpavlin commented May 15, 2023

Well, I meant to contribute to the nim-eth repository and then update the dependency if/when they merge it - It's fine to keep the file around until that happens with a note and a link to the upstream PR/issue.

But up to you, I am just not a big fan of keeping copied files from external repositories around:) Makes maintenance harder in case of security issues in dependencies etc.

Or at least file an issue on nim-eth asking if it is possible for them to remove the dependency by moving the parseCmdArg outside of nat.nim and see what they say?:)

@Ivansete-status
Copy link
Collaborator Author

Well, I meant to contribute to the nim-eth repository and then update the dependency if/when they merge it - It's fine to keep the file around until that happens with a note and a link to the upstream PR/issue.

But up to you, I am just not a big fan of keeping copied files from external repositories around:) Makes maintenance harder in case of security issues in dependencies etc.

Or at least file an issue on nim-eth asking if it is possible for them to remove the dependency by moving the parseCmdArg outside of nat.nim and see what they say?:)

I absolutely agree mate. I don't like either that so I will raise an issue for them and see what they say :)

@Ivansete-status
Copy link
Collaborator Author

Hi @vpavlin, I've created the next PR but I can't add reviewers into it.
status-im/nim-eth#609

@vpavlin
Copy link
Member

vpavlin commented May 15, 2023

Awesome!

@jm-clius
Copy link
Contributor

In order to help the review, perhaps it's a good idea to split the nat changes to a separate PR first? What changes were introduced from the original eth/net/nat other than not importing confutils? It seems e.g. that we've added a Result rather than raise exceptions, which is a good change IMO.

Also, I assume there's no way we can create a wrapper for the nim-eth nat module that reuses some of the functionality rather than rewrite everything (I haven't checked how widely the imported ConfigurationError is used)?

@vpavlin
Copy link
Member

vpavlin commented May 15, 2023

I believe the only real solution is to get this fixed upstream (i.e. in the dependency), but I agree that to unblock this PR until upstream fixed, very clean and explicit changes to the forked nat.nim are necessary.

@Ivansete-status
Copy link
Collaborator Author

Following @jm-clius's advise, please take first a look at the next PR. Once it is merged I will make this one simpler :)
#1740
Thanks!

@Ivansete-status Ivansete-status self-assigned this May 17, 2023
@jm-clius
Copy link
Contributor

@Ivansete-status Good idea to convert PRs like this one to "Draft" while it's not ready to be merged.

@Ivansete-status
Copy link
Collaborator Author

Morning all!
Thanks for the comments so far @vpavlin , @jm-clius!
That can be re-reviewed again when you have some time :)

@Ivansete-status Ivansete-status changed the title feat: cbindings - allowing libwaku.so (dynamic) library and setupNat reorganization for libwaku feat: cbindings - allowing libwaku.so (dynamic) library May 18, 2023
Copy link
Contributor

@jm-clius jm-clius left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

Copy link
Member

@vpavlin vpavlin left a comment

Choose a reason for hiding this comment

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

THis looks way cleaner:) Thanks! LGTM

@Ivansete-status Ivansete-status merged commit d0aa388 into master May 19, 2023
@Ivansete-status Ivansete-status deleted the feat-1632-cbindings-relay branch May 19, 2023 06:20
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