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/NodeSmartContractPermissioningConditions.java similarity index 85% 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/NodeSmartContractPermissioningConditions.java index fe96d6204b..2b6e304181 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/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.SmartContractNodePermissioningTransactions; +import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.perm.NodeSmartContractPermissioningTransactions; -public class SmartContractNodePermissioningConditions { +public class NodeSmartContractPermissioningConditions { - private final SmartContractNodePermissioningTransactions transactions; + private final NodeSmartContractPermissioningTransactions transactions; - public SmartContractNodePermissioningConditions( - final SmartContractNodePermissioningTransactions transactions) { + public NodeSmartContractPermissioningConditions( + final NodeSmartContractPermissioningTransactions transactions) { this.transactions = transactions; } 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 c5a78501da..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 @@ -207,7 +207,7 @@ private SmartContractPermissioningConfiguration smartContractPermissioningConfig 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/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/NodeSmartContractPermissioningIsAllowedTransaction.java similarity index 92% 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/NodeSmartContractPermissioningIsAllowedTransaction.java index 612c40e884..6c7186e89a 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/NodeSmartContractPermissioningIsAllowedTransaction.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 NodeSmartContractPermissioningIsAllowedTransaction 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 NodeSmartContractPermissioningIsAllowedTransaction( 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/dsl/transaction/perm/SmartContractNodePermissioningTransactions.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/NodeSmartContractPermissioningTransactions.java similarity index 81% 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/NodeSmartContractPermissioningTransactions.java index 32f455a883..55e3e1a240 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/NodeSmartContractPermissioningTransactions.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 NodeSmartContractPermissioningTransactions { private final Accounts accounts; - public SmartContractNodePermissioningTransactions(final Accounts accounts) { + public NodeSmartContractPermissioningTransactions(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 NodeSmartContractPermissioningIsAllowedTransaction( 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/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 80% 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..951b9111a5 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.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.SmartContractNodePermissioningTransactions; +import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.perm.NodeSmartContractPermissioningTransactions; import java.io.IOException; -class SmartContractNodePermissioningAcceptanceTestBase extends AcceptanceTestBase { +class NodeSmartContractNodePermissioningAcceptanceTestBase extends AcceptanceTestBase { - private final SmartContractNodePermissioningTransactions smartContractNodePermissioning; - private final SmartContractNodePermissioningConditions smartContractNodePermissioningConditions; + 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"; protected final Cluster permissionedCluster; - protected SmartContractNodePermissioningAcceptanceTestBase() { + protected NodeSmartContractNodePermissioningAcceptanceTestBase() { super(); - smartContractNodePermissioning = new SmartContractNodePermissioningTransactions(accounts); - smartContractNodePermissioningConditions = - new SmartContractNodePermissioningConditions(smartContractNodePermissioning); + smartContractNodePermissioning = new NodeSmartContractPermissioningTransactions(accounts); + nodeSmartContractPermissioningConditions = + new NodeSmartContractPermissioningConditions(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 nodeSmartContractPermissioningConditions.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 nodeSmartContractPermissioningConditions.nodeIsForbidden(CONTRACT_ADDRESS, node); } protected Condition connectionIsAllowed(final Node source, final Node target) { - return smartContractNodePermissioningConditions.connectionIsAllowed( + return nodeSmartContractPermissioningConditions.connectionIsAllowed( CONTRACT_ADDRESS, source, target); } protected Condition connectionIsForbidden(final Node source, final Node target) { - return smartContractNodePermissioningConditions.connectionIsForbidden( + return nodeSmartContractPermissioningConditions.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..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 @@ -52,9 +52,9 @@ public NodePermissioningController create( SmartContractPermissioningConfiguration smartContractPermissioningConfiguration = permissioningConfiguration.getSmartContractConfig().get(); if (smartContractPermissioningConfiguration.isSmartContractNodeWhitelistEnabled()) { - SmartContractPermissioningController smartContractProvider = - new SmartContractPermissioningController( - smartContractPermissioningConfiguration.getSmartContractAddress(), + NodeSmartContractPermissioningController smartContractProvider = + new NodeSmartContractPermissioningController( + smartContractPermissioningConfiguration.getNodeSmartContractAddress(), transactionSimulator); providers.add(smartContractProvider); } 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/PermissioningConfigurationBuilder.java b/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/PermissioningConfigurationBuilder.java index ceb48efebf..a39f2d20fe 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 @@ -30,7 +30,7 @@ public class PermissioningConfigurationBuilder { public static SmartContractPermissioningConfiguration smartContractPermissioningConfiguration( final Address address, final boolean smartContractPermissionedNodeEnabled) { SmartContractPermissioningConfiguration config = new SmartContractPermissioningConfiguration(); - config.setSmartContractAddress(address); + 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 index e05c819397..95e47af4cd 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/SmartContractPermissioningConfiguration.java @@ -16,7 +16,10 @@ public class SmartContractPermissioningConfiguration { private boolean smartContractNodeWhitelistEnabled; - private Address smartContractAddress; + private Address nodeSmartContractAddress; + + private boolean smartContractAccountWhitelistEnabled; + private Address accountSmartContractAddress; public static SmartContractPermissioningConfiguration createDefault() { return new SmartContractPermissioningConfiguration(); @@ -31,11 +34,28 @@ public void setSmartContractNodeWhitelistEnabled( this.smartContractNodeWhitelistEnabled = smartContractNodeWhitelistEnabled; } - public Address getSmartContractAddress() { - return smartContractAddress; + 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 setSmartContractAddress(final Address smartContractAddress) { - this.smartContractAddress = smartContractAddress; + public void setAccountSmartContractAddress(final Address accountSmartContractAddress) { + this.accountSmartContractAddress = accountSmartContractAddress; } } 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..b9a40295f4 --- /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.Transaction; + +@FunctionalInterface +public interface AccountPermissioningProvider { + boolean isPermitted(final Transaction transaction); +} 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..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.NodeSmartContractPermissioningController; 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.transaction.TransactionSimulator; import tech.pegasys.pantheon.util.enode.EnodeURL; @@ -65,7 +65,7 @@ public void testCreateWithNeitherPermissioningEnabled() { @Test public void testCreateWithSmartContractNodePermissioningEnabledOnly() { smartContractPermissioningConfiguration = new SmartContractPermissioningConfiguration(); - smartContractPermissioningConfiguration.setSmartContractAddress( + smartContractPermissioningConfiguration.setNodeSmartContractAddress( Address.fromHexString("0x0000000000000000000000000000000000001234")); smartContractPermissioningConfiguration.setSmartContractNodeWhitelistEnabled(true); config = @@ -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(); } @@ -113,7 +113,7 @@ public void testCreateWithLocalNodeAndSmartContractPermissioningEnabled() { localPermissioningConfig.setNodePermissioningConfigFilePath("fake-file-path"); smartContractPermissioningConfiguration = new SmartContractPermissioningConfiguration(); - smartContractPermissioningConfiguration.setSmartContractAddress( + smartContractPermissioningConfiguration.setNodeSmartContractAddress( Address.fromHexString("0x0000000000000000000000000000000000001234")); smartContractPermissioningConfiguration.setSmartContractNodeWhitelistEnabled(true); config = @@ -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/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java b/pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java index a4ac106c72..ad820a66b8 100644 --- a/pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java +++ b/pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java @@ -378,7 +378,7 @@ public void permissionsSmartContractMustUseOption() { smartContractAddress); final SmartContractPermissioningConfiguration smartContractPermissioningConfiguration = new SmartContractPermissioningConfiguration(); - smartContractPermissioningConfiguration.setSmartContractAddress( + smartContractPermissioningConfiguration.setNodeSmartContractAddress( Address.fromHexString(smartContractAddress)); smartContractPermissioningConfiguration.setSmartContractNodeWhitelistEnabled(true);