Skip to content

Commit

Permalink
Makefile: fix rust smart contracts build
Browse files Browse the repository at this point in the history
The contracts built using `make build-contracts-rs` were not working on
a production network because they included the `casper_print` FFI. This
happened because of the way `cargo` optimizes builds of dependencies.
Because one of the contracts had a requirement for the `test-support`
feature, all contracts were built with the `casper-contract` that had
that feature enabled (and which enabled the `casper_print` FFI).
Now we build each smart contract idependently to make sure that never
happens.

Signed-off-by: Alexandru Sardan <[email protected]>
  • Loading branch information
Alexandru Sardan committed Apr 11, 2024
1 parent b2b2fba commit f1a27fe
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,12 @@ CONTRACT_TARGET_DIR_AS = target_as

build-contract-rs/%:
cd smart_contracts/contracts && RUSTFLAGS=$(RUSTC_FLAGS) $(CARGO) build --verbose --release $(filter-out --release, $(CARGO_FLAGS)) --package $*
wasm-strip $(CONTRACT_TARGET_DIR)/$(subst -,_,$*).wasm 2>/dev/null | true

.PHONY: build-all-contracts-rs
build-all-contracts-rs:
cd smart_contracts/contracts && \
RUSTFLAGS=$(RUSTC_FLAGS) $(CARGO) build --verbose --release $(filter-out --release, $(CARGO_FLAGS)) $(patsubst %, -p %, $(ALL_CONTRACTS))
build-all-contracts-rs: $(patsubst %, build-contract-rs/%, $(ALL_CONTRACTS))

.PHONY: build-client-contracts-rs
build-client-contracts-rs:
cd smart_contracts/contracts && \
$(CARGO) build --release $(filter-out --release, $(CARGO_FLAGS)) $(patsubst %, -p %, $(CLIENT_CONTRACTS))
build-client-contracts-rs: $(patsubst %, build-contract-rs/%, $(CLIENT_CONTRACTS))

strip-contract/%:
wasm-strip $(CONTRACT_TARGET_DIR)/$(subst -,_,$*).wasm 2>/dev/null | true
Expand Down

0 comments on commit f1a27fe

Please sign in to comment.