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

Stratum nicehash. Avoid recalculating target with every job. #1156

Merged
merged 1 commit into from May 26, 2018

Conversation

Projects
None yet
3 participants
@jean-m-cyr
Collaborator

jean-m-cyr commented May 25, 2018

nicehash will periodically adjust difficulty, sending it as
a float value to be converted to 32 byte target. There is no
need to do the conversion with every job.

Stratum nicehash. Avoid recalculating target with every job.
nicehash will periodically adjust difficulty, sending it as
a float value to be converted to 32 byte target. There is no
need to do the conversion with every job.
double nextWorkDifficulty = jPrm.get((Json::Value::ArrayIndex)0, 1).asDouble();
if (nextWorkDifficulty <= 0.0001) nextWorkDifficulty = 0.0001;
diffToTarget((uint32_t*)m_nextWorkBoundary.data(), nextWorkDifficulty);
cnote << "Difficulty set to" << nextWorkDifficulty;

This comment has been minimized.

@AndreaLanfranchi

AndreaLanfranchi May 25, 2018

Collaborator

Do not know if this is the right place where to put it.
PoolManager does the same on p_client->onWorkReceived(...)

@AndreaLanfranchi

AndreaLanfranchi May 25, 2018

Collaborator

Do not know if this is the right place where to put it.
PoolManager does the same on p_client->onWorkReceived(...)

This comment has been minimized.

@jean-m-cyr

jean-m-cyr May 25, 2018

Collaborator

Two different things.

  • Here we've received a stratum2 (nicehash) difficulty indication message from the protocol. We display it as a float. and it is multiplied by the maximum target value to get the target value.

  • In PoolManager, we look for target value changes and when they occur we do the reverse calculation to get the difficulty, which is displayed in units on 1 million (since that's the way pools specify difficulty). This applies to all stratum versions since for non stratum2 versions the target value is part of the job notification.

It's all very confusing... there are many ways to express difficulty.

1 - as a fraction of the maximum target value.
2 - As a 256 bit target value.
3 - Max. target / current target (inverse of 1st form).
4 - (Max. target / current target) / 1000000.

All are equivalent. This code displays in format 1. The pool manager uses format 4.

@jean-m-cyr

jean-m-cyr May 25, 2018

Collaborator

Two different things.

  • Here we've received a stratum2 (nicehash) difficulty indication message from the protocol. We display it as a float. and it is multiplied by the maximum target value to get the target value.

  • In PoolManager, we look for target value changes and when they occur we do the reverse calculation to get the difficulty, which is displayed in units on 1 million (since that's the way pools specify difficulty). This applies to all stratum versions since for non stratum2 versions the target value is part of the job notification.

It's all very confusing... there are many ways to express difficulty.

1 - as a fraction of the maximum target value.
2 - As a 256 bit target value.
3 - Max. target / current target (inverse of 1st form).
4 - (Max. target / current target) / 1000000.

All are equivalent. This code displays in format 1. The pool manager uses format 4.

This comment has been minimized.

@AndreaLanfranchi

AndreaLanfranchi May 26, 2018

Collaborator

Hmmm ... think we should find a standard way to express diff.
I guess (but it's only a guess) that the most understandable by users is the 4th way.

@AndreaLanfranchi

AndreaLanfranchi May 26, 2018

Collaborator

Hmmm ... think we should find a standard way to express diff.
I guess (but it's only a guess) that the most understandable by users is the 4th way.

This comment has been minimized.

@jean-m-cyr

jean-m-cyr May 26, 2018

Collaborator

I should point out that this update changes nothing in this respect. No log messages were changed or added by this modification.

@jean-m-cyr

jean-m-cyr May 26, 2018

Collaborator

I should point out that this update changes nothing in this respect. No log messages were changed or added by this modification.

@AndreaLanfranchi

Good for me.

@chfast

chfast approved these changes May 26, 2018

@@ -792,8 +792,8 @@ void EthStratumClient::processReponse(Json::Value& responseObject)
cnote << "Subscribed to stratum server";
m_nextWorkDifficulty = 1;
m_nextWorkBoundary = h256("0xffff000000000000000000000000000000000000000000000000000000000000");

This comment has been minimized.

@chfast

chfast May 26, 2018

Contributor

Why not all f?

@chfast

chfast May 26, 2018

Contributor

Why not all f?

This comment has been minimized.

@jean-m-cyr

jean-m-cyr May 26, 2018

Collaborator

This seems to be the max target value used in all ethereum code. Not sure why it's not all F's.

@jean-m-cyr

jean-m-cyr May 26, 2018

Collaborator

This seems to be the max target value used in all ethereum code. Not sure why it's not all F's.

@jean-m-cyr jean-m-cyr merged commit 0c36782 into master May 26, 2018

3 checks passed

ci/circleci Your tests passed on CircleCI!
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@jean-m-cyr jean-m-cyr deleted the stratum2 branch May 26, 2018

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