Omniscia Moby Audit
TransparentUpgradeableProxy Static Analysis Findings
TransparentUpgradeableProxy Static Analysis Findings
TUP-01S: Multiple Top-Level Declarations
Type | Severity | Location |
---|---|---|
Code Style | TransparentUpgradeableProxy.sol:L17, L96, L183 |
Description:
The referenced file contains multiple top-level declarations that decrease the legibility of the codebase.
Example:
contracts/proxy/TransparentUpgradeableProxy.sol
17abstract contract Proxy {18 /**19 * @dev Delegates the current call to `implementation`.20 *21 * This function does not return to its internall call site, it will return directly to the external caller.22 */23 function _delegate(address implementation) internal {24 // solhint-disable-next-line no-inline-assembly25 assembly {26 // Copy msg.data. We take full control of memory in this inline assembly27 // block because it will not return to Solidity code. We overwrite the28 // Solidity scratch pad at memory position 0.29 calldatacopy(0, 0, calldatasize())30
31 // Call the implementation.32 // out and outsize are 0 because we don't know the size yet.33 let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)34
35 // Copy the returned data.36 returndatacopy(0, 0, returndatasize())37
38 switch result39 // delegatecall returns 0 on error.40 case 0 { revert(0, returndatasize()) }41 default { return(0, returndatasize()) }42 }43 }44
45 /**46 * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function47 * and {_fallback} should delegate.48 */49 function _implementation() internal virtual view returns (address);50
51 /**52 * @dev Delegates the current call to the address returned by `_implementation()`.53 *54 * This function does not return to its internall call site, it will return directly to the external caller.55 */56 function _fallback() internal {57 // _beforeFallback();58 _delegate(_implementation());59 }60
61 /**62 * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other63 * function in the contract matches the call data.64 */65 fallback () payable external {66 _fallback();67 }68
69 /**70 * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data71 * is empty.72 */73 receive () payable external {74 _fallback();75 }76
77 /**78 * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`79 * call, or as part of the Solidity `fallback` or `receive` functions.80 *81 * If overriden should call `super._beforeFallback()`.82 */83 function _beforeFallback() internal virtual {84 }85}86
87/**88 * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an89 * implementation address that can be changed. This address is stored in storage in the location specified by90 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the91 * implementation behind the proxy.92 *93 * Upgradeability is only provided internally through {_upgradeTo}. For an externally upgradeable proxy see94 * {TransparentUpgradeableProxy}.95 */96contract UpgradeableProxy is Proxy {
Recommendation:
We advise all highlighted top-level declarations to be split into their respective code files, avoiding unnecessary imports as well as increasing the legibility of the codebase.
Alleviation (b02fae335f62cc1f5f4236fb4d982ad16a32bd26):
The file has been removed from the codebase rendering this exhibit no longer applicable.