-
Notifications
You must be signed in to change notification settings - Fork 639
fix: make Log2Floor and Log2Ceil return 0 for input 0 instead of panicking #3652
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
base: master
Are you sure you want to change the base?
fix: make Log2Floor and Log2Ceil return 0 for input 0 instead of panicking #3652
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@oooLowNeoNooo, we really only have separate bold.math and arbmath packages because bold used to be in a separate github repository.
Would you consider moving this bold.math package over into arbmath so that we only have one implementation of Log2Ceil across the codebase?
}) | ||
} | ||
|
||
func FuzzUnsingedIntegerLog2Floor(f *testing.F) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also bring over the fuzzing and benchmarking tests.
Please fix up the lint errors as well. |
Fix inconsistent behavior between bold/math and util/arbmath log2 implementations
This inconsistency was causing potential issues in critical code paths like
bold/state-commitments/history/history_commitment.go where Log2Floor is used
for Merkle tree depth calculations.
Changes:
This change is mathematically sound for tree depth calculations where log2(0) = 0
represents zero depth needed for zero elements.