Skip to content

Commit d2e7b60

Browse files
authored
Merge branch 'kaspanet:master' into pnn-v1
2 parents aa627a2 + 3370225 commit d2e7b60

File tree

594 files changed

+34121
-14146
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

594 files changed

+34121
-14146
lines changed

.cargo/config.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Cargo configuration for musl builds
2+
# This configures linker flags to handle mimalloc conflicts with libstdc++
3+
# Since kaspa-alloc uses mimalloc with 'override' feature (which conflicts with
4+
# libstdc++'s operator new/delete in musl static builds), we use linker flags
5+
# to allow multiple definitions. The linker will use the first definition it encounters.
6+
7+
[target.x86_64-unknown-linux-musl]
8+
rustflags = [
9+
"-C", "link-arg=-Wl,--allow-multiple-definition",
10+
]
11+
12+
# Static link CRT on Windows to avoid VCRedist dependency
13+
# (similar to how we use musl on Linux for portable binaries)
14+
[target.x86_64-pc-windows-msvc]
15+
rustflags = ["-C", "target-feature=+crt-static"]

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.git
2+
target

.github/workflows/ci.yaml

Lines changed: 118 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,8 @@ jobs:
1818
- name: Install stable toolchain
1919
uses: dtolnay/rust-toolchain@stable
2020

21-
- name: Cache
22-
uses: actions/cache@v4
23-
with:
24-
path: |
25-
~/.cargo/bin/
26-
~/.cargo/registry/index/
27-
~/.cargo/registry/cache/
28-
~/.cargo/git/db/
29-
target/
30-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
21+
- name: Set up cache
22+
uses: Swatinem/rust-cache@v2
3123

3224
- name: Run cargo check
3325
run: cargo check --tests --workspace --benches
@@ -100,36 +92,27 @@ jobs:
10092
uses: Swatinem/rust-cache@v2
10193

10294
- name: Install cargo-nextest
103-
run: cargo install cargo-nextest
104-
105-
- name: Cache
106-
uses: actions/cache@v4
95+
uses: taiki-e/install-action@v2
10796
with:
108-
path: |
109-
~/.cargo/bin/
110-
~/.cargo/registry/index/
111-
~/.cargo/registry/cache/
112-
~/.cargo/git/db/
113-
target/
114-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
97+
tool: cargo-nextest
11598

11699
- name: Run cargo build with devnet-prealloc feature
117-
run: cargo build --release --features devnet-prealloc --workspace --all --tests --benches
100+
run: cargo build --features devnet-prealloc --workspace --all --tests --benches
118101

119102
- name: Run cargo test regular features
120-
run: cargo nextest run --release --workspace
103+
run: cargo nextest run --workspace
121104

122105
- name: Run cargo doc tests
123-
run: cargo test --doc --release --workspace
106+
run: cargo test --doc --workspace
124107

125108
- name: Run cargo test on kaspa-hashes without asm
126-
run: cargo nextest run --release -p kaspa-hashes --features=no-asm --benches
109+
run: cargo nextest run -p kaspa-hashes --features=no-asm --benches
127110

128111
- name: Run cargo doc tests with features=no-asm on kaspa-hashes
129-
run: cargo test --doc --release -p kaspa-hashes --features=no-asm
112+
run: cargo test --doc -p kaspa-hashes --features=no-asm
130113

131114
- name: Run cargo doc
132-
run: cargo doc --release --no-deps --workspace
115+
run: cargo doc --no-deps --workspace
133116
- name: Run kip-10 example
134117
run: cargo run --example kip-10
135118

@@ -198,25 +181,37 @@ jobs:
198181
- name: Install stable toolchain
199182
uses: dtolnay/rust-toolchain@stable
200183
with:
184+
toolchain: 1.93.0
201185
components: rustfmt, clippy
202186

203-
- name: Cache
204-
uses: actions/cache@v4
205-
with:
206-
path: |
207-
~/.cargo/bin/
208-
~/.cargo/registry/index/
209-
~/.cargo/registry/cache/
210-
~/.cargo/git/db/
211-
target/
212-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
187+
- name: Set up cache
188+
uses: Swatinem/rust-cache@v2
213189

214190
- name: Run cargo fmt
215191
run: cargo fmt --all -- --check
216192

