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

_guardEntries can be optimized #22

Open
St4rgarden opened this issue Jul 14, 2023 · 0 comments
Open

_guardEntries can be optimized #22

St4rgarden opened this issue Jul 14, 2023 · 0 comments

Comments

@St4rgarden
Copy link

The humble reentrancy guard built into HSG is the inefficient and older way to implement re-entrancy guard.

Each time the guard is set to a value of 1 from zero it requires a full 20_000 SSTORE call; and refunds 19_900 gas when decremented.

Changing a previously initialized value from 1 to 2 and back to 1 can be significantly more efficient; depending on how much of a transaction's refund can be utilized. In the case of calling a function that relies on applying it's own refund mechanism - the cap can be hit and the refund from "deleting" the _guardEntries variable will not be applied.

Changing the value from 1 to 2 only costs 2900 gas - and refunds 2800 when decremented.

Screenshot 2023-07-13 at 9 30 54 PM

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

1 participant