Skip to content

docs: warn about keeping compiler versions consistent across upgrades#29547

Open
mvanhorn wants to merge 1 commit into
ProvableHQ:masterfrom
mvanhorn:docs/29383-compiler-version-consistency-upgrades
Open

docs: warn about keeping compiler versions consistent across upgrades#29547
mvanhorn wants to merge 1 commit into
ProvableHQ:masterfrom
mvanhorn:docs/29383-compiler-version-consistency-upgrades

Conversation

@mvanhorn

Copy link
Copy Markdown
Contributor

Motivation

The program upgradability guide does not warn that the Leo compiler version used to deploy a program should match the version used for later upgrades. Different compiler versions can emit different bytecode for identical source, which can break checksum-governed upgrades since those compare an on-chain checksum against the program's code. This adds a short callout next to the @checksum pattern explaining the risk, recommending that maintainers pin the Leo compiler version across the initial deploy and all upgrades, and showing how to check versions with leo --version and how to inspect a deployment's source with leo query program <NAME> (and --edition <N>).

The guidance stays conservative: it does not assert an exact bytecode-stability guarantee, only that you should not assume stability across compiler versions and should pin to be safe.

Fixes #29383

Test Plan

Documentation-only change to documentation/guides/program_upgradability.md.

  • npx markdownlint-cli2 documentation/guides/program_upgradability.md -> 0 errors
  • git diff --check -> no whitespace errors
  • Verified the referenced commands against the CLI source: leo query program accepts an --edition flag (crates/leo/src/cli/commands/query/program.rs), and there is no flag that prints a compiler version, which the callout states explicitly.

Related PRs

None.

AI was used for assistance.

Comment on lines +137 to +154
### Warning: Keep Compiler Versions Consistent

Checksum-governed upgrades are bytecode-sensitive. Do not assume bytecode is stable across Leo compiler versions: different compiler versions can produce different bytecode for identical source, which can cause a checksum-governed upgrade to fail.

Pin the Leo compiler version used for the initial deployment and all subsequent upgrades. Before deploying or approving an upgrade, check the local toolchain:

```bash
leo --version
```

To inspect the source currently deployed on the network, query the program. Use `--edition <N>` when you need to inspect a specific edition:

```bash
leo query program <NAME>
leo query program <NAME> --edition <N>
```

The query returns deployed source; it does not print the compiler version. Use it with your pinned toolchain record and rebuild with the same Leo version to avoid bytecode drift.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Keeping the compiler version stable is important for more than just checksum-governed upgrades. Constructors, for example, can't change between upgrades and some features may change (and even break) between compiler versions. So really this whole section should be more general purpose I think.

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.

Document the importance of keeping compiler versions consistent across upgrades

2 participants