Skip to content

Commit 5c8cfa8

Browse files
authored
Merge pull request #3426 from autonomys/fix-runtime-builds
Fix runtime no-std/std builds, and other missing features
2 parents 7f51ed8 + 75217f5 commit 5c8cfa8

File tree

21 files changed

+179
-42
lines changed

21 files changed

+179
-42
lines changed

.github/workflows/rust.yml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,72 @@ jobs:
162162
cargo -Zgitoxide -Zgit clippy --locked --all-targets --features rocm -- -D warnings
163163
if: runner.os == 'Windows'
164164

165+
cargo-runtime-build:
166+
strategy:
167+
matrix:
168+
os: ${{ fromJson(github.repository_owner == 'autonomys' &&
169+
'[
170+
"runs-on=${{ github.run_id }}/runner=self-hosted-ubuntu-22.04-x86-64",
171+
["self-hosted", "windows-server-2022-x86-64"],
172+
["self-hosted", "macos-14-arm64"]
173+
]' ||
174+
'["ubuntu-22.04", "windows-2022", "macos-14"]') }}
175+
runs-on: ${{ matrix.os }}
176+
177+
steps:
178+
- name: Checkout
179+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
180+
181+
# On macOS, we need a proper Clang version, not Apple's custom version without wasm32 support
182+
- name: Install LLVM and Clang for macOS
183+
uses: KyleMayes/install-llvm-action@dec985c8d7b46a2f363ea1a78f660c946a3349ea # v2.0.1
184+
with:
185+
env: true
186+
version: 17
187+
if: runner.os == 'macOS'
188+
189+
# Because macOS, see https://andreasfertig.blog/2021/02/clang-and-gcc-on-macos-catalina-finding-the-include-paths/
190+
- name: Configure C compiler macOS
191+
run: |
192+
echo "SDKROOT=$(xcrun --show-sdk-path)" >> $GITHUB_ENV
193+
if: runner.os == 'macOS'
194+
195+
- name: Install glibtoolize (macOS)
196+
run: brew install libtool
197+
if: runner.os == 'macOS'
198+
199+
- name: Install Protoc
200+
uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b # v3.0.0
201+
with:
202+
repo-token: ${{ secrets.GITHUB_TOKEN }}
203+
204+
# Needed for hwloc
205+
- name: Install automake (macOS)
206+
run: brew install automake
207+
if: runner.os == 'macOS'
208+
209+
- name: Configure cache
210+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
211+
with:
212+
path: |
213+
~/.cargo/registry
214+
~/.cargo/git
215+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
216+
restore-keys: |
217+
${{ runner.os }}-cargo-
218+
219+
- name: build subspace-runtime
220+
run: |
221+
cargo -Zgitoxide -Zgit build --locked --package subspace-runtime
222+
223+
- name: build evm-domain-runtime
224+
run: |
225+
cargo -Zgitoxide -Zgit build --locked --package evm-domain-runtime
226+
227+
- name: build auto-id-domain-runtime
228+
run: |
229+
cargo -Zgitoxide -Zgit build --locked --package auto-id-domain-runtime
230+
165231
cargo-test:
166232
strategy:
167233
matrix:
@@ -226,3 +292,50 @@ jobs:
226292
- name: cargo nextest run --locked
227293
run: |
228294
cargo -Zgitoxide -Zgit nextest run --locked
295+
296+
# This job checks all crates individually, including no_std and other featureless builds.
297+
# We need to check crates individually for missing features, because cargo does feature
298+
# unification, which hides missing features when crates are built together.
299+
cargo-check-individually:
300+
strategy:
301+
matrix:
302+
# We only want to run these slower checks on the fastest runner
303+
os: ${{ fromJson(github.repository_owner == 'autonomys' &&
304+
'[
305+
"runs-on=${{ github.run_id }}/runner=self-hosted-ubuntu-22.04-x86-64",
306+
]' ||
307+
'["ubuntu-22.04"]') }}
308+
runs-on: ${{ matrix.os }}
309+
310+
steps:
311+
- name: Checkout
312+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
313+
314+
- name: Install Protoc
315+
uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b # v3.0.0
316+
with:
317+
repo-token: ${{ secrets.GITHUB_TOKEN }}
318+
319+
- name: Configure cache
320+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
321+
with:
322+
path: |
323+
~/.cargo/registry
324+
~/.cargo/git
325+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
326+
restore-keys: |
327+
${{ runner.os }}-cargo-
328+
329+
- name: check all crates individually
330+
run: |
331+
for crate in $(grep 'path =' Cargo.toml | sed 's/.*path *= *"\([^"]*\).*/\1/' | sort); do
332+
echo "$crate";
333+
pushd "$crate";
334+
if ! cargo -Zgitoxide -Zgit check --locked --all-targets; then
335+
pwd;
336+
popd;
337+
exit 1;
338+
fi;
339+
pwd;
340+
popd;
341+
done

