Assessment reports>Mitosis>Informational findings>Missing instance index update in migration function
Category: Coding Mistakes

Missing instance index update in migration function

Informational Impact
Informational Severity
N/A Likelihood

Description

In the EOLVaultFactory contract, the migrate function fails to properly update the instance index mapping for the destination vault type. While the function correctly removes the instance from the source vault type's tracking, it does not set the corresponding index in the destination's instanceIndex mapping:

function migrate(VaultType from, VaultType to, address instance, bytes calldata data) external onlyOwner {
    // ...
    $.infos[from].instances.pop();
    delete $.infos[from].instanceIndex[instance]; // Use delete instead of setting to 0

    $.infos[to].instances.push(instance);
    // Missing: $.infos[to].instanceIndex[instance] = $.infos[to].instances.length - 1;
    // ...
}

The function adds the instance to the destination's instances array but fails to update the instanceIndex mapping that would associate the instance address with its index in the array. This index is typically used for efficient instance lookup and to support operations like removal.

Impact

This is a minor code-quality issue that could potentially lead to inconsistencies in the vault factory's state tracking, though the impact is limited to administrative functionality.

Recommendations

Add the missing mapping update line to properly maintain the instance index:

$.infos[to].instanceIndex[instance] = $.infos[to].instances.length - 1;

Remediation

This issue has been acknowledged by Mitosis, and a fix was implemented in commit b98239c3.

Zellic © 2025Back to top ↑