sherlock-audit / 2024-08-tokamak-network-judging

1 stars 0 forks source link

Use internal functions for querying nativeTokenAddress() in L1StandardBridge and L1CrossDomainMessenger #88

Open nguyenzung opened 2 days ago

nguyenzung commented 2 days ago

Current implementation on L1StandardBridge and L1CrossDomainMessenger

    function nativeTokenAddress() public view returns (address) {
        return systemConfig.nativeTokenAddress();
    }

Improvement:

    function nativeTokenAddress() public view returns (address) {
        return _nativeToken();
    }

       function _nativeToken() internal view returns (address) {
        return systemConfig.nativeTokenAddress();
    }

Using internal function instead of nativeTokenAddress() in the same contract helps us saving gas because there is no more sub-context created calling to itself

theo-learner commented 2 days ago

Note: this issue is self-reported by protocol team (Tokamak Network)

sherlock-admin2 commented 1 day ago

The protocol team fixed this issue in the following PRs/commits: https://github.com/tokamak-network/tokamak-thanos/pull/289