217193
- name: Run cargo clippy
218194
run: cargo clippy --workspace --tests --benches --examples -- -D warnings
219195

196+
check-no-std:
197+
name: Check no_std
198+
runs-on: ubuntu-latest
199+
steps:
200+
- name: Checkout sources
201+
uses: actions/checkout@v4
202+
203+
- name: Install stable toolchain
204+
uses: dtolnay/rust-toolchain@stable
205+
206+
- name: Add thumbv7em-none-eabi target
207+
run: rustup target add thumbv7em-none-eabi
208+
209+
- name: Set up cache
210+
uses: Swatinem/rust-cache@v2
211+
212+
- name: Run no_std cargo check for crypto/addresses
213+
run: cargo check -p kaspa-addresses --no-default-features --target thumbv7em-none-eabi
214+
220215

221216
check-wasm32:
222217
name: Check WASM32
@@ -259,16 +254,8 @@ jobs:
259254
- name: Add wasm32 target
260255
run: rustup target add wasm32-unknown-unknown
261256

262-
- name: Cache
263-
uses: actions/cache@v4
264-
with:
265-
path: |
266-
~/.cargo/bin/
267-
~/.cargo/registry/index/
268-
~/.cargo/registry/cache/
269-
~/.cargo/git/db/
270-
target/
271-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
257+
- name: Set up cache
258+
uses: Swatinem/rust-cache@v2
272259

273260
# append here any new wasm32 crate not already covered by the existing checks
274261

@@ -280,6 +267,74 @@ jobs:
280267

281268
- name: Run cargo check of kaspa-wasm for wasm32 target
282269
run: cargo clippy -p kaspa-wasm --target wasm32-unknown-unknown
270+
271+
test-wasm32:
272+
name: Test WASM32
273+
runs-on: ubuntu-latest
274+
steps:
275+
- name: Checkout sources
276+
uses: actions/checkout@v4
277+
278+
- name: Install Protoc
279+
uses: arduino/setup-protoc@v3
280+
with:
281+
repo-token: ${{ secrets.GITHUB_TOKEN }}
282+
283+
- name: Install llvm
284+
id: install_llvm
285+
continue-on-error: true
286+
run: |
287+
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
288+
sudo apt-get install -y clang-15 lldb-15 lld-15 clangd-15 clang-tidy-15 clang-format-15 clang-tools-15 llvm-15-dev lld-15 lldb-15 llvm-15-tools libomp-15-dev libc++-15-dev libc++abi-15-dev libclang-common-15-dev libclang-15-dev libclang-cpp15-dev libunwind-15-dev
289+
# Make Clang 15 default
290+
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/lib/llvm-15/bin/clang++ 100
291+
sudo update-alternatives --install /usr/bin/clang clang /usr/lib/llvm-15/bin/clang 100
292+
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/lib/llvm-15/bin/clang-format 100
293+
sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/lib/llvm-15/bin/clang-tidy 100
294+
sudo update-alternatives --install /usr/bin/run-clang-tidy run-clang-tidy /usr/lib/llvm-15/bin/run-clang-tidy 100
295+
# Alias cc to clang
296+
sudo update-alternatives --install /usr/bin/cc cc /usr/lib/llvm-15/bin/clang 0
297+
sudo update-alternatives --install /usr/bin/c++ c++ /usr/lib/llvm-15/bin/clang++ 0
298+
299+
- name: Install gcc-multilib
300+
# gcc-multilib allows clang to find gnu libraries properly
301+
run: |
302+
sudo apt-get update
303+
sudo apt install -y gcc-multilib
304+
305+
- name: Install stable toolchain
306+
if: steps.install_llvm.outcome == 'success' && steps.install_llvm.conclusion == 'success'
307+
uses: dtolnay/rust-toolchain@stable
308+
309+
- name: Install wasm-pack
310+
uses: taiki-e/install-action@v2
311+
with:
312+
tool: wasm-pack
313+
314+
- name: Add wasm32 target
315+
run: rustup target add wasm32-unknown-unknown
316+
317+
- name: Set up cache
318+
uses: Swatinem/rust-cache@v2
319+
320+
- name: Install Node.js
321+
uses: actions/setup-node@v6
322+
with:
323+
node-version: 20
324+
325+
- name: Install NodeJS dependencies
326+
run: npm install --global typedoc typescript
327+
328+
# append here any new crates that contains wasm test suites (and aren't already covered)
329+
- name: Run wasm tests for consensus/core
330+
run: wasm-pack test --node consensus/core
331+
332+
- name: Run wasm tests for crypto/addresses
333+
run: wasm-pack test --node crypto/addresses
334+
335+
- name: Run wasm tests for wallet/pskt
336+
run: wasm-pack test --node wallet/pskt
337+
283338

