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

Return early if now == rho. #87

Open
MicahZoltu opened this issue Oct 31, 2019 · 2 comments
Open

Return early if now == rho. #87

MicahZoltu opened this issue Oct 31, 2019 · 2 comments

Comments

@MicahZoltu
Copy link

dss/src/pot.sol

Line 138 in effdda3

require(now >= rho);

This function is a no-op if rho == now. Rather than wasting a bunch of effort (gas) executing this function in that case, it should just return early. While the caller can do if (pot.rho != now) pot.drip(), it is much more expensive for them to do this than it is for this method to do that.

@epheph
Copy link

epheph commented Oct 31, 2019

This proposed optimization seems especially impactful as each run executes 5 SSTOREs (all rewriting the same value after either adding 0 or multiplying by 1) and many more SLOADs.

The if statement @MicahZoltu is proposing would save over 30K gas per call.

@godsflaw
Copy link
Contributor

I think we should keep this issue open in case we want to resurrect this PR in the chance governance ever decided to upgrade these contracts.

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

Successfully merging a pull request may close this issue.

3 participants