diff --git a/core/src/main/kotlin/net/corda/core/internal/PlatformVersionSwitches.kt b/core/src/main/kotlin/net/corda/core/internal/PlatformVersionSwitches.kt index 4370f998b9..3c80c1a3b8 100644 --- a/core/src/main/kotlin/net/corda/core/internal/PlatformVersionSwitches.kt +++ b/core/src/main/kotlin/net/corda/core/internal/PlatformVersionSwitches.kt @@ -17,4 +17,5 @@ object PlatformVersionSwitches { const val BATCH_DOWNLOAD_COUNTERPARTY_BACKCHAIN = 6 const val ENABLE_P2P_COMPRESSION = 7 const val CERTIFICATE_ROTATION = 9 + const val NEW_MESSAGE_ID_STRUCTURE = 9 } \ No newline at end of file diff --git a/node/src/main/kotlin/net/corda/node/services/statemachine/SessionRejectException.kt b/node/src/main/kotlin/net/corda/node/services/statemachine/SessionRejectException.kt index 9f52e5a0d4..aeca392ee2 100644 --- a/node/src/main/kotlin/net/corda/node/services/statemachine/SessionRejectException.kt +++ b/node/src/main/kotlin/net/corda/node/services/statemachine/SessionRejectException.kt @@ -12,4 +12,6 @@ open class SessionRejectException(message: String) : CordaException(message) { class NotAFlow(val initiatorClass: Class<*>) : SessionRejectException("${initiatorClass.name} is not a flow") class NotRegistered(val initiatorFlowClass: Class>) : SessionRejectException("${initiatorFlowClass.name} is not registered") + + class IncompatibleVersions(counterpartyPlatformVersion: Int, minRequiredVersion: Int) : SessionRejectException("The minimum platform version this node can communicate with ($minRequiredVersion) is larger than the platform version of your node ($counterpartyPlatformVersion)") } diff --git a/node/src/main/kotlin/net/corda/node/services/statemachine/SingleThreadedStateMachineManager.kt b/node/src/main/kotlin/net/corda/node/services/statemachine/SingleThreadedStateMachineManager.kt index 467ffc21dd..54dd1373bd 100644 --- a/node/src/main/kotlin/net/corda/node/services/statemachine/SingleThreadedStateMachineManager.kt +++ b/node/src/main/kotlin/net/corda/node/services/statemachine/SingleThreadedStateMachineManager.kt @@ -17,6 +17,7 @@ import net.corda.core.flows.StateMachineRunId import net.corda.core.identity.Party import net.corda.core.internal.FlowStateMachine import net.corda.core.internal.FlowStateMachineHandle +import net.corda.core.internal.PlatformVersionSwitches.NEW_MESSAGE_ID_STRUCTURE import net.corda.core.internal.VisibleForTesting import net.corda.core.internal.bufferUntilSubscribed import net.corda.core.internal.castIfPossible @@ -756,6 +757,12 @@ internal class SingleThreadedStateMachineManager( } private fun onSessionInit(sessionMessage: InitialSessionMessage, sender: Party, event: ExternalEvent.ExternalMessageEvent) { + if (event.receivedMessage.platformVersion < NEW_MESSAGE_ID_STRUCTURE) { + val error = SessionRejectException.IncompatibleVersions(event.receivedMessage.platformVersion, NEW_MESSAGE_ID_STRUCTURE) + flowHospital.sessionInitErrored(sessionMessage, sender, event, error) + return + } + try { val initiatedFlowFactory = getInitiatedFlowFactory(sessionMessage) val initiatedSessionId = event.receivedMessage.uniqueMessageId.sessionIdentifier