CORDA-2005: FinalityFlow has been made into an inlined flow to resolve issue with FinalityHandler (#4050)

FinalityHandler is insecure in that it is open to receive any transaction from any party.

Any CorDapp targeting platform version 4 or above is required use the new c'tors which take in FlowSession objects to the counterpart flow. This flow must subcall ReceiveFinalityFlow to receive and record the finalised transaction.

Old CorDapps (with target platform version < 4) will continue to work as previously. However if there are no old CorDapps loaded then the node will disable FinalityHandler.
This commit is contained in:
Shams Asari
2018-11-14 14:16:22 +00:00
committed by GitHub
parent 8e6d4b4b38
commit e8b6f5f2f2
76 changed files with 1251 additions and 469 deletions

View File

@ -1,9 +1,10 @@
package net.corda.docs.kotlin
package net.corda.docs.kotlin.txbuild
import net.corda.core.contracts.LinearState
import net.corda.core.contracts.StateAndRef
import net.corda.core.contracts.UniqueIdentifier
import net.corda.core.identity.Party
import net.corda.core.internal.packageName
import net.corda.core.node.ServiceHub
import net.corda.core.node.services.queryBy
import net.corda.core.node.services.vault.QueryCriteria
@ -33,7 +34,7 @@ class WorkflowTransactionBuildTutorialTest {
@Before
fun setup() {
mockNet = MockNetwork(threadPerNode = true, cordappPackages = listOf("net.corda.docs"))
mockNet = MockNetwork(threadPerNode = true, cordappPackages = listOf(javaClass.packageName))
aliceNode = mockNet.createPartyNode(ALICE_NAME)
bobNode = mockNet.createPartyNode(BOB_NAME)
alice = aliceNode.services.myInfo.identityFromX500Name(ALICE_NAME)

View File

@ -1,13 +1,14 @@
package net.corda.docs.kotlin
package net.corda.docs.kotlin.vault
import net.corda.core.contracts.Amount
import net.corda.core.contracts.ContractState
import net.corda.core.identity.Party
import net.corda.core.internal.packageName
import net.corda.core.node.services.queryBy
import net.corda.core.node.services.vault.*
import net.corda.core.utilities.OpaqueBytes
import net.corda.core.utilities.getOrThrow
import net.corda.docs.java.tutorial.helloworld.IOUFlow
import net.corda.docs.kotlin.tutorial.helloworld.IOUFlow
import net.corda.finance.*
import net.corda.finance.contracts.getCashBalances
import net.corda.finance.flows.CashIssueFlow
@ -17,7 +18,7 @@ import net.corda.testing.node.MockNetwork
import net.corda.testing.node.StartedMockNode
import org.assertj.core.api.Assertions.assertThatCode
import org.junit.After
import org.junit.Assert
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Test
import java.util.*
@ -30,7 +31,7 @@ class CustomVaultQueryTest {
@Before
fun setup() {
mockNet = MockNetwork(threadPerNode = true, cordappPackages = listOf("net.corda.finance", "net.corda.docs", "com.template"))
mockNet = MockNetwork(threadPerNode = true, cordappPackages = listOf("net.corda.finance", IOUFlow::class.packageName, javaClass.packageName, "com.template"))
nodeA = mockNet.createPartyNode()
nodeB = mockNet.createPartyNode()
notary = mockNet.defaultNotaryIdentity
@ -43,7 +44,6 @@ class CustomVaultQueryTest {
@Test
fun `query by max recorded time`() {
nodeA.startFlow(IOUFlow(1000, nodeB.info.singleIdentity())).getOrThrow()
nodeA.startFlow(IOUFlow(500, nodeB.info.singleIdentity())).getOrThrow()
@ -69,9 +69,9 @@ class CustomVaultQueryTest {
topUpCurrencies()
val (cashBalancesAfterTopup, _) = getBalances()
Assert.assertEquals(cashBalancesOriginal[GBP]?.times(2), cashBalancesAfterTopup[GBP])
Assert.assertEquals(cashBalancesOriginal[USD]?.times(2) , cashBalancesAfterTopup[USD])
Assert.assertEquals(cashBalancesOriginal[CHF]?.times( 2), cashBalancesAfterTopup[CHF])
assertEquals(cashBalancesOriginal[GBP]?.times(2), cashBalancesAfterTopup[GBP])
assertEquals(cashBalancesOriginal[USD]?.times(2) , cashBalancesAfterTopup[USD])
assertEquals(cashBalancesOriginal[CHF]?.times( 2), cashBalancesAfterTopup[CHF])
}
private fun issueCashForCurrency(amountToIssue: Amount<Currency>) {
@ -86,7 +86,8 @@ class CustomVaultQueryTest {
nodeA.info.singleIdentity(),
OpaqueBytes.of(0x01),
nodeA.info.singleIdentity(),
notary)).getOrThrow()
notary)
).getOrThrow()
}
private fun getBalances(): Pair<Map<Currency, Amount<Currency>>, Map<Currency, Amount<Currency>>> {