Skip to content

Conversation

@JoshuaBatty
Copy link
Collaborator

@JoshuaBatty JoshuaBatty commented Dec 11, 2025

Structure Changes

  • Restructured the dependency guide for better flow (Adding → Using → Resolution → Caching → Editions → Deploying)

Content Changes

  • Added clear explanation of local vs network dependencies upfront
  • Added step-by-step dependency resolution process
  • Explained why proof-generating commands (execute, deploy, upgrade, synthesize) bypass cache
  • Documented edition pinning use cases
  • Added note about V8 constructor requirements at deploy time
  • Clarified that local dependencies don't have editions

Rendered

Motivation

This documentation update accompanies ProvableHQ/leo#29027 which improves edition handling for dependencies. The existing docs did not clearly explain the distinction between local and network dependencies, or why different commands handle caching differently. This should help clarify these concepts for users.

JoshuaBatty and others added 2 commits December 10, 2025 12:55
- Restructure to explain local vs network dependencies upfront
- Add step-by-step dependency resolution explanation
- Explain why proof-generating commands bypass cache
- Document edition pinning use cases
- Add V8 constructor requirement note for deploy
Copy link
Collaborator

@AleoAlexander AleoAlexander left a comment

Choose a reason for hiding this comment

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

A few comments

Comment on lines +18 to 29
```bash
leo add credits.aleo
```
or
```
```bash
leo add credits
```

If you are deploying to mainnet, you will need to specify mainnet imports using the `--network` flag as follows:

```
For mainnet programs, specify the network:
```bash
leo add credits --network mainnet
```
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's best practice to always include the --network flag, even for Testnet.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

My instinct is to only show flags when they're necessary, since testnet is the default, leo add credits just works. Showing --network testnet everywhere might imply it's required when it's not. The mainnet example already demonstrates the flag exists for when you need it. Thoughts?

Copy link
Collaborator

@AleoAlexander AleoAlexander Dec 22, 2025

Choose a reason for hiding this comment

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

Turns out this guide is old. leo add was changed so that one of the following is required:

<--local <LOCAL>|--network|--edition <EDITION>>

For some reason, you can't specify the network here. I imagine that it uses either the environment variable, the .env file, or the CLI argument when you call leo build.

Comment on lines 89 to 120
## How Dependency Resolution Works

When you run a Leo command, dependencies are resolved as follows:

1. **Read `program.json`** to find declared dependencies
2. **For each dependency:**
- **Local**: Read the Leo source from the specified path and compile it
- **Network**: Fetch the bytecode from the Aleo network (or cache)
3. **Resolve transitive dependencies** - if your dependency imports other programs, those are fetched too
4. **Topologically sort** all programs so dependencies are processed before dependents

### Caching Behavior

Network dependencies are cached locally at `~/.aleo/registry/{network}/{program_name}/{edition}/` to avoid repeated downloads.

Different commands handle caching differently:

| Command | Cache Behavior |
|---------|---------------|
| `leo build` | Uses cache |
| `leo run` | Uses cache |
| `leo execute` | Always fetches fresh |
| `leo deploy` | Always fetches fresh |
| `leo upgrade` | Always fetches fresh |
| `leo synthesize` | Always fetches fresh |

Commands that generate proofs (`execute`, `deploy`, `upgrade`, `synthesize`) always fetch fresh bytecode because proofs include commitments to the exact bytecode of dependencies. Using stale cached bytecode would produce invalid proofs if a dependency has been upgraded on-chain.

To force a fresh fetch during `build` or `run`:
```bash
leo build --no-cache
```
Copy link
Collaborator

Choose a reason for hiding this comment

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

I recommend moving this section to the bottom of the page

Copy link
Collaborator Author

@JoshuaBatty JoshuaBatty Dec 12, 2025

Choose a reason for hiding this comment

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

I'd lean towards keeping it here. The flow goes from "how resolution works" → "caching" → "editions" → "deployment", which follows the conceptual order a reader would encounter these ideas.

Moving editions after deployment feels like an afterthought when it's actually core to understanding what gets fetched. Happy to move it if you feel strongly though!

Copy link
Collaborator

@AleoAlexander AleoAlexander Dec 22, 2025

Choose a reason for hiding this comment

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

I don't have a strong preference, so let's keep it as is!

vicsn
vicsn previously approved these changes Dec 11, 2025
Copy link
Collaborator

@vicsn vicsn left a comment

Choose a reason for hiding this comment

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

I have a few questions but overall LGTM.

Would love a redesign to make it simpler to use for developers.

}
```

Local dependencies are compiled from source whenever you build. They never require network access.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will dependencies of the local dependency be fetched from the network?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, transitive dependencies are fetched based on their own location type. If your local dependency imports a network program, that gets fetched from the network. If it imports another local path, that's read from disk.

- When a dependency upgrade would break your program
- When you want to avoid unexpected behavior changes

**Note:** Local dependencies don't have editions - they're always compiled from your current source code.
Copy link
Collaborator

Choose a reason for hiding this comment

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

What happens when the local dependency also lives in the network?

In any case, it must have some edition right, either 0 if this is the first deployment or perhaps higher if it's already present?

Not sure if the edition is actually materially used for anything.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If it's marked as local, Leo just compiles from source and ignores any network presence. Editions only come into play for network dependencies - they tell Leo which on-chain version to fetch. Local deps don't have editions because you're compiling your source, not fetching bytecode.

At deploy time, if the local dep hasn't been deployed yet it becomes edition 0. If it already exists on-chain, the deploy would fail (you'd need to upgrade instead).

Co-authored-by: Alexander Kim <[email protected]>
Signed-off-by: Joshua Batty <[email protected]>
JoshuaBatty and others added 7 commits December 12, 2025 11:09
Co-authored-by: Alexander Kim <[email protected]>
Signed-off-by: Joshua Batty <[email protected]>
Co-authored-by: Alexander Kim <[email protected]>
Signed-off-by: Joshua Batty <[email protected]>
Co-authored-by: Alexander Kim <[email protected]>
Signed-off-by: Joshua Batty <[email protected]>
Co-authored-by: Alexander Kim <[email protected]>
Signed-off-by: Joshua Batty <[email protected]>
Co-authored-by: Alexander Kim <[email protected]>
Signed-off-by: Joshua Batty <[email protected]>
Co-authored-by: Alexander Kim <[email protected]>
Signed-off-by: Joshua Batty <[email protected]>
Co-authored-by: Alexander Kim <[email protected]>
Signed-off-by: Joshua Batty <[email protected]>
@JoshuaBatty
Copy link
Collaborator Author

I have a few questions but overall LGTM.

Would love a redesign to make it simpler to use for developers.

Agreed. Once we have the lock file actually populated a lot of this complexity around edition pinning goes away. Leo would just auto-record resolved editions on first build, and developers wouldn't need to think about it unless they explicitly want to update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants