Skip to content

Conversation

d0cd
Copy link
Collaborator

@d0cd d0cd commented May 1, 2025

This PR supports program upgradability in Leo.
To that end we:

See this issue to track snarkVM support.

See the examples for more information.

To Reviewers. This PR has ballooned since it's inception. Let me know if you'd like me to break it up into pieces.

@d0cd d0cd force-pushed the feat/program-upgradability branch from 36e36e9 to 75d8b19 Compare May 8, 2025 23:25
@d0cd d0cd changed the base branch from mainnet to feat/cli-improvements May 8, 2025 23:25
@d0cd d0cd requested a review from vicsn July 24, 2025 16:58
Copy link
Collaborator

@mikebenfield mikebenfield left a comment

Choose a reason for hiding this comment

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

tests/expectations/execution/program_core_functions.out is empty.

BTW I realized the line

        Err(e) => e.to_string(),

in test_execution.rs should have a buf.extract_errs(); might help you see the actual error happening here.

One thing that's not clear to me is how we expect this to roll out. Are we going to allow programs with no constructors or not? Are we going to merge this, and just have the mainnet branch of Leo depend on an unreleased Snarkvm commit for now?

.expect("Type checking guarantees that the program name is valid");
// If the program name matches the current program ID, then use `checksum`, otherwise fully qualify the operand.
let operand = match program_id.to_string()
== self.program_id.expect("The program ID is set before traversing the program").to_string()
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: you could just remove both of the to_string()s

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is necessary because equality for ProgramId includes the span.

function foo(a: bool) {
assert_eq(true, a);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: whitespace

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Could you clarify?

@d0cd
Copy link
Collaborator Author

d0cd commented Jul 25, 2025

One thing that's not clear to me is how we expect this to roll out. Are we going to allow programs with no constructors or not? Are we going to merge this, and just have the mainnet branch of Leo depend on an unreleased Snarkvm commit for now?

The implementation supports programs without constructors.
leo deploy checks for the consensus version and tells users whether the network expects constructors or not.

You bring up a good question on merging into mainnet.
I think this PR is a strong motivation for bringing back a staging branch into our merge process.
So the flow would look like mainnet <-- staging <-- PRs.
We will still only cut releases for mainnet, but the staging branch well let us merge PRs without blocking development.

input r0 as field;
assert.eq true true;
output r0 as field;
Error [ECMP0376012]: Unable to resolve call to generic function `def`. A non-const expression `C` was provided where a const generic parameter is required.
Copy link
Collaborator

Choose a reason for hiding this comment

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

The output of this test changed.. The reason for that is the change you made in monomorphization/program.rs that does a post order traversal of the call graph without considering entry points. The reason why we need to consider entry points is to ignore const generic inlines that have been monomorphized already but are still there without users. Otherwise, we will emit an error saying that such functions cannot be monomorphized which is incorrect. I should have made that clearer in a comment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for pointing that out!
Should be resolved.

@d0cd d0cd merged commit 97aae32 into mainnet Aug 4, 2025
8 checks passed
@d0cd d0cd deleted the feat/program-upgradability branch August 4, 2025 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[chore] Consider a better name for const_propagation_and_unrolling.rs [Feature] Consider a slightly different UI for reporting on executions
4 participants