Repository navigation
Conversation
Builds and verifies a premature commitment for 400 members and threshold 340. The cold variant first decodes every verification vector from its database encoding, as GetVerifiedContributions does on a cache miss.
At commit time GetVerifiedContributions re-read and decoded every member's verification vector from LevelDB, although the session still held them in memory. Fill the cache when a verified contribution is written and keep an entry while its vector is still referenced. The commit step for 400 members and threshold 340 goes from 5.0 s to 0.2 s.
|
🔍 Review in progress — actively reviewing now (commit 898351d) · triage: low |
|
No actionable comments were generated in the recent review. WalkthroughThe DKG benchmark code now supports an explicit threshold and includes benchmarks for commitment building and verification. The session manager now caches verified vectors, updates cached secret-key contributions, and retains expired entries while they have references outside the cache. Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Merge Risk:
|
|
Tested this for v24.0.1, where it replaces the cache part of #8130.
#8128 now carries this commit. The "Require a milestone" check is failing here only because no milestone is set yet. 🤖 Posted autonomously by Claude on behalf of pasta. |
Issue being fixed or feature implemented
Building a premature commitment for
llmq_400_85takes about 5 seconds of single-threaded work, almost all of it avoidable.SendCommitmentand the verification of every received premature commitment callCDKGSessionManager::GetVerifiedContributions, which reads each member's verification vector back from LevelDB and decodes it: 400 members x 340 BLS public keys, about 34 µs per key (25 µs subgroup check, 8 µs point decompression). The contributions cache was filled only by reads and expired after 60 seconds, so it was always cold at commit time, although the DKG session still held the same vectors in memory.#8130 reports that this delay made members miss short commit phases on mainnet, and fixes it. This PR is a smaller alternative to the cache part of #8130.
What was done?
WriteVerifiedVvecContributionnow also puts the vector intocontributionsCache, sharing the pointer the session already holds (no copy).WriteVerifiedSkContributionupdates the cached entry, so a share verified or justified later is visible to the next lookup.CleanupCachedrops an entry after 60 seconds only when nothing else references its vector, so entries live as long as their session and entries loaded from disk expire as before.BLSDKG_BuildCommitment_cold_400,BLSDKG_BuildCommitment_cached_400,BLSDKG_VerifyCommitment_400.The database writes and the cold-read path are unchanged, so restarts, watchers and later quorum builds behave as before.
Compared to #8130
#8130 has the same idea but is +580 −9 across 7 files. This PR is +88 −6 across 3 files and reaches the same speed.
One behaviour difference from #8130: under the legacy BLS scheme (before v19) a received vector is cached as decoded, without the subgroup check that the database read applies. #8130 falls back to the database read in that case. There's no reason to keep different behaviour for 2 scenarios.
How Has This Been Tested?
Measurements
x86_64, blst, release build, 400 members / threshold 340:
BLSDKG_BuildCommitment_cold_400(decode from database encoding first)BLSDKG_BuildCommitment_cached_400BLSDKG_VerifyCommitment_400(per received commitment)Through the real
CDKGSessionManager, using the end-to-end benchmark from #8130: 5.03 s on develop, 0.20 s with this PR, 0.22 s on #8130, same commitment hash in all three.Breaking Changes
None. No protocol, message, consensus or on-disk change.
Checklist: