Add zero-value guards to abaci.sol auction parameter setters#390
Open
daatsuka wants to merge 1 commit intosky-ecosystem:masterfrom
Open
Add zero-value guards to abaci.sol auction parameter setters#390daatsuka wants to merge 1 commit intosky-ecosystem:masterfrom
daatsuka wants to merge 1 commit intosky-ecosystem:masterfrom
Conversation
…rability found in abaci.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In
src/abaci.sol, bothLinearDecrease.file()andStairstepExponentialDecrease.file()previously accepted zero as a valid value fortauandsteprespectively. This is a problem becauseLinearDecrease.price()divides bytauandStairstepExponentialDecrease.price()divides bystep— setting either to zero through the adminfile()function would cause every subsequentprice()call to revert with an unrecoverable division-by-zero, effectively bricking any active auction that depends on these price curves.The two
file()functions now wrap the assignment in arequire(... > 0)check so the contract rejects the misconfiguration at the moment it is attempted, rather than silently accepting it and failing later at auction runtime. The error strings follow the existing convention in the codebase (LinearDecrease/tau-is-zero,StairstepExponentialDecrease/step-is-zero) and thecutparameter already had its own upper-bound guard inStairstepExponentialDecrease, so thestepguard brings it to parity.On the test side,
src/test/abaci.t.solgains a smallVminterface to accessexpectRevert, along with two new test functions —test_linear_decrease_tau_zero_reverts()andtest_stairstep_step_zero_reverts()— each deploying a fresh contract instance and confirming thatfile("tau", 0)andfile("step", 0)revert with the expected error message. I ran the full suite locally withforge testand all tests pass cleanly, including the existingtest_linear_decrease,test_stairstep_exp_decrease, andtest_continuous_exp_decreasecases, so the new guards do not interfere with legitimate parameter values.Closes #297