crates/pallet-rewards/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ sp-runtime.workspace = true
3030
subspace-runtime-primitives.workspace = true
3131

3232
[dev-dependencies]
33-
pallet-balances.workspace = true
33+
pallet-balances = { workspace = true, features = ["std"] }
3434
sp-io.workspace = true
3535

3636
[features]

crates/pallet-subspace/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ subspace-verification.workspace = true
3232
[dev-dependencies]
3333
env_logger.workspace = true
3434
futures.workspace = true
35-
pallet-balances.workspace = true
35+
pallet-balances = { workspace = true, features = ["std"] }
3636
rand = { workspace = true, features = ["min_const_gen"] }
3737
sp-io.workspace = true
3838
subspace-archiving.workspace = true

crates/sc-consensus-subspace/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ sc-transaction-pool-api.workspace = true
3030
sc-utils.workspace = true
3131
sp-api.workspace = true
3232
sp-blockchain.workspace = true
33-
sp-block-builder.workspace = true
33+
sp-block-builder = { workspace = true, features = ["std"] }
3434
sp-consensus.workspace = true
35-
sp-consensus-subspace.workspace = true
35+
sp-consensus-subspace = { workspace = true, features = ["std"] }
3636
sp-consensus-slots.workspace = true
3737
sp-core.workspace = true
3838
sp-inherents.workspace = true
39-
sp-objects.workspace = true
39+
sp-objects = { workspace = true, features = ["std"] }
4040
sp-runtime.workspace = true
4141
subspace-archiving.workspace = true
4242
subspace-core-primitives.workspace = true

crates/sc-domains/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ frame-benchmarking = { workspace = true, optional = true }
2020
sc-client-api.workspace = true
2121
sc-executor.workspace = true
2222
sp-api.workspace = true
23-
sp-auto-id.workspace = true
23+
sp-auto-id = { workspace = true, features = ["std"] }
2424
sp-blockchain.workspace = true
2525
sp-core.workspace = true
26-
sp-domains.workspace = true
27-
sp-domains-fraud-proof.workspace = true
26+
sp-domains = { workspace = true, features = ["std"] }
27+
sp-domains-fraud-proof = { workspace = true, features = ["std"] }
2828
sp-externalities.workspace = true
2929
sp-io.workspace = true
30-
sp-messenger-host-functions.workspace = true
30+
sp-messenger-host-functions = { workspace = true, features = ["std"] }
3131
sp-runtime.workspace = true
3232
sp-subspace-mmr.workspace = true
3333

