From e5b54a07c4d0846ad7a0c2978c9ab94db6919899 Mon Sep 17 00:00:00 2001 From: Joel Dudley Date: Thu, 5 Apr 2018 09:15:05 +0100 Subject: [PATCH 1/4] Adds a missing import. --- .../src/main/kotlin/net/corda/docs/tutorial/twoparty/flow.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/source/example-code/src/main/kotlin/net/corda/docs/tutorial/twoparty/flow.kt b/docs/source/example-code/src/main/kotlin/net/corda/docs/tutorial/twoparty/flow.kt index dc4825c1b1..27f4705501 100644 --- a/docs/source/example-code/src/main/kotlin/net/corda/docs/tutorial/twoparty/flow.kt +++ b/docs/source/example-code/src/main/kotlin/net/corda/docs/tutorial/twoparty/flow.kt @@ -10,6 +10,7 @@ import net.corda.core.messaging.CordaRPCOps import net.corda.core.serialization.SerializationWhitelist import net.corda.core.transactions.TransactionBuilder import net.corda.core.utilities.ProgressTracker +import net.corda.webserver.services.WebServerPluginRegistry import java.util.function.Function import javax.ws.rs.GET import javax.ws.rs.Path From 9a1c27e3e0fc168c59f174557367646b208c3613 Mon Sep 17 00:00:00 2001 From: Viktor Kolomeyko Date: Thu, 5 Apr 2018 09:33:03 +0100 Subject: [PATCH 2/4] Improve performance of NodeStatePersistenceTests (#2921) Packages re-jig was meant to reduce the size of the jars that are being produced by the node driver. E.g. previously `MessageState` was in package `net.corda` which resulted in jar file of around 2MB to be created. Same for `NodeStatePersistenceTests` which was in `net.corda.node` --- .../FlowsDrainingModeContentionTest.kt | 8 ++++---- .../NodeStatePersistenceTests.kt | 19 ++++++++----------- .../corda/{ => testMessage}/MessageState.kt | 4 ++-- .../net/corda/node/internal/AbstractNode.kt | 3 +++ .../identity/PersistentIdentityService.kt | 1 + 5 files changed, 18 insertions(+), 17 deletions(-) rename node/src/integration-test/kotlin/net/corda/node/{ => persistence}/NodeStatePersistenceTests.kt (91%) rename node/src/integration-test/kotlin/net/corda/{ => testMessage}/MessageState.kt (95%) diff --git a/node/src/integration-test/kotlin/net/corda/node/modes/draining/FlowsDrainingModeContentionTest.kt b/node/src/integration-test/kotlin/net/corda/node/modes/draining/FlowsDrainingModeContentionTest.kt index d432e853f1..27e542d5a8 100644 --- a/node/src/integration-test/kotlin/net/corda/node/modes/draining/FlowsDrainingModeContentionTest.kt +++ b/node/src/integration-test/kotlin/net/corda/node/modes/draining/FlowsDrainingModeContentionTest.kt @@ -1,10 +1,10 @@ package net.corda.node.modes.draining import co.paralleluniverse.fibers.Suspendable -import net.corda.MESSAGE_CONTRACT_PROGRAM_ID -import net.corda.Message -import net.corda.MessageContract -import net.corda.MessageState +import net.corda.testMessage.MESSAGE_CONTRACT_PROGRAM_ID +import net.corda.testMessage.Message +import net.corda.testMessage.MessageContract +import net.corda.testMessage.MessageState import net.corda.core.contracts.Command import net.corda.core.contracts.StateAndContract import net.corda.core.flows.* diff --git a/node/src/integration-test/kotlin/net/corda/node/NodeStatePersistenceTests.kt b/node/src/integration-test/kotlin/net/corda/node/persistence/NodeStatePersistenceTests.kt similarity index 91% rename from node/src/integration-test/kotlin/net/corda/node/NodeStatePersistenceTests.kt rename to node/src/integration-test/kotlin/net/corda/node/persistence/NodeStatePersistenceTests.kt index e0b0599ba6..7f7153d94c 100644 --- a/node/src/integration-test/kotlin/net/corda/node/NodeStatePersistenceTests.kt +++ b/node/src/integration-test/kotlin/net/corda/node/persistence/NodeStatePersistenceTests.kt @@ -1,10 +1,10 @@ -package net.corda.node +package net.corda.node.persistence import co.paralleluniverse.fibers.Suspendable -import net.corda.MESSAGE_CONTRACT_PROGRAM_ID -import net.corda.Message -import net.corda.MessageContract -import net.corda.MessageState +import net.corda.testMessage.MESSAGE_CONTRACT_PROGRAM_ID +import net.corda.testMessage.Message +import net.corda.testMessage.MessageContract +import net.corda.testMessage.MessageState import net.corda.client.rpc.CordaRPCClient import net.corda.core.contracts.Command import net.corda.core.contracts.StateAndContract @@ -35,13 +35,10 @@ import kotlin.test.assertNotNull class NodeStatePersistenceTests { @Test fun `persistent state survives node restart`() { - // Temporary disable this test when executed on Windows. It is known to be sporadically failing. - // More investigation is needed to establish why. - assumeFalse(System.getProperty("os.name").toLowerCase().startsWith("win")) - val user = User("mark", "dadada", setOf(startFlow(), invokeRpc("vaultQuery"))) val message = Message("Hello world!") - val stateAndRef: StateAndRef? = driver(DriverParameters(isDebug = true, startNodesInProcess = isQuasarAgentSpecified(), portAllocation = RandomFree, extraCordappPackagesToScan = listOf(MessageState::class.packageName))) { + val stateAndRef: StateAndRef? = driver(DriverParameters(isDebug = true, startNodesInProcess = isQuasarAgentSpecified(), + portAllocation = RandomFree, extraCordappPackagesToScan = listOf(MessageState::class.packageName))) { val nodeName = { val nodeHandle = startNode(rpcUsers = listOf(user)).getOrThrow() val nodeName = nodeHandle.nodeInfo.singleIdentity().name @@ -104,7 +101,7 @@ class NodeStatePersistenceTests { fun isQuasarAgentSpecified(): Boolean { val jvmArgs = ManagementFactory.getRuntimeMXBean().inputArguments - return jvmArgs.any { it.startsWith("-javaagent:") && it.endsWith("quasar.jar") } + return jvmArgs.any { it.startsWith("-javaagent:") && it.contains("quasar") } } @StartableByRPC diff --git a/node/src/integration-test/kotlin/net/corda/MessageState.kt b/node/src/integration-test/kotlin/net/corda/testMessage/MessageState.kt similarity index 95% rename from node/src/integration-test/kotlin/net/corda/MessageState.kt rename to node/src/integration-test/kotlin/net/corda/testMessage/MessageState.kt index cb7a8ecdab..a965a857aa 100644 --- a/node/src/integration-test/kotlin/net/corda/MessageState.kt +++ b/node/src/integration-test/kotlin/net/corda/testMessage/MessageState.kt @@ -1,4 +1,4 @@ -package net.corda +package net.corda.testMessage import net.corda.core.contracts.* import net.corda.core.identity.AbstractParty @@ -48,7 +48,7 @@ object MessageSchemaV1 : MappedSchema( ) : PersistentState() } -const val MESSAGE_CONTRACT_PROGRAM_ID = "net.corda.MessageContract" +const val MESSAGE_CONTRACT_PROGRAM_ID = "net.corda.testMessage.MessageContract" open class MessageContract : Contract { override fun verify(tx: LedgerTransaction) { diff --git a/node/src/main/kotlin/net/corda/node/internal/AbstractNode.kt b/node/src/main/kotlin/net/corda/node/internal/AbstractNode.kt index e244117dae..84ef675566 100644 --- a/node/src/main/kotlin/net/corda/node/internal/AbstractNode.kt +++ b/node/src/main/kotlin/net/corda/node/internal/AbstractNode.kt @@ -218,8 +218,11 @@ abstract class AbstractNode(val configuration: NodeConfiguration, identityService.loadIdentities(nodeInfo.legalIdentitiesAndCerts) val metrics = MetricRegistry() val transactionStorage = makeTransactionStorage(database, configuration.transactionCacheSizeBytes) + log.debug("Transaction storage created") attachments = NodeAttachmentService(metrics, configuration.attachmentContentCacheSizeBytes, configuration.attachmentCacheBound) + log.debug("Attachment service created") val cordappProvider = CordappProviderImpl(cordappLoader, CordappConfigFileProvider(), attachments, networkParameters.whitelistedContractImplementations) + log.debug("Cordapp provider created") val servicesForResolution = ServicesForResolutionImpl(identityService, attachments, cordappProvider, networkParameters, transactionStorage) val nodeProperties = NodePropertiesPersistentStore(StubbedNodeUniqueIdProvider::value, database) val nodeServices = makeServices( diff --git a/node/src/main/kotlin/net/corda/node/services/identity/PersistentIdentityService.kt b/node/src/main/kotlin/net/corda/node/services/identity/PersistentIdentityService.kt index a76b1f39a7..c5784c0bd0 100644 --- a/node/src/main/kotlin/net/corda/node/services/identity/PersistentIdentityService.kt +++ b/node/src/main/kotlin/net/corda/node/services/identity/PersistentIdentityService.kt @@ -110,6 +110,7 @@ class PersistentIdentityService(override val trustRoot: X509Certificate, confidentialIdentities.forEach { principalToParties.addWithDuplicatesAllowed(it.name, mapToKey(it), false) } + log.debug("Identities loaded") } @Throws(CertificateExpiredException::class, CertificateNotYetValidException::class, InvalidAlgorithmParameterException::class) From 71fa61020e70e6218877f5c7762d1c62f8de313b Mon Sep 17 00:00:00 2001 From: Michal Kit Date: Thu, 5 Apr 2018 11:25:41 +0100 Subject: [PATCH 3/4] Adding a unit test for SignedNodeInfo verification (#2925) --- .../nodeapi/internal/SignedNodeInfoTest.kt | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/node-api/src/test/kotlin/net/corda/nodeapi/internal/SignedNodeInfoTest.kt b/node-api/src/test/kotlin/net/corda/nodeapi/internal/SignedNodeInfoTest.kt index 933dd46f41..83b4662c49 100644 --- a/node-api/src/test/kotlin/net/corda/nodeapi/internal/SignedNodeInfoTest.kt +++ b/node-api/src/test/kotlin/net/corda/nodeapi/internal/SignedNodeInfoTest.kt @@ -1,6 +1,13 @@ package net.corda.nodeapi.internal +import net.corda.core.crypto.CompositeKey import net.corda.core.crypto.Crypto +import net.corda.core.identity.CordaX500Name +import net.corda.core.identity.PartyAndCertificate +import net.corda.core.node.NodeInfo +import net.corda.core.utilities.NetworkHostAndPort +import net.corda.nodeapi.internal.crypto.CertificateType +import net.corda.nodeapi.internal.crypto.X509Utilities import net.corda.testing.core.ALICE_NAME import net.corda.testing.core.BOB_NAME import net.corda.testing.core.SerializationEnvironmentRule @@ -10,6 +17,9 @@ import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThatThrownBy import org.junit.Rule import org.junit.Test +import java.security.KeyPair +import java.security.PrivateKey +import java.security.PublicKey import java.security.SignatureException class SignedNodeInfoTest { @@ -45,6 +55,19 @@ class SignedNodeInfoTest { .hasMessageContaining("Missing signatures") } + @Test + fun `verifying composite keys only`() { + val aliceKeyPair = generateKeyPair() + val bobKeyPair = generateKeyPair() + val identityKeyPair = generateKeyPair() + val compositeKey = CompositeKey.Builder().addKeys(aliceKeyPair.public, bobKeyPair.public).build(threshold = 1) + val nodeInfo = createNodeInfoWithSingleIdentity(ALICE_NAME, aliceKeyPair, compositeKey) + val signedNodeInfo = nodeInfo.signWith(listOf(identityKeyPair.private)) + assertThatThrownBy { signedNodeInfo.verified() } + .isInstanceOf(IllegalArgumentException::class.java) + .hasMessageContaining("At least one identity with a non-composite key needs to be specified.") + } + @Test fun `verifying extra signature`() { val (_, aliceKey) = nodeInfoBuilder.addIdentity(ALICE_NAME) @@ -77,4 +100,26 @@ class SignedNodeInfoTest { } private fun generateKeyPair() = Crypto.generateKeyPair() + + private fun createNodeInfoWithSingleIdentity(name: CordaX500Name, nodeKeyPair: KeyPair, identityCertPublicKey: PublicKey): NodeInfo { + val nodeCertificateAndKeyPair = createDevNodeCa(DEV_INTERMEDIATE_CA, name, nodeKeyPair) + val identityCert = X509Utilities.createCertificate( + CertificateType.LEGAL_IDENTITY, + nodeCertificateAndKeyPair.certificate, + nodeCertificateAndKeyPair.keyPair, + nodeCertificateAndKeyPair.certificate.subjectX500Principal, + identityCertPublicKey) + val certPath = X509Utilities.buildCertPath( + identityCert, + nodeCertificateAndKeyPair.certificate, + DEV_INTERMEDIATE_CA.certificate, + DEV_ROOT_CA.certificate) + val partyAndCertificate = PartyAndCertificate(certPath) + return NodeInfo( + listOf(NetworkHostAndPort("my.${partyAndCertificate.party.name.organisation}.com", 1234)), + listOf(partyAndCertificate), + 1, + 1 + ) + } } From 54db391e3c989f00ebd65636095e58bcf2b8994b Mon Sep 17 00:00:00 2001 From: Michele Sollecito Date: Thu, 5 Apr 2018 11:53:12 +0100 Subject: [PATCH 4/4] [CORDA-1294]: Fix corda-shell publication. (#2926) --- tools/shell/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/shell/build.gradle b/tools/shell/build.gradle index 7a0721593f..4551df38b6 100644 --- a/tools/shell/build.gradle +++ b/tools/shell/build.gradle @@ -3,6 +3,7 @@ apply plugin: 'java' apply plugin: 'application' apply plugin: 'net.corda.plugins.quasar-utils' apply plugin: 'net.corda.plugins.publish-utils' +apply plugin: 'com.jfrog.artifactory' description 'Corda Shell'