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

Update all Cargo.toml files to use workspace dependency versions #6501

Closed
wants to merge 7 commits into from

Conversation

alfiedotwtf
Copy link
Contributor

@alfiedotwtf alfiedotwtf commented Sep 5, 2024

Description

This PR relates to #6179 which aims to simplify individual workspace member dependency versioning by deferring upstream to the workspace dependencies itself.

I've also extended #6179 as it currently only relates to external dependencies - I've noticed that whenever Sway has a version bump, the diffs manually update all of the many Cargo.toml files to the new globally shared version. We can also use workspaces here to defer each Cargo.toml package version to the workspace package version as well.

This PR is in 3 parts:

  1. Update all Cargo.toml external dependencies to use the shared versions defined in the workspace dependencies
  2. Update all Cargo.toml package version to defer to the workspace package version.
  3. Update all external dependencies to their latest versions

If an individual workspace member needs to break away from the shared workspace package version, we can still do that:

  • Update the individual Cargo.toml to the new version (as normal)
  • Update all references within the whole repository to state this new version

Notes:

  • [dev-dependencies] was not factored out since [workspace.dev-dependencies] is currently not supported by Cargo.toml, meaning all dev dependencies would have to be brought into [workspace.dependencies] which I assume is not what we would want to do.
  • [target.'cfg(not(target_os = "macos"))'.dependencies] was not factored out since these crates should only be brought in if the condition is met, but again as the only way to do this would be to move it to [workspace.dependencies], I would advise to keep them separated.

Checklist

  • [✅] I have linked to any relevant issues.
  • [✅] I have commented my code, particularly in hard-to-understand areas.
  • [␆] I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • [␆] I have added tests that prove my fix is effective or that my feature works.
  • [␆] I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • [✅] I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • [✅] I have requested a review from the relevant team or maintainers.

Copy link

codspeed-hq bot commented Sep 5, 2024

CodSpeed Performance Report

Merging #6501 will degrade performances by 17.31%

Comparing alfie/6179-cargo-workspace-version (4957517) with master (a073a95)

Summary

⚡ 1 improvements
❌ 1 regressions
✅ 20 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark master alfie/6179-cargo-workspace-version Change
code_lens 6.1 µs 5.5 µs +11.09%
document_symbol 4.3 ms 5.2 ms -17.31%

@alfiedotwtf alfiedotwtf force-pushed the alfie/6179-cargo-workspace-version branch 2 times, most recently from ba0e9d3 to ff3c935 Compare September 6, 2024 11:08
@alfiedotwtf alfiedotwtf marked this pull request as ready for review September 6, 2024 11:35
@alfiedotwtf alfiedotwtf requested review from a team as code owners September 6, 2024 11:35
.github/workflows/ci.yml Outdated Show resolved Hide resolved
@Voxelot
Copy link
Member

Voxelot commented Sep 6, 2024

nice 😎
Screenshot from 2024-09-06 11-01-55

Copy link
Member

@sdankel sdankel left a comment

Choose a reason for hiding this comment

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

Looks good, just a few comments.

Cargo.toml Outdated Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
Cargo.toml Show resolved Hide resolved
Cargo.toml Show resolved Hide resolved
@sdankel
Copy link
Member

sdankel commented Sep 6, 2024

Closes #5845

@JoshuaBatty
Copy link
Member

Awesome to see this. so much cleaner.

@alfiedotwtf alfiedotwtf force-pushed the alfie/6179-cargo-workspace-version branch from ff3c935 to cb684bf Compare September 9, 2024 07:25
@alfiedotwtf alfiedotwtf marked this pull request as draft September 10, 2024 08:42
@alfiedotwtf alfiedotwtf force-pushed the alfie/6179-cargo-workspace-version branch 3 times, most recently from 771d4ad to 0df0880 Compare September 12, 2024 06:43
@alfiedotwtf alfiedotwtf self-assigned this Sep 12, 2024
@alfiedotwtf alfiedotwtf added compiler General compiler. Should eventually become more specific as the issue is triaged code quality dependencies labels Sep 12, 2024
@alfiedotwtf alfiedotwtf force-pushed the alfie/6179-cargo-workspace-version branch 8 times, most recently from 4692b0e to 52b4570 Compare September 13, 2024 19:06
- Support `act` in ci.yml for local testing
- Add documentation for `act` testing
- Add `act` binary to .gitignore
- Version bump differences
- Test fixtures
- Minor changes for errors and typos
@alfiedotwtf alfiedotwtf force-pushed the alfie/6179-cargo-workspace-version branch from 6780e76 to 8c73032 Compare September 16, 2024 09:28
@@ -1201,6 +1201,7 @@ impl<'a> TypeCheckContext<'a> {
}

if !maybe_method_decl_refs.is_empty() {
#[allow(clippy::mutable_key_type)]
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we shouldn't enforce this clippy lint since we need to disable it in quite a few places...

@@ -65,8 +68,8 @@ pretty_assertions = "1.4.0"
rand = "0.8"
regex = "^1.10.2"
sway-lsp-test-utils = { path = "tests/utils" }
tikv-jemallocator = "0.5"
tower = { version = "0.4.12", default-features = false, features = ["util"] }
tikv-jemallocator = "0.6.0"
Copy link
Member

Choose a reason for hiding this comment

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

I personally prefer using "x.y" instead of "x.y.z" for dependency versions, as it automatically incorporates bug fixes and security updates within the x.y.* range. What are your thoughts about adopting this approach?

Copy link
Member

@JoshuaBatty JoshuaBatty left a comment

Choose a reason for hiding this comment

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

Nice work Alfie, just a couple of small nits.

@JoshuaBatty JoshuaBatty requested a review from a team September 16, 2024 23:32
@@ -423,32 +426,40 @@ jobs:
contents: write
steps:
- uses: actions/checkout@v3
- name: Install toolchain
- name: Install Rust toolchain
if: ${{ !env.ACT }}
Copy link
Member

Choose a reason for hiding this comment

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

nit: I'd prefer to do the act-related stuff in a separate PR since it's not related to updating the dependencies

Cargo.toml Show resolved Hide resolved
bytes = "1.3.0"
chrono = { version = "0.4", default-features = false }
cid = "0.11"
clap = "4.5.4"
Copy link
Member

Choose a reason for hiding this comment

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

image

Cargo.toml Show resolved Hide resolved
num-bigint = "0.4.3"
num-traits = "0.2.16"
object = "0.36.4"
once_cell = "1.18.0"
Copy link
Member

Choose a reason for hiding this comment

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

image

object = "0.36.4"
once_cell = "1.18.0"
opener = "0.7.2"
parking_lot = "0.12.1"
Copy link
Member

Choose a reason for hiding this comment

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

Uploading image.png…

serde_ignored = "0.1.9"
serde_json = "1.0.91"
serde_with = "3.3.0"
serde_yaml = "0.9.27"
Copy link
Member

Choose a reason for hiding this comment

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

latest is "0.9.34"

Copy link
Member

Choose a reason for hiding this comment

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

Yeah i think we should just be setting it to use 0.9 and leave the minor version part off. Same everywhere really.

tempfile = "3"
term-table = "1.3"
termion = "4.0.2"
textwrap = "0.16.0"
Copy link
Member

Choose a reason for hiding this comment

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

image

Cargo.toml Show resolved Hide resolved
Copy link
Member

@sdankel sdankel left a comment

Choose a reason for hiding this comment

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

Looks good overall, just a few nits. I highlighted some other dependencies that have newer versions since it looks like you're aiming to upgrade everything in this PR now.

@alfiedotwtf alfiedotwtf marked this pull request as draft September 17, 2024 10:46
@alfiedotwtf alfiedotwtf marked this pull request as draft September 17, 2024 10:46
Copy link
Member

@kayagokalp kayagokalp left a comment

Choose a reason for hiding this comment

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

Looks like i forgot to post my review 🤦 anyways it seems like the generated bytecode for the proxy contract changed after this one. I wan't to take a closer look but it is not nice (also not sure how this is possible) that dependency updates are causing bytecode changes in the compiler.

Do we know why?

@@ -341,7 +341,7 @@ async fn test_simple_deploy() {
node.kill().unwrap();
let expected = vec![DeployedContract {
id: ContractId::from_str(
"50fe882cbef5f3da6da82509a66b7e5e0a64a40d70164861c01c908a332198ae",
Copy link
Member

Choose a reason for hiding this comment

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

Do we know why these are changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've turned this PR back into draft, and am pulling out all the changes so that we can see which crates can be updated with no code changes, and which ones end up doing changes like these.

Unfortunately it's a bit time consuming because you end up having to wait for the whole ci.yml to finish before the next 'edit -> test -> debug` cycle

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I finally found the cause! Bumping rustc-hash from 1.1 to 2.0 changes the bytecode. I guess it makes sense given the name of the crate, but dang it's not reproducible.

Oh... from the 1.3.0 changelog:

This replaces the previous "fxhash" algorithm originating in Firefox with a custom hasher

I'm going to have a good guess that the old and new hashers don't produce the same output. Ah, yep... all the fixtures for test_hash!() changed between the algo switch.

JoshuaBatty pushed a commit that referenced this pull request Sep 20, 2024
## Description

For #6179, PR #6501 kept bumping into errors as it was doing too many
things, so I've split that PR into multiple PRs. This is the first, and
the only thing it does is move all of the various `Cargo.toml`
dependencies into the single workspace `Cargo.toml`.

Future PRs will:
- Update dependency versions
- Update code that breaks from the version bumps

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
JoshuaBatty added a commit that referenced this pull request Sep 21, 2024
## Description

This is a continuation of #6179, and follows on from PR #6501. These are
broken into separate PRs so that we can discuss each PR `HEAD`
separately so that the PRs that can get merged, do so quickly.
Otherwise, the further along they get stale the more work they all need
in order to keep up to `master` without being hard to find which change
introduced a possible broken build.

This PR only does a version bump to every crate dependency that does not
need any code changes to apply cleanly.

Following this PR will be a new PR, where every commit updates a single
crate along with the files that were needed to be changed in order to
work again. The crates that will need code changes are:

- tokio 1.12: -> 1.40
- rustc-hash: 1.1 -> 2.0
- miden-core: 0.3 -> 0.10
- notify: 5.0 -> 6.1
- notify-debouncer-mini: 0.2 -> 0.4
- revm: 2.3 -> 14.0
- syn: 1.0 -> 2.0
- tikv-jemallocator: 0.5 -> 0.6
- toml_edit: 0.21 -> 0.22

There should also be a commit to upgrade Rust itself to >= `1.81.0`.

... and for another day, there's 3 crates that will take a bit of time
to get working, and so will go under a different issue #6536:

- annotate-snippets
- lsp-types
- uint

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.

Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality compiler General compiler. Should eventually become more specific as the issue is triaged dependencies
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants