code-423n4 / 2022-06-connext-findings

1 stars 0 forks source link

Gas Optimizations #94

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

https://github.com/code-423n4/2022-06-connext/blob/main/contracts/contracts/core/connext/libraries/AssetLogic.sol#L226

Function swapFromLocalAssetIfNeededForExactOut: If _amount is 0 then no need to perform any other step in swapFromLocalAssetIfNeededForExactOut function

if (_amount == 0) {
      return (true, _amount, _asset);
    }

https://github.com/code-423n4/2022-06-connext/blob/main/contracts/contracts/core/shared/ProposedOwnable.sol#L161

_setOwner: This function can be defined as private instead of internal

0xleastwood commented 2 years ago

The first optimisation doesn't seem to be possible because this code path is not hit unless _amount != 0. See its use in _reconcileProcessPortal for context on why.

The second optimisation is minor.