crates/sc-proof-of-time/Cargo.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ sc-client-api.workspace = true
2222
sc-consensus-slots.workspace = true
2323
sc-network.workspace = true
2424
sc-network-gossip.workspace = true
25-
sp-api.workspace = true
25+
sp-api = { workspace = true, features = ["std"] }
2626
sp-blockchain.workspace = true
2727
sp-consensus.workspace = true
28-
sp-consensus-slots.workspace = true
29-
sp-consensus-subspace.workspace = true
30-
sp-inherents.workspace = true
31-
sp-runtime.workspace = true
32-
subspace-core-primitives.workspace = true
28+
sp-consensus-slots = { workspace = true, features = ["std"] }
29+
sp-consensus-subspace = { workspace = true, features = ["std"] }
30+
sp-inherents = { workspace = true, features = ["std"] }
31+
sp-runtime = { workspace = true, features = ["std"] }
32+
subspace-core-primitives = { workspace = true, features = ["std"] }
3333
subspace-proof-of-time.workspace = true
3434
thread-priority.workspace = true
3535
tokio = { workspace = true, features = ["sync"] }
36-
tracing.workspace = true
36+
tracing = { workspace = true, features = ["std"] }

crates/sc-subspace-block-relay/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ sc-client-api.workspace = true
2121
sc-network.workspace = true
2222
sc-network-common.workspace = true
2323
sc-network-sync.workspace = true
24-
sp-api.workspace = true
25-
sp-consensus-subspace.workspace = true
24+
sp-api = { workspace = true, features = ["std"] }
25+
sp-consensus-subspace = { workspace = true, features = ["std"] }
2626
sc-transaction-pool-api.workspace = true
27-
sp-runtime.workspace = true
27+
sp-runtime = { workspace = true, features = ["std"] }
2828
strum_macros.workspace = true
29-
subspace-core-primitives.workspace = true
29+
subspace-core-primitives = { workspace = true, features = ["std"] }
3030
substrate-prometheus-endpoint.workspace = true
3131
thiserror.workspace = true
32-
tracing.workspace = true
32+
tracing = { workspace = true, features = ["std"] }

crates/sp-domains-fraud-proof/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,7 @@ std = [
7575
"hash-db/std",
7676
"log/std",
7777
"scale-info/std",
78-
"domain-block-preprocessor",
7978
"sc-client-api",
80-
"sc-executor",
8179
"sc-executor/std",
8280
"sp-api/std",
8381
"sp-blockchain",

crates/sp-domains/Cargo.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ rlp = { workspace = true, optional = true }
5050
num-traits.workspace = true
5151
rand = { workspace = true, features = ["min_const_gen"] }
5252

53+
# test-ethereum dependencies
54+
ethereum.workspace = true
55+
fp-self-contained = { workspace = true, features = ["default"] }
56+
frame-system.workspace = true
57+
libsecp256k1 = { workspace = true, features = ["static-context", "hmac"] }
58+
pallet-evm.workspace = true
59+
rlp.workspace = true
60+
5361
[features]
5462
default = ["std"]
5563
std = [
@@ -76,6 +84,13 @@ std = [
7684
"subspace-core-primitives/std",
7785
"subspace-runtime-primitives/std",
7886
"trie-db/std",
87+
# test-ethereum dependencies
88+
"ethereum?/std",
89+
"fp-self-contained?/std",
90+
"frame-system?/std",
91+
"libsecp256k1?/std",
92+
"pallet-evm?/std",
93+
"rlp?/std",
7994
]
8095
runtime-benchmarks = []
8196
test-ethereum = [

crates/subspace-archiving/Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,14 @@ subspace-erasure-coding.workspace = true
2525
subspace-kzg.workspace = true
2626
thiserror.workspace = true
2727

28+
# This is required to for benchmark dependency features to work correctly
29+
rand = { workspace = true, optional = true }
30+
2831
[dev-dependencies]
2932
criterion.workspace = true
3033
rand = { workspace = true, features = ["min_const_gen"] }
3134
subspace-core-primitives.workspace = true
32-
subspace-verification.workspace = true
35+
subspace-verification = { workspace = true, features = ["kzg"] }
3336

3437
[features]
3538
default = ["std"]
@@ -44,6 +47,8 @@ serde = [
4447
std = [
4548
"parity-scale-codec/std",
4649
"parallel",
50+
"rand?/std",
51+
"rand?/std_rng",
4752
"serde",
4853
"subspace-core-primitives/std",
4954
"subspace-erasure-coding/std",

0 commit comments

Comments
 (0)