Fix GH-683 critical issues from code review #693
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix Critical Issues from Code Review of PR #684
Summary
This PR addresses the critical issues identified in the code review of PR #684 (branch GH-683). The fixes focus on improving code quality, fixing typos, enhancing performance, and making the code more idiomatic Rust.
Changes Made
🔧 Critical Fixes
Fixed all "costume" → "custom" typos (Critical)
custom_serialize
,custom_deserialize
,custom_hash
Fixed test function name typo
hashing_for_app_arp_error_kind_works
→hashing_for_app_rpc_error_kind_works
Improved hash test efficiency
Added overflow protection
ErrorStats::increment
now usessaturating_add
to prevent panic on u16 overflowReplaced magic numbers with named constants
Renamed
dup()
→clone_boxed()
Made ValidationFailureClockReal a unit struct
{}
to unit struct;
Improved test error messages
.unwrap()
with.expect("descriptive message")
in testsFixed inconsistent error messages
Fixed comment inconsistencies
Files Modified
node/src/accountant/db_access_objects/payable_dao.rs
node/src/blockchain/errors/blockchain_db_error/app_rpc_web3_error_kind.rs
node/src/blockchain/errors/blockchain_db_error/masq_error_kind.rs
node/src/blockchain/errors/blockchain_db_error/mod.rs
node/src/blockchain/errors/blockchain_loggable_error/app_rpc_web3_error.rs
node/src/blockchain/errors/blockchain_loggable_error/masq_error.rs
node/src/blockchain/errors/blockchain_loggable_error/mod.rs
node/src/blockchain/errors/common_methods.rs
node/src/blockchain/errors/test_utils.rs
node/src/blockchain/errors/validation_status.rs
Items Not Addressed (Lower Priority)
The following items were identified in the code review but are considered lower priority and can be addressed in a follow-up PR if needed:
Performance Optimizations
add_attempt
more efficient: Currently takes ownership and returns Self. Could use&mut self
for better performanceCode Consistency
ServerUnreachable
vsUnreachable
- inconsistent naming between error typesArchitectural Considerations
HashMap<Box<dyn BlockchainDbError>, ErrorStats>
has trait object overheadThese items don't affect correctness or immediate functionality but could improve performance and maintainability in the future.
Testing
All changes maintain backward compatibility and don't alter the fundamental behavior of the error handling system. The improvements focus on:
Related Issues
Ready for review and merge into GH-683 branch