<!-- canonical: https://0xsimao.com/findings/mitosis-remote-returning-soon-epoch -->

# Cap::_checkRemoteStateAndAdvance() may be optimized by returning early as soon as a different epoch is found in a remote domain

Low/Info · Three Sigma · Cross-chain liquidity layer 1 · 25th June, 2024

Finding 3S-Mitosis-N15 of the Mitosis security review.

- Protocol: https://mitosis.org/
- Report: /reports/mitosis
- Source: https://cdn.sanity.io/files/qoqld077/production/b6b3bd7bb47407d99e76abb7c6dc615c1db5018e.pdf

---

### Description

Cap::_checkRemoteStateAndAdvance() advances the next epoch if all domains are equal
to the minimum domain found. Thus, if any of the domains is not equal to the minimum, it
will return anyway.

### Recommendation

Given that it returns if any of epochs of the domains is different, there is no need to search
for the minimum. It's enough picking the domain of index 0 and returning if any of the other
domains is not the same. It later only advances the epoch if the epoch of the domains is
bigger than the local, so if they all match the current local domain, it will not advance
anyway.

### Status

Addressed in [#40ef30e](https://github.com/mitosis-org/evm/pull/206/commits/40ef30ebc52b4677b1c717ac81d3995a4c075186).

---

Related findings:

- [OstiumOpenPnl::average() can be simplified by adding a state variable that tracks the cumulative sum of nextEpochValues](https://0xsimao.com/findings/ostium-average-tracks-sum-epoch): Ostium
- [Funding cap in `IDOPoolAbstract::_basicParticipationCheck()` is imprecise and can lead to excessive tokens sold](https://0xsimao.com/findings/blast-ido-pools-participation-imprecise-excessive-sold): Blast IDO Pools
- [_tempTokenToCheck in BaseRouter does not need to be a state variable](https://0xsimao.com/findings/fuji-finance-temp-need-state-variable): Fuji Finance
- [Unnecessary check in StandardGovernor.state](https://0xsimao.com/findings/m-0-unnecessary-standard-governor-state): M^0 Minter Gateway
