Skip to content

feat:cargo check features#237

Open
pityjllk wants to merge 23 commits intomainfrom
feat/cargo-check-features
Open

feat:cargo check features#237
pityjllk wants to merge 23 commits intomainfrom
feat/cargo-check-features

Conversation

@pityjllk
Copy link
Copy Markdown
Collaborator

@pityjllk pityjllk commented Mar 17, 2026

Summary

We use cargo-hack to verify that every feature in the workspace compiles correctly in isolation — both on the host and for wasm32-unknown-unknown. This catches issues like missing feature
gates, unused imports behind cfg flags, and broken feature combinations that normal cargo check misses because it only tests default features.

The check runs individual cargo check invocations across the workspace, covering:

  • Each feature tested alone (--each-feature) for most crates
  • Full powerset of variant features (--feature-powerset --at-least-one-of) for crates where enums are entirely feature-gated (defuse-token-id, defuse-ton-connect, defuse-escrow-swap)
  • Warnings treated as errors (-D warnings) on all passes

Changes

  • Makefile: Added check-all-features-host, check-all-features-wasm, and check-examples targets
  • CI: Installs cargo-hack and runs make check-all-features on every PR
  • Cargo.toml: Enabled arbitrary/derive at workspace level (near-sdk uses derive(Arbitrary) without enabling the feature itself)
  • Feature fixes: Added missing feature gates for defuse-sep53 (ed25519), defuse-ton-connect (abi propagation), defuse-token-id (arbitrary implies nep245), and conditional imports in
    ton-connect/schema/mod.rs
  • sandbox: Gated imt module behind its feature flag

Summary by CodeRabbit

  • Chores

    • CI now runs stricter WASM/clippy checks plus workspace-wide feature and example checks.
    • Build tooling expanded to exercise all feature combinations and host/wasm variants; help output updated.
    • Formatting flow extended to include additional formatters.
    • Adjusted workspace and crate dependency feature declarations for compatibility.
  • Refactor

    • Public API signatures updated for consistency.
    • Added conditional feature-gating to modules and methods to reduce compilation surface.
    • Updated cryptography feature selections in signature crates.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 17, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds workspace-wide feature-powerset checks to CI and Makefile, centralizes arbitrary workspace dependency with derive enabled, removes redundant per-crate derive flags, updates several crate feature flags and cfg-gates, modifies a few public method signatures and import paths.

Changes

Cohort / File(s) Summary
CI / Workflow
.github/workflows/ci.yml
Switches clippy invocation for a contract to --target wasm32-unknown-unknown; adds steps to install cargo-hack, run make check-all-features, and make check-examples.
Makefile / Build targets
Makefile
Adds feature-powerset testing variables (CRATES_AT_LEAST_ONE_VARIANT, CRATES_HOST_ONLY), parsing helpers, RUSTFLAGS_CHECK, host/wasm CARGO_CHECK_* wrappers, check-all-features(-host/-wasm), check, and check-examples targets; adds taplo format to fmt; updates help.
Workspace Cargo
Cargo.toml
Changes workspace arbitrary to arbitrary = { version = "1", features = ["derive"] } with explanatory comments.
Per-crate Cargo edits
contracts/wallet/Cargo.toml, crates/crypto/Cargo.toml
Removes per-crate arbitrary derive features so crates rely on workspace arbitrary; adjusts crates/crypto dev-dependency syntax.
Signature crates features
crates/signatures/sep53/Cargo.toml, crates/signatures/ton-connect/Cargo.toml
sep53: change defuse-crypto feature from ["secp256k1"]["ed25519"]. ton-connect: expand abi feature to include defuse-crypto/abi and defuse-serde-utils/abi.
Schema & API changes
crates/signatures/ton-connect/src/schema/mod.rs
Gates create_payload_hash with #[cfg(any(feature = "binary", feature = "text"))]; replace Error::custom with tlb_ton::Error::custom; call near_sdk::env::sha256_array.
Testing sandbox & tokens
crates/testing/sandbox/src/extensions/defuse/tokens/mod.rs
Adds #[cfg(feature = "imt")] to the public imt module (conditional exposure).
NEP-245 API
crates/near/nep245/src/checked.rs
Change RefundLogDelta methods to take self by value (pub const fn overhead(self) -> usize, pub const fn savings(self) -> usize).

Sequence Diagram(s)

mermaid
sequenceDiagram
autonumber
participant Dev as Developer (push/PR)
participant CI as CI Runner
participant Installer as taiki-e/install-action
participant Make as Makefile targets
participant CargoHack as cargo-hack / cargo
participant Crates as Workspace Crates
CI->>Installer: install cargo-hack
CI->>Make: run make check-all-features
Make->>CargoHack: run host checks (cargo hack check --each-feature ...)
CargoHack->>Crates: iterate features across crates (host)
Make->>CargoHack: run wasm checks (--target wasm32-unknown-unknown ...)
CargoHack->>Crates: iterate features across crates (wasm)
CI->>Make: run make check-examples
Make->>CargoHack: run cargo clippy --examples
CargoHack->>Crates: clippy examples

(Note: rectangles/boxes not required; flow shows primary interactions.)

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • hlgltvnnk
  • mitinarseny

Poem

🐇 I hop through Cargo.toml and Makefile tracks,

Features lined up neatly, no stray syntax hacks,
CI flutters, cargo-hack hums a tune,
Crates compile beneath the watchful moon,
🥕 a tiny rabbit cheers — merge it soon!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat:cargo check features' directly describes the main change—adding cargo-hack-based feature checking to the build process across host and wasm targets.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/cargo-check-features

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@Makefile`:
- Around line 108-111: The Makefile advertises and CI expects a
check-all-features target but it is missing; add a new phony alias target named
check-all-features that depends on the existing targets check-all-features-host
and check-all-features-wasm (so that running make check-all-features runs both
feature checks), and ensure .PHONY includes check-all-features; update the check
target to continue depending on check-all-features-host and
check-all-features-wasm (or on the new check-all-features alias) so CI and the
help text stop failing.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0ae3deee-2ae5-4e2e-b724-311ef9e1f2a3

📥 Commits

Reviewing files that changed from the base of the PR and between 885db84 and 44a050f.

📒 Files selected for processing (10)
  • .github/workflows/ci.yml
  • Cargo.toml
  • Makefile
  • contracts/wallet/Cargo.toml
  • crates/crypto/Cargo.toml
  • crates/primitives/token-id/Cargo.toml
  • crates/signatures/sep53/Cargo.toml
  • crates/signatures/ton-connect/Cargo.toml
  • crates/signatures/ton-connect/src/schema/mod.rs
  • crates/testing/sandbox/src/extensions/defuse/tokens/mod.rs

Copy link
Copy Markdown
Collaborator

@mitinarseny mitinarseny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow

Makefile Outdated

RUSTFLAGS_CHECK = -D warnings
# --cfg clippy: near-sdk compile_error!s on host unless one of its allowed cfgs is set
CARGO_CHECK_HOST = RUSTFLAGS='$(RUSTFLAGS_CHECK) --cfg clippy' cargo hack check --exclude-features contract --no-dev-deps
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contract feature should be ok to be checked when near-sdk/unit-testing is enabled

Copy link
Copy Markdown
Collaborator Author

@pityjllk pityjllk Mar 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, but at the end of a day 2 configurations that we release are :

  • host compiler + abi features without contract feature
  • wasm compiler + contract feature

so using unit-testing feels hacky ....

wdyt

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but then it means that we don't run clippy on the code that we're unit-testing..

@pityjllk pityjllk force-pushed the feat/cargo-check-features branch from 5511d95 to 3aba5f7 Compare March 17, 2026 13:23
@pityjllk pityjllk force-pushed the feat/cargo-check-features branch from 3aba5f7 to 0a02ec5 Compare March 17, 2026 14:37
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (1)
Makefile (1)

109-111: ⚠️ Potential issue | 🔴 Critical

Add missing check-all-features target to prevent CI failure.

CI workflow (.github/workflows/ci.yml line 61) calls make check-all-features, but this target doesn't exist. Line 88 advertises it in help, and line 109 declares .PHONY: check but not check-all-features. Running make check-all-features will fail with "No rule to make target".

,

Proposed fix
-.PHONY: check check-all-features-host check-all-features-wasm check-examples
+.PHONY: check check-all-features check-all-features-host check-all-features-wasm check-examples
 
-check: check-all-features-host check-all-features-wasm check-examples
+check-all-features: check-all-features-host check-all-features-wasm check-examples
+
+check: check-all-features
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Makefile` around lines 109 - 111, Add the missing Makefile target named
check-all-features so the CI call succeeds: create a rule "check-all-features:
check-all-features-host check-all-features-wasm check-examples" and add
check-all-features to the .PHONY line (alongside check, check-all-features-host,
check-all-features-wasm, check-examples) so running make check-all-features
invokes the three sub-targets as intended.
🧹 Nitpick comments (1)
Makefile (1)

