Skip to content

Make 6-duplicate-mutable-accounts lint handle more cases #7

Open
@oslfmt

Description

@oslfmt

The current lint implementation handles the case when there are only two duplicate accounts just fine. This is because there only needs to be one constraint, to check the keys between a and b are not equal.

If there are >2 duplicate mutable accounts in the program, things become more complex, because of two main reasons. First, as more identical accounts are added, the number of constraints does not scale linearly. For example, if we have 3 accounts, we don't have 1 extra constraint, but 2 extra constraints. If we add 1 account to bring the total to 4, we have to add 3 more constraints to make sure all keys are unique.

Second, as multiple constraints are added, they don't have to all be specified in a single #[account] macro. Instead of creating a single macro, with the constraints comma-separated, like #[account(constraint = x, constraint = y...)], the program may choose to have many different macros, partitioning the set of required constraints in whatever way, for whatever reason.

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