From 176ace0d5db6189aeeb5528e5eb65bdac048c4d1 Mon Sep 17 00:00:00 2001 From: Mark Terry Date: Thu, 9 May 2019 22:31:06 +1000 Subject: [PATCH 1/5] [PAN-2601] Renamed SmartContractPermissioningController -> NodeSmartContractPermissioningController incl. relevant fields etc. --- ...tContractNodePermissioningConditions.java} | 10 +++---- .../node/factory/PermissionedNodeBuilder.java | 10 +++---- ...ontractNodePermissioningTransactions.java} | 12 ++++---- ...actPermissioningAllowNodeTransaction.java} | 8 +++--- ...ioningConnectionIsAllowedTransaction.java} | 10 +++---- ...ctPermissioningForbidNodeTransaction.java} | 8 +++--- ...ermissioningNodeIsAllowedTransaction.java} | 8 +++--- ...tractNodePermissioningAcceptanceTest.java} | 4 +-- ...tNodePermissioningAcceptanceTestBase.java} | 26 ++++++++--------- .../NodePermissioningControllerFactory.java | 10 +++---- ...rtContractPermissioningConfiguration.java} | 6 ++-- ...SmartContractPermissioningController.java} | 4 +-- .../PermissioningConfiguration.java | 6 ++-- .../PermissioningConfigurationBuilder.java | 4 +-- ...tContractPermissioningControllerTest.java} | 22 +++++++-------- ...odePermissioningControllerFactoryTest.java | 28 +++++++++---------- .../pegasys/pantheon/cli/PantheonCommand.java | 8 +++--- .../pantheon/cli/PantheonCommandTest.java | 12 ++++---- 18 files changed, 98 insertions(+), 98 deletions(-) rename acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/perm/{SmartContractNodePermissioningConditions.java => NodeSmartContractNodePermissioningConditions.java} (83%) rename acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/{SmartContractNodePermissioningTransactions.java => NodeSmartContractNodePermissioningTransactions.java} (80%) rename acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/{SmartContractPermissioningAllowNodeTransaction.java => NodeSmartContractPermissioningAllowNodeTransaction.java} (90%) rename acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/{SmartContractPermissioningConnectionIsAllowedTransaction.java => NodeSmartContractPermissioningConnectionIsAllowedTransaction.java} (86%) rename acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/{SmartContractPermissioningForbidNodeTransaction.java => NodeSmartContractPermissioningForbidNodeTransaction.java} (90%) rename acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/{SmartContractPermissioningNodeIsAllowedTransaction.java => NodeSmartContractPermissioningNodeIsAllowedTransaction.java} (91%) rename acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/permissioning/{SmartContractNodePermissioningAcceptanceTest.java => NodeNodeSmartContractNodePermissioningAcceptanceTest.java} (96%) rename acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/permissioning/{SmartContractNodePermissioningAcceptanceTestBase.java => NodeSmartContractNodePermissioningAcceptanceTestBase.java} (76%) rename ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/{SmartContractPermissioningConfiguration.java => NodeSmartContractPermissioningConfiguration.java} (86%) rename ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/{SmartContractPermissioningController.java => NodeSmartContractPermissioningController.java} (97%) rename ethereum/permissioning/src/test/java/tech/pegasys/pantheon/ethereum/permissioning/{SmartContractPermissioningControllerTest.java => NodeSmartContractPermissioningControllerTest.java} (92%) diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/perm/SmartContractNodePermissioningConditions.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/perm/NodeSmartContractNodePermissioningConditions.java similarity index 83% rename from acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/perm/SmartContractNodePermissioningConditions.java rename to acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/perm/NodeSmartContractNodePermissioningConditions.java index fe96d6204b..624c4da3a6 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/perm/SmartContractNodePermissioningConditions.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/perm/NodeSmartContractNodePermissioningConditions.java @@ -14,14 +14,14 @@ import tech.pegasys.pantheon.tests.acceptance.dsl.condition.Condition; import tech.pegasys.pantheon.tests.acceptance.dsl.node.Node; -import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.perm.SmartContractNodePermissioningTransactions; +import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.perm.NodeSmartContractNodePermissioningTransactions; -public class SmartContractNodePermissioningConditions { +public class NodeSmartContractNodePermissioningConditions { - private final SmartContractNodePermissioningTransactions transactions; + private final NodeSmartContractNodePermissioningTransactions transactions; - public SmartContractNodePermissioningConditions( - final SmartContractNodePermissioningTransactions transactions) { + public NodeSmartContractNodePermissioningConditions( + final NodeSmartContractNodePermissioningTransactions transactions) { this.transactions = transactions; } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PermissionedNodeBuilder.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PermissionedNodeBuilder.java index c5a78501da..1aa340ee6c 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PermissionedNodeBuilder.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PermissionedNodeBuilder.java @@ -21,7 +21,7 @@ import tech.pegasys.pantheon.ethereum.jsonrpc.RpcApis; import tech.pegasys.pantheon.ethereum.permissioning.LocalPermissioningConfiguration; import tech.pegasys.pantheon.ethereum.permissioning.PermissioningConfiguration; -import tech.pegasys.pantheon.ethereum.permissioning.SmartContractPermissioningConfiguration; +import tech.pegasys.pantheon.ethereum.permissioning.NodeSmartContractPermissioningConfiguration; import tech.pegasys.pantheon.ethereum.permissioning.WhitelistPersistor; import tech.pegasys.pantheon.ethereum.permissioning.WhitelistPersistor.WHITELIST_TYPE; import tech.pegasys.pantheon.tests.acceptance.dsl.node.Node; @@ -138,7 +138,7 @@ public PantheonNode build() { localPermConfig = Optional.of(localConfigPermissioningConfiguration()); } - Optional smartContractPermConfig = Optional.empty(); + Optional smartContractPermConfig = Optional.empty(); if (smartContractPermissioningEnabled) { smartContractPermConfig = Optional.of(smartContractPermissioningConfiguration()); } @@ -203,9 +203,9 @@ private LocalPermissioningConfiguration localConfigPermissioningConfiguration() return localPermissioningConfiguration; } - private SmartContractPermissioningConfiguration smartContractPermissioningConfiguration() { - SmartContractPermissioningConfiguration config = - SmartContractPermissioningConfiguration.createDefault(); + private NodeSmartContractPermissioningConfiguration smartContractPermissioningConfiguration() { + NodeSmartContractPermissioningConfiguration config = + NodeSmartContractPermissioningConfiguration.createDefault(); if (permissioningSmartContractAddress != null) { config.setSmartContractAddress(Address.fromHexString(permissioningSmartContractAddress)); config.setSmartContractNodeWhitelistEnabled(true); diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/SmartContractNodePermissioningTransactions.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/NodeSmartContractNodePermissioningTransactions.java similarity index 80% rename from acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/SmartContractNodePermissioningTransactions.java rename to acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/NodeSmartContractNodePermissioningTransactions.java index 32f455a883..f9934098ed 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/SmartContractNodePermissioningTransactions.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/NodeSmartContractNodePermissioningTransactions.java @@ -18,32 +18,32 @@ import tech.pegasys.pantheon.tests.acceptance.dsl.node.Node; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; -public class SmartContractNodePermissioningTransactions { +public class NodeSmartContractNodePermissioningTransactions { private final Accounts accounts; - public SmartContractNodePermissioningTransactions(final Accounts accounts) { + public NodeSmartContractNodePermissioningTransactions(final Accounts accounts) { this.accounts = accounts; } public Transaction allowNode(final String contractAddress, final Node node) { - return new SmartContractPermissioningAllowNodeTransaction( + return new NodeSmartContractPermissioningAllowNodeTransaction( accounts.getPrimaryBenefactor(), Address.fromHexString(contractAddress), node); } public Transaction forbidNode(final String contractAddress, final Node node) { - return new SmartContractPermissioningForbidNodeTransaction( + return new NodeSmartContractPermissioningForbidNodeTransaction( accounts.getPrimaryBenefactor(), Address.fromHexString(contractAddress), node); } public Transaction isNodeAllowed(final String contractAddress, final Node node) { - return new SmartContractPermissioningNodeIsAllowedTransaction( + return new NodeSmartContractPermissioningNodeIsAllowedTransaction( Address.fromHexString(contractAddress), node); } public Transaction isConnectionAllowed( final String contractAddress, final Node source, final Node target) { - return new SmartContractPermissioningConnectionIsAllowedTransaction( + return new NodeSmartContractPermissioningConnectionIsAllowedTransaction( Address.fromHexString(contractAddress), source, target); } } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/SmartContractPermissioningAllowNodeTransaction.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/NodeSmartContractPermissioningAllowNodeTransaction.java similarity index 90% rename from acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/SmartContractPermissioningAllowNodeTransaction.java rename to acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/NodeSmartContractPermissioningAllowNodeTransaction.java index 6638f2c74a..cfd1b7bb36 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/SmartContractPermissioningAllowNodeTransaction.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/NodeSmartContractPermissioningAllowNodeTransaction.java @@ -17,7 +17,7 @@ import tech.pegasys.pantheon.ethereum.core.Address; import tech.pegasys.pantheon.ethereum.core.Hash; -import tech.pegasys.pantheon.ethereum.permissioning.SmartContractPermissioningController; +import tech.pegasys.pantheon.ethereum.permissioning.NodeSmartContractPermissioningController; import tech.pegasys.pantheon.tests.acceptance.dsl.account.Account; import tech.pegasys.pantheon.tests.acceptance.dsl.node.Node; import tech.pegasys.pantheon.tests.acceptance.dsl.node.RunnableNode; @@ -32,7 +32,7 @@ import org.web3j.crypto.RawTransaction; import org.web3j.crypto.TransactionEncoder; -public class SmartContractPermissioningAllowNodeTransaction implements Transaction { +public class NodeSmartContractPermissioningAllowNodeTransaction implements Transaction { private static final BytesValue ADD_ENODE_SIGNATURE = tech.pegasys.pantheon.crypto.Hash.keccak256( @@ -43,7 +43,7 @@ public class SmartContractPermissioningAllowNodeTransaction implements Transacti private final Address contractAddress; private final Node node; - public SmartContractPermissioningAllowNodeTransaction( + public NodeSmartContractPermissioningAllowNodeTransaction( final Account sender, final Address contractAddress, final Node node) { this.sender = sender; this.contractAddress = contractAddress; @@ -65,7 +65,7 @@ public Hash execute(final JsonRequestFactories node) { private String signedTransactionData() { final String enodeURL = ((RunnableNode) node).enodeUrl().toASCIIString(); final BytesValue payload = - SmartContractPermissioningController.createPayload( + NodeSmartContractPermissioningController.createPayload( ADD_ENODE_SIGNATURE, EnodeURL.fromString(enodeURL)); RawTransaction transaction = diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/SmartContractPermissioningConnectionIsAllowedTransaction.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/NodeSmartContractPermissioningConnectionIsAllowedTransaction.java similarity index 86% rename from acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/SmartContractPermissioningConnectionIsAllowedTransaction.java rename to acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/NodeSmartContractPermissioningConnectionIsAllowedTransaction.java index fd31e1e69d..c50bebed55 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/SmartContractPermissioningConnectionIsAllowedTransaction.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/NodeSmartContractPermissioningConnectionIsAllowedTransaction.java @@ -13,10 +13,10 @@ package tech.pegasys.pantheon.tests.acceptance.dsl.transaction.perm; import static java.nio.charset.StandardCharsets.UTF_8; -import static tech.pegasys.pantheon.ethereum.permissioning.SmartContractPermissioningController.checkTransactionResult; +import static tech.pegasys.pantheon.ethereum.permissioning.NodeSmartContractPermissioningController.checkTransactionResult; import tech.pegasys.pantheon.ethereum.core.Address; -import tech.pegasys.pantheon.ethereum.permissioning.SmartContractPermissioningController; +import tech.pegasys.pantheon.ethereum.permissioning.NodeSmartContractPermissioningController; import tech.pegasys.pantheon.tests.acceptance.dsl.node.Node; import tech.pegasys.pantheon.tests.acceptance.dsl.node.RunnableNode; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.JsonRequestFactories; @@ -28,7 +28,7 @@ import org.web3j.protocol.core.DefaultBlockParameterName; -public class SmartContractPermissioningConnectionIsAllowedTransaction +public class NodeSmartContractPermissioningConnectionIsAllowedTransaction implements Transaction { private static final BytesValue IS_CONNECTION_ALLOWED_SIGNATURE = @@ -42,7 +42,7 @@ public class SmartContractPermissioningConnectionIsAllowedTransaction private final Node source; private final Node target; - public SmartContractPermissioningConnectionIsAllowedTransaction( + public NodeSmartContractPermissioningConnectionIsAllowedTransaction( final Address contractAddress, final Node source, final Node target) { this.contractAddress = contractAddress; this.source = source; @@ -64,7 +64,7 @@ private org.web3j.protocol.core.methods.request.Transaction payload() { final String sourceEnodeURL = ((RunnableNode) source).enodeUrl().toASCIIString(); final String targetEnodeURL = ((RunnableNode) target).enodeUrl().toASCIIString(); final BytesValue payload = - SmartContractPermissioningController.createPayload( + NodeSmartContractPermissioningController.createPayload( IS_CONNECTION_ALLOWED_SIGNATURE, EnodeURL.fromString(sourceEnodeURL), EnodeURL.fromString(targetEnodeURL)); diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/SmartContractPermissioningForbidNodeTransaction.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/NodeSmartContractPermissioningForbidNodeTransaction.java similarity index 90% rename from acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/SmartContractPermissioningForbidNodeTransaction.java rename to acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/NodeSmartContractPermissioningForbidNodeTransaction.java index 468e63920d..569d472d9e 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/SmartContractPermissioningForbidNodeTransaction.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/NodeSmartContractPermissioningForbidNodeTransaction.java @@ -17,7 +17,7 @@ import tech.pegasys.pantheon.ethereum.core.Address; import tech.pegasys.pantheon.ethereum.core.Hash; -import tech.pegasys.pantheon.ethereum.permissioning.SmartContractPermissioningController; +import tech.pegasys.pantheon.ethereum.permissioning.NodeSmartContractPermissioningController; import tech.pegasys.pantheon.tests.acceptance.dsl.account.Account; import tech.pegasys.pantheon.tests.acceptance.dsl.node.Node; import tech.pegasys.pantheon.tests.acceptance.dsl.node.RunnableNode; @@ -32,7 +32,7 @@ import org.web3j.crypto.RawTransaction; import org.web3j.crypto.TransactionEncoder; -public class SmartContractPermissioningForbidNodeTransaction implements Transaction { +public class NodeSmartContractPermissioningForbidNodeTransaction implements Transaction { private static final BytesValue REMOVE_ENODE_SIGNATURE = tech.pegasys.pantheon.crypto.Hash.keccak256( @@ -43,7 +43,7 @@ public class SmartContractPermissioningForbidNodeTransaction implements Transact private final Address contractAddress; private final Node node; - public SmartContractPermissioningForbidNodeTransaction( + public NodeSmartContractPermissioningForbidNodeTransaction( final Account sender, final Address contractAddress, final Node node) { this.sender = sender; this.contractAddress = contractAddress; @@ -65,7 +65,7 @@ public Hash execute(final JsonRequestFactories node) { private String signedTransactionData() { final String enodeURL = ((RunnableNode) node).enodeUrl().toASCIIString(); final BytesValue payload = - SmartContractPermissioningController.createPayload( + NodeSmartContractPermissioningController.createPayload( REMOVE_ENODE_SIGNATURE, EnodeURL.fromString(enodeURL)); RawTransaction transaction = diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/SmartContractPermissioningNodeIsAllowedTransaction.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/NodeSmartContractPermissioningNodeIsAllowedTransaction.java similarity index 91% rename from acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/SmartContractPermissioningNodeIsAllowedTransaction.java rename to acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/NodeSmartContractPermissioningNodeIsAllowedTransaction.java index 612c40e884..2c9b13100e 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/SmartContractPermissioningNodeIsAllowedTransaction.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/NodeSmartContractPermissioningNodeIsAllowedTransaction.java @@ -15,7 +15,7 @@ import static java.nio.charset.StandardCharsets.UTF_8; import tech.pegasys.pantheon.ethereum.core.Address; -import tech.pegasys.pantheon.ethereum.permissioning.SmartContractPermissioningController; +import tech.pegasys.pantheon.ethereum.permissioning.NodeSmartContractPermissioningController; import tech.pegasys.pantheon.tests.acceptance.dsl.node.Node; import tech.pegasys.pantheon.tests.acceptance.dsl.node.RunnableNode; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.JsonRequestFactories; @@ -27,7 +27,7 @@ import org.web3j.protocol.core.DefaultBlockParameterName; -public class SmartContractPermissioningNodeIsAllowedTransaction implements Transaction { +public class NodeSmartContractPermissioningNodeIsAllowedTransaction implements Transaction { private static final BytesValue IS_NODE_ALLOWED_SIGNATURE = tech.pegasys.pantheon.crypto.Hash.keccak256( @@ -37,7 +37,7 @@ public class SmartContractPermissioningNodeIsAllowedTransaction implements Trans private final Address contractAddress; private final Node node; - public SmartContractPermissioningNodeIsAllowedTransaction( + public NodeSmartContractPermissioningNodeIsAllowedTransaction( final Address contractAddress, final Node node) { this.contractAddress = contractAddress; this.node = node; @@ -83,7 +83,7 @@ static Boolean checkTransactionResult(final BytesValue result) { private org.web3j.protocol.core.methods.request.Transaction payload() { final String sourceEnodeURL = ((RunnableNode) node).enodeUrl().toASCIIString(); final BytesValue payload = - SmartContractPermissioningController.createPayload( + NodeSmartContractPermissioningController.createPayload( IS_NODE_ALLOWED_SIGNATURE, EnodeURL.fromString(sourceEnodeURL)); return org.web3j.protocol.core.methods.request.Transaction.createFunctionCallTransaction( diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/permissioning/SmartContractNodePermissioningAcceptanceTest.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/permissioning/NodeNodeSmartContractNodePermissioningAcceptanceTest.java similarity index 96% rename from acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/permissioning/SmartContractNodePermissioningAcceptanceTest.java rename to acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/permissioning/NodeNodeSmartContractNodePermissioningAcceptanceTest.java index 5ca7be39c8..bac4e14c2c 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/permissioning/SmartContractNodePermissioningAcceptanceTest.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/permissioning/NodeNodeSmartContractNodePermissioningAcceptanceTest.java @@ -17,8 +17,8 @@ import org.junit.Before; import org.junit.Test; -public class SmartContractNodePermissioningAcceptanceTest - extends SmartContractNodePermissioningAcceptanceTestBase { +public class NodeNodeSmartContractNodePermissioningAcceptanceTest + extends NodeSmartContractNodePermissioningAcceptanceTestBase { private Node bootnode; private Node permissionedNode; diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/permissioning/SmartContractNodePermissioningAcceptanceTestBase.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/permissioning/NodeSmartContractNodePermissioningAcceptanceTestBase.java similarity index 76% rename from acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/permissioning/SmartContractNodePermissioningAcceptanceTestBase.java rename to acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/permissioning/NodeSmartContractNodePermissioningAcceptanceTestBase.java index 5bfbb1d556..41f9b8b493 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/permissioning/SmartContractNodePermissioningAcceptanceTestBase.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/permissioning/NodeSmartContractNodePermissioningAcceptanceTestBase.java @@ -15,31 +15,31 @@ import tech.pegasys.pantheon.ethereum.core.Hash; import tech.pegasys.pantheon.tests.acceptance.dsl.AcceptanceTestBase; import tech.pegasys.pantheon.tests.acceptance.dsl.condition.Condition; -import tech.pegasys.pantheon.tests.acceptance.dsl.condition.perm.SmartContractNodePermissioningConditions; +import tech.pegasys.pantheon.tests.acceptance.dsl.condition.perm.NodeSmartContractNodePermissioningConditions; import tech.pegasys.pantheon.tests.acceptance.dsl.node.Node; import tech.pegasys.pantheon.tests.acceptance.dsl.node.cluster.Cluster; import tech.pegasys.pantheon.tests.acceptance.dsl.node.cluster.ClusterConfiguration; import tech.pegasys.pantheon.tests.acceptance.dsl.node.cluster.ClusterConfigurationBuilder; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; -import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.perm.SmartContractNodePermissioningTransactions; +import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.perm.NodeSmartContractNodePermissioningTransactions; import java.io.IOException; -class SmartContractNodePermissioningAcceptanceTestBase extends AcceptanceTestBase { +class NodeSmartContractNodePermissioningAcceptanceTestBase extends AcceptanceTestBase { - private final SmartContractNodePermissioningTransactions smartContractNodePermissioning; - private final SmartContractNodePermissioningConditions smartContractNodePermissioningConditions; + private final NodeSmartContractNodePermissioningTransactions smartContractNodePermissioning; + private final NodeSmartContractNodePermissioningConditions nodeSmartContractNodePermissioningConditions; private static final String CONTRACT_ADDRESS = "0x0000000000000000000000000000000000009999"; private static final String GENESIS_FILE = "/permissioning/simple_permissioning_genesis.json"; protected final Cluster permissionedCluster; - protected SmartContractNodePermissioningAcceptanceTestBase() { + protected NodeSmartContractNodePermissioningAcceptanceTestBase() { super(); - smartContractNodePermissioning = new SmartContractNodePermissioningTransactions(accounts); - smartContractNodePermissioningConditions = - new SmartContractNodePermissioningConditions(smartContractNodePermissioning); + smartContractNodePermissioning = new NodeSmartContractNodePermissioningTransactions(accounts); + nodeSmartContractNodePermissioningConditions = + new NodeSmartContractNodePermissioningConditions(smartContractNodePermissioning); this.permissionedCluster = permissionedCluster(); } @@ -84,7 +84,7 @@ protected Transaction allowNode(final Node node) { } protected Condition nodeIsAllowed(final Node node) { - return smartContractNodePermissioningConditions.nodeIsAllowed(CONTRACT_ADDRESS, node); + return nodeSmartContractNodePermissioningConditions.nodeIsAllowed(CONTRACT_ADDRESS, node); } protected Transaction forbidNode(final Node node) { @@ -92,16 +92,16 @@ protected Transaction forbidNode(final Node node) { } protected Condition nodeIsForbidden(final Node node) { - return smartContractNodePermissioningConditions.nodeIsForbidden(CONTRACT_ADDRESS, node); + return nodeSmartContractNodePermissioningConditions.nodeIsForbidden(CONTRACT_ADDRESS, node); } protected Condition connectionIsAllowed(final Node source, final Node target) { - return smartContractNodePermissioningConditions.connectionIsAllowed( + return nodeSmartContractNodePermissioningConditions.connectionIsAllowed( CONTRACT_ADDRESS, source, target); } protected Condition connectionIsForbidden(final Node source, final Node target) { - return smartContractNodePermissioningConditions.connectionIsForbidden( + return nodeSmartContractNodePermissioningConditions.connectionIsForbidden( CONTRACT_ADDRESS, source, target); } } diff --git a/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/NodePermissioningControllerFactory.java b/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/NodePermissioningControllerFactory.java index e1506e3e38..47314d757f 100644 --- a/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/NodePermissioningControllerFactory.java +++ b/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/NodePermissioningControllerFactory.java @@ -49,12 +49,12 @@ public NodePermissioningController create( } if (permissioningConfiguration.getSmartContractConfig().isPresent()) { - SmartContractPermissioningConfiguration smartContractPermissioningConfiguration = + NodeSmartContractPermissioningConfiguration nodeSmartContractPermissioningConfiguration = permissioningConfiguration.getSmartContractConfig().get(); - if (smartContractPermissioningConfiguration.isSmartContractNodeWhitelistEnabled()) { - SmartContractPermissioningController smartContractProvider = - new SmartContractPermissioningController( - smartContractPermissioningConfiguration.getSmartContractAddress(), + if (nodeSmartContractPermissioningConfiguration.isSmartContractNodeWhitelistEnabled()) { + NodeSmartContractPermissioningController smartContractProvider = + new NodeSmartContractPermissioningController( + nodeSmartContractPermissioningConfiguration.getSmartContractAddress(), transactionSimulator); providers.add(smartContractProvider); } diff --git a/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/SmartContractPermissioningConfiguration.java b/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/NodeSmartContractPermissioningConfiguration.java similarity index 86% rename from ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/SmartContractPermissioningConfiguration.java rename to ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/NodeSmartContractPermissioningConfiguration.java index e05c819397..7f01c14dce 100644 --- a/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/SmartContractPermissioningConfiguration.java +++ b/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/NodeSmartContractPermissioningConfiguration.java @@ -14,12 +14,12 @@ import tech.pegasys.pantheon.ethereum.core.Address; -public class SmartContractPermissioningConfiguration { +public class NodeSmartContractPermissioningConfiguration { private boolean smartContractNodeWhitelistEnabled; private Address smartContractAddress; - public static SmartContractPermissioningConfiguration createDefault() { - return new SmartContractPermissioningConfiguration(); + public static NodeSmartContractPermissioningConfiguration createDefault() { + return new NodeSmartContractPermissioningConfiguration(); } public boolean isSmartContractNodeWhitelistEnabled() { diff --git a/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/SmartContractPermissioningController.java b/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/NodeSmartContractPermissioningController.java similarity index 97% rename from ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/SmartContractPermissioningController.java rename to ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/NodeSmartContractPermissioningController.java index 1bc12a2325..81fb9bac02 100644 --- a/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/SmartContractPermissioningController.java +++ b/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/NodeSmartContractPermissioningController.java @@ -31,7 +31,7 @@ * Controller that can read from a smart contract that exposes the permissioning call * connectionAllowed(bytes32,bytes32,bytes16,uint16,bytes32,bytes32,bytes16,uint16) */ -public class SmartContractPermissioningController implements NodePermissioningProvider { +public class NodeSmartContractPermissioningController implements NodePermissioningProvider { private final Address contractAddress; private final TransactionSimulator transactionSimulator; @@ -61,7 +61,7 @@ private static BytesValue hashSignature(final String signature) { * @param contractAddress The address at which the permissioning smart contract resides * @param transactionSimulator A transaction simulator with attached blockchain and world state */ - public SmartContractPermissioningController( + public NodeSmartContractPermissioningController( final Address contractAddress, final TransactionSimulator transactionSimulator) { this.contractAddress = contractAddress; this.transactionSimulator = transactionSimulator; diff --git a/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/PermissioningConfiguration.java b/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/PermissioningConfiguration.java index 34efcfde9c..3ba30be4c5 100644 --- a/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/PermissioningConfiguration.java +++ b/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/PermissioningConfiguration.java @@ -16,11 +16,11 @@ public class PermissioningConfiguration { private Optional localConfig; - private Optional smartContractConfig; + private Optional smartContractConfig; public PermissioningConfiguration( final Optional localConfig, - final Optional smartContractConfig) { + final Optional smartContractConfig) { this.localConfig = localConfig; this.smartContractConfig = smartContractConfig; } @@ -29,7 +29,7 @@ public Optional getLocalConfig() { return localConfig; } - public Optional getSmartContractConfig() { + public Optional getSmartContractConfig() { return smartContractConfig; } diff --git a/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/PermissioningConfigurationBuilder.java b/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/PermissioningConfigurationBuilder.java index 17d8d901dd..1cc0e1076f 100644 --- a/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/PermissioningConfigurationBuilder.java +++ b/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/PermissioningConfigurationBuilder.java @@ -27,9 +27,9 @@ public class PermissioningConfigurationBuilder { public static final String ACCOUNTS_WHITELIST_KEY = "accounts-whitelist"; public static final String NODES_WHITELIST_KEY = "nodes-whitelist"; - public static SmartContractPermissioningConfiguration smartContractPermissioningConfiguration( + public static NodeSmartContractPermissioningConfiguration smartContractPermissioningConfiguration( final Address address, final boolean smartContractPermissionedNodeEnabled) { - SmartContractPermissioningConfiguration config = new SmartContractPermissioningConfiguration(); + NodeSmartContractPermissioningConfiguration config = new NodeSmartContractPermissioningConfiguration(); config.setSmartContractAddress(address); config.setSmartContractNodeWhitelistEnabled(smartContractPermissionedNodeEnabled); return config; diff --git a/ethereum/permissioning/src/test/java/tech/pegasys/pantheon/ethereum/permissioning/SmartContractPermissioningControllerTest.java b/ethereum/permissioning/src/test/java/tech/pegasys/pantheon/ethereum/permissioning/NodeSmartContractPermissioningControllerTest.java similarity index 92% rename from ethereum/permissioning/src/test/java/tech/pegasys/pantheon/ethereum/permissioning/SmartContractPermissioningControllerTest.java rename to ethereum/permissioning/src/test/java/tech/pegasys/pantheon/ethereum/permissioning/NodeSmartContractPermissioningControllerTest.java index 66292d48a6..0e66f81418 100644 --- a/ethereum/permissioning/src/test/java/tech/pegasys/pantheon/ethereum/permissioning/SmartContractPermissioningControllerTest.java +++ b/ethereum/permissioning/src/test/java/tech/pegasys/pantheon/ethereum/permissioning/NodeSmartContractPermissioningControllerTest.java @@ -33,9 +33,9 @@ import com.google.common.io.Resources; import org.junit.Test; -public class SmartContractPermissioningControllerTest { +public class NodeSmartContractPermissioningControllerTest { - private SmartContractPermissioningController setupController( + private NodeSmartContractPermissioningController setupController( final String resourceName, final String contractAddressString) throws IOException { final ProtocolSchedule protocolSchedule = MainnetProtocolSchedule.create(); @@ -53,12 +53,12 @@ private SmartContractPermissioningController setupController( new TransactionSimulator(blockchain, worldArchive, protocolSchedule); final Address contractAddress = Address.fromHexString(contractAddressString); - return new SmartContractPermissioningController(contractAddress, ts); + return new NodeSmartContractPermissioningController(contractAddress, ts); } @Test public void testIpv4Included() throws IOException { - final SmartContractPermissioningController controller = + final NodeSmartContractPermissioningController controller = setupController( "/SmartContractPermissioningControllerTest/preseededSmartPermissioning.json", "0x0000000000000000000000000000000000001234"); @@ -74,7 +74,7 @@ public void testIpv4Included() throws IOException { @Test public void testIpv4DestinationMissing() throws IOException { - final SmartContractPermissioningController controller = + final NodeSmartContractPermissioningController controller = setupController( "/SmartContractPermissioningControllerTest/preseededSmartPermissioning.json", "0x0000000000000000000000000000000000001234"); @@ -90,7 +90,7 @@ public void testIpv4DestinationMissing() throws IOException { @Test public void testIpv4SourceMissing() throws IOException { - final SmartContractPermissioningController controller = + final NodeSmartContractPermissioningController controller = setupController( "/SmartContractPermissioningControllerTest/preseededSmartPermissioning.json", "0x0000000000000000000000000000000000001234"); @@ -106,7 +106,7 @@ public void testIpv4SourceMissing() throws IOException { @Test public void testIpv6Included() throws IOException { - final SmartContractPermissioningController controller = + final NodeSmartContractPermissioningController controller = setupController( "/SmartContractPermissioningControllerTest/preseededSmartPermissioning.json", "0x0000000000000000000000000000000000001234"); @@ -122,7 +122,7 @@ public void testIpv6Included() throws IOException { @Test public void testIpv6SourceMissing() throws IOException { - final SmartContractPermissioningController controller = + final NodeSmartContractPermissioningController controller = setupController( "/SmartContractPermissioningControllerTest/preseededSmartPermissioning.json", "0x0000000000000000000000000000000000001234"); @@ -138,7 +138,7 @@ public void testIpv6SourceMissing() throws IOException { @Test public void testIpv6DestinationMissing() throws IOException { - final SmartContractPermissioningController controller = + final NodeSmartContractPermissioningController controller = setupController( "/SmartContractPermissioningControllerTest/preseededSmartPermissioning.json", "0x0000000000000000000000000000000000001234"); @@ -154,7 +154,7 @@ public void testIpv6DestinationMissing() throws IOException { @Test public void testPermissioningContractMissing() throws IOException { - final SmartContractPermissioningController controller = + final NodeSmartContractPermissioningController controller = setupController( "/SmartContractPermissioningControllerTest/noSmartPermissioning.json", "0x0000000000000000000000000000000000001234"); @@ -172,7 +172,7 @@ public void testPermissioningContractMissing() throws IOException { @Test public void testPermissioningContractCorrupt() throws IOException { - final SmartContractPermissioningController controller = + final NodeSmartContractPermissioningController controller = setupController( "/SmartContractPermissioningControllerTest/corruptSmartPermissioning.json", "0x0000000000000000000000000000000000001234"); diff --git a/ethereum/permissioning/src/test/java/tech/pegasys/pantheon/ethereum/permissioning/node/NodePermissioningControllerFactoryTest.java b/ethereum/permissioning/src/test/java/tech/pegasys/pantheon/ethereum/permissioning/node/NodePermissioningControllerFactoryTest.java index 770b0dcf46..7dcbd33ffb 100644 --- a/ethereum/permissioning/src/test/java/tech/pegasys/pantheon/ethereum/permissioning/node/NodePermissioningControllerFactoryTest.java +++ b/ethereum/permissioning/src/test/java/tech/pegasys/pantheon/ethereum/permissioning/node/NodePermissioningControllerFactoryTest.java @@ -20,8 +20,8 @@ import tech.pegasys.pantheon.ethereum.permissioning.NodeLocalConfigPermissioningController; import tech.pegasys.pantheon.ethereum.permissioning.NodePermissioningControllerFactory; import tech.pegasys.pantheon.ethereum.permissioning.PermissioningConfiguration; -import tech.pegasys.pantheon.ethereum.permissioning.SmartContractPermissioningConfiguration; -import tech.pegasys.pantheon.ethereum.permissioning.SmartContractPermissioningController; +import tech.pegasys.pantheon.ethereum.permissioning.NodeSmartContractPermissioningConfiguration; +import tech.pegasys.pantheon.ethereum.permissioning.NodeSmartContractPermissioningController; import tech.pegasys.pantheon.ethereum.transaction.TransactionSimulator; import tech.pegasys.pantheon.util.enode.EnodeURL; @@ -46,7 +46,7 @@ public class NodePermissioningControllerFactoryTest { Collection bootnodes = Collections.emptyList(); EnodeURL selfEnode = EnodeURL.fromString(enode); LocalPermissioningConfiguration localPermissioningConfig; - SmartContractPermissioningConfiguration smartContractPermissioningConfiguration; + NodeSmartContractPermissioningConfiguration nodeSmartContractPermissioningConfiguration; PermissioningConfiguration config; @Test @@ -64,13 +64,13 @@ public void testCreateWithNeitherPermissioningEnabled() { @Test public void testCreateWithSmartContractNodePermissioningEnabledOnly() { - smartContractPermissioningConfiguration = new SmartContractPermissioningConfiguration(); - smartContractPermissioningConfiguration.setSmartContractAddress( + nodeSmartContractPermissioningConfiguration = new NodeSmartContractPermissioningConfiguration(); + nodeSmartContractPermissioningConfiguration.setSmartContractAddress( Address.fromHexString("0x0000000000000000000000000000000000001234")); - smartContractPermissioningConfiguration.setSmartContractNodeWhitelistEnabled(true); + nodeSmartContractPermissioningConfiguration.setSmartContractNodeWhitelistEnabled(true); config = new PermissioningConfiguration( - Optional.empty(), Optional.of(smartContractPermissioningConfiguration)); + Optional.empty(), Optional.of(nodeSmartContractPermissioningConfiguration)); NodePermissioningControllerFactory factory = new NodePermissioningControllerFactory(); NodePermissioningController controller = @@ -81,7 +81,7 @@ public void testCreateWithSmartContractNodePermissioningEnabledOnly() { assertThat(providers.size()).isEqualTo(1); NodePermissioningProvider p1 = providers.get(0); - assertThat(p1).isInstanceOf(SmartContractPermissioningController.class); + assertThat(p1).isInstanceOf(NodeSmartContractPermissioningController.class); assertThat(controller.getSyncStatusNodePermissioningProvider()).isPresent(); } @@ -112,14 +112,14 @@ public void testCreateWithLocalNodeAndSmartContractPermissioningEnabled() { localPermissioningConfig.setNodeWhitelist(Collections.emptyList()); localPermissioningConfig.setNodePermissioningConfigFilePath("fake-file-path"); - smartContractPermissioningConfiguration = new SmartContractPermissioningConfiguration(); - smartContractPermissioningConfiguration.setSmartContractAddress( + nodeSmartContractPermissioningConfiguration = new NodeSmartContractPermissioningConfiguration(); + nodeSmartContractPermissioningConfiguration.setSmartContractAddress( Address.fromHexString("0x0000000000000000000000000000000000001234")); - smartContractPermissioningConfiguration.setSmartContractNodeWhitelistEnabled(true); + nodeSmartContractPermissioningConfiguration.setSmartContractNodeWhitelistEnabled(true); config = new PermissioningConfiguration( Optional.of(localPermissioningConfig), - Optional.of(smartContractPermissioningConfiguration)); + Optional.of(nodeSmartContractPermissioningConfiguration)); NodePermissioningControllerFactory factory = new NodePermissioningControllerFactory(); NodePermissioningController controller = @@ -132,10 +132,10 @@ public void testCreateWithLocalNodeAndSmartContractPermissioningEnabled() { NodePermissioningProvider p1 = providers.get(0); NodePermissioningProvider p2 = providers.get(1); if (p1.getClass() == NodeLocalConfigPermissioningController.class) { - assertThat(p2).isInstanceOf(SmartContractPermissioningController.class); + assertThat(p2).isInstanceOf(NodeSmartContractPermissioningController.class); } else { assertThat(p2).isInstanceOf(NodeLocalConfigPermissioningController.class); - assertThat(p1).isInstanceOf(SmartContractPermissioningController.class); + assertThat(p1).isInstanceOf(NodeSmartContractPermissioningController.class); } assertThat(controller.getSyncStatusNodePermissioningProvider()).isPresent(); } diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java b/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java index aea3a61776..cc06337dc1 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java @@ -58,7 +58,7 @@ import tech.pegasys.pantheon.ethereum.permissioning.LocalPermissioningConfiguration; import tech.pegasys.pantheon.ethereum.permissioning.PermissioningConfiguration; import tech.pegasys.pantheon.ethereum.permissioning.PermissioningConfigurationBuilder; -import tech.pegasys.pantheon.ethereum.permissioning.SmartContractPermissioningConfiguration; +import tech.pegasys.pantheon.ethereum.permissioning.NodeSmartContractPermissioningConfiguration; import tech.pegasys.pantheon.metrics.MetricCategory; import tech.pegasys.pantheon.metrics.MetricsSystem; import tech.pegasys.pantheon.metrics.prometheus.MetricsConfiguration; @@ -884,7 +884,7 @@ MetricsConfiguration metricsConfiguration() { private Optional permissioningConfiguration() throws Exception { final Optional localPermissioningConfigurationOptional; - final Optional + final Optional smartContractPermissioningConfigurationOptional; if (!(localPermissionsEnabled() || contractPermissionsEnabled())) { @@ -930,11 +930,11 @@ private Optional permissioningConfiguration() throws this.commandLine, "No contract address specified. Cannot enable contract based permissions."); } - final SmartContractPermissioningConfiguration smartContractPermissioningConfiguration = + final NodeSmartContractPermissioningConfiguration nodeSmartContractPermissioningConfiguration = PermissioningConfigurationBuilder.smartContractPermissioningConfiguration( permissionsNodesContractAddress, permissionsNodesContractEnabled); smartContractPermissioningConfigurationOptional = - Optional.of(smartContractPermissioningConfiguration); + Optional.of(nodeSmartContractPermissioningConfiguration); } else { if (permissionsNodesContractAddress != null) { logger.warn( diff --git a/pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java b/pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java index a4ac106c72..efab97b389 100644 --- a/pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java +++ b/pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java @@ -47,7 +47,7 @@ import tech.pegasys.pantheon.ethereum.jsonrpc.websocket.WebSocketConfiguration; import tech.pegasys.pantheon.ethereum.permissioning.LocalPermissioningConfiguration; import tech.pegasys.pantheon.ethereum.permissioning.PermissioningConfiguration; -import tech.pegasys.pantheon.ethereum.permissioning.SmartContractPermissioningConfiguration; +import tech.pegasys.pantheon.ethereum.permissioning.NodeSmartContractPermissioningConfiguration; import tech.pegasys.pantheon.metrics.MetricCategory; import tech.pegasys.pantheon.metrics.prometheus.MetricsConfiguration; import tech.pegasys.pantheon.util.bytes.BytesValue; @@ -376,11 +376,11 @@ public void permissionsSmartContractMustUseOption() { "--permissions-nodes-contract-enabled", "--permissions-nodes-contract-address", smartContractAddress); - final SmartContractPermissioningConfiguration smartContractPermissioningConfiguration = - new SmartContractPermissioningConfiguration(); - smartContractPermissioningConfiguration.setSmartContractAddress( + final NodeSmartContractPermissioningConfiguration nodeSmartContractPermissioningConfiguration = + new NodeSmartContractPermissioningConfiguration(); + nodeSmartContractPermissioningConfiguration.setSmartContractAddress( Address.fromHexString(smartContractAddress)); - smartContractPermissioningConfiguration.setSmartContractNodeWhitelistEnabled(true); + nodeSmartContractPermissioningConfiguration.setSmartContractNodeWhitelistEnabled(true); verify(mockRunnerBuilder) .permissioningConfiguration(permissioningConfigurationArgumentCaptor.capture()); @@ -388,7 +388,7 @@ public void permissionsSmartContractMustUseOption() { PermissioningConfiguration config = permissioningConfigurationArgumentCaptor.getValue(); assertThat(config.getSmartContractConfig().get()) - .isEqualToComparingFieldByField(smartContractPermissioningConfiguration); + .isEqualToComparingFieldByField(nodeSmartContractPermissioningConfiguration); assertThat(commandErrorOutput.toString()).isEmpty(); assertThat(commandOutput.toString()).isEmpty(); From 0ff8f5ecadd60a08440a3e0f3bdb1645f7eba286 Mon Sep 17 00:00:00 2001 From: Mark Terry Date: Thu, 9 May 2019 22:39:37 +1000 Subject: [PATCH 2/5] [PAN-2601] Added account smart contract fields to SmartContractPermissioningConfiguration. --- .../dsl/node/ProcessPantheonNodeRunner.java | 4 +- .../node/factory/PermissionedNodeBuilder.java | 12 ++-- ...PermissioningNodeIsAllowedTransaction.java | 3 +- ...ctNodePermissioningAcceptanceTestBase.java | 3 +- .../NodePermissioningControllerFactory.java | 6 +- ...artContractPermissioningConfiguration.java | 41 ------------- .../PermissioningConfiguration.java | 6 +- .../PermissioningConfigurationBuilder.java | 6 +- ...artContractPermissioningConfiguration.java | 61 +++++++++++++++++++ ...odePermissioningControllerFactoryTest.java | 22 +++---- .../pegasys/pantheon/cli/PantheonCommand.java | 8 +-- .../pantheon/cli/PantheonCommandTest.java | 12 ++-- 12 files changed, 103 insertions(+), 81 deletions(-) delete mode 100644 ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/NodeSmartContractPermissioningConfiguration.java create mode 100644 ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/SmartContractPermissioningConfiguration.java diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ProcessPantheonNodeRunner.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ProcessPantheonNodeRunner.java index 590d6d2b55..efb386339b 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ProcessPantheonNodeRunner.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ProcessPantheonNodeRunner.java @@ -172,9 +172,9 @@ public void startNode(final PantheonNode node) { if (permissioningConfiguration.isSmartContractNodeWhitelistEnabled()) { params.add("--permissions-nodes-contract-enabled"); } - if (permissioningConfiguration.getSmartContractAddress() != null) { + if (permissioningConfiguration.getNodeSmartContractAddress() != null) { params.add("--permissions-nodes-contract-address"); - params.add(permissioningConfiguration.getSmartContractAddress().toString()); + params.add(permissioningConfiguration.getNodeSmartContractAddress().toString()); } }); diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PermissionedNodeBuilder.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PermissionedNodeBuilder.java index 1aa340ee6c..6007dac607 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PermissionedNodeBuilder.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PermissionedNodeBuilder.java @@ -21,7 +21,7 @@ import tech.pegasys.pantheon.ethereum.jsonrpc.RpcApis; import tech.pegasys.pantheon.ethereum.permissioning.LocalPermissioningConfiguration; import tech.pegasys.pantheon.ethereum.permissioning.PermissioningConfiguration; -import tech.pegasys.pantheon.ethereum.permissioning.NodeSmartContractPermissioningConfiguration; +import tech.pegasys.pantheon.ethereum.permissioning.SmartContractPermissioningConfiguration; import tech.pegasys.pantheon.ethereum.permissioning.WhitelistPersistor; import tech.pegasys.pantheon.ethereum.permissioning.WhitelistPersistor.WHITELIST_TYPE; import tech.pegasys.pantheon.tests.acceptance.dsl.node.Node; @@ -138,7 +138,7 @@ public PantheonNode build() { localPermConfig = Optional.of(localConfigPermissioningConfiguration()); } - Optional smartContractPermConfig = Optional.empty(); + Optional smartContractPermConfig = Optional.empty(); if (smartContractPermissioningEnabled) { smartContractPermConfig = Optional.of(smartContractPermissioningConfiguration()); } @@ -203,11 +203,11 @@ private LocalPermissioningConfiguration localConfigPermissioningConfiguration() return localPermissioningConfiguration; } - private NodeSmartContractPermissioningConfiguration smartContractPermissioningConfiguration() { - NodeSmartContractPermissioningConfiguration config = - NodeSmartContractPermissioningConfiguration.createDefault(); + private SmartContractPermissioningConfiguration smartContractPermissioningConfiguration() { + SmartContractPermissioningConfiguration config = + SmartContractPermissioningConfiguration.createDefault(); if (permissioningSmartContractAddress != null) { - config.setSmartContractAddress(Address.fromHexString(permissioningSmartContractAddress)); + config.setNodeSmartContractAddress(Address.fromHexString(permissioningSmartContractAddress)); config.setSmartContractNodeWhitelistEnabled(true); } return config; diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/NodeSmartContractPermissioningNodeIsAllowedTransaction.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/NodeSmartContractPermissioningNodeIsAllowedTransaction.java index 2c9b13100e..7a26bf7ad0 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/NodeSmartContractPermissioningNodeIsAllowedTransaction.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/NodeSmartContractPermissioningNodeIsAllowedTransaction.java @@ -27,7 +27,8 @@ import org.web3j.protocol.core.DefaultBlockParameterName; -public class NodeSmartContractPermissioningNodeIsAllowedTransaction implements Transaction { +public class NodeSmartContractPermissioningNodeIsAllowedTransaction + implements Transaction { private static final BytesValue IS_NODE_ALLOWED_SIGNATURE = tech.pegasys.pantheon.crypto.Hash.keccak256( diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/permissioning/NodeSmartContractNodePermissioningAcceptanceTestBase.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/permissioning/NodeSmartContractNodePermissioningAcceptanceTestBase.java index 41f9b8b493..9e0cea8762 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/permissioning/NodeSmartContractNodePermissioningAcceptanceTestBase.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/permissioning/NodeSmartContractNodePermissioningAcceptanceTestBase.java @@ -28,7 +28,8 @@ class NodeSmartContractNodePermissioningAcceptanceTestBase extends AcceptanceTestBase { private final NodeSmartContractNodePermissioningTransactions smartContractNodePermissioning; - private final NodeSmartContractNodePermissioningConditions nodeSmartContractNodePermissioningConditions; + private final NodeSmartContractNodePermissioningConditions + nodeSmartContractNodePermissioningConditions; private static final String CONTRACT_ADDRESS = "0x0000000000000000000000000000000000009999"; private static final String GENESIS_FILE = "/permissioning/simple_permissioning_genesis.json"; diff --git a/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/NodePermissioningControllerFactory.java b/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/NodePermissioningControllerFactory.java index 47314d757f..edbbb48a6e 100644 --- a/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/NodePermissioningControllerFactory.java +++ b/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/NodePermissioningControllerFactory.java @@ -49,12 +49,12 @@ public NodePermissioningController create( } if (permissioningConfiguration.getSmartContractConfig().isPresent()) { - NodeSmartContractPermissioningConfiguration nodeSmartContractPermissioningConfiguration = + SmartContractPermissioningConfiguration smartContractPermissioningConfiguration = permissioningConfiguration.getSmartContractConfig().get(); - if (nodeSmartContractPermissioningConfiguration.isSmartContractNodeWhitelistEnabled()) { + if (smartContractPermissioningConfiguration.isSmartContractNodeWhitelistEnabled()) { NodeSmartContractPermissioningController smartContractProvider = new NodeSmartContractPermissioningController( - nodeSmartContractPermissioningConfiguration.getSmartContractAddress(), + smartContractPermissioningConfiguration.getNodeSmartContractAddress(), transactionSimulator); providers.add(smartContractProvider); } diff --git a/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/NodeSmartContractPermissioningConfiguration.java b/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/NodeSmartContractPermissioningConfiguration.java deleted file mode 100644 index 7f01c14dce..0000000000 --- a/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/NodeSmartContractPermissioningConfiguration.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2018 ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package tech.pegasys.pantheon.ethereum.permissioning; - -import tech.pegasys.pantheon.ethereum.core.Address; - -public class NodeSmartContractPermissioningConfiguration { - private boolean smartContractNodeWhitelistEnabled; - private Address smartContractAddress; - - public static NodeSmartContractPermissioningConfiguration createDefault() { - return new NodeSmartContractPermissioningConfiguration(); - } - - public boolean isSmartContractNodeWhitelistEnabled() { - return smartContractNodeWhitelistEnabled; - } - - public void setSmartContractNodeWhitelistEnabled( - final boolean smartContractNodeWhitelistEnabled) { - this.smartContractNodeWhitelistEnabled = smartContractNodeWhitelistEnabled; - } - - public Address getSmartContractAddress() { - return smartContractAddress; - } - - public void setSmartContractAddress(final Address smartContractAddress) { - this.smartContractAddress = smartContractAddress; - } -} diff --git a/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/PermissioningConfiguration.java b/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/PermissioningConfiguration.java index 3ba30be4c5..34efcfde9c 100644 --- a/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/PermissioningConfiguration.java +++ b/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/PermissioningConfiguration.java @@ -16,11 +16,11 @@ public class PermissioningConfiguration { private Optional localConfig; - private Optional smartContractConfig; + private Optional smartContractConfig; public PermissioningConfiguration( final Optional localConfig, - final Optional smartContractConfig) { + final Optional smartContractConfig) { this.localConfig = localConfig; this.smartContractConfig = smartContractConfig; } @@ -29,7 +29,7 @@ public Optional getLocalConfig() { return localConfig; } - public Optional getSmartContractConfig() { + public Optional getSmartContractConfig() { return smartContractConfig; } diff --git a/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/PermissioningConfigurationBuilder.java b/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/PermissioningConfigurationBuilder.java index 1cc0e1076f..05621f7b38 100644 --- a/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/PermissioningConfigurationBuilder.java +++ b/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/PermissioningConfigurationBuilder.java @@ -27,10 +27,10 @@ public class PermissioningConfigurationBuilder { public static final String ACCOUNTS_WHITELIST_KEY = "accounts-whitelist"; public static final String NODES_WHITELIST_KEY = "nodes-whitelist"; - public static NodeSmartContractPermissioningConfiguration smartContractPermissioningConfiguration( + public static SmartContractPermissioningConfiguration smartContractPermissioningConfiguration( final Address address, final boolean smartContractPermissionedNodeEnabled) { - NodeSmartContractPermissioningConfiguration config = new NodeSmartContractPermissioningConfiguration(); - config.setSmartContractAddress(address); + SmartContractPermissioningConfiguration config = new SmartContractPermissioningConfiguration(); + config.setNodeSmartContractAddress(address); config.setSmartContractNodeWhitelistEnabled(smartContractPermissionedNodeEnabled); return config; } diff --git a/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/SmartContractPermissioningConfiguration.java b/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/SmartContractPermissioningConfiguration.java new file mode 100644 index 0000000000..95e47af4cd --- /dev/null +++ b/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/SmartContractPermissioningConfiguration.java @@ -0,0 +1,61 @@ +/* + * Copyright 2018 ConsenSys AG. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package tech.pegasys.pantheon.ethereum.permissioning; + +import tech.pegasys.pantheon.ethereum.core.Address; + +public class SmartContractPermissioningConfiguration { + private boolean smartContractNodeWhitelistEnabled; + private Address nodeSmartContractAddress; + + private boolean smartContractAccountWhitelistEnabled; + private Address accountSmartContractAddress; + + public static SmartContractPermissioningConfiguration createDefault() { + return new SmartContractPermissioningConfiguration(); + } + + public boolean isSmartContractNodeWhitelistEnabled() { + return smartContractNodeWhitelistEnabled; + } + + public void setSmartContractNodeWhitelistEnabled( + final boolean smartContractNodeWhitelistEnabled) { + this.smartContractNodeWhitelistEnabled = smartContractNodeWhitelistEnabled; + } + + public Address getNodeSmartContractAddress() { + return nodeSmartContractAddress; + } + + public void setNodeSmartContractAddress(final Address nodeSmartContractAddress) { + this.nodeSmartContractAddress = nodeSmartContractAddress; + } + + public boolean isSmartContractAccountWhitelistEnabled() { + return smartContractAccountWhitelistEnabled; + } + + public void setSmartContractAccountWhitelistEnabled( + final boolean smartContractAccountWhitelistEnabled) { + this.smartContractAccountWhitelistEnabled = smartContractAccountWhitelistEnabled; + } + + public Address getAccountSmartContractAddress() { + return accountSmartContractAddress; + } + + public void setAccountSmartContractAddress(final Address accountSmartContractAddress) { + this.accountSmartContractAddress = accountSmartContractAddress; + } +} diff --git a/ethereum/permissioning/src/test/java/tech/pegasys/pantheon/ethereum/permissioning/node/NodePermissioningControllerFactoryTest.java b/ethereum/permissioning/src/test/java/tech/pegasys/pantheon/ethereum/permissioning/node/NodePermissioningControllerFactoryTest.java index 7dcbd33ffb..0940245f08 100644 --- a/ethereum/permissioning/src/test/java/tech/pegasys/pantheon/ethereum/permissioning/node/NodePermissioningControllerFactoryTest.java +++ b/ethereum/permissioning/src/test/java/tech/pegasys/pantheon/ethereum/permissioning/node/NodePermissioningControllerFactoryTest.java @@ -19,9 +19,9 @@ import tech.pegasys.pantheon.ethereum.permissioning.LocalPermissioningConfiguration; import tech.pegasys.pantheon.ethereum.permissioning.NodeLocalConfigPermissioningController; import tech.pegasys.pantheon.ethereum.permissioning.NodePermissioningControllerFactory; -import tech.pegasys.pantheon.ethereum.permissioning.PermissioningConfiguration; -import tech.pegasys.pantheon.ethereum.permissioning.NodeSmartContractPermissioningConfiguration; import tech.pegasys.pantheon.ethereum.permissioning.NodeSmartContractPermissioningController; +import tech.pegasys.pantheon.ethereum.permissioning.PermissioningConfiguration; +import tech.pegasys.pantheon.ethereum.permissioning.SmartContractPermissioningConfiguration; import tech.pegasys.pantheon.ethereum.transaction.TransactionSimulator; import tech.pegasys.pantheon.util.enode.EnodeURL; @@ -46,7 +46,7 @@ public class NodePermissioningControllerFactoryTest { Collection bootnodes = Collections.emptyList(); EnodeURL selfEnode = EnodeURL.fromString(enode); LocalPermissioningConfiguration localPermissioningConfig; - NodeSmartContractPermissioningConfiguration nodeSmartContractPermissioningConfiguration; + SmartContractPermissioningConfiguration smartContractPermissioningConfiguration; PermissioningConfiguration config; @Test @@ -64,13 +64,13 @@ public void testCreateWithNeitherPermissioningEnabled() { @Test public void testCreateWithSmartContractNodePermissioningEnabledOnly() { - nodeSmartContractPermissioningConfiguration = new NodeSmartContractPermissioningConfiguration(); - nodeSmartContractPermissioningConfiguration.setSmartContractAddress( + smartContractPermissioningConfiguration = new SmartContractPermissioningConfiguration(); + smartContractPermissioningConfiguration.setNodeSmartContractAddress( Address.fromHexString("0x0000000000000000000000000000000000001234")); - nodeSmartContractPermissioningConfiguration.setSmartContractNodeWhitelistEnabled(true); + smartContractPermissioningConfiguration.setSmartContractNodeWhitelistEnabled(true); config = new PermissioningConfiguration( - Optional.empty(), Optional.of(nodeSmartContractPermissioningConfiguration)); + Optional.empty(), Optional.of(smartContractPermissioningConfiguration)); NodePermissioningControllerFactory factory = new NodePermissioningControllerFactory(); NodePermissioningController controller = @@ -112,14 +112,14 @@ public void testCreateWithLocalNodeAndSmartContractPermissioningEnabled() { localPermissioningConfig.setNodeWhitelist(Collections.emptyList()); localPermissioningConfig.setNodePermissioningConfigFilePath("fake-file-path"); - nodeSmartContractPermissioningConfiguration = new NodeSmartContractPermissioningConfiguration(); - nodeSmartContractPermissioningConfiguration.setSmartContractAddress( + smartContractPermissioningConfiguration = new SmartContractPermissioningConfiguration(); + smartContractPermissioningConfiguration.setNodeSmartContractAddress( Address.fromHexString("0x0000000000000000000000000000000000001234")); - nodeSmartContractPermissioningConfiguration.setSmartContractNodeWhitelistEnabled(true); + smartContractPermissioningConfiguration.setSmartContractNodeWhitelistEnabled(true); config = new PermissioningConfiguration( Optional.of(localPermissioningConfig), - Optional.of(nodeSmartContractPermissioningConfiguration)); + Optional.of(smartContractPermissioningConfiguration)); NodePermissioningControllerFactory factory = new NodePermissioningControllerFactory(); NodePermissioningController controller = diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java b/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java index cc06337dc1..aea3a61776 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java @@ -58,7 +58,7 @@ import tech.pegasys.pantheon.ethereum.permissioning.LocalPermissioningConfiguration; import tech.pegasys.pantheon.ethereum.permissioning.PermissioningConfiguration; import tech.pegasys.pantheon.ethereum.permissioning.PermissioningConfigurationBuilder; -import tech.pegasys.pantheon.ethereum.permissioning.NodeSmartContractPermissioningConfiguration; +import tech.pegasys.pantheon.ethereum.permissioning.SmartContractPermissioningConfiguration; import tech.pegasys.pantheon.metrics.MetricCategory; import tech.pegasys.pantheon.metrics.MetricsSystem; import tech.pegasys.pantheon.metrics.prometheus.MetricsConfiguration; @@ -884,7 +884,7 @@ MetricsConfiguration metricsConfiguration() { private Optional permissioningConfiguration() throws Exception { final Optional localPermissioningConfigurationOptional; - final Optional + final Optional smartContractPermissioningConfigurationOptional; if (!(localPermissionsEnabled() || contractPermissionsEnabled())) { @@ -930,11 +930,11 @@ private Optional permissioningConfiguration() throws this.commandLine, "No contract address specified. Cannot enable contract based permissions."); } - final NodeSmartContractPermissioningConfiguration nodeSmartContractPermissioningConfiguration = + final SmartContractPermissioningConfiguration smartContractPermissioningConfiguration = PermissioningConfigurationBuilder.smartContractPermissioningConfiguration( permissionsNodesContractAddress, permissionsNodesContractEnabled); smartContractPermissioningConfigurationOptional = - Optional.of(nodeSmartContractPermissioningConfiguration); + Optional.of(smartContractPermissioningConfiguration); } else { if (permissionsNodesContractAddress != null) { logger.warn( diff --git a/pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java b/pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java index efab97b389..ad820a66b8 100644 --- a/pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java +++ b/pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java @@ -47,7 +47,7 @@ import tech.pegasys.pantheon.ethereum.jsonrpc.websocket.WebSocketConfiguration; import tech.pegasys.pantheon.ethereum.permissioning.LocalPermissioningConfiguration; import tech.pegasys.pantheon.ethereum.permissioning.PermissioningConfiguration; -import tech.pegasys.pantheon.ethereum.permissioning.NodeSmartContractPermissioningConfiguration; +import tech.pegasys.pantheon.ethereum.permissioning.SmartContractPermissioningConfiguration; import tech.pegasys.pantheon.metrics.MetricCategory; import tech.pegasys.pantheon.metrics.prometheus.MetricsConfiguration; import tech.pegasys.pantheon.util.bytes.BytesValue; @@ -376,11 +376,11 @@ public void permissionsSmartContractMustUseOption() { "--permissions-nodes-contract-enabled", "--permissions-nodes-contract-address", smartContractAddress); - final NodeSmartContractPermissioningConfiguration nodeSmartContractPermissioningConfiguration = - new NodeSmartContractPermissioningConfiguration(); - nodeSmartContractPermissioningConfiguration.setSmartContractAddress( + final SmartContractPermissioningConfiguration smartContractPermissioningConfiguration = + new SmartContractPermissioningConfiguration(); + smartContractPermissioningConfiguration.setNodeSmartContractAddress( Address.fromHexString(smartContractAddress)); - nodeSmartContractPermissioningConfiguration.setSmartContractNodeWhitelistEnabled(true); + smartContractPermissioningConfiguration.setSmartContractNodeWhitelistEnabled(true); verify(mockRunnerBuilder) .permissioningConfiguration(permissioningConfigurationArgumentCaptor.capture()); @@ -388,7 +388,7 @@ public void permissionsSmartContractMustUseOption() { PermissioningConfiguration config = permissioningConfigurationArgumentCaptor.getValue(); assertThat(config.getSmartContractConfig().get()) - .isEqualToComparingFieldByField(nodeSmartContractPermissioningConfiguration); + .isEqualToComparingFieldByField(smartContractPermissioningConfiguration); assertThat(commandErrorOutput.toString()).isEmpty(); assertThat(commandOutput.toString()).isEmpty(); From cfec4436ce981b1ec8e6765d0c0be3f652b6f626 Mon Sep 17 00:00:00 2001 From: Mark Terry Date: Fri, 10 May 2019 09:48:57 +1000 Subject: [PATCH 3/5] [PAN-2601] Added AccountPermissioningProvider. --- .../account/AccountPermissioningProvider.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/account/AccountPermissioningProvider.java diff --git a/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/account/AccountPermissioningProvider.java b/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/account/AccountPermissioningProvider.java new file mode 100644 index 0000000000..8f20f7190b --- /dev/null +++ b/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/account/AccountPermissioningProvider.java @@ -0,0 +1,20 @@ +/* + * Copyright 2019 ConsenSys AG. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package tech.pegasys.pantheon.ethereum.permissioning.account; + +import tech.pegasys.pantheon.ethereum.core.Address; + +@FunctionalInterface +public interface AccountPermissioningProvider { + boolean isPermitted(final Address sourceAddress); +} From dae31418a406447bc74715b545d539c6bd25de46 Mon Sep 17 00:00:00 2001 From: Mark Terry Date: Fri, 10 May 2019 12:38:08 +1000 Subject: [PATCH 4/5] [PAN-2601] Removed superfluous 'node' from some class and field names. --- ...SmartContractPermissioningConditions.java} | 10 ++++---- ...actPermissioningIsAllowedTransaction.java} | 4 ++-- ...artContractPermissioningTransactions.java} | 6 ++--- ...ctNodePermissioningAcceptanceTestBase.java | 23 +++++++++---------- .../account/AccountPermissioningProvider.java | 4 ++-- 5 files changed, 23 insertions(+), 24 deletions(-) rename acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/perm/{NodeSmartContractNodePermissioningConditions.java => NodeSmartContractPermissioningConditions.java} (83%) rename acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/{NodeSmartContractPermissioningNodeIsAllowedTransaction.java => NodeSmartContractPermissioningIsAllowedTransaction.java} (96%) rename acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/{NodeSmartContractNodePermissioningTransactions.java => NodeSmartContractPermissioningTransactions.java} (90%) diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/perm/NodeSmartContractNodePermissioningConditions.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/perm/NodeSmartContractPermissioningConditions.java similarity index 83% rename from acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/perm/NodeSmartContractNodePermissioningConditions.java rename to acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/perm/NodeSmartContractPermissioningConditions.java index 624c4da3a6..2b6e304181 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/perm/NodeSmartContractNodePermissioningConditions.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/perm/NodeSmartContractPermissioningConditions.java @@ -14,14 +14,14 @@ import tech.pegasys.pantheon.tests.acceptance.dsl.condition.Condition; import tech.pegasys.pantheon.tests.acceptance.dsl.node.Node; -import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.perm.NodeSmartContractNodePermissioningTransactions; +import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.perm.NodeSmartContractPermissioningTransactions; -public class NodeSmartContractNodePermissioningConditions { +public class NodeSmartContractPermissioningConditions { - private final NodeSmartContractNodePermissioningTransactions transactions; + private final NodeSmartContractPermissioningTransactions transactions; - public NodeSmartContractNodePermissioningConditions( - final NodeSmartContractNodePermissioningTransactions transactions) { + public NodeSmartContractPermissioningConditions( + final NodeSmartContractPermissioningTransactions transactions) { this.transactions = transactions; } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/NodeSmartContractPermissioningNodeIsAllowedTransaction.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/NodeSmartContractPermissioningIsAllowedTransaction.java similarity index 96% rename from acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/NodeSmartContractPermissioningNodeIsAllowedTransaction.java rename to acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/NodeSmartContractPermissioningIsAllowedTransaction.java index 7a26bf7ad0..cc39b364fa 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/NodeSmartContractPermissioningNodeIsAllowedTransaction.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/NodeSmartContractPermissioningIsAllowedTransaction.java @@ -27,7 +27,7 @@ import org.web3j.protocol.core.DefaultBlockParameterName; -public class NodeSmartContractPermissioningNodeIsAllowedTransaction +public class NodeSmartContractPermissioningIsAllowedTransaction implements Transaction { private static final BytesValue IS_NODE_ALLOWED_SIGNATURE = @@ -38,7 +38,7 @@ public class NodeSmartContractPermissioningNodeIsAllowedTransaction private final Address contractAddress; private final Node node; - public NodeSmartContractPermissioningNodeIsAllowedTransaction( + public NodeSmartContractPermissioningIsAllowedTransaction( final Address contractAddress, final Node node) { this.contractAddress = contractAddress; this.node = node; diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/NodeSmartContractNodePermissioningTransactions.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/NodeSmartContractPermissioningTransactions.java similarity index 90% rename from acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/NodeSmartContractNodePermissioningTransactions.java rename to acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/NodeSmartContractPermissioningTransactions.java index f9934098ed..55e3e1a240 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/NodeSmartContractNodePermissioningTransactions.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/NodeSmartContractPermissioningTransactions.java @@ -18,11 +18,11 @@ import tech.pegasys.pantheon.tests.acceptance.dsl.node.Node; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; -public class NodeSmartContractNodePermissioningTransactions { +public class NodeSmartContractPermissioningTransactions { private final Accounts accounts; - public NodeSmartContractNodePermissioningTransactions(final Accounts accounts) { + public NodeSmartContractPermissioningTransactions(final Accounts accounts) { this.accounts = accounts; } @@ -37,7 +37,7 @@ public Transaction forbidNode(final String contractAddress, final Node nod } public Transaction isNodeAllowed(final String contractAddress, final Node node) { - return new NodeSmartContractPermissioningNodeIsAllowedTransaction( + return new NodeSmartContractPermissioningIsAllowedTransaction( Address.fromHexString(contractAddress), node); } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/permissioning/NodeSmartContractNodePermissioningAcceptanceTestBase.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/permissioning/NodeSmartContractNodePermissioningAcceptanceTestBase.java index 9e0cea8762..951b9111a5 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/permissioning/NodeSmartContractNodePermissioningAcceptanceTestBase.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/permissioning/NodeSmartContractNodePermissioningAcceptanceTestBase.java @@ -15,21 +15,20 @@ import tech.pegasys.pantheon.ethereum.core.Hash; import tech.pegasys.pantheon.tests.acceptance.dsl.AcceptanceTestBase; import tech.pegasys.pantheon.tests.acceptance.dsl.condition.Condition; -import tech.pegasys.pantheon.tests.acceptance.dsl.condition.perm.NodeSmartContractNodePermissioningConditions; +import tech.pegasys.pantheon.tests.acceptance.dsl.condition.perm.NodeSmartContractPermissioningConditions; import tech.pegasys.pantheon.tests.acceptance.dsl.node.Node; import tech.pegasys.pantheon.tests.acceptance.dsl.node.cluster.Cluster; import tech.pegasys.pantheon.tests.acceptance.dsl.node.cluster.ClusterConfiguration; import tech.pegasys.pantheon.tests.acceptance.dsl.node.cluster.ClusterConfigurationBuilder; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; -import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.perm.NodeSmartContractNodePermissioningTransactions; +import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.perm.NodeSmartContractPermissioningTransactions; import java.io.IOException; class NodeSmartContractNodePermissioningAcceptanceTestBase extends AcceptanceTestBase { - private final NodeSmartContractNodePermissioningTransactions smartContractNodePermissioning; - private final NodeSmartContractNodePermissioningConditions - nodeSmartContractNodePermissioningConditions; + private final NodeSmartContractPermissioningTransactions smartContractNodePermissioning; + private final NodeSmartContractPermissioningConditions nodeSmartContractPermissioningConditions; private static final String CONTRACT_ADDRESS = "0x0000000000000000000000000000000000009999"; private static final String GENESIS_FILE = "/permissioning/simple_permissioning_genesis.json"; @@ -38,9 +37,9 @@ class NodeSmartContractNodePermissioningAcceptanceTestBase extends AcceptanceTes protected NodeSmartContractNodePermissioningAcceptanceTestBase() { super(); - smartContractNodePermissioning = new NodeSmartContractNodePermissioningTransactions(accounts); - nodeSmartContractNodePermissioningConditions = - new NodeSmartContractNodePermissioningConditions(smartContractNodePermissioning); + smartContractNodePermissioning = new NodeSmartContractPermissioningTransactions(accounts); + nodeSmartContractPermissioningConditions = + new NodeSmartContractPermissioningConditions(smartContractNodePermissioning); this.permissionedCluster = permissionedCluster(); } @@ -85,7 +84,7 @@ protected Transaction allowNode(final Node node) { } protected Condition nodeIsAllowed(final Node node) { - return nodeSmartContractNodePermissioningConditions.nodeIsAllowed(CONTRACT_ADDRESS, node); + return nodeSmartContractPermissioningConditions.nodeIsAllowed(CONTRACT_ADDRESS, node); } protected Transaction forbidNode(final Node node) { @@ -93,16 +92,16 @@ protected Transaction forbidNode(final Node node) { } protected Condition nodeIsForbidden(final Node node) { - return nodeSmartContractNodePermissioningConditions.nodeIsForbidden(CONTRACT_ADDRESS, node); + return nodeSmartContractPermissioningConditions.nodeIsForbidden(CONTRACT_ADDRESS, node); } protected Condition connectionIsAllowed(final Node source, final Node target) { - return nodeSmartContractNodePermissioningConditions.connectionIsAllowed( + return nodeSmartContractPermissioningConditions.connectionIsAllowed( CONTRACT_ADDRESS, source, target); } protected Condition connectionIsForbidden(final Node source, final Node target) { - return nodeSmartContractNodePermissioningConditions.connectionIsForbidden( + return nodeSmartContractPermissioningConditions.connectionIsForbidden( CONTRACT_ADDRESS, source, target); } } diff --git a/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/account/AccountPermissioningProvider.java b/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/account/AccountPermissioningProvider.java index 8f20f7190b..b9a40295f4 100644 --- a/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/account/AccountPermissioningProvider.java +++ b/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/account/AccountPermissioningProvider.java @@ -12,9 +12,9 @@ */ package tech.pegasys.pantheon.ethereum.permissioning.account; -import tech.pegasys.pantheon.ethereum.core.Address; +import tech.pegasys.pantheon.ethereum.core.Transaction; @FunctionalInterface public interface AccountPermissioningProvider { - boolean isPermitted(final Address sourceAddress); + boolean isPermitted(final Transaction transaction); } From b90b5c2c9d0a790db714a894fc18e630ae5fb38c Mon Sep 17 00:00:00 2001 From: Mark Terry Date: Fri, 10 May 2019 13:04:24 +1000 Subject: [PATCH 5/5] [PAN-2601] Spotless. --- .../NodeSmartContractPermissioningIsAllowedTransaction.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/NodeSmartContractPermissioningIsAllowedTransaction.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/NodeSmartContractPermissioningIsAllowedTransaction.java index cc39b364fa..6c7186e89a 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/NodeSmartContractPermissioningIsAllowedTransaction.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/NodeSmartContractPermissioningIsAllowedTransaction.java @@ -27,8 +27,7 @@ import org.web3j.protocol.core.DefaultBlockParameterName; -public class NodeSmartContractPermissioningIsAllowedTransaction - implements Transaction { +public class NodeSmartContractPermissioningIsAllowedTransaction implements Transaction { private static final BytesValue IS_NODE_ALLOWED_SIGNATURE = tech.pegasys.pantheon.crypto.Hash.keccak256(