-
Notifications
You must be signed in to change notification settings - Fork 882
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
Implemented priv_getLogs #686
Conversation
4af9d1c
to
9a59768
Compare
Signed-off-by: Lucas Saldanha <lucas.saldanha@consensys.net>
Signed-off-by: Lucas Saldanha <lucas.saldanha@consensys.net>
@@ -73,6 +73,14 @@ public Hash getBlockhash() { | |||
return blockhash; | |||
} | |||
|
|||
public boolean isValid() { | |||
if (!getFromBlock().isLatest() && !getToBlock().isLatest() && getBlockhash() != 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.
The filter parameters are a bit confusing. I understand that one of them has to be set, but what takes precedence if a from/to is set and the hash as well? Should that fail?
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 rules are confusing. Basically, if from/to aren't latest, you can't specify the blockhash.
To be frank, I think we have a bug in this validation. When I compare with the JSON-RPC spec.
The spec says that you can't use fromBlock/toBlock with blockhash at all.
I've talked to Madeline about it and she will raise a JI to review and fix this behaviour.
We are using the exact same logic as eth_getLogs. That's why we decided to keep the same behaviour until we review it. And, if we need to change anything, we change in both methods in the future.
...ava/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetLogs.java
Show resolved
Hide resolved
return Collections.emptyList(); | ||
} | ||
|
||
final List<PrivateTransactionMetadata> privateTransactionMetadatas = |
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.
Why don't you just call it "privateTransactionMetadataList"?
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.
Done!
final List<PrivateTransactionMetadata> privateTransactionMetadatas = | ||
privateWorldStateReader.getPrivateTransactionsMetadata(privacyGroupId, blockHash); | ||
|
||
final List<PrivateTransactionReceipt> privateTransactionReceipts = |
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.
privateTransactionReceiptList?
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.
Done!
public void privacyGroupIdIsRequired() { | ||
final JsonRpcRequestContext request = privGetLogRequest(null, mock(FilterParameter.class)); | ||
|
||
final Throwable thrown = catchThrowable(() -> method.response(request)); |
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.
You should just use assertThatThrownBy() ...
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.
Duh! I always forget about it! Done!
public void filterParameterIsRequired() { | ||
final JsonRpcRequestContext request = privGetLogRequest(PRIVACY_GROUP_ID, null); | ||
|
||
final Throwable thrown = catchThrowable(() -> method.response(request)); |
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.
s.a.
privGetLogRequestWithUser(PRIVACY_GROUP_ID, filterParameter, user); | ||
final Throwable thrown = catchThrowable(() -> method.response(request)); | ||
|
||
assertThat(thrown).isInstanceOf(MultiTenancyValidationException.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.
assertThatThrownBy?
@@ -236,7 +236,8 @@ private void verifyPrivateFromMatchesEnclavePublicKey( | |||
} | |||
} | |||
|
|||
private void verifyPrivacyGroupContainsEnclavePublicKey( | |||
@Override | |||
public void verifyPrivacyGroupContainsEnclavePublicKey( | |||
final String privacyGroupId, final String enclavePublicKey) { | |||
final PrivacyGroup privacyGroup = enclave.retrievePrivacyGroup(privacyGroupId); |
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.
are you sure that the privacyGroup cannot be 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.
Well, if it is null you won't find any matching privacy group, right?
And in the json-rpc method we are make the privacy group id a required parameter. I don't think we need to be extra defensive here in this internal class.
@@ -46,4 +54,20 @@ public PrivateWorldStateReader( | |||
.flatMap(worldState -> Optional.ofNullable(worldState.get(contractAddress))) | |||
.flatMap(account -> Optional.ofNullable(account.getCode())); | |||
} | |||
|
|||
public List<PrivateTransactionMetadata> getPrivateTransactionsMetadata( |
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.
should that be "getPrivateTransactionMetadataList"?
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.
Done
@Test | ||
public void verifyPrivacyGroupMatchesEnclaveKeySucceeds() { | ||
final PrivacyGroup privacyGroup = | ||
new PrivacyGroup(PRIVACY_GROUP_ID, Type.PANTHEON, "", "", List.of(ENCLAVE_PUBLIC_KEY1)); |
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.
Could create a const privacy group ... The same one is used twice.
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.
Done :)
Signed-off-by: Lucas Saldanha <lucas.saldanha@consensys.net>
Signed-off-by: Lucas Saldanha <lucas.saldanha@consensys.net>
9a59768
to
0e97569
Compare
Signed-off-by: Lucas Saldanha <lucas.saldanha@consensys.net>
Signed-off-by: Lucas Saldanha <lucas.saldanha@consensys.net>
final PrivateTransactionManager privateTransactionManager = | ||
new LegacyPrivateTransactionManager( | ||
besu, GAS_PROVIDER, senderCredentials, chainId, privateFrom, privateFor); | ||
PrivateTransactionManager privateTransactionManager; |
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.
nit: can be final
Implemented
priv_getLogs
. This JSON-RPC method is similar toeth_getLogs
, but used to read logs from private transaction receipts.Closes #628