284339
build-wasm32:
285340
name: Build WASM32 SDK
@@ -324,7 +379,9 @@ jobs:
324379
uses: dtolnay/rust-toolchain@stable
325380

326381
- name: Install wasm-pack
327-
run: cargo install wasm-pack
382+
uses: taiki-e/install-action@v2
383+
with:
384+
tool: wasm-pack
328385

329386
- name: Add wasm32 target
330387
run: rustup target add wasm32-unknown-unknown
@@ -337,30 +394,21 @@ jobs:
337394
- name: Install NodeJS dependencies
338395
run: npm install --global typedoc typescript
339396

340-
- name: Cache
341-
uses: actions/cache@v4
342-
with:
343-
path: |
344-
~/.cargo/bin/
345-
~/.cargo/registry/index/
346-
~/.cargo/registry/cache/
347-
~/.cargo/git/db/
348-
target/
349-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
397+
- name: Set up cache
398+
uses: Swatinem/rust-cache@v2
350399

351400
- name: Build wasm release
352401
run: |
353402
pushd .
354403
cd wasm
355404
bash build-release
356405
popd
357-
mv wasm/release/kaspa-wasm32-sdk.zip wasm/release/kaspa-wasm32-sdk-${{ env.SHORT_SHA }}.zip
358406
359407
- name: Upload WASM build to GitHub
360408
uses: actions/upload-artifact@v4
361409
with:
362-
name: kaspa-wasm32-sdk-${{ env.SHORT_SHA }}.zip
363-
path: wasm/release/kaspa-wasm32-sdk-${{ env.SHORT_SHA }}.zip
410+
name: kaspa-wasm32-sdk-${{ env.SHORT_SHA }}
411+
path: wasm/release/
364412
build-release:
365413
name: Build Linux Release
366414
runs-on: ubuntu-latest
@@ -376,33 +424,18 @@ jobs:
376424
- name: Install stable toolchain
377425
uses: dtolnay/rust-toolchain@stable
378426

379-
- name: Cache Cargo Build Outputs
380-
uses: actions/cache@v4
381-
with:
382-
path: |
383-
~/.cargo/bin/
384-
~/.cargo/registry/index/
385-
~/.cargo/registry/cache/
386-
~/.cargo/git/db/
387-
target/
388-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
389-
restore-keys: |
390-
${{ runner.os }}-cargo-
391-
392-
- name: Cache Toolchain
393-
uses: actions/cache@v4
394-
with:
395-
path: |
396-
~/x-tools
397-
key: ${{ runner.os }}-musl-${{ hashFiles('**/musl-toolchain/preset.sh') }}
398-
restore-keys: |
399-
${{ runner.os }}-musl-
427+
- name: Set up Rust cache
428+
uses: Swatinem/rust-cache@v2
400429

401-
402430
- name: Build RK with musl toolchain
403431
if: runner.os == 'Linux'
404432
run: |
405433
# Run build script for musl toolchain
406434
source musl-toolchain/build.sh
407-
# Build for musl
408-
cargo --verbose build --bin kaspad --bin rothschild --bin kaspa-wallet --release --target x86_64-unknown-linux-musl
435+
# Build bridge with allow-multiple-definition flag to handle mimalloc conflicts with libstdc++ in musl builds
436+
# This flag is only needed for kaspa-stratum-bridge due to its dual mimalloc dependency structure
437+
export RUSTFLAGS="$RUSTFLAGS -C link-arg=-Wl,--allow-multiple-definition"
438+
439+
# Build other binaries first (without the allow-multiple-definition flag)
440+
cargo build --bin kaspad --bin rothschild --bin kaspa-wallet --bin stratum-bridge --release --target x86_64-unknown-linux-musl
441+

0 commit comments

Comments
 (0)