Skip to content

Fix standard SV2 Merkle root byte order - #4

Open
feepool wants to merge 1 commit into
ckolivas:masterfrom
feepool:sv2-merkle-root-wire-order
Open

Fix standard SV2 Merkle root byte order#4
feepool wants to merge 1 commit into
ckolivas:masterfrom
feepool:sv2-merkle-root-wire-order

Conversation

@feepool

@feepool feepool commented Aug 18, 2026

Copy link
Copy Markdown

Summary

Fix standard Stratum V2 mining jobs so the advertised NewMiningJob.merkle_root
matches the Merkle root used when CKPool validates submitted shares.

Problem

The standard-SV2 path computed the raw SHA256d Merkle digest and then applied
CKPool's existing flip_32() conversion before placing it in the SV2 U256
field. SV2 carries the digest bytes in little-endian integer order, so this
word swap advertised a different Merkle root from the one used by
submission_diff().

Miners consequently hash a different header than CKPool validates. V1 is not
affected because this conversion is specific to the standard-SV2 job path.

Fix

  • Preserve the raw SHA256d digest bytes for the standard-SV2 U256 Merkle-root
    field.
  • Add a small serialization helper documenting the byte-order contract.
  • Add a regression test using a non-symmetric digest pattern so a future
    word-swap regression is caught.

Validation

Built from current upstream master (5fca384e) with:

./configure --enable-sv2
make -j$(nproc)
make check

Configuration confirmed IPC mining and SV2 enabled. The upstream test suite
passed all 9 tests with 0 failures. The corrected binary also built
successfully with no compiler warnings from this change.

@feepool
feepool marked this pull request as ready for review August 18, 2026 01:45
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.

1 participant