Adds priv_getcode#408
Conversation
|
|
||
| public PrivGetCode( | ||
| final BlockchainQueries blockchain, | ||
| final PrivacyParameters privacyParameters, |
There was a problem hiding this comment.
It looks like we are passing down the PrivacyParameter object only to get an instance of the privateStateArchive. I think we should change this to receive the privateStateArchive directly.
|
|
||
| @Override | ||
| public JsonRpcResponse response(final JsonRpcRequestContext requestContext) { | ||
| LOG.trace("Executing {}", RpcMethod.PRIV_GET_CODE.getMethodName()); |
There was a problem hiding this comment.
We already have DEBUG log level for JSON-RPC calls. I don't think we need this one.
| import org.apache.tuweni.bytes.Bytes; | ||
| import org.apache.tuweni.bytes.Bytes32; | ||
|
|
||
| public class PrivGetCode implements JsonRpcMethod { |
There was a problem hiding this comment.
We have an abstraction for methods that have the block paramater to handle named or numbers, etc.
Take a look at PrivCall and how it extends AbstractBlockParameterMethod. I believe we should make PrivGetCode extend AbstractBlockParameterMethod.
| public JsonRpcResponse response(final JsonRpcRequestContext requestContext) { | ||
| LOG.trace("Executing {}", RpcMethod.PRIV_GET_CODE.getMethodName()); | ||
|
|
||
| final Address address = |
There was a problem hiding this comment.
We have standardized that for any priv_ methods that have an equivalent eth_ method, we will make the first parameter (index 0) the privacyGroupId. And all other parameters will be the same.
So, the expected params for priv_getCode are:
params: [
'privacy_group_id',
'0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b',
'0x2' // 2
]
Take a look at PrivCall implementation
| final Hash latestStateRoot = | ||
| privateStateRootResolver.resolveLastStateRoot( | ||
| privacyGroupId, | ||
| blockParameter.isNumeric() && blockParameter.getNumber().isPresent() |
There was a problem hiding this comment.
As I mentioned before, extending AbstractBlockParameterMethod should help you handling the block paramter.
|
Would you please add an entry on |
| @RunWith(MockitoJUnitRunner.class) | ||
| public class PrivGetCodeTest { | ||
|
|
||
| @Rule public final TemporaryFolder temp = new TemporaryFolder(); |
There was a problem hiding this comment.
temp doesn't seem to be used
Signed-off-by: Joshua Richardson <joshua@richardson.tech>
|
I've now addressed all comments from @lucassaldanha and @pinges, however by changing the parameter order, Web3j has had to undergo a refactor which has not yet been released, and therefore the |
Signed-off-by: Joshua Richardson <joshua@richardson.tech>
|
Bumped the Web3j version, so this should now be ready to go. |
Signed-off-by: Joshua Richardson <joshua@richardson.tech>
| new JsonRpcRequest( | ||
| "2.0", | ||
| "priv_getCode", | ||
| new Object[] { |
There was a problem hiding this comment.
We need to fix the order of the parameters here.
Signed-off-by: Joshua Richardson <joshua@richardson.tech>
Signed-off-by: Joshua Richardson <joshua@richardson.tech>
priv_getCode was previously implemented on another branch, but that became stale & difficult to rebase, so it was quicker to just branch off master and pull in my relevant commits to this branch by cherry-picking.
Signed-off-by: Joshua Richardson joshua@richardson.tech
PR description
Adds priv_getCode, the implementation of eth_getCode but for private transactions.
Fixed Issue(s)