fix(contracts): restore lib.rs, fix fuzz path, index TTLs, archive timestamp - #1266
Merged
Conversation
Commit ddd006b replaced the entire 8 000-line lib.rs with a single #![no_std] line, leaving the crate uncompilable and all module declarations (mod payments; mod registry_read; etc.) missing. Restore lib.rs from ddd006b^ and re-apply every fix that was merged after the file was deleted: - e5db392: persist health records, fix sentinel address in index_donor_unit, harden get_record/verify_access, update event API usage in tests - 5cdd28b: validate dispute timeout (zero / > max), use checked_add for dispute_deadline to prevent overflow - 6334337: enforce custodian checks in withdraw_blood, quarantine_blood, finalize_quarantine; add storage_lifecycle test coverage - 1ae8c2c: clear pending approvals on configure_multisig to invalidate stale votes closes Emeka000#1238
…toml The [[bin]] entry in contracts/fuzz/Cargo.toml declared: path = "fuzz_targets/fuzz_payments.rs" (plural) but the file on disk was fuzz_targets/fuzz_payment.rs (singular). Rename the file to fuzz_payments.rs so the path in Cargo.toml is satisfied. This unblocks cargo fuzz build for the entire fuzz crate — the mismatched path caused a hard build failure that prevented fuzz_custody_transfer and fuzz_disputes from being built as well. closes Emeka000#1241
Two related storage_lifecycle.rs bugs fixed together: Emeka000#1240 — BankUnits/DonorUnits/HospitalUnits/StatusUnits indexes were never TTL-bumped. Once any entry's TTL lapses the ledger archives it and reads silently return an empty Vec, causing get_units_by_bank / get_units_by_donor / etc. to report zero inventory with no error. - bump_rent_for_unit now accepts Option<&BloodUnit> to extend the TTL of BankUnits, DonorUnits (per-bank + global sentinel), HospitalUnits (when recipient_hospital is set), and StatusUnits keys alongside the existing core keys. - bump_all_registries now bumps all seven StatusUnits variants and scans BLOOD_UNITS once to bump every BankUnits, DonorUnits, and HospitalUnits index entry currently in storage. Emeka000#1239 — archive_custody_events derived terminal_timestamp from unit.delivery_timestamp / transfer_timestamp, both of which are unset for Discarded/Expired units (set only by confirm_transfer / initiate_transfer). This caused terminal_timestamp to fall back to 0, making the 30-day cooling-off guard always false and custody events immediately archivable for any non-transfer terminal state. Fix: derive terminal_timestamp from the last StatusChangeEvent in the unit's history, matching the approach used by archive_unit_history. closes Emeka000#1240 closes Emeka000#1239
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.
Summary
Fixes four contract bugs in three commits.
closes #1238 — Restore lib.rs (entire crate was uncompilable)
Commit
ddd006breplaced the fullcontracts/src/lib.rs(~8 000 lines) with a single#![no_std]line, deleting theErrorenum, all#[contracttype]definitions, the#[contract]/#[contractimpl]block, and everymoddeclaration. The crate failed to compile andcargo testcollected 0 tests.Restored
lib.rsfrom the parent of that commit and re-applied all fixes that had been merged afterward:index_donor_unit; hardenget_record/verify_access; update event-API usage in testschecked_addfordispute_deadlineto prevent overflowwithdraw_blood,quarantine_blood,finalize_quarantine; add storage_lifecycle test coveragePENDING_APPROVALSonconfigure_multisigto invalidate stale votescloses #1241 — Fix fuzz crate bin path (fuzz_payment.rs → fuzz_payments.rs)
contracts/fuzz/Cargo.tomldeclaredpath = "fuzz_targets/fuzz_payments.rs"(plural) but the file on disk wasfuzz_payment.rs(singular). Renamed the file to match the declared path. This hard build failure prevented all three fuzz targets from being built.closes #1240 — Bump TTL for BankUnits/DonorUnits/HospitalUnits/StatusUnits indexes
Neither
bump_rent_for_unitnorbump_all_registriesextended the TTL of the secondary index keys. Once any entry's rent lapses, reads silently return an emptyVec— inventory queries reporting zero units with no error.bump_rent_for_unitnow acceptsOption<&BloodUnit>and extends TTL for the unit'sBankUnits,DonorUnits(per-bank + global),HospitalUnits, andStatusUnitskeys.bump_all_registriesnow bumps all sevenStatusUnitsvariants and scansBLOOD_UNITSonce to bump all per-actor index entries.closes #1239 — Fix archive_custody_events 30-day cooling-off guard
archive_custody_eventsderivedterminal_timestampfromunit.delivery_timestamp.or(unit.transfer_timestamp), falling back to0forDiscarded/Expiredunits (those fields are only set byconfirm_transfer/initiate_transfer). Becausecurrent_time >> ARCHIVE_AFTER_DAYS * SECONDS_PER_DAY, the guard was alwaysfalse— custody events were immediately archivable with no grace period.Fix: derive
terminal_timestampfrom the lastStatusChangeEventin the unit's history, matching the approach used by the siblingarchive_unit_historyfunction.Testing