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

RCMarket.sol - Gas optimization in claimCard #5

Open
code423n4 opened this issue Aug 19, 2021 · 2 comments
Open

RCMarket.sol - Gas optimization in claimCard #5

code423n4 opened this issue Aug 19, 2021 · 2 comments

Comments

@code423n4
Copy link
Contributor

Handle

PierrickGT

Vulnerability details

Impact

We can avoid one sload by storing card[_card].longestOwner in a private variable.

Proof of Concept

https://github.com/code-423n4/2021-08-realitycards/blob/514a6157fb7bd0df1d27a4affece131ba5056818/contracts/RCMarket.sol#L550-L551

Tools Used

Manual analysis

Recommended Mitigation Steps

Store card[_card].longestOwner in a private variable to avoid one sload.

address _cardLongestOwner = card[_card].longestOwner;

if (_user == _cardLongestOwner) {
    _transferCard(ownerOf(_card), _cardLongestOwner, _card);
} else {
    leaderboard.claimNFT(_user, _card);
    factory.mintCopyOfNFT(_user, _card);
}
@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Aug 19, 2021
code423n4 added a commit that referenced this issue Aug 19, 2021
@Splidge Splidge added the duplicate This issue or pull request already exists label Aug 26, 2021
@Splidge
Copy link
Collaborator

Splidge commented Aug 26, 2021

Duplicate of #6

@Splidge Splidge marked this as a duplicate of #6 Aug 26, 2021
@Splidge Splidge closed this as completed Aug 26, 2021
@0xean
Copy link
Collaborator

0xean commented Sep 2, 2021

Not a duplicate, same optimization, different location in the code.

@0xean 0xean reopened this Sep 2, 2021
@0xean 0xean removed the duplicate This issue or pull request already exists label Sep 2, 2021
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

3 participants