Skip to content
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

Braiins/cross testing #1396

Merged
merged 2 commits into from
Jan 29, 2025
Merged

Conversation

jakubtrnka
Copy link
Contributor

@jakubtrnka jakubtrnka commented Jan 24, 2025

Fix for #1395

There has been some incompatibility between braiins miner and SRI pool. I was looking into it and found the root cause of the issue. It was in Merkle Root.

  1. I added an independent test-vector for the merkle-root calculation. It worked correctly.
  2. Then I figured out that SRI pool sends a 33 bytes merkle-root array, while braiins miner expects only 32 byte array. I wrote a unit test for the expected message format
  3. I fixed the message format to pass the test
  4. Tested on Braiins Miniminer BMM100 with nightly firmware release. - it successfully mined on on the SRI pool and template provider https://github.com/Sjors/bitcoin/releases/tag/sv2-tp-0.1.13 Submits produced by miner were accepted

Please note that the unit tests are probably not in the correct place. I didn't have time to try to find the best place for them.

Copy link

codecov bot commented Jan 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 19.20%. Comparing base (c605e0d) to head (f54512a).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1396      +/-   ##
==========================================
+ Coverage   19.08%   19.20%   +0.11%     
==========================================
  Files         166      166              
  Lines       11066    11107      +41     
==========================================
+ Hits         2112     2133      +21     
- Misses       8954     8974      +20     
Flag Coverage Δ
binary_codec_sv2-coverage 0.00% <ø> (ø)
binary_serde_sv2-coverage 3.55% <ø> (ø)
binary_sv2-coverage 5.34% <ø> (ø)
bip32_derivation-coverage 0.00% <ø> (ø)
buffer_sv2-coverage 25.02% <ø> (ø)
codec_sv2-coverage 0.01% <ø> (ø)
common_messages_sv2-coverage 0.13% <ø> (ø)
const_sv2-coverage 0.00% <ø> (ø)
error_handling-coverage 0.00% <ø> (ø)
framing_sv2-coverage 0.28% <ø> (ø)
jd_client-coverage 0.00% <ø> (ø)
jd_server-coverage 7.79% <ø> (ø)
job_declaration_sv2-coverage 0.00% <ø> (ø)
key-utils-coverage 2.39% <ø> (ø)
mining-coverage 2.44% <ø> (+0.01%) ⬆️
mining_device-coverage 0.00% <ø> (ø)
mining_proxy_sv2-coverage 0.70% <ø> (ø)
noise_sv2-coverage 4.44% <ø> (ø)
pool_sv2-coverage 2.04% <ø> (ø)
protocols 24.74% <ø> (+0.16%) ⬆️
roles 6.54% <ø> (ø)
roles_logic_sv2-coverage 9.06% <ø> (+1.12%) ⬆️
sv2_ffi-coverage 0.00% <ø> (ø)
template_distribution_sv2-coverage 0.00% <ø> (ø)
translator_sv2-coverage 9.60% <ø> (ø)
utils 25.13% <ø> (?)
v1-coverage 2.41% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@plebhash

This comment was marked as outdated.

@Fi3
Copy link
Collaborator

Fi3 commented Jan 28, 2025

cACK

@@ -2,7 +2,7 @@
use alloc::vec::Vec;
#[cfg(not(feature = "with_serde"))]
use binary_sv2::binary_codec_sv2;
use binary_sv2::{Deserialize, Seq0255, Serialize, Sv2Option, B032, B064K, U256};
use binary_sv2::{Deserialize, Seq0255, Serialize, Sv2Option, B064K, U256};
Copy link
Collaborator

Choose a reason for hiding this comment

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

If B032 doesn't exist in the spec, maybe binary_sv2 shouldn't define it?

More rigorously, should it wiped from the codebase?

Copy link
Collaborator

Choose a reason for hiding this comment

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

B32 doesn't exist in the spec.

B0_32 does exist in the spec.

Data Type Byte Length Description
B0_32 1 + LENGTH Byte array with 8-bit length prefix L. Unsigned integer, followed by a sequence of L bytes. Allowed range of length is 0 to 32.

https://stratumprotocol.org/specification/03-Protocol-Overview/#31-data-types-mapping

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh I see, it's still used for extranonce and extranonce_prefix.

Out of scope for this PR, but is it really worth having a separate B0_32 datatype instead of just using B0_255 and then having the spec limit the extranonce size to 31?

It would be less confusing, because extranonce_size is U16 which allows for much bigger values. (U8 would have made more sense, but not worth changing now).

Adding an explanation as to why that limit was picked would be good too.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the reason behind the limit of 32 bytes was set because it's enough to use it in a custom way from the pool (e.g. setting the pool tag in the coinbase tx), while letting the rest of the space to the miner to use it as real extranonce space.

@plebhash plebhash force-pushed the braiins/cross-testing branch from 63d214b to 0702b14 Compare January 29, 2025 16:45
@plebhash plebhash force-pushed the braiins/cross-testing branch 2 times, most recently from 25ed4a8 to 5502fe7 Compare January 29, 2025 17:05
@plebhash plebhash added the ready-to-be-merged triggers auto rebase bot label Jan 29, 2025
@plebhash plebhash force-pushed the braiins/cross-testing branch from 5502fe7 to 85998cc Compare January 29, 2025 19:22
- Fix unit test new_mining_job_serialization
- Add testcase for NewMiningJob serialization
@plebhash plebhash force-pushed the braiins/cross-testing branch from 85998cc to f54512a Compare January 29, 2025 19:43
@plebhash plebhash merged commit c30fd6d into stratum-mining:main Jan 29, 2025
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-be-merged triggers auto rebase bot
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants