Add validation and tests for discriminant_size_bits parameter#286
Conversation
|
@BugBot review |
55151a6 to
c84381e
Compare
- Add validation to CreateDiscriminant to check for: * Positive values (rejects -1, 0) * Upper bound of 16384 (rejects 16400) * Multiple of 8 requirement * Non-empty seed - Add comprehensive tests for edge cases: * test_discriminant_size_bits_negative: -1 should fail * test_discriminant_size_bits_zero: 0 should fail * test_discriminant_size_bits_too_large: 16400 should fail * test_discriminant_size_bits_valid: 1024 should succeed - Fix Python binding to ensure exceptions are properly handled
c84381e to
21fa8dd
Compare
|
cursor review |
🚨 Bugbot couldn't runBugbot is not enabled for your user on this team. Ask your team administrator to increase your team's hard limit for Bugbot seats or add you to the allowlist in the Cursor dashboard. |
|
cursor review |
🚨 Bugbot couldn't runBugbot is not enabled for your user on this team. Ask your team administrator to increase your team's hard limit for Bugbot seats or add you to the allowlist in the Cursor dashboard. |
|
cursor review |
🚨 Bugbot couldn't runBugbot is not enabled for your user on this team. Ask your team administrator to increase your team's hard limit for Bugbot seats or add you to the allowlist in the Cursor dashboard. |
|
cursor review |
🚨 Bugbot couldn't runBugbot is not enabled for your user on this team. Ask your team administrator to increase your team's hard limit for Bugbot seats or add you to the allowlist in the Cursor dashboard. |
|
cursor review |
|
cursor review |
|
cursor review |
|
@hoffmang9 @emlowe Sorry for interjecting, just wanted to add a few thoughts: I understand that the only downstream client of chiavdf is the chia-blockchain package itself, i.e., both packages are part of the same whole. Since we are adding these sanity checks in the hot path, they will introduce some runtime overhead. If this overhead is non-negligible, and since we control the calling locations of |
|
I generated a speed-test.py: Example results for this branch: Example results for main at 2ac6d810d28363b5dba7f96061006c6550441c4b This was on an older Intel Mac to try to get the background noise to a minimum - MacBook Pro 13-inch, Four Thunderbolt 3 Ports, 3.1 GHz Dual-Core Intel Core i5, 8GB 2133MHz LPDDR3 running Ventura 13.7.8 After running a lot of iterations, I really don't see any difference in run times of If you have a better way to validate this, I'm open to an additional approach. |
|
Yes, these checks have negligible runtime impact. |
Fixes #282
Note
Add strict input validation to
CreateDiscriminantand introduce tests covering invalid and validdiscriminant_size_bitscases.CreateDiscriminantinsrc/create_discriminant.hwith input validation:length, cap at16384, enforce multiple-of-8, and non-emptyseed; throwstd::invalid_argumenton violations.tests/test_discriminant_validation.pywith cases for negative, zero, overly large, and validdiscriminant_size_bits.Written by Cursor Bugbot for commit f5abd89. This will update automatically on new commits. Configure here.