127-128: Missing blank line before .PHONY: fmt.

For readability and consistency with the rest of the Makefile, add a blank line between the check-all-features-wasm target and the .PHONY: fmt declaration.

Proposed fix
 	$(foreach c,$(CRATES_AT_LEAST_ONE_VARIANT),\
 	    $(CARGO_CHECK_WASM) -p $(call crate_name,$c) --feature-powerset --at-least-one-of $(call crate_features,$c) &&) true
+
 .PHONY: fmt
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Makefile` around lines 127 - 128, There is no blank line between the end of
the check-all-features-wasm target (the recipe that ends with
"$(CARGO_CHECK_WASM) -p $(call crate_name,$c) --feature-powerset
--at-least-one-of $(call crate_features,$c) &&) true") and the `.PHONY: fmt`
declaration; insert a single empty line between that target block and the
`.PHONY: fmt` line so the Makefile matches the existing formatting and improves
readability.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/signatures/sep53/Cargo.toml`:
- Line 9: The dependency entry in Cargo.toml for defuse-crypto includes an
unused "secp256k1" feature; edit the defuse-crypto line in
crates/signatures/sep53/Cargo.toml to remove "secp256k1" and leave only features
= ["ed25519"] (the sep53 crate's lib.rs imports Ed25519), then run cargo
check/build to verify compilation still succeeds.

In `@crates/signatures/ton-connect/src/schema/mod.rs`:
- Around line 29-30: Remove the consecutive blank lines in the top-level module
file mod.rs to satisfy the formatter; open
crates/signatures/ton-connect/src/schema/mod.rs and delete the extra empty lines
so there are no multiple consecutive blank lines between items (leave single
blank lines where appropriate).

---

Duplicate comments:
In `@Makefile`:
- Around line 109-111: Add the missing Makefile target named check-all-features
so the CI call succeeds: create a rule "check-all-features:
check-all-features-host check-all-features-wasm check-examples" and add
check-all-features to the .PHONY line (alongside check, check-all-features-host,
check-all-features-wasm, check-examples) so running make check-all-features
invokes the three sub-targets as intended.

---

Nitpick comments:
In `@Makefile`:
- Around line 127-128: There is no blank line between the end of the
check-all-features-wasm target (the recipe that ends with "$(CARGO_CHECK_WASM)
-p $(call crate_name,$c) --feature-powerset --at-least-one-of $(call
crate_features,$c) &&) true") and the `.PHONY: fmt` declaration; insert a single
empty line between that target block and the `.PHONY: fmt` line so the Makefile
matches the existing formatting and improves readability.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a4c001f3-a258-440d-8354-6a14bffb1377

📥 Commits

Reviewing files that changed from the base of the PR and between 44a050f and 0a02ec5.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (9)
  • .github/workflows/ci.yml
  • Cargo.toml
  • Makefile
  • contracts/wallet/Cargo.toml
  • crates/crypto/Cargo.toml
  • crates/near/nep245/src/checked.rs
  • crates/signatures/sep53/Cargo.toml
  • crates/signatures/ton-connect/Cargo.toml
  • crates/signatures/ton-connect/src/schema/mod.rs
🚧 Files skipped from review as they are similar to previous changes (3)
  • .github/workflows/ci.yml
  • crates/crypto/Cargo.toml
  • crates/signatures/ton-connect/Cargo.toml

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
Makefile (1)

109-112: ⚠️ Potential issue | 🟡 Minor

Add check-all-features to .PHONY.

Line 112 defines the aggregate target, but Line 109 still omits it from .PHONY. If a file or directory named check-all-features ever appears, make can treat the target as up to date and skip the checks.

♻️ Proposed fix
-.PHONY: check check-all-features-host check-all-features-wasm check-examples
+.PHONY: check check-all-features check-all-features-host check-all-features-wasm check-examples
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Makefile` around lines 109 - 112, The .PHONY line is missing the aggregate
target check-all-features which can cause make to skip running it if a
file/directory with that name exists; update the .PHONY declaration (currently
listing check check-all-features-host check-all-features-wasm check-examples) to
also include check-all-features so that the make target check-all-features is
always treated as phony and always executed when invoked.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/ci.yml:
- Around line 55-57: The "Run clippy for defuse" GitHub Actions step currently
runs `cargo clippy --manifest-path ./contracts/defuse/Cargo.toml
--features=contract --target wasm32-unknown-unknown` but doesn't promote
warnings to errors; update that step (the "Run clippy for defuse" workflow job)
to append the clippy flag to deny warnings by adding `-- -D warnings` to the
command so Clippy warnings fail CI.

---

Duplicate comments:
In `@Makefile`:
- Around line 109-112: The .PHONY line is missing the aggregate target
check-all-features which can cause make to skip running it if a file/directory
with that name exists; update the .PHONY declaration (currently listing check
check-all-features-host check-all-features-wasm check-examples) to also include
check-all-features so that the make target check-all-features is always treated
as phony and always executed when invoked.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e68146fe-da5e-4491-8a25-d5bfad98ebe3

📥 Commits

Reviewing files that changed from the base of the PR and between 0a02ec5 and 9fc3ee1.

📒 Files selected for processing (2)
  • .github/workflows/ci.yml
  • Makefile

@pityjllk pityjllk changed the title Feat/cargo check features feat:cargo check features Mar 17, 2026
Makefile Outdated
Comment on lines +87 to +88
@echo " clippy Run clippy lints"
@echo " check-all-features Check all feature combos with cargo-hack"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we make it by default? i.e. check

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, only listed check in help

Makefile Outdated
Comment on lines +120 to +121
$(foreach c,$(CRATES_AT_LEAST_ONE_VARIANT),\
$(CARGO_CHECK_HOST) -p $(call crate_name,$c) --feature-powerset --at-least-one-of $(call crate_features,$c) &&) true
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we make them to appear as separate instructions instead of one-liner?

Suggested change
$(foreach c,$(CRATES_AT_LEAST_ONE_VARIANT),\
$(CARGO_CHECK_HOST) -p $(call crate_name,$c) --feature-powerset --at-least-one-of $(call crate_features,$c) &&) true
$(foreach c,$(CRATES_AT_LEAST_ONE_VARIANT),\
$(CARGO_CHECK_HOST) -p $(call crate_name,$c) --feature-powerset --at-least-one-of $(call crate_features,$c))

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

made it work with TARGET::

make -n check
RUSTFLAGS='-D warnings --cfg clippy' cargo hack check --exclude-features contract --no-dev-deps --workspace --each-feature --exclude-no-default-features \
            --exclude defuse-token-id --exclude defuse-ton-connect --exclude defuse-escrow-swap
RUSTFLAGS='-D warnings --cfg clippy' cargo hack check --exclude-features contract --no-dev-deps -p defuse-token-id --feature-powerset --at-least-one-of nep141,nep171,nep245,imt
RUSTFLAGS='-D warnings --cfg clippy' cargo hack check --exclude-features contract --no-dev-deps -p defuse-ton-connect --feature-powerset --at-least-one-of text,binary,cell
RUSTFLAGS='-D warnings --cfg clippy' cargo hack check --exclude-features contract --no-dev-deps -p defuse-escrow-swap --feature-powerset --at-least-one-of nep141,nep245
RUSTFLAGS='-D warnings' cargo hack check --target wasm32-unknown-unknown --exclude-features abi --exclude-features near-api-types --exclude-features near-api --no-dev-deps --workspace --each-feature --exclude-no-default-features \
            --exclude defuse-token-id --exclude defuse-ton-connect --exclude defuse-escrow-swap \
            --exclude defuse-test-utils --exclude defuse-sandbox --exclude defuse-randomness --exclude defuse-tests
RUSTFLAGS='-D warnings' cargo hack check --target wasm32-unknown-unknown --exclude-features abi --exclude-features near-api-types --exclude-features near-api --no-dev-deps -p defuse-token-id --feature-powerset --at-least-one-of nep141,nep171,nep245,imt
RUSTFLAGS='-D warnings' cargo hack check --target wasm32-unknown-unknown --exclude-features abi --exclude-features near-api-types --exclude-features near-api --no-dev-deps -p defuse-ton-connect --feature-powerset --at-least-one-of text,binary,cell
RUSTFLAGS='-D warnings' cargo hack check --target wasm32-unknown-unknown --exclude-features abi --exclude-features near-api-types --exclude-features near-api --no-dev-deps -p defuse-escrow-swap --feature-powerset --at-least-one-of nep141,nep245
RUSTFLAGS='-D warnings' cargo clippy --workspace --examples

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! But now the question is: since we're not using clippy anymore but just faking it via --cfg clippy, does it mean that all clippy::* warnings are suspended now?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it just satisfies the near-sdk and is general enough so work for both serde-sdk dependant and not dependant crate, i will move to clippy in one of the following prs, fo

Makefile Outdated
Comment on lines +6 to +22
# Crates where every enum variant is feature-gated, requiring at least one
# variant feature. These need --feature-powerset + --at-least-one-of instead
# of --each-feature (which tests features in isolation).
# Format: crate=feature1,feature2,...
CRATES_AT_LEAST_ONE_VARIANT := \
defuse-token-id=nep141,nep171,nep245,imt \
defuse-ton-connect=text,binary,cell \
defuse-escrow-swap=nep141,nep245

# Testing crates that cannot compile for wasm32-unknown-unknown.
# defuse-randomness uses rand/getrandom which lacks wasm32 support;
# it only reaches the defuse contract via dev-dependencies, never in the WASM binary.
CRATES_HOST_ONLY := \
defuse-test-utils \
defuse-sandbox \
defuse-randomness \
defuse-tests
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in general, what is the advantage of it compared to matrix of features in CI? Similar to how it's done in near-sdk repo
https://github.com/near/near-sdk-rs/blob/e484fd308b37ab1a08114ac9b820d71ff79c188a/.github/workflows/test.yml#L24-L27

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it checks combination of all possible features for each crate separately.

info: --no-dev-deps modifies real `Cargo.toml` while cargo-hack is running and restores it when finished
info: running `cargo check --no-default-features --features abi,arbitrary,binary,cell,text` on defuse-ton-connect (1/32)
info: running `cargo check --no-default-features --features binary` on defuse-ton-connect (2/32)
info: running `cargo check --no-default-features --features abi,binary` on defuse-ton-connect (3/32)
info: running `cargo check --no-default-features --features arbitrary,binary` on defuse-ton-connect (4/32)
info: running `cargo check --no-default-features --features abi,arbitrary,binary` on defuse-ton-connect (5/32)
info: running `cargo check --no-default-features --features cell` on defuse-ton-connect (6/32)
info: running `cargo check --no-default-features --features abi,cell` on defuse-ton-connect (7/32)
info: running `cargo check --no-default-features --features arbitrary,cell` on defuse-ton-connect (8/32)
info: running `cargo check --no-default-features --features abi,arbitrary,cell` on defuse-ton-connect (9/32)
info: running `cargo check --no-default-features --features binary,cell` on defuse-ton-connect (10/32)
info: running `cargo check --no-default-features --features abi,binary,cell` on defuse-ton-connect (11/32)
info: running `cargo check --no-default-features --features arbitrary,binary,cell` on defuse-ton-connect (12/32)
info: running `cargo check --no-default-features --features abi,arbitrary,binary,cell` on defuse-ton-connect (13/32)
info: running `cargo check --no-default-features --features default` on defuse-ton-connect (14/32)
info: running `cargo check --no-default-features --features abi,default` on defuse-ton-connect (15/32)
info: running `cargo check --no-default-features --features arbitrary,default` on defuse-ton-connect (16/32)
info: running `cargo check --no-default-features --features abi,arbitrary,default` on defuse-ton-connect (17/32)
info: running `cargo check --no-default-features --features text` on defuse-ton-connect (18/32)
info: running `cargo check --no-default-features --features abi,text` on defuse-ton-connect (19/32)
info: running `cargo check --no-default-features --features arbitrary,text` on defuse-ton-connect (20/32)
info: running `cargo check --no-default-features --features abi,arbitrary,text` on defuse-ton-connect (21/32)
info: running `cargo check --no-default-features --features binary,text` on defuse-ton-connect (22/32)
info: running `cargo check --no-default-features --features abi,binary,text` on defuse-ton-connect (23/32)
info: running `cargo check --no-default-features --features arbitrary,binary,text` on defuse-ton-connect (24/32)
info: running `cargo check --no-default-features --features abi,arbitrary,binary,text` on defuse-ton-connect (25/32)
info: running `cargo check --no-default-features --features cell,text` on defuse-ton-connect (26/32)
info: running `cargo check --no-default-features --features abi,cell,text` on defuse-ton-connect (27/32)
info: running `cargo check --no-default-features --features arbitrary,cell,text` on defuse-ton-connect (28/32)
info: running `cargo check --no-default-features --features abi,arbitrary,cell,text` on defuse-ton-connect (29/32)
info: running `cargo check --no-default-features --features binary,cell,text` on defuse-ton-connect (30/32)
info: running `cargo check --no-default-features --features abi,binary,cell,text` on defuse-ton-connect (31/32)
info: running `cargo check --no-default-features --features arbitrary,binary,cell,text` on defuse-ton-connect (32/32)
info: --no-dev-deps modifies real `Cargo.toml` while cargo-hack is running and restores it when finished


Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried it, very cool!

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@Makefile`:
- Around line 113-133: The check-all-features target can run
check-all-features-host and check-all-features-wasm in parallel causing
cargo-hack races; add a .NOTPARALLEL rule for check-all-features to serialize
execution (i.e., declare ".NOTPARALLEL: check-all-features") so the commands
that use CARGO_CHECK_HOST and CARGO_CHECK_WASM (which rewrite Cargo.toml) never
run concurrently.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: badb781c-2ab4-4e24-aaaa-0aa79d9e7456

📥 Commits

Reviewing files that changed from the base of the PR and between 9fc3ee1 and 6e13692.

📒 Files selected for processing (4)
  • Makefile
  • crates/signatures/sep53/Cargo.toml
  • crates/signatures/ton-connect/Cargo.toml
  • crates/signatures/ton-connect/src/schema/mod.rs
✅ Files skipped from review due to trivial changes (2)
  • crates/signatures/sep53/Cargo.toml
  • crates/signatures/ton-connect/Cargo.toml
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/signatures/ton-connect/src/schema/mod.rs

Makefile Outdated
Comment on lines +113 to +133
check-all-features: check-all-features-host check-all-features-wasm

check-examples:
RUSTFLAGS='$(RUSTFLAGS_CHECK)' cargo clippy --workspace --examples

check-all-features-host::
$(CARGO_CHECK_HOST) --workspace --each-feature --exclude-no-default-features \
$(foreach c,$(CRATES_AT_LEAST_ONE_VARIANT),--exclude $(call crate_name,$c))

$(foreach c,$(CRATES_AT_LEAST_ONE_VARIANT),\
$(eval check-all-features-host::; \
$(CARGO_CHECK_HOST) -p $(call crate_name,$c) --feature-powerset --at-least-one-of $(call crate_features,$c)))

check-all-features-wasm::
$(CARGO_CHECK_WASM) --workspace --each-feature --exclude-no-default-features \
$(foreach c,$(CRATES_AT_LEAST_ONE_VARIANT),--exclude $(call crate_name,$c)) \
$(addprefix --exclude ,$(CRATES_HOST_ONLY))

$(foreach c,$(CRATES_AT_LEAST_ONE_VARIANT),\
$(eval check-all-features-wasm::; \
$(CARGO_CHECK_WASM) -p $(call crate_name,$c) --feature-powerset --at-least-one-of $(call crate_features,$c)))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Serialization guards:"
rg -n '^\.(NOTPARALLEL|WAIT)\b' Makefile || true

echo
echo "Aggregate feature-check target:"
sed -n '113,133p' Makefile

echo
echo "Manifest-mutating cargo-hack invocations:"
rg -n --fixed-strings '--no-dev-deps' Makefile

Repository: near/intents

Length of output: 1562


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Serialization guards in Makefile ==="
grep -n '^\.(NOTPARALLEL\|WAIT)\b' Makefile || echo "No serialization guards found"

echo
echo "=== Checking for cargo-hack in Makefile ==="
grep -n 'cargo.hack\|--no-dev-deps\|--feature-powerset' Makefile || echo "No direct cargo-hack invocations found"

echo
echo "=== Variable definitions for CARGO_CHECK_HOST and CARGO_CHECK_WASM ==="
grep -n 'CARGO_CHECK_HOST\|CARGO_CHECK_WASM' Makefile | head -20

echo
echo "=== Full Makefile content to understand variable usage ==="
wc -l Makefile

Repository: near/intents

Length of output: 1687


Guard check-all-features against parallel cargo-hack runs.

Under make -j, the check-all-features target (line 113) schedules both check-all-features-host and check-all-features-wasm in parallel. Both use cargo hack check --no-dev-deps (defined in CARGO_CHECK_HOST and CARGO_CHECK_WASM on lines 30–31), which temporarily rewrites Cargo.toml. This can cause nondeterministic failures. Serialize this target by adding .NOTPARALLEL: check-all-features.

Minimal fix
+.NOTPARALLEL: check-all-features
 check-all-features: check-all-features-host check-all-features-wasm
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Makefile` around lines 113 - 133, The check-all-features target can run
check-all-features-host and check-all-features-wasm in parallel causing
cargo-hack races; add a .NOTPARALLEL rule for check-all-features to serialize
execution (i.e., declare ".NOTPARALLEL: check-all-features") so the commands
that use CARGO_CHECK_HOST and CARGO_CHECK_WASM (which rewrite Cargo.toml) never
run concurrently.

Makefile Outdated
Comment on lines +6 to +22
# Crates where every enum variant is feature-gated, requiring at least one
# variant feature. These need --feature-powerset + --at-least-one-of instead
# of --each-feature (which tests features in isolation).
# Format: crate=feature1,feature2,...
CRATES_AT_LEAST_ONE_VARIANT := \
defuse-token-id=nep141,nep171,nep245,imt \
defuse-ton-connect=text,binary,cell \
defuse-escrow-swap=nep141,nep245

# Testing crates that cannot compile for wasm32-unknown-unknown.
# defuse-randomness uses rand/getrandom which lacks wasm32 support;
# it only reaches the defuse contract via dev-dependencies, never in the WASM binary.
CRATES_HOST_ONLY := \
defuse-test-utils \
defuse-sandbox \
defuse-randomness \
defuse-tests
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried it, very cool!

Makefile Outdated
Comment on lines +30 to +31
CARGO_CHECK_HOST = RUSTFLAGS='$(RUSTFLAGS_CHECK) --cfg clippy' cargo hack check --exclude-features contract --no-dev-deps
CARGO_CHECK_WASM = RUSTFLAGS='$(RUSTFLAGS_CHECK)' cargo hack check --target wasm32-unknown-unknown --exclude-features abi --exclude-features near-api-types --exclude-features near-api --no-dev-deps
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Let's remove --no-dev-deps, as it results in longer runs in IDE due to messing around with rust-analyzer
  2. What prevents us from using cargo hack clippy already?
Suggested change
CARGO_CHECK_HOST = RUSTFLAGS='$(RUSTFLAGS_CHECK) --cfg clippy' cargo hack check --exclude-features contract --no-dev-deps
CARGO_CHECK_WASM = RUSTFLAGS='$(RUSTFLAGS_CHECK)' cargo hack check --target wasm32-unknown-unknown --exclude-features abi --exclude-features near-api-types --exclude-features near-api --no-dev-deps
CARGO_CHECK_HOST = RUSTFLAGS='$(RUSTFLAGS_CHECK) --cfg clippy' cargo hack clippy --exclude-features contract
CARGO_CHECK_WASM = RUSTFLAGS='$(RUSTFLAGS_CHECK)' cargo hack clippy --target wasm32-unknown-unknown --exclude-features abi --exclude-features near-api-types --exclude-features near-api

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What prevents us from using cargo hack clippy already?

nothing just didnt wanted stack up multiple things in single pr, i think its better to keep prs minimalistis, as they are easy to review and maintatin 👍 the purpose of this pr is to verify that crates that define particular features are able to be compile with different features combinations (we did not have such checks before)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please move all the crappy stuff to the end of the file, while keeping minimalistic and understandable targets on top?

Makefile Outdated

RUSTFLAGS_CHECK = -D warnings
# --cfg clippy: near-sdk compile_error!s on host unless one of its allowed cfgs is set
CARGO_CHECK_HOST = RUSTFLAGS='$(RUSTFLAGS_CHECK) --cfg clippy' cargo hack check --exclude-features contract --no-dev-deps
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but then it means that we don't run clippy on the code that we're unit-testing..

Makefile Outdated

.PHONY: check check-all-features-host check-all-features-wasm check-examples

check: check-all-features check-examples
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add clippy target as a pre-requisite here as well? So I can run all of these simply by make check

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would rather fix clippy findings in separate pr

@pityjllk
Copy link
Copy Markdown
Collaborator Author

Yes, but then it means that we don't run clippy on the code that we're unit-testing..

this pr only adds new checks, does not remove nor modify any of the existing ones, lets improve things incrementally

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
Makefile (1)

95-96: Orphaned .PHONY declaration.

The .PHONY: fmt declaration on line 95 is isolated from its target definition on line 140. Consider moving it adjacent to the fmt target for clarity, or grouping all .PHONY declarations together.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Makefile` around lines 95 - 96, Move the orphaned .PHONY declaration so it's
adjacent to the fmt target (or group it with other .PHONY lines): locate the
existing ".PHONY: fmt" and the "fmt" target in the Makefile and either relocate
the .PHONY line directly above the fmt target definition or consolidate it with
the file's other .PHONY declarations to keep declarations and targets together.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@Makefile`:
- Around line 95-96: Move the orphaned .PHONY declaration so it's adjacent to
the fmt target (or group it with other .PHONY lines): locate the existing
".PHONY: fmt" and the "fmt" target in the Makefile and either relocate the
.PHONY line directly above the fmt target definition or consolidate it with the
file's other .PHONY declarations to keep declarations and targets together.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d652d299-7774-4cbe-abb0-928c5f12f367

📥 Commits

Reviewing files that changed from the base of the PR and between 6e13692 and 7a98695.

📒 Files selected for processing (1)
  • Makefile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants