Fix/remove noop state size stubs - #1383
Merged
afurious merged 3 commits intoAug 22, 2026
Merged
Conversation
Remove the five always-Ok check_* functions from contract_state_size.rs (check_contributor_limit, check_pledger_limit, check_string_len, check_roadmap_limit, check_stretch_goal_limit) and all their call sites in lib.rs. The real enforcement was already provided by the validate_*_capacity family introduced in audit Crowdfunding-DApp#23 (issue Crowdfunding-DApp#1307). The no-op stubs provided no additional protection and created a future-regression hazard: a reviewer scanning lib.rs could not tell from context alone that a .map_err(...)? call against a check_* function was a dead guard, making it plausible for a future cleanup to drop the adjacent validate_* call while keeping the innocuous-looking check_* one. The one call site where the no-op stub was the sole check — description length on new roadmap items (check_string_len) — is replaced with a call to the existing validate_roadmap_description, closing the live validation gap without changing the error path. Closes Crowdfunding-DApp#1381 Cross-ref: audit Crowdfunding-DApp#23 (issue Crowdfunding-DApp#1307)
The four always-Ok check_* functions (check_contributor_limit, check_pledger_limit, check_string_len, check_roadmap_limit) were originally identified by audit Crowdfunding-DApp#23 as silent no-ops wired at every collection-growth site in lib.rs alongside the real validate_*_capacity guards. Those stubs and their call sites had already been removed from production code (contract_state_size.rs and lib.rs) when the real validate_* family was introduced. This commit completes the cleanup by: - Rewriting the previously-commented-out contract_state_size_test module to test the actual current API (validate_* bool functions) instead of the removed check_* / StateSizeError API. - Re-enabling the module in lib.rs (was //mod contract_state_size_test;). - 44 new tests added; 197 total pass, clippy clean. The roadmap-description length gap is also closed: validate_roadmap_description is already called in add_roadmap_item before any item is pushed, so no validation gap exists at that site. Closes Crowdfunding-DApp#1307 Cross-reference: audit Crowdfunding-DApp#23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Title: chore(crowdfund): remove no-op
contract_state_size check_* stubs
───────────────────────────────────────────────
Description:
Summary
Closes #1307 · Cross-references: audit #23
Audit #23 identified four always-Ok(()) stub
functions in contract_state_size.rs —
check_contributor_limit, check_pledger_limit,
check_string_len, and check_roadmap_limit —
wired at every collection-growth entry point in
lib.rs alongside the real validate_capacity
guards that do the actual enforcement. The
stubs created a latent trap: any future
refactor that dropped the "obviously redundant"
validate call while keeping the
innocuous-looking check_* call would silently
reintroduce an unbounded-growth bug that
compiles clean and passes review.
The production-code half of that fix (removing
the stubs from contract_state_size.rs and their
call sites from lib.rs) had already landed.
This PR completes the cleanup:
the actual current API — 12 validate_*
functions (all returning bool) and the 3
published constants — replacing the stale file
that still imported the removed check_* /
StateSizeError API and had been commented out
to keep the build green.
lib.rs (was // mod contract_state_size_test;).
roadmap-description-length site:
validate_roadmap_description is already called
in add_roadmap_item before any item is
appended.
Changes
┌────────────────┬─────────────────────────┐
│ File │ What changed │
├────────────────┼─────────────────────────┤
│ src/contract_s │ Rewritten — 44 tests │
│ tate_size_test │ against the real │
│ .rs │ validate_* API │
├────────────────┼─────────────────────────┤
│ src/lib.rs │ mod │
│ │ contract_state_size_tes │
│ │ t uncommented │
└────────────────┴─────────────────────────┘
Testing
cargo test -p crowdfund # 197 passed, 0
failed (was 153 before this PR)
cargo clippy -p crowdfund -- -D warnings #
clean