-
Notifications
You must be signed in to change notification settings - Fork 130
NC-1244 Implement JSON-RPC method "eth_getWork" #70
Conversation
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.
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" |
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.
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.
...s/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetWorkAcceptanceTest.java
Show resolved
Hide resolved
ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/EthHash.java
Show resolved
Hide resolved
@@ -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"), |
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.
All other error messages start with a capital letter.
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.
}; | ||
return new JsonRpcSuccessResponse(req.getId(), result); | ||
} else { | ||
LOG.error("Mining is not operational, eth_getWork request cannot be processed"); |
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.
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 @@ | |||
/* |
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.
Looks like this is a straight copy from the EthHash?
nit: Nice idea, but maybe not relevant to this changeset.
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.
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 = |
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.
seems like a bad idea making this "ThreadLocal" variable publicly visible - can it be moved into the DagSeed class?
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.
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; |
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.
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.
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.
from what @CjHare and I could gather, the dagSeed is a hash
Debugged Change Requests Actioned
This PR needs ad proper description ! |
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.
Thanks for addressing my comments.
Just need to double check with Trent that the mining changes are ok.
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
Special notes for your reviewer:
Release note
Prerequisites: