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

Replace lazy_static dependency in chain crate with once_cell #220

Merged

Conversation

philmartin2525
Copy link
Contributor

@philmartin2525 philmartin2525 commented Jan 21, 2022

Addresses #213

This PR replaces usage of the lazy_static! macro with the once_cell::sync::Lazy type. This accomplishes the same goals as lazy_static! by lazily initializing global data. once_cell has the following advantages over lazy_static:

Other comparisons between the two libraries

  • All-time downloads (according to crates.io):
  • Github contributors/stars

dr-orlovsky
dr-orlovsky previously approved these changes Jan 21, 2022
Copy link
Member

@dr-orlovsky dr-orlovsky left a comment

Choose a reason for hiding this comment

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

Thank you for this proposal! BTW it does not closes #213, since the idea was not to use any form of static and try to convert that into a constant expressions (I didn't wrote that in the description of the issue, sorry). It was not that lazy_static is bad, it is just we would like to reduce the size of dependency tree - and "frequently updated" sounds a bit scary for a project that aims ossification (as a client-side-validated library).

Nevertheless this is a clear improvement over what we have now. Especially I like the part that once_cell is going to become a part of the rust itself and with time we will be able to remove this from the dependencies.

Will merge once CI will finish running.

@dr-orlovsky
Copy link
Member

Sorry, it seems it requires reformatting + rebase on the master (according to the merge policy of the repo). Can you do it please?

@codecov
Copy link

codecov bot commented Jan 21, 2022

Codecov Report

Merging #220 (0617fcc) into master (64d727f) will increase coverage by 1.6%.
The diff coverage is 87.5%.

❗ Current head 0617fcc differs from pull request most recent head d6e621a. Consider uploading reports for the commit d6e621a to get more accurate results
Impacted file tree graph

@@           Coverage Diff            @@
##           master    #220     +/-   ##
========================================
+ Coverage    68.4%   70.0%   +1.6%     
========================================
  Files           5       5             
  Lines        1273    1226     -47     
========================================
- Hits          871     858     -13     
+ Misses        402     368     -34     
Impacted Files Coverage Δ
chain/src/lib.rs 87.7% <87.5%> (+0.1%) ⬆️
src/lib.rs 35.1% <0.0%> (-12.1%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 64d727f...d6e621a. Read the comment docs.

@philmartin2525
Copy link
Contributor Author

I updated the description to indicate this doesn't satisfy #213 . Next time I will get clarification.

I will check the formatting and other issues.

@philmartin2525
Copy link
Contributor Author

The formatting error should be fixed with the latest commit:

  • cargo fmt --all -- --check passed locally
  • cargo clippy --workspace --all-features failed in the CI checks, fails locally with latest commit, as does the latest master branch

As for rebasing onto master, the output of rebase is Current branch replace-lazy-static-with-once-cell is up to date. Am I missing something about the merge policy?

@philmartin2525 philmartin2525 force-pushed the replace-lazy-static-with-once-cell branch from aedfdec to 0617fcc Compare January 21, 2022 08:47
@philmartin2525
Copy link
Contributor Author

As for rebasing onto master, the output of rebase is Current branch replace-lazy-static-with-once-cell is up to date. Am I missing something about the merge policy?

I see what you mean now. I was pulling from the wrong remote. It should be cleanly rebased now.

@dr-orlovsky dr-orlovsky added the dependency Problem/bug caused by broken dependency label Jan 31, 2022
@dr-orlovsky dr-orlovsky merged commit f5d3725 into LNP-BP:master Jan 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependency Problem/bug caused by broken dependency
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants