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

Add proper support for eth_hashrate #1019

Closed
timbeiko opened this issue Jun 2, 2020 · 3 comments · Fixed by #1063
Closed

Add proper support for eth_hashrate #1019

timbeiko opened this issue Jun 2, 2020 · 3 comments · Fixed by #1063
Assignees
Labels
bug Something isn't working enhancement New feature or request P3 Medium (ex: JSON-RPC request not working with a specific client library due to loose spec assumtion)

Comments

@timbeiko
Copy link
Contributor

timbeiko commented Jun 2, 2020

We should properly support eth_hashrate, as it currently always returns 0.

We need to add eth_submitHashrate that is just a two arg function, a BigInteger first arg (value) and a hash as second arg (key) and we put it in a hashmap. Then for eth_hashrate we sum up the values of the map with the cpu rate.

We may want to size limit the hashmap (where we evict the least recently updated value) and remove zero rates to prevent memory bloat attacks.

@timbeiko timbeiko added the enhancement New feature or request label Jun 2, 2020
@RatanRSur
Copy link
Contributor

If we always return 0, does this count as a bug?

@timbeiko timbeiko added the bug Something isn't working label Jun 2, 2020
@matkt matkt self-assigned this Jun 3, 2020
@timbeiko timbeiko added this to the Chupacabra Sprint 66 milestone Jun 3, 2020
@matkt
Copy link
Contributor

matkt commented Jun 8, 2020

If we always return 0, does this count as a bug?

I would say it’s an improvement rather than a bug

@matkt
Copy link
Contributor

matkt commented Jun 8, 2020

Implementation

  • Implemented submitHashrate endpoint which is by default limited to 1000 sealers. Adding a 1001 will remove the oldest from the list (0x0 hashrate is refused)
  • Updated eth_hashrateendpoint so that it returns the cumulative hashrate of all sealers if the list is not empty. Otherwise it returns the local hashrate
  • Added hashrate submission with Stratum1EthProxyProtocol and Stratum1Protocol
  • Added CLI Option to modify the number of sealers limit

Test

  • Tested the hashrate submission with stratum
  • Tested the hashrate submission with json rpc api
{"id":1,"jsonrpc":"2.0","method":"eth_submitHashrate","params":["0x00","0x01"]}
{"id":1,"jsonrpc":"2.0","method":"eth_submitHashrate","params":["0x01","0x01"]}
  • Tested with CPU and GPU mining

See this PR : #1063

@timbeiko timbeiko added the P3 Medium (ex: JSON-RPC request not working with a specific client library due to loose spec assumtion) label Jun 8, 2020
@matkt matkt linked a pull request Jun 9, 2020 that will close this issue
@matkt matkt reopened this Jun 15, 2020
@matkt matkt closed this as completed Jun 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request P3 Medium (ex: JSON-RPC request not working with a specific client library due to loose spec assumtion)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants