-
Notifications
You must be signed in to change notification settings - Fork 295
Optimize construct_bm_job #1321
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
base: master
Are you sure you want to change the base?
Conversation
This PR eliminates several inefficient codepaths * Limit back and forth reversing of byte or word orders; * Remove merkle_root_be and prev_block_hash_be from bm_job; * All parameters are converted to binary once; * Stack allocation instead of malloc; * Remove unused functions; * Unroll byte and word reversal functions.
Georges760
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A very GOOD PR, GG Mutatrum!
Didn't test it on HW but since you did it on both 97 and 70, should be fine, this kind of change easily brake mining, so as long as it mine well, it is fine.
Thanks, it messes with your sanity this stuff.
Indeed, if something is wrong, there's three options:
|
|
|
bold PR; thanks for risking your sanity to improve the mining job construction. I'll give this a try on my BM1368 Supra today. @johnny9 you might be interested in seeing this. |
| TEST_ASSERT_EQUAL_UINT8_ARRAY(expected_midstate_bin, job.midstate, 32); | ||
| uint8_t expected_midstate_bin_reversed[32]; | ||
| reverse_32bit_words(expected_midstate_bin, expected_midstate_bin_reversed); | ||
| reverse_endianness_per_word(expected_midstate_bin_reversed); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this, my suspicion is that the hex string above is not in the same order as it would actually come out of the midstate. In code, the endianness isn't changed, only word order.
Paving the way for #420 and dropping the job queues, slowly getting there. |
|
Looks like good cleanup at first glance. I need to take a closer look at the test case changes to be sure it's functionally working well. |
Only the setup of test cases has changed, or expected values are converted to binary, all the assertions in the test cases are the same. The only one I'm not happy with is this one: #1321 (comment) One other thing I'm considering is to move out all the The only manipulation happening then is the word endianness swap of prev_block_hash, but that is an actual bitcoin vs stratum difference. |
This PR eliminates several inefficient codepaths in constructing new jobs:
merkle_root_beandprev_block_hash_befrombm_job;calculate_coinbase_tx_hashandcalculate_merkle_root_hashreturn hashes instead of hex strings;Verified on BM1397 and BM1370.