Skip to content
This repository has been archived by the owner on May 4, 2024. It is now read-only.

[12/x][move-package/lock] Use DependencyGraph in download_dependency_repos #788

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

amnn
Copy link
Collaborator

@amnn amnn commented Jan 2, 2023

Another occasion where the previous implementation recursively traversed the transitive dependency graph -- the new approach discovers the graph and then iterates through its nodes to download them.

The second step is currently technically unnecessary, but becomes relevant in the presence of externally resolved dependencies where third-party resolvers can introduce sub-graphs into the DependencyGraph without having to explore them locally.

Test Plan

move/language/tools/move-package$ cargo nextest

Stack

@amnn
Copy link
Collaborator Author

amnn commented Jan 2, 2023

There are a couple of potential future improvements to package fetching that I haven't planned for this stack, but are probably worth doing in the limit (I will create issues for these):

  • Centralise the management of fetching/updating remote repositories to avoid multiple updates in a single build. Currently a remote dependency might get fetched once while exploring the DependencyGraph, and then again when converting it into a ResolvedGraph. The second fetch/update will be quick, but is unnecessary nevertheless (and it means that the progress output shows two fetches, which is annoying and potentially confusing).
  • Always commit the lock file and rely on reading that to get a dependency's transitive dependencies (rather than recursively traversing manifest files).

amnn added 6 commits January 23, 2023 22:16
The initial design of `DependencyGraph` only allowed for one
`addr_subst` and `digest` per package in the transitive dependency
graph, but in actuality there can be as many of these as there are
dependency edges to that package:

- Different `addr_subst` for different packages `P`, `Q` depending on
  `R` allows the same address in `R` to appear as different addresses
  in `P` and `Q`.
- If `R` is a dependency of `P` and a dev-dependency of `Q`, then its
  source digest may differ between the two.

Fixed by moving the `subst` and `digest` to be edge labels in the
graph, rather than node labels.

Note that this also changes the lock file format in the following
ways:

- A package's dependencies are now no longer just the name of the
  dependency, but an inline table containing the name and optionally
  the digest and address substitution.
- The key within the `move` table that contains all the transitive
  dependencies is now called `package` rather than `dependency` (this
  was mainly driven by the naming within the schema, which required a
  name for the new, richer format for a package's dependencies.)

Test Plan:

```
move/language/tools/move-cli$ cargo nextest
move/language/tools/move-package$ cargo nextest
```
Function to return a package's immediate dependencies in the
transitive dependency graph, for use by `ResolutionGraph` when
resolving renamings and in-scope addresses during resolution

Test Plan:

New tests:

```
move/language/tools/move-package$ cargo nextest
```
Extract the logic for unifying named addresses across address
assignments, substitutions and renamings from `ResolvingGraph` into
its own class -- `ResolvingTable`.

This is to be used when integrating `DependencyGraph` into
`ResolutionGraph`.

Test Plan:

New unit tests:

```
move/language/tools/move-package$ cargo nextest
```
@amnn amnn force-pushed the lock-12-download-deps branch from b9e8938 to 2db2efb Compare January 23, 2023 22:27
amnn added 4 commits January 26, 2023 17:13
Integrate `DependencyGraph` and `ResolvingTable` into the creation of
`ResolvedGraph`.  This change replaces the recursive dependency
traversal logic of `ResolutionGraph` that `DependencyGraph` was based
on with a linear traversal of the package's transitive dependencies,
extracted from an existing `DependencyGraph`.

This is part of the preparation for integrating third-party package
managers into the package resolution process:  They can now inject
further transitive dependencies into the DependencyGraph which will be
fetched during resolution to create the `ResolvedGraph`.

Although some error message wording changes (particularly where it
previously relied on recursive calls for building up error context),
the logic is otherwise unchanged.

Test Plan:

Existing test cases:

```
move$ cargo-nextest nextest run -E 'package(move-cli) | package(move-package)'
```
Update the README to reflect the inclusion of `DependencyGraph`,
`LockFile`, and `ResolvingTable`.
…repos

Another occasion where the previous implementation recursively
traversed the transitive dependency graph -- the new approach
discovers the graph and then iterates through its nodes to download
them.

The second step is currently technically unnecessary, but becomes
relevant in the presence of externally resolved dependencies where
third-party resolvers can introduce sub-graphs into the
`DependencyGraph` without having to explore them locally.

Test Plan:

```
move/language/tools/move-package$ cargo nextest
```
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant