You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge #6826: refactor: introduce SignHash type for improved type safety in LLMQ signing
fd6ad86 refactor: Use uniform initialization syntax for SignHash (pasta)
b34fd1b chore: resolve clang-format issue (pasta)
ac9e5b7 refactor: standardize SignHash usage across LLMQ components (pasta)
f446223 refactor: leverage SignHash type throughout LLMQ signing code (pasta)
0465463 refactor: extract BuildSignHash to SignHash type for better static typing (pasta)
Pull request description:
## Summary
This PR introduces a dedicated `SignHash` type to replace the generic `uint256` usage for LLMQ sign hashes, improving type safety and code clarity throughout the signing subsystem.
## Motivation
Previously, `BuildSignHash` was a standalone function returning `uint256`, which:
- Required forward declarations to avoid circular dependencies
- Lacked type safety (any uint256 could be passed where a sign hash was expected)
- Made code intent less clear
## Changes
### New SignHash Type
- Created `SignHash` class extending `BaseHash<uint256>` (following existing patterns like `AssumeutxoHash`)
- Encapsulates the hash calculation logic in the constructor
- Provides serialization support for database compatibility
- Includes `std::hash` specialization for use as unordered_map keys
### Refactored APIs
- `CSigBase::buildSignHash()` now returns `SignHash` instead of `uint256`
- Sign hash calculation moved from standalone function to `SignHash` constructor
- Removed forward declarations from `assetlocktx.cpp` and `quorums.cpp`
### Type Safety Improvements
- SignHash is now a distinct type throughout LLMQ code
- Conversion to `uint256` via `.Get()` only at API boundaries (BLS verification, database operations)
- Maintains clean abstraction - BLS library continues using `uint256` as it shouldn't depend on higher-level LLMQ types
## Benefits
- **Elimination of circular dependencies** - No more forward declarations needed
- **Better type safety** - Compiler catches type mismatches
- **Clearer code intent** - Explicit when working with sign hashes vs other hashes
- **Future flexibility** - Can add SignHash-specific methods if needed
- **Zero runtime overhead** - All changes are compile-time type safety improvements
## Test plan
- [x] Unit tests pass (`test_dash --run_test=evo_islock_tests`)
- [x] Code compiles without warnings
- [x] No circular dependencies introduced
🤖 Generated with [Claude Code](https://claude.ai/code)
ACKs for top commit:
UdjinM6:
utACK fd6ad86
Tree-SHA512: dc4c54ce4154cebceaeca48e79fa8cf0fdeee2cd3025fa0c05f84b130dffe993af03bca0f80f9c3dc950bf0b2cd3986e706f5bb4824e9cf03058c97b98aaa1d5
0 commit comments