Skip to content

Commit ef31071

Browse files
committed
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.
1 parent a4875e0 commit ef31071

9 files changed

Lines changed: 46 additions & 61 deletions

File tree

.github/workflows/solana.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ jobs:
4747
run: cargo fmt --check --all --manifest-path Cargo.toml
4848

4949
- name: Run `cargo check`
50-
run: cargo check --workspace --tests --manifest-path Cargo.toml
50+
run: cargo check --workspace --tests --manifest-path Cargo.toml --features mainnet
5151

5252
- name: Run `cargo clippy`
53-
run: cargo clippy --workspace --tests --manifest-path Cargo.toml -- -Dclippy::cast_possible_truncation
53+
run: cargo clippy --workspace --tests --manifest-path Cargo.toml --features mainnet -- -Dclippy::cast_possible_truncation
5454

5555
- name: Cache solana tools
5656
id: cache-solana

solana/Cargo.lock

Lines changed: 11 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

solana/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ solana-address-lookup-table-program = "=1.18.26"
5555
spl-token = "4.0.0"
5656
spl-token-2022 = "3.0.2"
5757

58-
wormhole-anchor-sdk = { git = "https://github.com/wormholelabs-xyz/wormhole-scaffolding", branch = "solana/anchor-0.29.0", default-features = false }
58+
wormhole-anchor-sdk = { git = "https://github.com/wormhole-foundation/wormhole-scaffolding.git", rev = "d38ef8944edfb479ab7eb9399e065711b1dbec13", default-features = false } # TODO: depends on https://github.com/wormhole-foundation/wormhole-scaffolding/pull/105, need to update this once merged
5959
wormhole-sdk = { git = "https://github.com/wormhole-foundation/wormhole", rev = "eee4641" }
6060
serde_wormhole = { git = "https://github.com/wormhole-foundation/wormhole", rev = "eee4641" }
6161

solana/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ cargo-build:
2121
# After building, remove the generics from the idl file. This is necessary as of anchor 0.29.0,
2222
# because the javascript library does not support generics yet, and just panics
2323
anchor-build:
24-
anchor build --arch sbf
24+
anchor build --arch sbf -- --features mainnet
2525
for jsonfile in target/idl/*.json; do \
2626
echo "Removing generics from" $$jsonfile; \
2727
./scripts/patch-idl $$jsonfile; \
2828
done
2929

30-
artifacts-mainnet:
30+
artifacts-mainnet:
3131
$(MAKE) _artifacts TARGET_DIR=$@ NETWORK=mainnet
3232

3333
artifacts-solana-devnet:

solana/programs/example-native-token-transfers/Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,23 @@ crate-type = ["cdylib", "lib"]
99
name = "example_native_token_transfers"
1010

1111
[features]
12-
default = ["mainnet"]
12+
default = []
1313
no-entrypoint = []
1414
no-idl = []
1515
no-log-ix-name = []
1616
cpi = ["no-entrypoint"]
1717
idl-build = [
1818
"anchor-lang/idl-build",
1919
"anchor-spl/idl-build",
20+
"wormhole-anchor-sdk/idl-build",
21+
"wormhole-anchor-sdk/no-custom-discriminator",
22+
"wormhole-anchor-sdk/mainnet",
2023
]
2124
# cargo-test-sbf will pass this along
2225
test-sbf = []
2326
# networks
2427
mainnet = [ "wormhole-anchor-sdk/mainnet" ]
25-
bridge-address-from-env = [ "wormhole-anchor-sdk/bridge-address-from-env" ]
28+
bridge-address-from-env = [ "wormhole-anchor-sdk/from-env" ]
2629
solana-devnet = [ "wormhole-anchor-sdk/solana-devnet" ]
2730
tilt-devnet = [ "wormhole-anchor-sdk/tilt-devnet" ]
2831
tilt-devnet2 = [ "tilt-devnet" ]

solana/programs/ntt-quoter/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ crate-type = ["cdylib", "lib"]
88
name = "ntt_quoter"
99

1010
[features]
11-
default = ["mainnet", "no-idl"]
11+
default = ["no-idl"]
1212
no-entrypoint = []
1313
no-idl = []
1414
no-log-ix-name = []
1515
cpi = ["no-entrypoint"]
1616

17-
mainnet = []
18-
solana-devnet = []
19-
tilt-devnet = []
20-
tilt-devnet2 = ["tilt-devnet"]
17+
mainnet = ["example-native-token-transfers/mainnet"]
18+
solana-devnet = ["example-native-token-transfers/solana-devnet"]
19+
tilt-devnet = ["example-native-token-transfers/tilt-devnet"]
20+
tilt-devnet2 = ["example-native-token-transfers/tilt-devnet2"]
2121

2222
[lints]
2323
workspace = true

solana/programs/ntt-transceiver/Cargo.toml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ crate-type = ["cdylib", "lib"]
99
name = "ntt_transceiver"
1010

1111
[features]
12-
default = ["mainnet"]
12+
default = []
1313
no-entrypoint = ["example-native-token-transfers/no-entrypoint"]
1414
no-idl = []
1515
no-log-ix-name = []
@@ -18,7 +18,8 @@ idl-build = [
1818
"anchor-lang/idl-build",
1919
"anchor-spl/idl-build",
2020
"example-native-token-transfers/idl-build",
21-
"wormhole-anchor-sdk/mainnet" # TODO: is this kosher? builds idl without passing on our feature flags
21+
"wormhole-anchor-sdk/mainnet",
22+
"wormhole-transceiver"
2223
]
2324
wormhole-transceiver = ["example-native-token-transfers/cpi"]
2425
transceiver-type-from-env = []
@@ -27,11 +28,11 @@ test-sbf = []
2728
# only enable for tests
2829
testing = []
2930
# networks
30-
mainnet = [ "wormhole-transceiver", "wormhole-anchor-sdk/mainnet", "example-native-token-transfers/mainnet" ]
31-
bridge-address-from-env = [ "wormhole-anchor-sdk/bridge-address-from-env", "wormhole-svm-definitions/from-env", "example-native-token-transfers/bridge-address-from-env" ]
32-
solana-devnet = [ "wormhole-transceiver", "wormhole-anchor-sdk/solana-devnet", "wormhole-svm-definitions/testnet", "example-native-token-transfers/solana-devnet" ]
33-
tilt-devnet = [ "wormhole-transceiver", "wormhole-anchor-sdk/tilt-devnet", "wormhole-svm-definitions/localnet", "example-native-token-transfers/tilt-devnet" ]
34-
tilt-devnet2 = [ "wormhole-transceiver", "tilt-devnet", "wormhole-svm-definitions/localnet", "example-native-token-transfers/tilt-devnet2" ]
31+
mainnet = [ "wormhole-transceiver", "wormhole-anchor-sdk/mainnet", "wormhole-svm-definitions/solana", "example-native-token-transfers/mainnet" ]
32+
bridge-address-from-env = [ "wormhole-anchor-sdk/from-env", "wormhole-svm-definitions/from-env", "example-native-token-transfers/bridge-address-from-env" ]
33+
solana-devnet = [ "wormhole-transceiver", "wormhole-anchor-sdk/solana-devnet", "wormhole-svm-definitions/solana", "wormhole-svm-definitions/testnet", "example-native-token-transfers/solana-devnet" ]
34+
tilt-devnet = [ "wormhole-transceiver", "wormhole-anchor-sdk/tilt-devnet", "wormhole-svm-definitions/solana", "wormhole-svm-definitions/localnet", "example-native-token-transfers/tilt-devnet" ]
35+
tilt-devnet2 = [ "wormhole-transceiver", "tilt-devnet", "wormhole-svm-definitions/solana", "wormhole-svm-definitions/localnet", "example-native-token-transfers/tilt-devnet2" ]
3536

3637
[lints]
3738
workspace = true
@@ -47,9 +48,9 @@ wormhole-sdk.workspace = true
4748

4849
example-native-token-transfers = { path = "../example-native-token-transfers", default-features = false }
4950
ntt-messages = { path = "../../modules/ntt-messages", features = ["anchor", "hash"] }
50-
wormhole-post-message-shim-interface = { git = "https://github.com/wormhole-foundation/wormhole", branch = "svm/anchor-v0.29.0-shim-interface", features = ["no-entrypoint", "cpi"] }
51-
wormhole-verify-vaa-shim-interface = { git = "https://github.com/wormhole-foundation/wormhole", branch = "svm/anchor-v0.29.0-shim-interface", features = ["no-entrypoint", "cpi"] }
52-
wormhole-svm-definitions = { git = "https://github.com/wormholelabs-xyz/wormhole", branch = "svm-shims-fr-env-addr" }
51+
wormhole-post-message-shim-interface = { git = "https://github.com/wormhole-foundation/wormhole", rev = "325cca4b628f17536f54b079eeb82b41247bfbef", features = ["no-entrypoint", "cpi"] }
52+
wormhole-verify-vaa-shim-interface = { git = "https://github.com/wormhole-foundation/wormhole", rev = "325cca4b628f17536f54b079eeb82b41247bfbef", features = ["no-entrypoint", "cpi"] }
53+
wormhole-svm-definitions = { git = "https://github.com/wormhole-foundation/wormhole", rev = "325cca4b628f17536f54b079eeb82b41247bfbef" }
5354

5455
[dev-dependencies]
5556
solana-program-test.workspace = true

solana/programs/wormhole-governance/Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,19 @@ crate-type = ["cdylib", "lib"]
99
name = "wormhole_governance"
1010

1111
[features]
12-
default = ["mainnet"]
12+
default = []
1313
no-entrypoint = []
1414
no-idl = []
1515
no-log-ix-name = []
1616
cpi = ["no-entrypoint"]
1717
idl-build = [
1818
"anchor-lang/idl-build",
19+
"wormhole-anchor-sdk/idl-build",
20+
"wormhole-anchor-sdk/no-custom-discriminator",
21+
"wormhole-anchor-sdk/mainnet",
1922
]
2023

21-
bridge-address-from-env = [ "wormhole-anchor-sdk/bridge-address-from-env" ]
24+
bridge-address-from-env = [ "wormhole-anchor-sdk/from-env" ]
2225
mainnet = [ "wormhole-anchor-sdk/mainnet" ]
2326
solana-devnet = [ "wormhole-anchor-sdk/solana-devnet" ]
2427
tilt-devnet = [ "wormhole-anchor-sdk/tilt-devnet" ]

solana/tests/cargo/Cargo.toml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ test-sbf = []
1111
shim = ["ntt-transceiver"]
1212
# networks
1313
mainnet = [ "wormhole-anchor-sdk/mainnet", "example-native-token-transfers/mainnet", "ntt-transceiver/mainnet" ]
14-
bridge-address-from-env = [ "wormhole-anchor-sdk/bridge-address-from-env", "wormhole-svm-definitions/from-env", "example-native-token-transfers/bridge-address-from-env", "ntt-transceiver/bridge-address-from-env" ]
15-
solana-devnet = [ "wormhole-anchor-sdk/solana-devnet", "wormhole-svm-definitions/testnet", "example-native-token-transfers/solana-devnet", "ntt-transceiver/solana-devnet" ]
16-
tilt-devnet = [ "wormhole-anchor-sdk/tilt-devnet", "wormhole-svm-definitions/localnet", "example-native-token-transfers/tilt-devnet", "ntt-transceiver/tilt-devnet" ]
17-
tilt-devnet2 = [ "tilt-devnet", "wormhole-svm-definitions/localnet", "example-native-token-transfers/tilt-devnet2", "ntt-transceiver/tilt-devnet2" ]
14+
bridge-address-from-env = [ "wormhole-anchor-sdk/from-env", "example-native-token-transfers/bridge-address-from-env", "ntt-transceiver/bridge-address-from-env" ]
15+
solana-devnet = [ "wormhole-anchor-sdk/solana-devnet", "example-native-token-transfers/solana-devnet", "ntt-transceiver/solana-devnet" ]
16+
tilt-devnet = [ "wormhole-anchor-sdk/tilt-devnet", "example-native-token-transfers/tilt-devnet", "ntt-transceiver/tilt-devnet" ]
17+
tilt-devnet2 = [ "tilt-devnet", "example-native-token-transfers/tilt-devnet2", "ntt-transceiver/tilt-devnet2" ]
1818

1919
[lints]
2020
workspace = true
@@ -48,5 +48,3 @@ example-native-token-transfers = { path = "../../programs/example-native-token-t
4848
ntt-messages = { path = "../../modules/ntt-messages", features = ["anchor", "hash"] }
4949
ntt-transceiver = { path = "../../programs/ntt-transceiver", features = ["testing"], optional = true }
5050
wormhole-governance = { path = "../../programs/wormhole-governance", features = ["no-entrypoint"] }
51-
wormhole-svm-definitions = { git = "https://github.com/wormholelabs-xyz/wormhole", branch = "svm-shims-fr-env-addr" }
52-
wormhole-svm-shim = { git = "https://github.com/wormhole-foundation/wormhole", branch = "svm/anchor-v0.29.0-shim-interface" }

0 commit comments

Comments
 (0)