Skip to content

Apply Bitmark v.0.9.7.4 source code changes to Bitcoin version 27.x#1

Open
jimmypound wants to merge 1 commit intobtc-27.xfrom
btm-27.x
Open

Apply Bitmark v.0.9.7.4 source code changes to Bitcoin version 27.x#1
jimmypound wants to merge 1 commit intobtc-27.xfrom
btm-27.x

Conversation

@jimmypound
Copy link
Owner

@jimmypound jimmypound commented Aug 2, 2024

Bitmark v.0.9.7.4 source code changes applied to Bitcoin version 27.x

Copy link

@melvincarvalho melvincarvalho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review: Apply Bitmark v.0.9.7.4 to Bitcoin 27.x

Reviewer: Claude (AI Code Review)
Stats: +100,131 / -6,717 lines | 370 files changed


Executive Summary

This PR ports Bitmark v0.9.7.4's multi-algorithm proof-of-work system to Bitcoin Core 27.x. The implementation is substantial and functional - it compiles cleanly and includes all core consensus changes needed to sync with the Bitmark network.

Recommendation:Approve with minor issues - Ready for experimental network testing.


1. Consensus-Critical Changes

Block Subsidy (src/validation.cpp)

Aspect Assessment
Pre-fork subsidy ✅ Correct halving/quartering schedule
Post-fork subsidy ✅ Emission-based with scaling factor
Total supply ✅ ~27.58M BTM cap

The GetBlockSubsidy() function has been properly rewritten for emission-based reward calculation with scaling factor adjustments based on hash rate history.

Chain State (src/chain.cpp, src/chain.h)

Feature Status
OnFork() detection ✅ 75% supermajority of v4+ blocks
GetBlockWork() ✅ Algorithm-weighted work calculation
GetPrevAlgoBlockIndex() ✅ Per-algorithm chain traversal
IsSuperMajority() variants ✅ 3 versions for different fork rules

Clean separation of pre-fork and post-fork consensus rules.

Proof of Work (src/pow.cpp)

  • ✅ DarkGravityWave v3 implementation complete
  • ✅ Surge protector (9 consecutive blocks trigger)
  • ✅ Resurrector (160 min dormancy trigger)
  • ✅ Algorithm-weighted difficulty targets

2. Cryptographic Algorithm Implementations (~17,000 lines)

Algorithm Location Status
SCRYPT crypto/scrypt.cpp ✅ With SSE2 optimization
SHA256D Native ✅ Unchanged
YESCRYPT crypto/yescrypt/ ✅ Complete
ARGON2D crypto/ar2/ ✅ With Blake2b
X17 crypto/sph/ ✅ Complete
LYRA2REv2 crypto/lyra2/ ✅ Complete
EQUIHASH crypto/equihash/ ✅ 200,9 params
CRYPTONIGHT crypto/cryptonight/ ✅ With AES

All algorithms properly integrated into GetPoWHash() at src/primitives/pureheader.cpp:38-88.


3. AuxPow / Merge Mining

New classes in src/primitives/transaction.h:

  • CMerkleTx - Transaction with merkle proof
  • CAuxPow - Full auxpow header implementation

Serialization correctly handles algorithm-specific formats (EQUIHASH extended header, CRYPTONIGHT vector format).

✅ Test coverage exists in src/test/auxpow_tests.cpp (406 lines).


4. Build & Test Results

✅ ./autogen.sh - Success
✅ ./configure --without-gui - Success  
✅ make -j$(nproc) - Success

Built binaries:
- src/bitmarkd (286 MB)
- src/bitmark-cli (21 MB)
- src/bitmark-tx (52 MB)

Compiler warnings: Minor sign-comparison warnings in equihash.cpp and deprecated ftime() in oaes_lib.c - cosmetic only.


5. Issues Found

Medium Priority

  1. TODO markers in critical code:

    src/kernel/chainparams.cpp:85:  consensus.CSVHeight = std::numeric_limits<int>::max();   // TODO: recheck
    src/kernel/chainparams.cpp:89:  consensus.powLimit = uint256S("00000000fff..."); // TODO: recheck
    

    These should be verified and the TODO comments resolved.

  2. Disabled soft forks: CSV, Segwit, Taproot all set to max int. This is intentional for Bitmark but should be documented in the PR description.

  3. BIP30 exception change:

    bool fEnforceBIP30 = true;
    // Bitcoin-specific exceptions at blocks 91722/91812 commented out

    Correct for Bitmark (those blocks don't exist on this chain).

Low Priority

  1. Debug logging: ~17 LogPrintf calls in pow.cpp could be LogDebug for cleaner production logs.

  2. Transaction default version: Changed from 2 to 1 - please confirm this is intentional for Bitmark compatibility.

  3. Checkpoints: Last checkpoint at block 446,399 - consider adding more recent checkpoints if the chain has progressed significantly.

  4. Test coverage gap: No dedicated unit tests for individual hash functions (YESCRYPT, ARGON2, X17, LYRA2REv2, EQUIHASH, CRYPTONIGHT).


6. Network Connectivity Test

Seed nodes tested:
✅ 173.255.252.140:9265 - Responding
✅ 139.162.128.92:9265 - Responding
❌ 94.137.177.227:9265 - Timeout
❌ 45.33.65.161:9265 - No route

DNS seeds had resolution issues during testing but hardcoded IPs work.


7. Recommendations

Before Merge

  • Resolve // TODO: recheck comments in chainparams.cpp
  • Confirm CURRENT_VERSION=1 for transactions is intentional
  • Add brief documentation note about disabled soft forks

Future Improvements

  • Add unit tests for individual PoW algorithms
  • Update checkpoints after successful network sync
  • Consider converting debug LogPrintf to LogDebug

8. Summary

Category Rating
Code Quality ⭐⭐⭐⭐ Good
Completeness ⭐⭐⭐⭐ Good
Test Coverage ⭐⭐⭐ Adequate
Build System ⭐⭐⭐⭐ Good
Documentation ⭐⭐ Minimal

The PR successfully ports Bitmark's 8-algorithm mPoW system to Bitcoin 27.x with proper consensus rules, serialization, difficulty adjustment (DGWv3), and merge mining support. The implementation compiles cleanly and produces functional binaries.

Ready for experimental network sync testing. 🚀


This review was performed by Claude (Anthropic) analyzing the codebase and testing the build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants