Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gas optimizations - Remove isMarket from RCMarket #161

Open
code423n4 opened this issue Jun 16, 2021 · 2 comments
Open

Gas optimizations - Remove isMarket from RCMarket #161

code423n4 opened this issue Jun 16, 2021 · 2 comments

Comments

@code423n4
Copy link
Contributor

Handle

a_delamo

Vulnerability details

Impact

RCMarket contains the constant variable isMarket to indicate it is a Market bool public constant override isMarket = true;.
This is after used in RCFactory

function changeMarketApproval(address _market) external onlyGovernors {
        require(_market != address(0));
        // check it's an RC contract
        IRCMarket _marketToApprove = IRCMarket(_market);
        assert(_marketToApprove.isMarket());
        isMarketApproved[_market] = !isMarketApproved[_market];
        emit LogMarketApproved(_market, isMarketApproved[_market]);
    }

Why not use mappingOfMarkets to verify the address is a Market? This would reduce the state space used.

@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Jun 16, 2021
code423n4 added a commit that referenced this issue Jun 16, 2021
@Splidge
Copy link
Collaborator

Splidge commented Jun 17, 2021

That certainly would be easier 👍

@Splidge
Copy link
Collaborator

Splidge commented Jun 21, 2021

In implementing this I discovered the problem.
The check isMarket() is mainly used when we deploy a new reference market contract. This checks that it is a market but doesn't add it to the mappingOfMarkets because it's not actually an active market.
I've changed changeMarketApproval to use the mapping in this commit but I'm going to leave the constant isMarket in the market mainly for the check in setReferenceContractAddress()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants