-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix: bls benchmarks crash when ran independently #6977
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
fix: bls benchmarks crash when ran independently #6977
Conversation
✅ No Merge Conflicts DetectedThis PR currently has no conflicts with other open PRs. |
WalkthroughThe changes add BLS (Boneh-Lynn-Shacham) signature scheme support to the Bitcoin benchmark file. This includes importing the BLS header, initializing BLS during setup via Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📥 CommitsReviewing files that changed from the base of the PR and between f6bae67cc12beecc2c995c627543ec84c7dedc17 and f961e04. 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
I guess with BLSDKG_ we are benchmarking basic bls scheme in BLS_ ones somehow so there are no crashes. With this patch and no BLSDKG_ we'll benchmark legacy scheme so results would be kind of useless/confusing. How about forcing basic scheme here instead? see a3896db2b2 |
|
@UdjinM6 why do you suggest storing / resetting the atomic; why not just enforce it to false at the beginning of each bench? |
This could work too I guess, I just tried to avoid any potential side effects for other benchmarks. |
|
Actually... we could probably just set it to false for everyone. diff --git a/src/bench/bench_bitcoin.cpp b/src/bench/bench_bitcoin.cpp
index c5fe3fbdfd..77d5232377 100644
--- a/src/bench/bench_bitcoin.cpp
+++ b/src/bench/bench_bitcoin.cpp
@@ -11,6 +11,8 @@
#include <util/strencodings.h>
#include <util/system.h>
+#include <bls/bls.h>
+
#include <chrono>
#include <cstdint>
#include <iostream>
@@ -64,6 +66,7 @@ int main(int argc, char** argv)
SetupBenchArgs(argsman);
SapphireAutoDetect();
SHA256AutoDetect();
+ bls::bls_legacy_scheme.store(false);
std::string error;
if (!argsman.ParseParameters(argc, argv, error)) {
tfm::format(std::cerr, "Error parsing command line arguments: %s\n", error); |
|
Another thing I just noticed is that there is no |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 18951 🏁 Script executed: Length of output: 6776 🏁 Script executed: Length of output: 1646 @UdjinM6 No, it's not okay. The missing Here's why:Based on my analysis: What
Why it's missing:
Why it matters:
Recommendation: #include <bench/bench.h>
#include <bls/bls.h> // Add this include
#include <clientversion.h>
#include <crypto/sha256.h>
#include <crypto/x11/dispatch.h>
#include <fs.h>
#include <util/strencodings.h>
#include <util/system.h>
// ... rest of code ...
int main(int argc, char** argv)
{
ArgsManager argsman;
SetupBenchArgs(argsman);
SapphireAutoDetect();
SHA256AutoDetect();
BLSInit(); // Add this line
std::string error;
// ... rest of main function ...
}This ensures proper initialization of the BLS library's secure memory allocators before any benchmarks run. ฅ^•ﻌ•^ฅ 🧠 Learnings used |
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.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between e428db1c77c1640263267f911fb6af9d4308327a and 576c11a3a433242e07f0a419e3a6e714f64aa52f.
📒 Files selected for processing (1)
src/bench/bench_bitcoin.cpp(3 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: knst
Repo: dashpay/dash PR: 6692
File: src/llmq/blockprocessor.cpp:217-224
Timestamp: 2025-08-19T14:57:31.801Z
Learning: In PR #6692, knst acknowledged a null pointer dereference issue in ProcessBlock() method where LookupBlockIndex may return nullptr but is passed to gsl::not_null, and created follow-up PR #6789 to address it, consistent with avoiding scope creep in performance-focused PRs.
Learnt from: kwvg
Repo: dashpay/dash PR: 6543
File: src/wallet/receive.cpp:240-251
Timestamp: 2025-02-06T14:34:30.466Z
Learning: Pull request #6543 is focused on move-only changes and refactoring, specifically backporting from Bitcoin. Behavior changes should be proposed in separate PRs.
Learnt from: knst
Repo: dashpay/dash PR: 6916
File: src/univalue/include/univalue.h:81-88
Timestamp: 2025-10-25T07:08:51.918Z
Learning: For backport PRs from bitcoin/bitcoin, bitcoin-core/gui, etc., backported changes should match the original upstream PRs even if they appear strange, modify vendored code, or seem to violate coding guidelines. Still flag genuine issues like bugs, undefined behavior, crashes, compilation errors, or linter failures.
Learnt from: knst
Repo: dashpay/dash PR: 6871
File: contrib/guix/libexec/build.sh:358-360
Timestamp: 2025-10-05T20:38:28.457Z
Learning: In the Dash repository, when backporting code from Bitcoin Core, typos and minor issues in comments should be kept as-is to reduce merge conflicts in future backports, even if they remain unfixed in Bitcoin Core's master branch.
Learnt from: kwvg
Repo: dashpay/dash PR: 6761
File: src/chainlock/signing.cpp:247-250
Timestamp: 2025-07-29T14:32:48.369Z
Learning: In PR #6761, kwvg acknowledged a null pointer check issue in ChainLockSigner::Cleanup() method but deferred it to follow-up, consistent with the pattern of avoiding scope creep in refactoring PRs.
📚 Learning: 2025-07-23T09:30:34.631Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6761
File: src/chainlock/signing.h:5-6
Timestamp: 2025-07-23T09:30:34.631Z
Learning: Dash Core uses BITCOIN_ prefix for header guards as the standard convention, inherited from Bitcoin Core. Only a few BLS-specific files in src/bls/ use DASH_ prefix. The vast majority of files (385+) use BITCOIN_ prefix.
Applied to files:
src/bench/bench_bitcoin.cpp
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
- GitHub Check: arm-linux-build / Build source
- GitHub Check: linux64_sqlite-build / Build source
- GitHub Check: linux64_fuzz-build / Build source
- GitHub Check: linux64_ubsan-build / Build source
- GitHub Check: linux64-build / Build source
- GitHub Check: mac-build / Build source
- GitHub Check: win64-build / Build source
- GitHub Check: linux64_tsan-build / Build source
- GitHub Check: linux64_nowallet-build / Build source
- GitHub Check: Lint / Run linters
🔇 Additional comments (1)
src/bench/bench_bitcoin.cpp (1)
7-7: LGTM: BLS header inclusion is correct.The include statement is properly positioned and necessary for accessing the BLSInit() function.
src/bench/bls.cpp
Outdated
| @@ -26,16 +26,17 @@ static void BuildTestVectors(size_t count, size_t invalidCount, | |||
| } | |||
| Shuffle(invalid.begin(), invalid.end(), FastRandomContext()); | |||
|
|
|||
| const bool scheme = bls::bls_legacy_scheme.load(); | |||
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.
I believe by default it will be true, but we shoulld benchmark non-legacy bls, should we?
|
should drop original commits and do #6977 (comment) instead or enforce basic bls scheme in any other way |
f6bae67 to
f961e04
Compare
knst
left a comment
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.
LGTM f961e04
UdjinM6
left a comment
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.
ACK f961e04
f961e04 fix: initialize BLS in benchmarking setup (pasta) Pull request description: ## Issue being fixed or feature implemented Crashes like below happen when BLS bench's are ran w/o BLS_DKG bench's ``` > $ ./src/bench/bench_dash --filter="BLS_.*" [±ci/run-bench ●] | ns/op | op/s | err% | total | benchmark |--------------------:|--------------------:|--------:|----------:|:---------- | 70,625.77 | 14,159.14 | 0.5% | 0.08 | `BLS_PubKeyAggregate_Batch_100` | 143,101.94 | 6,988.03 | 0.6% | 0.17 | `BLS_PubKeyAggregate_Batch_200` | 16,714.92 | 59,826.77 | 1.4% | 0.02 | `BLS_PubKeyAggregate_Batch_25` | 2,733.86 | 365,783.71 | 0.9% | 0.01 | `BLS_PubKeyAggregate_Batch_5` | 34,708.34 | 28,811.52 | 0.7% | 0.04 | `BLS_PubKeyAggregate_Batch_50` | 77,659.39 | 12,876.74 | 0.5% | 0.09 | `BLS_PubKeyAggregate_Iterative_100` | 155,927.75 | 6,413.23 | 0.8% | 0.19 | `BLS_PubKeyAggregate_Iterative_200` | 18,291.67 | 54,669.70 | 1.3% | 0.02 | `BLS_PubKeyAggregate_Iterative_25` | 2,830.29 | 353,320.46 | 0.5% | 0.01 | `BLS_PubKeyAggregate_Iterative_5` | 37,932.04 | 26,362.94 | 0.9% | 0.05 | `BLS_PubKeyAggregate_Iterative_50` | 777.73 | 1,285,787.58 | 1.5% | 0.01 | `BLS_PubKeyAggregate_Normal` | 390.42 | 2,561,315.62 | 1.2% | 0.01 | `BLS_SecKeyAggregate_Normal` | 516,138.10 | 1,937.47 | 0.3% | 0.62 | `BLS_Sign_Normal` | 1,463.50 | 683,294.10 | 0.8% | 0.01 | `BLS_SignatureAggregate_Normal` expected valid but it is invalid Assertion failure: assertion: false file: bls.cpp, line: 301 function: operator() 0#: (0x103732300) stacktraces.cpp:640 - __assert_rtn 1#: (0x102AB46CC) basic_ostream.h - BLS_Verify_Batched(ankerl::nanobench::Bench&)::$_0::operator()() const 2#: (0x102AB46CC) nanobench.h:1221 - ankerl::nanobench::Bench& ankerl::nanobench::Bench::run<BLS_Verify_Batched(ankerl::nanobench::Bench&)::$_0>(BLS_Verify_Batched(ankerl::nanobench::Bench&)::$_0&&) 3#: (0x102AAFBE4) vector:1933 - std::__1::vector<bool, std::__1::allocator<bool>>::__destroy_vector::operator()[abi:ne190102]() 4#: (0x102AAFBE4) vector:1942 - std::__1::vector<bool, std::__1::allocator<bool>>::~vector[abi:ne190102]() 5#: (0x102AAFBE4) vector:1942 - std::__1::vector<bool, std::__1::allocator<bool>>::~vector[abi:ne190102]() 6#: (0x102AAFBE4) bls.cpp:305 - BLS_Verify_Batched(ankerl::nanobench::Bench&) 7#: (0x102A9605C) function.h - std::__1::__function::__value_func<void (ankerl::nanobench::Bench&)>::operator()[abi:ne190102](ankerl::nanobench::Bench&) const 8#: (0x102A9605C) function.h:989 - std::__1::function<void (ankerl::nanobench::Bench&)>::operator()(ankerl::nanobench::Bench&) const 9#: (0x102A9605C) bench.cpp:120 - benchmark::BenchRunner::RunAll(benchmark::Args const&) 10#: (0x102AA8EE4) string:1881 - std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::__is_long[abi:ne190102]() const 11#: (0x102AA8EE4) string:1212 - std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_string() 12#: (0x102AA8EE4) string:1210 - std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_string() 13#: (0x102AA8EE4) bench.h:54 - benchmark::Args::~Args() 14#: (0x102AA8EE4) bench.h:54 - benchmark::Args::~Args() 15#: (0x102AA8EE4) bench_bitcoin.cpp:137 - main 16#: (0x1919C0274) <unknown-file> - ??? Assertion failed: (false), function operator(), file bls.cpp, line 301. [1] 20836 abort ./src/bench/bench_dash --filter="BLS_.*" ``` ## What was done? Don't assume scheme ## How Has This Been Tested? Bench ran ## Breaking Changes ## Checklist: _Go over all the following points, and put an `x` in all the boxes that apply._ - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: UdjinM6: ACK f961e04 Tree-SHA512: b71017742a6217d0aaac01113e0878e5adf4b0d33f97631784110cabab11cc09696505309089e5fc7eec1803d373a9e753b275268e14b418dd97787d47fd3ba4
736bb26 chore: bump manpages for 23.0.1 (pasta) d5c7d25 chore: bump nMinimumChainWork and defaultAssumeValid (pasta) 4f8aa71 chore: bump version to 23.0.1 (pasta) 0865b7c docs: add release notes for 23.0.1 (pasta) 2048b42 Merge #6986: test: new commandline argument -tinyblk to use blk size just 64kb instead 16Mb (pasta) 1a9b20c Merge #7013: fix: update BuildTestVectors call to adjust batch size based on output flag (pasta) 36e4679 Merge #7009: fix: include QDebug directly (pasta) 69d0c9c Merge #6999: feat: verify and repair evodb diffs automatically at node startup (pasta) ca16437 Merge #6996: perf: reduce cs_main lock scope in evodb verify/repair operations (pasta) 207526e Merge #6977: fix: bls benchmarks crash when ran independently (pasta) 226aaf4 Merge #6969: feat: add evodb verify and repair RPC commands (pasta) 92abe9b Merge #6964: perf: remove duplicated check of same key in the instant send database (pasta) 5a1ec4c Merge #6961: fix: correct BLS scheme setting in `MigrateLegacyDiffs()` when `nVersion` is present (pasta) bf653d3 Merge #6949: depends: Qt 5.15.18 (pasta) faf58cd merge bitcoin#30774: Qt 5.15.16 (Kittywhiskers Van Gogh) 6a995f5 Merge #6944: fix: HD chain encryption check ordering issue (pasta) Pull request description: ## Issue being fixed or feature implemented See commits; release v23.0.1 ## What was done? see commits ## How Has This Been Tested? ## Breaking Changes ## Checklist: _Go over all the following points, and put an `x` in all the boxes that apply._ - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: kwvg: utACK 736bb26 Tree-SHA512: fe02c4c3e520b11af54d09c47bda94112313456f9f1cb6d14e78ef16704b2a8ec8feb80fa914c55e152db2bcac7f278291824aaa36c8079eb9e0c9bff9e554a4
fe1cff3 chore: bump release to 23.0.2 (pasta) a8f15c1 Merge #7032: fix: drop gsl usage from RebuildListFromBlock function wrapper (pasta) 736bb26 chore: bump manpages for 23.0.1 (pasta) d5c7d25 chore: bump nMinimumChainWork and defaultAssumeValid (pasta) 4f8aa71 chore: bump version to 23.0.1 (pasta) 0865b7c docs: add release notes for 23.0.1 (pasta) 2048b42 Merge #6986: test: new commandline argument -tinyblk to use blk size just 64kb instead 16Mb (pasta) 1a9b20c Merge #7013: fix: update BuildTestVectors call to adjust batch size based on output flag (pasta) 36e4679 Merge #7009: fix: include QDebug directly (pasta) 69d0c9c Merge #6999: feat: verify and repair evodb diffs automatically at node startup (pasta) ca16437 Merge #6996: perf: reduce cs_main lock scope in evodb verify/repair operations (pasta) 207526e Merge #6977: fix: bls benchmarks crash when ran independently (pasta) 226aaf4 Merge #6969: feat: add evodb verify and repair RPC commands (pasta) 92abe9b Merge #6964: perf: remove duplicated check of same key in the instant send database (pasta) 5a1ec4c Merge #6961: fix: correct BLS scheme setting in `MigrateLegacyDiffs()` when `nVersion` is present (pasta) bf653d3 Merge #6949: depends: Qt 5.15.18 (pasta) faf58cd merge bitcoin#30774: Qt 5.15.16 (Kittywhiskers Van Gogh) 6a995f5 Merge #6944: fix: HD chain encryption check ordering issue (pasta) 6fd7059 chore: mark v23 as release (pasta) ae08f53 docs: integrate 6946 release notes into final (pasta) 74a222d Merge #6946: feat: show seed on wallet creation (pasta) 877343a Merge #6943: fix: don't treat arrays/objects as string literals for composite methods (pasta) 00368fb Merge #6940: fix: reuse best clsig to avoid potential race condition (pasta) 8eceb98 Merge #6938: fix: logic error in `CheckDecryptionKey` (pasta) 3f30664 Merge #6929: fix: repair `makeseeds.py`, `getblockchaininfo[softforks]` help text, drop extra `generate`s from test, resolve macOS GID issue (pasta) 7ba4f1c Merge #6928: docs: update man pages for 23.0 (pasta) a6c1d6a Merge #6920: chore: update minimum chain work, tx stats, checkpoints, seeds and SECURITY.md for v23 (pasta) 84df1f0 Merge #6909: chore: Translations 2025-10 (pasta) a6449b1 Merge #6885: fix: improve governance/proposal dialog strings (pasta) ebf3a64 docs: typos (pasta) 4ad5533 docs: typos (pasta) f407453 doc: Replace Bitcoin Core PR references with Dash Core backport PRs (pasta) 78d0725 docs: add note on proto bump and platformban p2p (pasta) e0519c3 docs: fix whitespace errors (pasta) bc8db22 docs: minor improvements to release notes (pasta) c338511 docs: reorganize rpc updates to organize extended address changes (thephez) 700c46e style: make heading style consistent (thephez) bd636bd docs: add contributors (pasta) 6d29bc3 docs: revert changes deferred to v24 (pasta) 615f5ff docs: make the downgrade warning more confident (pasta) 567771a Apply suggestions from code review (PastaPastaPasta) 2b3211a docs: add link to 22.1.3 release notes (pasta) 548a38a docs: remove individual release notes files (pasta) e770c25 docs: add v23.0.0 release notes and archive v22.1.3 (pasta) Pull request description: ## Issue being fixed or feature implemented Includes changes from 23.0.0 release too because we never merged it back. ## What was done? ## How Has This Been Tested? ## Breaking Changes ## Checklist: - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [ ] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: PastaPastaPasta: utACK 491db4a kwvg: utACK 491db4a Tree-SHA512: 61895cd1f9d01ac7be1d407afe1ddd24b98e8242cb03229ecd586a4d2d1c43dbc62c98da52a8c715b3a5943fb40e99b23251e691f778779af9d6da94392122a3
Issue being fixed or feature implemented
Crashes like below happen when BLS bench's are ran w/o BLS_DKG bench's
What was done?
Don't assume scheme
How Has This Been Tested?
Bench ran
Breaking Changes
Checklist:
Go over all the following points, and put an
xin all the boxes that apply.