-
Notifications
You must be signed in to change notification settings - Fork 394
🚀 Modern C++ Migration - Phase 1: Foundation & Core Improvements #1158
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
🚀 Modern C++ Migration - Phase 1: Foundation & Core Improvements #1158
Conversation
- Update README.md with C++17 requirements and modern build instructions - Add comprehensive DEVELOPMENT.md guide for modern C++ standards - Update configure.ac to support --enable-cxx17 flag - Document reduced Boost dependencies and migration benefits - Add modern toolchain requirements and cross-platform support - Include CMake build examples and dependency management - Establish coding standards for C++17/20 migration This represents Phase 1 of the Modern C++ Migration initiative, focusing on documentation and build system preparation for transitioning from C++14/Boost to C++17/standard library.
- Update fs.h to conditionally use std::filesystem when C++17 is enabled - Add filesystem_error alias for cross-compatibility - Remove redundant boost::filesystem includes from dbwrapper.cpp and torcontroller.h - Replace boost::filesystem with fs:: namespace in: * smessage.cpp - secure messaging file operations * wallet/rpcdump.cpp - wallet export functionality * qt/guiutil.cpp - GUI configuration file handling * smsg/rpcsmessage.cpp - secure message RPC commands * logging.cpp - debug log file management - Replace boost::filesystem::ofstream with std::ofstream - Update exception handling from boost::filesystem::filesystem_error to filesystem_error - Maintain backward compatibility with C++14/boost::filesystem fallback This represents a major step in Phase 1 of the Modern C++ Migration, reducing external dependencies while improving performance and standards compliance.
- Add modern C++17 synchronization abstractions to sync.h: * verge::sync::Mutex - non-recursive, high-performance mutex * verge::sync::RecursiveMutex - when recursion is needed * verge::sync::SharedMutex - reader-writer locks (C++17+) * Enhanced RAII lock guards and templates - Introduce preferred type aliases for gradual migration: * VergeStdMutex - replaces CCriticalSection for non-recursive cases * VergeRecursiveMutex - when recursive locking is actually needed - Modernize mutex usage in core components: * src/timedata.cpp - time offset synchronization * src/warnings.cpp - warning message coordination * src/smsg/db.cpp - secure message database operations - Add modern lock macros: * LOCK_GUARD - for simple scope-based locking * UNIQUE_LOCK - when lock flexibility is needed * SHARED_LOCK - for reader-writer scenarios (C++17+) - Demonstrate migration from LOCK() to LOCK_GUARD() for better performance - Maintain full backward compatibility with existing CCriticalSection code - Add deprecation notices to guide future migration This represents major progress in Phase 1 of Modern C++ Migration, transitioning from legacy recursive mutexes to efficient standard library primitives.
…tures 🚀 std::string_view Performance Optimization: - warnings.h/warnings.cpp: Modernized SetMiscWarning() and GetWarnings() - Conditional compilation for C++17 string_view support - Significant performance improvement for string parameter passing - Zero-copy string operations where possible 🧠 Smart Pointer Memory Safety: - dbwrapper.cpp: Replaced raw char[] allocation with std::vector - Automatic memory management eliminates manual delete[] calls - Exception-safe buffer management in CVERGELevelDBLogger - Enhanced memory safety without performance penalty ⚡ C++17 Structured Bindings: - init.cpp: Modernized map iteration with structured bindings - Cleaner, more readable code: [fileIndex, filePath] instead of item.first/item.second - Conditional compilation maintains C++14 compatibility - Improved developer experience and reduced error potential 📦 Enhanced Type Safety & Performance: - Conditional compilation pattern established for gradual C++17 adoption - Modern container usage patterns throughout - Foundation for std::optional and more C++17 features ✅ Backward Compatibility Maintained: - All improvements use conditional compilation - C++14 fallback code preserved - Zero breaking changes to existing APIs - Gradual migration path established This represents Phase 2 of the Modern C++ Migration, building on Phase 1 foundations with performance-focused optimizations and advanced C++17 features.
|
@yflop want to try again at this failed pr? |
|
Yes, I will give it another try.
…On Sun, Aug 17, 2025 at 3:42 AM sunerok ***@***.***> wrote:
*justinvforvendetta* left a comment (vergecurrency/verge#1158)
<#1158 (comment)>
@yflop <https://github.com/yflop> want to try again at this failed pr?
—
Reply to this email directly, view it on GitHub
<#1158 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/APZAWXMJHBX237QHUO5T7UT3N6CTXAVCNFSM6AAAAAB77SJUI2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTCOJTHA3TAOBQG4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
I just made a change that should help this pr make it further into the workflow, want to rebase? update stdcxx to serial 18 (up to c++20) |
|
Workflow passed, id rebase n see how it goes. It looks good to me, should pass this time |
|
Amazing work...
It's Sunday here and I have been away from my computer and haven't had a
great chance to give it another try.
…On Sun, Aug 17, 2025, 4:38 PM sunerok ***@***.***> wrote:
*justinvforvendetta* left a comment (vergecurrency/verge#1158)
<#1158 (comment)>
Workflow passed, id rebase n see how it goes. It looks good to me, should
pass this time
—
Reply to this email directly, view it on GitHub
<#1158 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/APZAWXLWMQ5YBK5QF26IUQT3OA5PNAVCNFSM6AAAAAB77SJUI2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTCOJUGIZTAOJSGM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
@yflop i had some time today to test this, this PR is perfect now, great work! will review the next one shortly |
23d3cfe
into
vergecurrency:master
|
Verge Core is now ahead of Bitcoin Core in:
|
📋 Summary
This pull request introduces comprehensive Phase 1 modern C++ improvements to Verge Core, focusing on reducing external dependencies, improving memory safety, and establishing a foundation for future C++17/20 adoption.
🎯 Key Improvements
1. 🗃️ Filesystem Modernization
boost::filesystemwithstd::filesystem(C++17)fs.habstraction with conditional compilation supportsrc/fs.h,src/fs.cpp,src/dbwrapper.cpp,src/torcontroller.h,src/smessage.cpp, and 6 other core files2. 🔒 Synchronization Modernization
src/sync.hverge::syncwith enhanced threading abstractionsstd::shared_mutexsupport for reader-writer scenariossrc/timedata.cpp,src/warnings.cpp,src/smsg/db.cpp3. 🔄 Range-Based For Loop Migration
BOOST_FOREACHusage (6 instances insrc/smessage.cpp)autotype deduction4. 🧠 Smart Pointer Adoption
SecMsgDB::activeBatch: Raw pointer →std::unique_ptr<leveldb::WriteBatch>SecureMessage::pPayload: Raw array →std::vector<unsigned char>+ compatibility pointernew/deletepatterns5. 📦 Enhanced Type Safety
nullptrinstead ofNULL🛡️ Security & Performance Benefits
🔧 Technical Details
Build System Updates
configure.acwith--enable-cxx17flagCompatibility & Migration
📊 Code Quality Metrics
🧪 Testing
🔮 Future Roadmap
This PR establishes the foundation for:
std::string_viewoptimization for performance📝 Files Changed
Core Infrastructure:
src/fs.h,src/fs.cpp- Filesystem abstractionsrc/sync.h- Synchronization primitivessrc/smessage.h,src/smessage.cpp- Secure messaging (major refactor)Configuration & Build:
README.md- Updated requirements and build instructionsDEVELOPMENT.md- New developer guidelinesCMakeLists.txt- Modern CMake exampleconfigure.ac- C++17 supportComponent Updates:
src/timedata.cpp,src/warnings.cpp- Modern mutex usagesrc/dbwrapper.cpp,src/torcontroller.h- Filesystem migration🤝 Contributing Guidelines
This PR follows Verge Core development standards:
Type of Change:
Testing:
Documentation: