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

Create test to catch duplicate dependencies #1582

Closed
20 tasks
yaahc opened this issue Jan 12, 2021 · 14 comments
Closed
20 tasks

Create test to catch duplicate dependencies #1582

yaahc opened this issue Jan 12, 2021 · 14 comments
Labels
A-rust Area: Updates to Rust code C-enhancement Category: This is an improvement E-help-wanted Call for participation: Help is requested to fix this issue. good first issue

Comments

@yaahc
Copy link
Contributor

yaahc commented Jan 12, 2021

Is your feature request related to a problem? Please describe.

Recently we found a regression in our metrics system in zebrad. The issue ended up being that we'd accidentally duplicated the metrics dependency during a recent refactor. The crates on the old version would silently fail to access the exporter when reporting metrics because the variable containing the exporter was duplicated in each version, and only the newer version's global exporter had been initialized.

Describe the solution you'd like

We've already fixed this problem in #1561 but we'd like to prevent this from happening again in the future. The plan is to use guppy to write a test/lint to catch and report duplicated dependencies are part of our CI process. The author @sunshowers helpfully already pointed me to where they've already implemented this lint for their work codebase (link).

We should more or less vendor this lint into our codebase. If possible we'd also like to do so in a way that is reusable so that other rust projects can utilize this same lint easily.

Design / Mentorship Instructions

TBD

I still need to talk some more with Rain about the design for the reusable version of diem/guppy.rs. My expectation is that it would look similar to clippy, but Rain has thought much more about this than I have so I want to get my ducks in a row before I commit to writing out a design.

I've talked to Rain and the plan we came up with is to create a cargo subcommand like clippy which we've decided to call seamare that is based on the guppy code in diem. This subcommand can then be distributed on crates.io and run in CI.

MVP Checklist

Additional Goals

  • Have LintEngine run all of the lints in parallel
  • Copy the rest of the applicable lints that exist in diem into seamare-lints
    • Each lint has it's own file
    • Each lint has tests (clippy's repo will be useful for inspiration here)
  • Support out of tree lints (Hard, ideas below)
    • Create an option in cargo-seamare for generating a skeleton project that is essentially a copy of itself, which can then be edited and have new lints added in via source
    • Support wasm plugins
    • dylib plugins???
  • Move seamare, cargo-seamare, and seamare-lints into their own organization and repo to consolidate implementations with upstream source

Describe alternatives you've considered

I've not really considered any other alternatives, as far as I know guppy is the exact right tool to solve this problem, and this is what it was designed for.

@yaahc yaahc added E-med A-rust Area: Updates to Rust code good first issue E-help-wanted Call for participation: Help is requested to fix this issue. C-enhancement Category: This is an improvement S-needs-triage Status: A bug report needs triage labels Jan 12, 2021
@zfnd-bot zfnd-bot bot added this to To Do in 🦓 Jan 12, 2021
yaahc added a commit that referenced this issue Jan 12, 2021
## Motivation

This PR is motivated by the regression identified in #1349. That PR notes that the metrics stopped working for most of the crates other than `zebrad`.

## Solution

This PR resolves the regression by deduplicating the `metrics` crate dependency. During a recent change we upgraded the metrics version in `zebrad` and a couple other of our crates, but we never updated the dependencies in `zebra-state`, `zebra-consensus`, or `zebra-network`. This caused the metrics macros to attempt to retrieve the current metrics exporter through the wrong function. We would install the metrics exporter in `0.13`, but then attempt to look it up through the `0.12` crate, which contains a different instance of the metrics exporter static variable which is unset. Doing this causes the metrics macros to return `None` for the current exporter after which they just silently give up.

## Related Issues

closes #1349

## Follow Up Work

I noticed we have quite a few duplicate dependencies in our tree. We might be able to save some compilation time by auditing those and deduplicating them as much as possible.

- #1582
Co-authored-by: teor <teor@riseup.net>
@teor2345
Copy link
Collaborator

This looks good.

Once we have a potential contributor, let's schedule the mentoring and review work as part of our sprints?

@sepiropht
Copy link

sepiropht commented Jan 13, 2021

i know some rust but never done crypto before, can i contribute ?

@yaahc
Copy link
Contributor Author

yaahc commented Jan 13, 2021

i know some rust but never done crypto before, can i contribute ?

Absolutely!

@sepiropht
Copy link

Ok cool i take it !

@sepiropht
Copy link

I just have to follow all the check listed above ?

@yaahc
Copy link
Contributor Author

yaahc commented Jan 13, 2021

I just have to follow all the check listed above ?

Yup, and let me know if you have any questions.

@teor2345
Copy link
Collaborator

@sepiropht try to focus on the "MVP Checklist" first.

The "Additional Goals" can wait until later.

@sepiropht
Copy link

Right now I'm not able to build the project, i have compilation errors in zebra-state zebra-state/src/service/check/difficulty.rs:138:14,
I use the current stable rustc toolcahin and i have all required dependencies
The only thing that i missing maybe is zebrad target for the toolchain, how do i set that ?

@teor2345
Copy link
Collaborator

@sepiropht please open another ticket with:

  • the exact Zebra commit you're building
  • the command you're using to build Zebra
  • your rustc version
  • the exact error you're getting

You might find the bug report template helpful, but it's designed for runtime bugs, not compilation bugs. So it asks for some information you won't have.

https://github.com/ZcashFoundation/zebra/issues/new/choose

@sepiropht
Copy link

Finally after rustup update i don't have this problem anymore and the project build. Thank @teor2345

@mpguerra mpguerra added this to No Estimate in Effort Affinity Grouping via automation Jan 15, 2021
@mpguerra mpguerra moved this from No Estimate to M - 5 in Effort Affinity Grouping Jan 18, 2021
@mpguerra mpguerra removed the S-needs-triage Status: A bug report needs triage label Feb 2, 2021
@yaahc
Copy link
Contributor Author

yaahc commented Feb 24, 2021

Hey @sepiropht, are you still working on this?

@WindSoilder
Copy link

Curious about this, does it needs to check the direct duplicate dependencies? Does nested dependencies need to be check?

@yaahc
Copy link
Contributor Author

yaahc commented Mar 2, 2021

Curious about this, does it needs to check the direct duplicate dependencies? Does nested dependencies need to be check?

I think the check is already implemented upstream and that it checks for duplicate direct dependencies, but it might be a good idea to make it configurable.

@teor2345
Copy link
Collaborator

teor2345 commented Dec 7, 2021

Done recently using cargo deny check bans.

@teor2345 teor2345 closed this as completed Dec 7, 2021
🦓 automation moved this from To Do to Done Dec 7, 2021
Effort Affinity Grouping automation moved this from M - 5 to Done Dec 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rust Area: Updates to Rust code C-enhancement Category: This is an improvement E-help-wanted Call for participation: Help is requested to fix this issue. good first issue
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

5 participants