Skip to content

Rule: Bump/endianness drift + init/realloc/close hygiene #6

@Cass402

Description

@Cass402

Summary

Detect mismatched bump usage, endianness inconsistencies, and unsafe account allocation/reallocation/closure patterns.
Related to #3

Why it matters

•	A mismatched bump between derive and constraint can cause unexpected PDA resolution failures.
•	Wrong endianness can corrupt account layouts.
•	Unsafe init, realloc, or close can leak lamports, break rent-exemption, or cause logic errors.

Proposed Approach

•	Compare bumps from find_program_address with bumps declared in account attributes.
•	Track numeric serialization patterns and warn on big/little-endian mismatches.
•	On init/realloc/close, check:
•	Rent-exemption math correctness
•	Zero-initialization on growth
•	No unchecked shrinking without data reset
•	Correct space calculation

Examples

Flag:

let (pda, bump0) = Pubkey::find_program_address(...);
#[account(seeds=[...], bump = bump1)] // bump1 != bump0
pub acct: Account<'info, Foo>;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions