How does the rate of getwork requests correlate with the hashrate of a miner?

3

1

In a setup where a standard bitcoind serves full difficulty targets to some mining nodes, how can I calculate the hashrate of a mining node from looking at the rate of getwork requests? Does this depend on the used mining program or the used mining extensions?

Noah

Posted 2012-04-15T11:53:36.883

Reputation: 1 369

1Why would you want to do something like that? If you want to minimize the amount of shares sent, you can just increase the difficulty by some factor, rather than giving full difficulty and using getworks as a measurement. Your solution could potentially lead to exploits where the miner would send more getwork requests while not processing them all.ThePiachu 2012-04-15T12:48:02.107

Thank you for pointing that out. I understand that this question is of little importance for practical implementations. It does however help to better understand the getwork mechanism. I was experimenting with a local setup and was wondering about the exact relationship.Noah 2012-04-15T13:06:04.010

Answers

3

The standard getwork protocol forces the miner to send a new request every second. This means that if a miner takes longer than 1 second to check all nonces in a given getwork (2^32), it will be making a new request before it checks all values in a given request, thus giving you 1 getwork request per second regardless of the hashrate.

If the miner can solve the getwork faster than that, it would be making requests more often. In theory, you could use this formula to calculate the hashrate:

Hashrate = noncemax/time

Where time is the interval between the getwork requests and noncemax is the size of nonce field (2^32). However, this assumes no time delay due to the network lag and so forth, so it's an ideal scenario. Moreover, some miners discard unfinished work after submitting a share, so it would appear they are doing more work in your configuration than they actually are.

If you intend on using getwork extensions, specifically noncerange and rollntime, you could calculate the hashrate more accurately. Noncerange would change your noncemax to whatever size you set, and rollntime would allow you to measure time intervals greater than one second. However, not all miners support the extensions.

ThePiachu

Posted 2012-04-15T11:53:36.883

Reputation: 41 594

Thank you for this explanation. In case anybody wonders about the same thing: in my local setup your formula results in hashrates which are consistently about 36% above the values I get displayed by cgminer. I am looking at various hashrates, ranging from (according to cgminer) about 600Mh/s at 5.23 seconds between getworks to 1700Mh/s at 1.86 seconds between getworks. I'm assuming this is due to the effects you mentioned. Thanks again!Noah 2012-04-15T14:26:02.553

Getwork is old. Could you discuss getblocktemplate? thanks

Geremia 2015-06-16T08:22:29.220

@Geremia Create a separate question and someone might elaborate.ThePiachu 2015-06-16T17:54:24.910