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 #53

Open
code423n4 opened this issue Jul 18, 2022 · 1 comment
Open

Gas Optimizations #53

code423n4 opened this issue Jul 18, 2022 · 1 comment

Comments

@code423n4
Copy link
Contributor

Gas Report

G-01: use unchecked when incrementing the loop's variable

Since the loop's variable can't overflow in most circumstances, you can safe gas by incrementing it inside a unchecked block:

for (uint i; i < length;) {
    unchecked {
        ++i;
    }
}

e.g.

G-02: Don't allow the user to send more ETH than necessary allows you to remove the refund logic

In the ETHRegistraryController contract, you allow the user to pay more than necessary for the registration. Any surplus amount is then refunded.

If you force the user to pay the exact amount, you can remove the refund logic and thus save gas.

code423n4 added a commit that referenced this issue Jul 18, 2022
@jefflau
Copy link
Collaborator

jefflau commented Aug 1, 2022

G-02: Don't allow the user to send more ETH than necessary allows you to remove the refund logic

Intended behavior because the amount of ETH varies based on the oracle.

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