Skip to content

Commit 208faeb

Browse files
committed
Merge branch 'brent/improve-wasm-build' (#2795)
* origin/brent/improve-wasm-build: changelog: add #2795 script/release: update wasm_for_tests path improve wasm build
2 parents e9e4712 + f3dbb47 commit 208faeb

File tree

141 files changed

+2196
-1075
lines changed

Some content is hidden

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

141 files changed

+2196
-1075
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Split up WASM transaction and validity-predicates into individual crates to
2+
improve build time. ([\#2795](https://github.com/anoma/namada/pull/2795))

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ paste = "1.0.9"
133133
pretty_assertions = "1.4.0"
134134
primitive-types = "0.12.1"
135135
proptest = "1.4.0"
136-
proptest-state-machine = "0.1.0"
136+
proptest-state-machine = "0.3.0"
137137
prost = "0.12.0"
138138
prost-types = "0.12.0"
139139
rand = {version = "0.8", default-features = false}

Makefile

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@ debug-cargo := $(env) $(debug-env) cargo
1717
nightly := $(shell cat rust-nightly-version)
1818

1919
# Path to the wasm source for the provided txs and VPs
20-
wasms := wasm/wasm_source
21-
wasms_for_tests := wasm_for_tests/wasm_source
22-
# Paths for all the wasm templates
23-
wasm_templates := wasm/tx_template wasm/vp_template
20+
wasms := wasm
21+
wasms_for_tests := wasm_for_tests
2422

2523
ifdef JOBS
2624
jobs := -j $(JOBS)
@@ -93,16 +91,17 @@ check-wasm = $(cargo) check --target wasm32-unknown-unknown --manifest-path $(wa
9391
check:
9492
$(cargo) check --workspace && \
9593
make -C $(wasms) check && \
96-
make -C $(wasms_for_tests) check && \
97-
$(foreach wasm,$(wasm_templates),$(check-wasm) && ) true
94+
make -C $(wasms_for_tests) check
9895

9996
check-mainnet:
10097
$(cargo) check --workspace --features "mainnet"
10198

10299
# Check that every crate can be built with default features and that namada crate
103100
# can be built for wasm
104101
check-crates:
102+
rustup target add --toolchain $(nightly) wasm32-unknown-unknown
105103
$(foreach p,$(crates), echo "Checking $(p)" && cargo +$(nightly) check -Z unstable-options --tests -p $(p) && ) \
104+
make -C $(wasms) check && \
106105
make -C $(wasms_for_tests) check && \
107106
cargo check --package namada --target wasm32-unknown-unknown --no-default-features --features "namada-sdk" && \
108107
cargo check --package namada_sdk --all-features
@@ -114,8 +113,7 @@ clippy:
114113
$(cargo) +$(nightly) clippy $(jobs) --all-targets --workspace --exclude namada_benchmarks -- -D warnings && \
115114
$(cargo) +$(nightly) clippy $(jobs) --all-targets --package namada_benchmarks -- -D warnings && \
116115
make -C $(wasms) clippy && \
117-
make -C $(wasms_for_tests) clippy && \
118-
$(foreach wasm,$(wasm_templates),$(clippy-wasm) && ) true
116+
make -C $(wasms_for_tests) clippy
119117

120118
clippy-mainnet:
121119
$(cargo) +$(nightly) clippy --all-targets --features "mainnet" -- -D warnings
@@ -255,15 +253,11 @@ test-pos-sm:
255253

256254
fmt-wasm = $(cargo) +$(nightly) fmt --manifest-path $(wasm)/Cargo.toml
257255
fmt:
258-
$(cargo) +$(nightly) fmt --all && \
259-
make -C $(wasms) fmt && \
260-
$(foreach wasm,$(wasm_templates),$(fmt-wasm) && ) true
256+
$(cargo) +$(nightly) fmt --all && make -C $(wasms) fmt
261257

262258
fmt-check-wasm = $(cargo) +$(nightly) fmt --manifest-path $(wasm)/Cargo.toml -- --check
263259
fmt-check:
264-
$(cargo) +$(nightly) fmt --all -- --check && \
265-
make -C $(wasms) fmt-check && \
266-
$(foreach wasm,$(wasm_templates),$(fmt-check-wasm) && ) true
260+
$(cargo) +$(nightly) fmt --all -- --check && make -C $(wasms) fmt-check
267261

268262
watch:
269263
$(cargo) watch
@@ -292,7 +286,7 @@ debug-wasm-scripts-docker: build-wasm-image-docker
292286

293287
# Build the validity predicate and transactions wasm
294288
build-wasm-scripts:
295-
rm wasm/*.wasm || true
289+
rm $(wasms)/*.wasm || true
296290
make -C $(wasms)
297291
make opt-wasm
298292
make checksum-wasm
@@ -304,6 +298,18 @@ debug-wasm-scripts:
304298
make opt-wasm
305299
make checksum-wasm
306300

301+
# Build the validity predicate and transactions wasm for tests
302+
build-wasm-tests-scripts:
303+
rm $(wasms_for_tests)/*.wasm || true
304+
make -C $(wasms_for_tests)
305+
make opt-wasm-tests
306+
307+
# Debug build the validity predicate and transactions wasm for tests
308+
debug-wasm-tests-scripts:
309+
rm $(wasms_for_tests)/*.wasm || true
310+
make -C $(wasms_for_tests) debug
311+
make opt-wasm-tests
312+
307313
# need python
308314
checksum-wasm:
309315
python3 wasm/checksums.py
@@ -312,6 +318,9 @@ checksum-wasm:
312318
opt-wasm:
313319
@for file in $(shell ls wasm/*.wasm); do wasm-opt -Oz -o $${file} $${file}; done
314320

321+
opt-wasm-tests:
322+
@for file in $(shell ls wasm_for_tests/*.wasm); do wasm-opt -Oz -o $${file} $${file}; done
323+
315324
clean-wasm-scripts:
316325
make -C $(wasms) clean
317326

crates/apps/src/lib/node/ledger/storage/rocksdb.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
//! - `all`: the hashes included up to the last block
4646
//! - `last`: the hashes included in the last block
4747
48-
use std::collections::HashSet;
4948
use std::fs::File;
5049
use std::io::{BufWriter, Write};
5150
use std::path::Path;
@@ -56,6 +55,7 @@ use borsh::BorshDeserialize;
5655
use borsh_ext::BorshSerializeExt;
5756
use data_encoding::HEXLOWER;
5857
use itertools::Either;
58+
use namada::core::collections::HashSet;
5959
use namada::core::storage::{
6060
BlockHeight, BlockResults, Epoch, EthEventsQueue, Header, Key, KeySeg,
6161
KEY_SEGMENT_SEPARATOR,
@@ -2105,9 +2105,7 @@ mod imp {
21052105

21062106
#[cfg(test)]
21072107
mod test {
2108-
use namada::core::address::{
2109-
gen_established_address, EstablishedAddressGen,
2110-
};
2108+
use namada::core::address::EstablishedAddressGen;
21112109
use namada::core::hash::Hash;
21122110
use namada::core::storage::{BlockHash, Epochs};
21132111
use namada::state::{MerkleTree, Sha256Hasher};

scripts/release.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ HASH_BEFORE=$(git rev-parse HEAD)
2525
cargo release --execute $VERSION
2626
HASH_AFTER=$(git rev-parse HEAD)
2727

28-
# update the wasm crate versions (2 fixups)
28+
# update the wasm workspace crate versions (2 fixups)
2929
cd $REPO_ROOT/wasm
3030
cargo update -w
3131
git add Cargo.lock
3232
git commit --fixup=$HASH_AFTER
3333
cargo release --execute $VERSION
3434

35-
# update the wasm_for_tests crate version, and rebuild them (3 fixups)
36-
cd $REPO_ROOT/wasm_for_tests/wasm_source
35+
# update the wasm_for_tests workspace crate version, and rebuild them (3 fixups)
36+
cd $REPO_ROOT/wasm_for_tests
3737
cargo update -w
3838
git add Cargo.lock
3939
git commit --fixup=$HASH_AFTER

0 commit comments

Comments
 (0)