From b9b4415d106303cb9667b5186d2eddb75a0e385a Mon Sep 17 00:00:00 2001 From: Chris Rankin Date: Sat, 31 Mar 2018 14:52:08 +0100 Subject: [PATCH 1/3] ENT-1463: Instantiate the contract class as part of contract verification. (#660) * Instantiating the contract class should be part of contract verification. We should not instantiate it while building LedgerTransaction. * Also catch any exceptions from instantiating the contract. --- .../net/corda/core/transactions/LedgerTransaction.kt | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/core/src/main/kotlin/net/corda/core/transactions/LedgerTransaction.kt b/core/src/main/kotlin/net/corda/core/transactions/LedgerTransaction.kt index 441b6591cf..4128e0b6c5 100644 --- a/core/src/main/kotlin/net/corda/core/transactions/LedgerTransaction.kt +++ b/core/src/main/kotlin/net/corda/core/transactions/LedgerTransaction.kt @@ -51,19 +51,17 @@ data class LedgerTransaction @JvmOverloads constructor( } private companion object { - private fun createContractFor(className: ContractClassName, classLoader: ClassLoader?): Try { + private fun contractClassFor(className: ContractClassName, classLoader: ClassLoader?): Try> { return Try.on { (classLoader ?: this::class.java.classLoader) .loadClass(className) .asSubclass(Contract::class.java) - .getConstructor() - .newInstance() } } } - private val contracts: Map> = (inputs.map { it.state } + outputs) - .map { it.contract to createContractFor(it.contract, it.data::class.java.classLoader) }.toMap() + private val contracts: Map>> = (inputs.map { it.state } + outputs) + .map { it.contract to contractClassFor(it.contract, it.data::class.java.classLoader) }.toMap() val inputStates: List get() = inputs.map { it.state.data } @@ -125,11 +123,11 @@ data class LedgerTransaction @JvmOverloads constructor( when (result) { is Try.Failure -> throw TransactionVerificationException.ContractCreationError(id, key, result.exception) is Try.Success -> { - val contract = result.value try { + val contract = result.value.newInstance() contract.verify(this) } catch (e: Throwable) { - throw TransactionVerificationException.ContractRejection(id, contract, e) + throw TransactionVerificationException.ContractRejection(id, result.value.name, e) } } } From 4106e9837d185f83a514fafbc4fc685048e8437d Mon Sep 17 00:00:00 2001 From: Joel Dudley Date: Tue, 3 Apr 2018 09:11:35 +0100 Subject: [PATCH 2/3] Clearer caveat about using observable states. --- docs/source/tutorial-observer-nodes.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/source/tutorial-observer-nodes.rst b/docs/source/tutorial-observer-nodes.rst index 52c7a5e67c..85940ac24c 100644 --- a/docs/source/tutorial-observer-nodes.rst +++ b/docs/source/tutorial-observer-nodes.rst @@ -38,11 +38,11 @@ reports from their database and observe new transactions coming in via RPC. Caveats ------- -* Nodes which act as both observers and direct participants in the ledger are not supported at this time. In - particular, coin selection may return states which you do not have the private keys to be able to sign for. Future - versions of Corda may address this issue, but for now, if you wish to both participate in the ledger and also observe - transactions that you can't sign for you will need to run two nodes and have two separate identities +* By default, vault queries do not differentiate between states you recorded as a participant/owner, and states you + recorded as an observer. You will have to write custom vault queries that only return states for which you are a + participant/owner. See https://docs.corda.net/api-vault-query.html#example-usage for information on how to do this. + This also means that ``Cash.generateSpend`` should not be used when recording ``Cash.State`` states as an observer * Nodes only record each transaction once. If a node has already recorded a transaction in non-observer mode, it cannot later re-record the same transaction as an observer. This issue is tracked here: - https://r3-cev.atlassian.net/browse/CORDA-883 \ No newline at end of file + https://r3-cev.atlassian.net/browse/CORDA-883 From abcdfeedf4de745080a118907da96bc55a8fbc85 Mon Sep 17 00:00:00 2001 From: Michele Sollecito Date: Tue, 3 Apr 2018 10:21:42 +0100 Subject: [PATCH 3/3] [CORDA-1294]: Publish corda-shell module. (#2905) --- build.gradle | 2 +- tools/shell/build.gradle | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 8b7f906d38..55d66b0994 100644 --- a/build.gradle +++ b/build.gradle @@ -293,7 +293,7 @@ bintrayConfig { projectUrl = 'https://github.com/corda/corda' gpgSign = true gpgPassphrase = System.getenv('CORDA_BINTRAY_GPG_PASSPHRASE') - publications = ['corda-jfx', 'corda-mock', 'corda-rpc', 'corda-core', 'corda', 'corda-finance', 'corda-node', 'corda-node-api', 'corda-test-common', 'corda-test-utils', 'corda-jackson', 'corda-verifier', 'corda-webserver-impl', 'corda-webserver', 'corda-node-driver', 'corda-confidential-identities'] + publications = ['corda-jfx', 'corda-mock', 'corda-rpc', 'corda-core', 'corda', 'corda-finance', 'corda-node', 'corda-node-api', 'corda-test-common', 'corda-test-utils', 'corda-jackson', 'corda-verifier', 'corda-webserver-impl', 'corda-webserver', 'corda-node-driver', 'corda-confidential-identities', 'corda-shell'] license { name = 'Apache-2.0' url = 'https://www.apache.org/licenses/LICENSE-2.0' diff --git a/tools/shell/build.gradle b/tools/shell/build.gradle index 73c5aafb16..7a0721593f 100644 --- a/tools/shell/build.gradle +++ b/tools/shell/build.gradle @@ -2,6 +2,7 @@ apply plugin: 'kotlin' apply plugin: 'java' apply plugin: 'application' apply plugin: 'net.corda.plugins.quasar-utils' +apply plugin: 'net.corda.plugins.publish-utils' description 'Corda Shell' @@ -90,3 +91,7 @@ task integrationTest(type: Test) { testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath } + +publish { + name jar.baseName +} \ No newline at end of file