Skip to content

Enforce usage of latest program edition#29027

Merged
JoshuaBatty merged 1 commit intomainnetfrom
josh/program_edition
Dec 12, 2025
Merged

Enforce usage of latest program edition#29027
JoshuaBatty merged 1 commit intomainnetfrom
josh/program_edition

Conversation

@JoshuaBatty
Copy link
Collaborator

@JoshuaBatty JoshuaBatty commented Dec 4, 2025

Summary

Closes #28983

This PR improves how Leo handles program editions, ensuring we use actual editions from the network rather than arbitrary defaults.

Changes

Edition Handling by Command

Command Local Programs Network Dependencies
run Default to edition 1 Fetch from network
execute Default to edition 1 Fetch from network
synthesize Default to edition 1 Fetch from network
deploy N/A Fetch from network + V8 constructor check
upgrade N/A Fetch from network + V8 constructor check

Why edition 1 for local programs?

Local programs haven't been deployed yet, so they don't have a real on-chain edition. We default to edition 1 to avoid snarkVM's V8+ check that rejects edition 0 programs without constructors. This keeps local development frictionless.

V8 Constructor Check

The check_edition_constructor_requirements validation is only applied during deploy and upgrade - the commands that actually interact with on-chain programs. If a network dependency is at edition 0 without a constructor, we error early with a clear message explaining the program needs to be upgraded on-chain.

image

@JoshuaBatty JoshuaBatty marked this pull request as draft December 4, 2025 03:24
@JoshuaBatty JoshuaBatty self-assigned this Dec 4, 2025
@JoshuaBatty JoshuaBatty added the fix Fixes a bug or issue. label Dec 4, 2025
@JoshuaBatty JoshuaBatty added the 🖥️ CLI Anything related to the Leo CLI. label Dec 4, 2025
@JoshuaBatty JoshuaBatty marked this pull request as ready for review December 4, 2025 04:03
@JoshuaBatty JoshuaBatty marked this pull request as draft December 4, 2025 04:12
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.

Thx! Minor fix required I think

// For local programs not yet deployed, default to edition 0 (first deployment).
// Network programs should already have their edition set by load_latest_programs_from_network.
// Note: The V8 constructor check doesn't apply here since `run` is local evaluation only.
let edition = edition.unwrap_or(0);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit. It could be nice to tell users when we're defaulting. Ditto for synthesize.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

great idea!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

0b0289e local programs now use LOCAL_PROGRAM_DEFAULT_EDITION (defaulting to 1) which keeps the logic clean and documented in one place.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I made a print function here so we still inform the user. e1db033

so now you would see something like:

- credits.aleo (already included)
- some_network_dep.aleo (edition: 3)
- my_local_program.aleo (local)

@JoshuaBatty JoshuaBatty marked this pull request as ready for review December 8, 2025 02:28
@JoshuaBatty JoshuaBatty requested review from d0cd and vicsn December 8, 2025 02:28
@JoshuaBatty
Copy link
Collaborator Author

JoshuaBatty commented Dec 8, 2025

Thanks for the initial reviews @d0cd and @vicsn! I've addressed your feedback and adapted the approach.

I've updated the PR description to reflect this. Let me know if you have any other concerns or suggestions. Thanks!

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.

Thank you for making progress on this badly documented part of the code!

I find myself still being confused and lacking knowledge about how local v.s. network dependencies behave across commands (deploy, execute, repeated commands, etc.), so I'll leave further review to the others.

However, on that note I would really appreciate:

Copy link
Collaborator

@d0cd d0cd left a comment

Choose a reason for hiding this comment

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

Thank you for your patience with this PR @JoshuaBatty!
The edition patch was a band-aid fix that I had made and it has come to bite us.

I thought about it for a while and I think it is actually okay to default the local program to edition 0.
I was concerned about this check in snarkVM, however, that's only run during transaction verification and uses the verifier's (the network) edition.
Since we don't verify the transaction when running Leo execute, we won't run into this error.
We should still warn users when we're defaulting so that they know.
@vicsn do you agree? Is there any other check on the VM side that I might be missing?

Otherwise this PR is really solid! It wrangles a lot of the complexity that was spread across a lot of the commands.

@JoshuaBatty
Copy link
Collaborator Author

JoshuaBatty commented Dec 9, 2025

Thanks @d0cd! I ran an experiment to verify:

Switched to edition 0 and ran the integration tests - snarkVM does reject edition 0 programs without constructors during local execution, not just transaction verification:

Cannot execute some_sample_leo_program.aleo on edition 0

So the options are:

Approach Pros Cons
Edition 1 (current) Constructor-less programs work locally Semantically incorrect ("upgraded" vs "new")
Edition 0 Technically correct Requires all local programs to have constructors

I'm inclined to stick with edition 1 since it's less friction for devs - but wanted to confirm that's the direction you'd prefer before we finalise.

@vicsn Happy to look into documentation improvements once we've landed on a final approach here.

@d0cd
Copy link
Collaborator

d0cd commented Dec 9, 2025

I'm inclined to stick with edition 1 since it's less friction for devs - but wanted to confirm that's the direction you'd prefer before we finalise.
Agreed! Thanks for diving deeply on this one.

Copy link
Collaborator

@d0cd d0cd left a comment

Choose a reason for hiding this comment

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

LGTM!

@JoshuaBatty
Copy link
Collaborator Author

JoshuaBatty commented Dec 11, 2025

Thanks for reviews everyone! @vicsn I've just opened a PR here to help clarify how local vs network dependencies work, caching behavior, and edition handling.

Keen to see how we can improve this situation further with further CLI improvements and possibly introducing a .lock file in the future as per our discussion last night.

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.

Deferring to the others!

Default local programs to edition 1 for run/execute/synthesize commands.
Fetch actual editions from network for dependencies. Apply V8 constructor
check only during deploy/upgrade.

Closes #28983
@JoshuaBatty JoshuaBatty merged commit d485a85 into mainnet Dec 12, 2025
5 checks passed
@JoshuaBatty JoshuaBatty deleted the josh/program_edition branch December 12, 2025 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🖥️ CLI Anything related to the Leo CLI. fix Fixes a bug or issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Doc] Enforce usage of the latest program edition

3 participants