Description
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.