Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

NC-1244 Implement JSON-RPC method "eth_getWork" #70

Merged
merged 15 commits into from
Oct 19, 2018
Merged

NC-1244 Implement JSON-RPC method "eth_getWork" #70

merged 15 commits into from
Oct 19, 2018

Conversation

Shinabyss
Copy link
Contributor

@Shinabyss Shinabyss commented Oct 16, 2018

PR Details

Implement JSON-RPC method eth_getWork same as geth

Description

Issue NC-1244

Related Issue

Motivation and Context

Implement JSON-RPC method eth_getWork same as corresponding function as geth

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Special notes for your reviewer:

Release note

NONE

Prerequisites:

  • I have read the CONTRIBUTING.md document.
  • This code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added appropriate tests that prove my change is effective
  • New and existing tests pass locally with my changes

@NicolasMassart NicolasMassart added the work in progress Work on this pull request is ongoing label Oct 17, 2018
@Shinabyss Shinabyss changed the title Nc 1244 NC-1244 Implement JSON-RPC method "eth_getWork" Oct 17, 2018
@Shinabyss Shinabyss removed the work in progress Work on this pull request is ongoing label Oct 18, 2018
Copy link
Contributor

@lucassaldanha lucassaldanha left a comment

Choose a reason for hiding this comment

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

Requested a couple of changes. Also, I think it is important to get Trent's review on the mining changes.

assertThat(thrown).isInstanceOf(ClientConnectionException.class);
assertThat(thrown.getMessage())
.contains(
"\"error\" : {\n"
Copy link
Contributor

Choose a reason for hiding this comment

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

Using \n can break the build on other OS (e.g. Windows). I suggest that you only check if the message contains no mining work available yet instead of trying to match the json object.

@@ -29,6 +29,7 @@
// Filter & Subscription Errors
FILTER_NOT_FOUND(-32000, "Filter not found"),
SUBSCRIPTION_NOT_FOUND(-32000, "Subscription not found"),
NO_MINING_WORK_FOUND(-32000, "no mining work available yet"),
Copy link
Contributor

Choose a reason for hiding this comment

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

All other error messages start with a capital letter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

screen shot 2018-10-18 at 2 04 03 pm

geth wasn't capital thus it was intentionally not made capital, but i will change this regardless

};
return new JsonRpcSuccessResponse(req.getId(), result);
} else {
LOG.error("Mining is not operational, eth_getWork request cannot be processed");
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not an error (from the application point of view). It is doing exactly what is expected. Change it to a debug/trace level.

@@ -0,0 +1,38 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this is a straight copy from the EthHash?

nit: Nice idea, but maybe not relevant to this changeset.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Taken out of the EthHash because getwork need it

@@ -58,7 +58,7 @@

private static final int ACCESSES = 64;

private static final ThreadLocal<MessageDigest> KECCAK_256 =
public static final ThreadLocal<MessageDigest> KECCAK_256 =
Copy link
Contributor

Choose a reason for hiding this comment

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

seems like a bad idea making this "ThreadLocal" variable publicly visible - can it be moved into the DagSeed class?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made this public variable on DagSeed class, the final should prevent it from being altered.

@@ -17,12 +17,13 @@
public class EthHashSolverInputs {
private final UInt256 target;
private final byte[] prePowHash;
private final long dagSeed; // typically block number
private final long blockNumber;
Copy link
Contributor

Choose a reason for hiding this comment

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

Not your problem: But is this the right information to be exposed to the JSON RPC? I had figured this was the dagseed hash, but tbh was guessing based on our algo requirements.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

from what @CjHare and I could gather, the dagSeed is a hash

@NicolasMassart
Copy link
Contributor

This PR needs ad proper description !

Copy link
Contributor

@lucassaldanha lucassaldanha left a comment

Choose a reason for hiding this comment

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

Thanks for addressing my comments.
Just need to double check with Trent that the mining changes are ok.

@Shinabyss Shinabyss merged commit 1325a41 into PegaSysEng:master Oct 19, 2018
@Shinabyss Shinabyss deleted the NC-1244 branch October 19, 2018 00:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants