-
Notifications
You must be signed in to change notification settings - Fork 130
[PAN-2946] - changes in core JSON-RPC method to support ReTestEth #1815
Conversation
Some of the methods need to have a changeable reference to stuff like blockchainqueries. For the impacted methods the solution is to wrap them in a Supplier<> interface. This includes new constructors for re-used methods. Also include the debug_accountRangeAt method as it's namespaced as debug. Also, rename the getter methods to align with standards.
* DebugStorageRange is needed too. * ethGetBlockByNumber needs the coinbase in a field labeled "author" * Set a flag for the previous to by default not send the coinbase in response * jsonrpc spec tests to verify author not sent. * On a rejected transaciton eth_sendRawTransaction wants an hash of Empty * again, controlled by a flag with option off *
@Override | ||
protected Object resultByBlockNumber(final JsonRpcRequest request, final long blockNumber) { | ||
final Object[] params = request.getParams(); | ||
final String addressHash = parameters.required(params, 2, String.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.
final String addressHash = parameters.required(params, 2, String.class); | |
final Hash addressHash = parameters.required(params, 2, Hash.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.
Retesteth likes to pass in odd length addresses, particularly zero addresses. Which is why I take it in as a string and at line 81 parse it in a lenient fashion. Going straight to hash throws Caused by: java.lang.IllegalArgumentException: Invalid odd-length hex binary representation 0
|
||
@Override | ||
protected BlockParameter blockParameter(final JsonRpcRequest request) { | ||
return parameters.required(request.getParams(), 0, BlockParameter.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.
The docs say the first parameter should be a number or hash. As is, this will only handle numbers or tags ("latest", "earliest", etc).
If we want to match the spec, we could extend BlockParameter
with a new BlockParameterOrHash
class. Or we could push back since none of the other JSON-RPC API's work like this.
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.
The docs say hash, but we never see a hash in practice. If it becomes a retesteth requirement I will probably go the BlockParameterOrHash
route, but as of now the docs require a form that is not used.
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.
LooksLike DebugStorageRangeAt
will need the BlockParameterOrHash
treatment. Recent change pushed into ReTestEth needs it now. :(
.get() | ||
.streamAccounts(Bytes32.fromHexStringLenient(addressHash), maxResults + 1) | ||
.collect(Collectors.toList()); | ||
Bytes32 nextKey = Bytes32.ZERO; |
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.
For symmetry with debug_storageRangeAt
, I think nextKey
should be null
(not returned) in this case.
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.
retesteh requires the zeros return. Not the most fault tolerant code.
@@ -89,6 +102,7 @@ | |||
this.timestamp = Quantity.create(header.getTimestamp()); | |||
this.ommers = ommers; | |||
this.transactions = transactions; | |||
this.coinbase = includeCoinbase ? header.getCoinbase().toString() : null; |
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.
I think it's cleaner to just always include coinbase
instead of adding a flag to switch on this. Shouldn't hurt anything if there's extra data returned that users aren't expecting. Kind of odd that it's not a standard field anyway.
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 only is it not in the JSON-RPC Spec, what reteseth wants is an author
field which has the same meaning test wise as coinbase
. If we expose it for all I would still want a flag and we expose coinbase
not author
.
@@ -185,4 +199,10 @@ public String getTimestamp() { | |||
public List<TransactionResult> getTransactions() { | |||
return transactions; | |||
} | |||
|
|||
@JsonGetter(value = "author") |
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 an odd name for this field 🤔
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.
very odd.
@@ -216,28 +216,8 @@ Formatter will be turned on to make this easier to read (one spec per line) | |||
|
|||
specs.put(EthNewPendingTransactionFilter.class, "eth_newPendingTransactionFilter"); | |||
|
|||
specs.put(EthUninstallFilter.class, "eth_uninstallFilter_NonexistentFilter"); | |||
specs.put(EthUninstallFilter.class, "eth_uninstallFilter_FilterIdTooLong"); | |||
specs.put(EthUninstallFilter.class, "eth_uninstallFilter_FilterIdNegative"); |
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.
What happened to these - bad merge??
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.
bad merge. Will fix.
* restore missing spec tests * rename to debig_accountRange * make sure stack trace come with invalidjsonrpcparams catch
"request": { | ||
"id": 414, | ||
"jsonrpc": "2.0", | ||
"method": "debug_accountRangeAt", |
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 method needs a rename for the tests too
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.
fixed, temporarily. Retesteth is changing the name but is unstable where they changed it.
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.
LGTM pending test fixes
* add BlockParameterOrBlockHash * Wire up debug_storageRangeAt and debug_accountRange to use it * spec tests
|
PR description
Some of the methods need to have a changeable reference to stuff like
blockchainqueries. For the impacted methods the solution is to wrap them
in a Supplier<> interface. This includes new constructors for re-used methods.
Also include the debug_accountRangeAt method as it'ss namespaced as debug.
Also, rename the getter methods to align with standards.