Skip to content

Commit daffe58

Browse files
ci: patch transitive crates.io soroban-sdk in OpenZeppelin contracts build
The Test with OpenZeppelin Contracts workflow redirects soroban-sdk to the local checkout via [workspace.dependencies] path overrides. Those only cover directly-named dependency edges, so the soroban-sdk pulled transitively by soroban-poseidon (a crates.io dependency of stellar-tokens) was not redirected. This linked two copies of soroban-sdk and produced a duplicate panic_impl lang item error (E0152, #1723). Add a [patch.crates-io] table so transitive copies resolve to the local checkout as well, unifying on a single soroban-sdk.
1 parent cdae1e3 commit daffe58

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

.github/workflows/test-with-openzeppelin-stellar-contracts.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,23 @@ jobs:
8686
# Add features field to path-patched entries without features
8787
sed -i '/soroban-sdk = {.*path = /{/features/!s| }|, features = ["experimental_spec_shaking_v2"] }|}' Cargo.toml
8888
89+
- name: Patch transitive crates.io dependencies
90+
working-directory: stellar-contracts
91+
run: |
92+
# Crates such as soroban-poseidon are pulled from crates.io and depend on
93+
# soroban-sdk from crates.io. The [workspace.dependencies] path rewrite above
94+
# cannot redirect those transitive copies, so two soroban-sdk crates get
95+
# linked, producing duplicate `panic_impl` lang item errors (E0152, #1723).
96+
# A [patch.crates-io] table redirects transitive copies to the local checkout
97+
# (valid while the local version is semver-compatible with the required one).
98+
crates=$(cd ../rs-soroban-sdk && cargo metadata --format-version 1 --no-deps | jq -r '.packages[] | select(.publish != []) | .name')
99+
echo "" >> Cargo.toml
100+
echo "[patch.crates-io]" >> Cargo.toml
101+
for crate in $crates; do
102+
rel_path=$(realpath --relative-to="." ../rs-soroban-sdk/$crate)
103+
echo "$crate = { path = \"$rel_path\" }" >> Cargo.toml
104+
done
105+
89106
- name: Diff
90107
run: (! git diff --exit-code) || (echo 'A diff is expected'; exit 1)
91108

0 commit comments

Comments
 (0)