Skip to content

svm: build ntt the proper way on other svms#730

Merged
evan-gray merged 2 commits intomainfrom
solana/bridge-addr-from-env
Dec 11, 2025
Merged

svm: build ntt the proper way on other svms#730
evan-gray merged 2 commits intomainfrom
solana/bridge-addr-from-env

Conversation

@kcsongor
Copy link
Copy Markdown
Contributor

@kcsongor kcsongor commented Oct 30, 2025

Present

Currently, deploying the SVM contract on SVM chains other than Solana is a bit messy. We depend on the wormhole-anchor-sdk crate, which defines program ids for solana mainnet/devnet/localnet. This crate pins anchor to 0.31.0, so we can't directly use it, and instead have been depending on a branch which downgraded to 0.29.0.
Since this SDK only includes addresses for the solana networks, when compiling for a different network (such as fogo), the CLI would patch the binary after compilation, replacing the solana address with the relevant fogo address.

This used to work, however, the 0.29.0 branch now includes a commit that allows us to override the bridge address with one from an environment variable. It does this by defining the value as a base58 string and parsing it into a Pubkey at runtime... meaning that the binary patching won't work on it. Technically it's not needed, because we can just pass the right address in the first place, but the CLI then does a sanity check to ensure that the right program ID shows up in the binary, which now fails as of a3a63d2. This means that currently, the current unreleased version of NTT cannot be built with the CLI (because the binary patching fails, then binary verification also fails, independently).


Future

This PR builds on a couple other ones:

Those PRs allow the anchor dependencies to be used with any anchor version, so we no longer need a dedicated backported 0.29.0 branch of wormhole-anchor-sdk. They also make the wormhole-svm-definitions crate the single source of truth for program ids and PDAs, in the form of const computation, so binary patching is no longer necessary, and binary verification passes (because the program ID can be assigned as a static array into the rodata section of the object file).

