Skip to content

[HIGH] storage::bump_all_persistent, get_contract_status, set_contract_status are dead code #80

Description

@Alqku

Summary

Three pub helpers in campaign/src/storage.rs are defined but never called from any contract entrypoint and never referenced again outside their own definition:

  1. pub fn bump_all_persistent(env: &Env, milestone_count: u32)
  2. pub fn get_contract_status(env: &Env) -> Option<u32>
  3. pub fn set_contract_status(env: &Env, status: u32)

DataKey::ContractStatus exists only to back helpers (2) and (3) — it has no other consumers.

Location

campaign/src/storage.rs:

  • Lines 312–327 — get_contract_status / set_contract_status and the DataKey::ContractStatus references.
  • Lines 377–399 — bump_all_persistent; the doc-comment on line 377 explicitly references a bump_storage admin function ("Call this from a bump_storage admin function to prevent archival during long-running campaigns") — no such function exists on CampaignContract in lib.rs.

A cross-repo search confirms there are no callers:

$ grep -rn 'set_contract_status\|get_contract_status' --include='*.rs' .
./src/storage.rs:312:pub fn get_contract_status(env: &Env) -> Option<u32> {
./src/storage.rs:322:pub fn set_contract_status(env: &Env, status: u32) {

Impact

  • Maintenance surface: future readers of storage.rs will assume these helpers are part of a feature that isn't actually wired up, leading to speculative refactors and tests against hypothetical behaviour.
  • API drift risk: pub fn exposure means downstream integrators or static analysers will pick them up as part of the contract surface even though they are unreachable from any contract method.
  • Dead-code warnings: clippy with -D warnings (which is what CI runs — see .github/workflows/ci.yml job clippy) currently does not flag these because pub items default to "considered used" at the crate level. Adding #![deny(dead_code)] (or auditing for true dead code, e.g. with cargo udeps) would expose them.

Fix

Two reasonable options:

Option A — Delete the helpers (preferred if there is no plan to wire them up):

  • Remove get_contract_status, set_contract_status, and the DataKey::ContractStatus variant from types.rs (or keep the variant if it is reserved for future use).
  • Remove bump_all_persistent (and its milestone-iteration loop in storage.rs).
  • Update the doc comment that references a non-existent bump_storage admin function.

Option B — Wire them up: Add a bump_storage admin method on CampaignContract that calls storage::bump_all_persistent(env, ...), gated by creator.require_auth() and a freeze-aware check. Either remove or document the intended call sites for get_contract_status / set_contract_status so the ContractStatus key has a real consumer.

Severity

[LOW] — pure dead-code / dead-API surface; no behaviour change required to fix. Pick Option A or B as a follow-up so the contract surface and the on-disk storage keyset stay in sync.

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official Campaign

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions