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

On Forc.toml change, forc should try to update only package nodes that appear in the lock::Diff #1686

Merged
merged 18 commits into from
Jun 2, 2022

Conversation

kayagokalp
Copy link
Member

@kayagokalp kayagokalp commented May 26, 2022

I will be simplifying and refactoring the code a little bit more so leaving this as a draft for now.

closes #900.

About the PR

Before this PR, forc was re-fetching all the dependencies once there is a mismatch between the lock file and the manifest.

For more context about the implementation please take a look into the discussion at the #900 and particularly this comment.

Basic Overview of What is Happening

  1. Removed and added dependencies are detected
  2. Removed dependencies handled by doing a BFS from the project node. Searching for detected removed dependencies and children of the removed dependencies (given that no other node depends on them) in the order of the breadth-first traversal.
  3. Added dependencies handled by first connecting the added dependency to the root node and then recursively fetching_children for the dependencies of the newly added dependency while checking if any dependency of the newly added dependency is already fetched.

To test:

  1. forc init --library child
  2. forc init parent
  3. forc build in the parent directory to build it before depending on the child.
  4. add the "child" library as a dependency for the "parent"
  5. forc build in the "parent" directory

This test procedure will be resulting in the following dependency graph:

after_step_5

@kayagokalp kayagokalp added enhancement New feature or request forc labels May 26, 2022
@kayagokalp kayagokalp self-assigned this May 26, 2022
forc-pkg/src/pkg.rs Outdated Show resolved Hide resolved
@kayagokalp
Copy link
Member Author

There are still some unnecessary calls to functions and duplicate code pieces, will be cleaning up and marking this as ready to review 🎉

@kayagokalp kayagokalp marked this pull request as ready for review May 30, 2022 12:10
@kayagokalp
Copy link
Member Author

Realized a bug while removing the packages. The BuildPlan creation from lock fails and BuildPlan is always created from new once there is a package removal. Converting the PR into draft until that is solved.

@kayagokalp kayagokalp marked this pull request as draft May 30, 2022 13:00
Copy link
Contributor

@mitchmindtree mitchmindtree left a comment

Choose a reason for hiding this comment

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

Great work @kayagokalp! I've left a few comments but for the most part I think this is on the right track.

As a side-note: looks like there's a lot of duplicated code between BuildPlan::validate and BuildPlan::get_difference_with_manifest 🤔 Seeing as the only role of validate was originally to check if the package sets match, perhaps we can just rename validate to diff_manifest and alter it to return the difference in packages?

forc-pkg/src/pkg.rs Outdated Show resolved Hide resolved
forc-pkg/src/pkg.rs Outdated Show resolved Hide resolved
forc-pkg/src/pkg.rs Outdated Show resolved Hide resolved
forc-pkg/src/pkg.rs Outdated Show resolved Hide resolved
forc-pkg/src/pkg.rs Outdated Show resolved Hide resolved
forc-pkg/src/pkg.rs Outdated Show resolved Hide resolved
forc-pkg/src/pkg.rs Outdated Show resolved Hide resolved
forc-pkg/src/pkg.rs Outdated Show resolved Hide resolved
forc-pkg/src/pkg.rs Outdated Show resolved Hide resolved
forc-pkg/src/pkg.rs Outdated Show resolved Hide resolved
@kayagokalp kayagokalp requested a review from mitchmindtree May 31, 2022 16:09
@kayagokalp kayagokalp marked this pull request as ready for review May 31, 2022 16:09
@kayagokalp
Copy link
Member Author

kayagokalp commented May 31, 2022

@mitchmindtree I did the clean-up you asked for and I think currently it looks a lot better, thanks for the great review! Merging this will also close #1778, if the solution applied is acceptable.

Copy link
Contributor

@mitchmindtree mitchmindtree left a comment

Choose a reason for hiding this comment

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

Definitely much closer! I've added a few more things that should be addressed first

forc-pkg/src/pkg.rs Outdated Show resolved Hide resolved
forc-pkg/src/pkg.rs Outdated Show resolved Hide resolved
forc-pkg/src/pkg.rs Outdated Show resolved Hide resolved
forc-pkg/src/pkg.rs Outdated Show resolved Hide resolved
forc-pkg/src/pkg.rs Outdated Show resolved Hide resolved
forc/src/ops/forc_build.rs Outdated Show resolved Hide resolved
forc/src/ops/forc_build.rs Outdated Show resolved Hide resolved
forc/src/ops/forc_build.rs Outdated Show resolved Hide resolved
@kayagokalp kayagokalp requested a review from mitchmindtree June 1, 2022 08:30
Copy link
Contributor

@mitchmindtree mitchmindtree left a comment

Choose a reason for hiding this comment

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

Looking great to me! Awesome work @kayagokalp :)

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.

Yeah this is really great @kayagokalp, nice work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request forc
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

On Forc.toml change, forc should try to update only package nodes that appear in the lock::Diff
3 participants