This PR just bumps the dependencies to those in the PRs linked above, and updates the CLI to support the new build method. As a convenience and for easier testing, we also add a new command to build an svm binary without deploying it. I verified that now we can build --local successfully (we couldn't before, it was failing binary verification, even for Solana, for the reasons explained above).

When the bridge-address-from-env flag is available (i.e. as of now), the CLI uses that flag to build the program. When it's not (i.e. all previous versions), we fall back to patching the binary when the target is not Solana.

This way of detecting the cargo flag allows us to:

  • build the binary properly for new versions going forward
  • support building older NTT releases without modification for other SVMs (e.g. fogo) by patching the binary
  • if the bridge-address-from-env feature is backported to older NTTs (should be straightforward), then the CLI will just pick up that compilation path automatically

@kcsongor kcsongor force-pushed the solana/bridge-addr-from-env branch 3 times, most recently from 77563ac to 83b3431 Compare October 30, 2025 19:14
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the Solana/SVM build system to remove hardcoded network defaults and improve flexibility. The changes enable runtime configuration of bridge addresses and align terminology to use "SVM" (Solana Virtual Machine) instead of "Solana" where appropriate for cross-chain compatibility.

  • Removes mainnet as the default feature from all Cargo.toml files, requiring explicit network selection
  • Updates dependency references to use the from-env feature pattern instead of bridge-address-from-env
  • Adds new svm build CLI command to build program binaries without deploying

Reviewed Changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
solana/programs/wormhole-governance/Cargo.toml Removes default mainnet feature, updates bridge-address-from-env to use from-env feature, adds idl-build dependencies
solana/programs/ntt-transceiver/Cargo.toml Removes default mainnet feature, updates bridge-address-from-env to use from-env, updates git dependencies to specific revisions
solana/programs/ntt-quoter/Cargo.toml Removes default mainnet feature, updates network features to propagate to example-native-token-transfers dependency
solana/programs/example-native-token-transfers/Cargo.toml Removes default mainnet feature, updates bridge-address-from-env to use from-env, adds idl-build dependencies
solana/Makefile Adds explicit --features mainnet flag to anchor-build command, fixes trailing whitespace
solana/Cargo.toml Updates wormhole-anchor-sdk and wormhole-svm-definitions git dependencies to new repositories and revisions
solana/Cargo.lock Updates dependency versions and removes duplicate wormhole-svm-definitions entry
cli/src/index.ts Renames Solana references to SVM in user-facing strings, adds new svm build command, refactors deploy logic into buildSvm function
.github/workflows/solana.yml Adds explicit --features mainnet to cargo check and clippy commands

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@kcsongor kcsongor force-pushed the solana/bridge-addr-from-env branch from 83b3431 to ec18f98 Compare November 7, 2025 16:52
@kcsongor kcsongor requested a review from scnale November 7, 2025 16:54
@kcsongor kcsongor force-pushed the solana/bridge-addr-from-env branch from ec18f98 to 190b4ee Compare November 7, 2025 19:03
@kcsongor kcsongor force-pushed the solana/bridge-addr-from-env branch from 190b4ee to 7136e69 Compare December 9, 2025 15:40
@kcsongor kcsongor marked this pull request as ready for review December 9, 2025 15:42
@kcsongor kcsongor force-pushed the solana/bridge-addr-from-env branch 4 times, most recently from b2bf64c to 3e1b5ef Compare December 9, 2025 16:55
Copy link
Copy Markdown
Contributor

@nvsriram nvsriram left a comment

Choose a reason for hiding this comment

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

LGTM!

We no longer need to depend on backported forks of
`wormhole-anchor-sdk`, `wormhole-verify-vaa-shim-interface`, and
`wormhole-post-message-shim-interface` as these have been updated to
support all anchor versions.

Furthermore, the new versions of these crates encode the program
IDs (such as Wormhole) as a static value again, meaning they will be in
the rodata section of the binary just like before, so the binary
patching method works on them for replacing the address.
Newer versions of NTT support a `bridge-address-from-env` flag, which
allows specifying the address of the Wormhole program from an
environment variable rather than relying on a pre-defined set of
addresses. We use that flag when available, and fall back to patching
the binary when it's not.

This way of detecting the cargo flag allows us to:
- build the binary properly for new versions going forward
- support building older NTT releases without modification for other
SVMs (e.g. fogo) by patching the binary
- if the `bridge-address-from-env` feature is backported to older
NTTs (should be straightforward), then the CLI will just pick up that
compilation path automatically
@evan-gray evan-gray force-pushed the solana/bridge-addr-from-env branch from 3e1b5ef to 823b724 Compare December 11, 2025 02:50
@evan-gray evan-gray merged commit d9c3e5e into main Dec 11, 2025
9 of 10 checks passed
@evan-gray evan-gray deleted the solana/bridge-addr-from-env branch December 11, 2025 11:43
evgeniko pushed a commit that referenced this pull request Dec 15, 2025
* solana: use updated crates

We no longer need to depend on backported forks of
`wormhole-anchor-sdk`, `wormhole-verify-vaa-shim-interface`, and
`wormhole-post-message-shim-interface` as these have been updated to
support all anchor versions.

Furthermore, the new versions of these crates encode the program
IDs (such as Wormhole) as a static value again, meaning they will be in
the rodata section of the binary just like before, so the binary
patching method works on them for replacing the address.

* cli: properly build svm binaries by passing core address

Newer versions of NTT support a `bridge-address-from-env` flag, which
allows specifying the address of the Wormhole program from an
environment variable rather than relying on a pre-defined set of
addresses. We use that flag when available, and fall back to patching
the binary when it's not.

This way of detecting the cargo flag allows us to:
- build the binary properly for new versions going forward
- support building older NTT releases without modification for other
SVMs (e.g. fogo) by patching the binary
- if the `bridge-address-from-env` feature is backported to older
NTTs (should be straightforward), then the CLI will just pick up that
compilation path automatically
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.

4 participants