-
Notifications
You must be signed in to change notification settings - Fork 130
Nc 1942 Add account whitelisting and refactor into permissioning package #460
Conversation
…NC-1942 # Conflicts: # pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java # pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java Resolved
…NC-1942 # Conflicts: # consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftControllerTest.java # docs/Getting-Started/ExplorerBlockDetails.png # docs/Getting-Started/ExplorerSearch.png # docs/Getting-Started/ExplorerSummary.png # ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/PermissioningConfiguration.java # ethereum/permissioning/src/test/java/tech/pegasys/pantheon/ethereum/permissioning/PermissioningConfigurationTest.java # pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java # pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java
…NC-1942 # Conflicts: # consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftControllerTest.java # docs/Getting-Started/ExplorerBlockDetails.png # docs/Getting-Started/ExplorerSearch.png # docs/Getting-Started/ExplorerSummary.png # ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/PermissioningConfiguration.java # ethereum/permissioning/src/test/java/tech/pegasys/pantheon/ethereum/permissioning/PermissioningConfigurationTest.java # pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java # pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java
…NC-1942 # Conflicts: # consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftControllerTest.java # docs/Getting-Started/ExplorerBlockDetails.png # docs/Getting-Started/ExplorerSearch.png # docs/Getting-Started/ExplorerSummary.png # ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/PermissioningConfiguration.java # ethereum/permissioning/src/test/java/tech/pegasys/pantheon/ethereum/permissioning/PermissioningConfigurationTest.java # pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java # pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java
@@ -131,6 +134,16 @@ public PendingTransactions getPendingTransactions() { | |||
return basicValidationResult; | |||
} | |||
|
|||
if (accountWhitelistController.isPresent() |
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.
It would be good to have this whole logic inside a private method with a meaningful name like checkIfAccountIsWhitelisted
or something similar.
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.
actioned
ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/core/TransactionPoolTest.java
Show resolved
Hide resolved
AccountWhitelistController accountWhitelistController = | ||
new AccountWhitelistController(permissioningConfiguration); | ||
|
||
transactionPool.setAccountWhitelist(accountWhitelistController); |
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.
We don't need to call the setter if the account whitelist property hasn't been set. Why don't we check it here?
if (permissioningConfiguration.isAccountWhitelistSet()) {
transactionPool.setAccountWhitelist(accountWhitelistController);
}
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.
actioned
@@ -404,13 +404,24 @@ private void setRefreshDelay(final Long refreshDelay) { | |||
names = {"--nodes-whitelist"}, | |||
paramLabel = "<enode://id@host:port>", | |||
description = | |||
"Comma separated enode URLs for permissioned networks. Not intended to be used with mainnet or public testnets.", | |||
"Comma separated enode URLs for permissioned networks. You may specify an empty list.", |
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've reverted a text change here - can you change it back?
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.
actioned
description = | ||
"Comma separated hexString of account public key " | ||
+ "for permissioned/role-based transaction. You may specify an empty list.", | ||
split = ",", |
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/transaction/transactions
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.
actioned
split = ",", | ||
arity = "0..*", | ||
converter = EnodeToURIPropertyConverter.class | ||
) | ||
private final Collection<URI> nodesWhitelist = null; | ||
|
||
@Option( | ||
names = {"--accounts-whitelist"}, | ||
paramLabel = "<hexString of account public key>", |
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/key/keys
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.
actioned
@@ -131,6 +134,13 @@ public PendingTransactions getPendingTransactions() { | |||
return basicValidationResult; | |||
} | |||
|
|||
String sender = transaction.getSender().toString(); | |||
if (!checkIfAccountIsWhitelisted(sender)) { |
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.
Now that I read this, I think the if statement will be better as something like:
if (!accountIsWhitelisted(sender)) {
What do you think?
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.
Or maybe even accountIsNotWhitelisted(sender))
so we don't need to negate the expression... idk
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.
actioned
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.
It is looking good now. I've added another comment re readability and Sally has got some comments herself that I believe it would be good to implement.
PR description
Create account whitelisting serving as the groundwork for role based permissioning system for transactions
Include:
Fixed Issue(s)