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

Minor gas savings in require statements returning strings #31

Open
nicholashc opened this issue Nov 17, 2018 · 3 comments
Open

Minor gas savings in require statements returning strings #31

nicholashc opened this issue Nov 17, 2018 · 3 comments
Assignees

Comments

@nicholashc
Copy link

Description

Including an optional string comment in a passing require statement increases the gas cost of that transaction.

Scenario

Every require statement in the scope of this bounty includes a string comment that explains why the transaction would throw an exception. While helpful in debugging contracts during development, users rarely see these strings returned when they interact with the contract. For example, if a user sends a transaction via MetaMask, they do not see the string even if their transaction triggered an exception. These strings add additional gas costs to valid transactions compared to the same require statements without the strings.

Impact

This is a very minor note. Removing the string comments would save something on the order of ~100-200 gas per transaction.

Fix

Consider removing or shortening the strings in the require statements and adding them as comments in the verified contract.

@ghost
Copy link

ghost commented Nov 18, 2018

Users rarely see these strings returned when they interact with the contract.

My understanding is that EIP 140 and similar efforts are moving to have these strings returned to users all of the time. It would be forward-looking to continue to include the string comments in the require statements of Offers.sol, especially with such a minimal potential gain of ~100-200 gas.

@hwrdtm hwrdtm self-assigned this Nov 19, 2018
@hwrdtm
Copy link
Contributor

hwrdtm commented Nov 19, 2018

Thanks @nicholashc for your feedback! We will take it into consideration

@arthcmr
Copy link
Contributor

arthcmr commented Nov 27, 2018

Thanks for your participation, @nicholashc! Our team has reviewed your submission, and we are pleased to reward you for your report.

Severity: Note
Points: 50

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

No branches or pull requests

3 participants