mirror of
https://github.com/corda/corda.git
synced 2025-01-18 10:46:38 +00:00
Deprecate deduplicationSeed, initiationEntropy fields from sessionState and session-init messages
This commit is contained in:
parent
64e7fdd83a
commit
086a406fc5
@ -52,7 +52,6 @@ data class SessionId(val value: BigInteger) {
|
|||||||
*
|
*
|
||||||
* @param initiatorSessionId the session ID of the initiator. On the sending side this is the *source* ID, on the
|
* @param initiatorSessionId the session ID of the initiator. On the sending side this is the *source* ID, on the
|
||||||
* receiving side this is the *sink* ID.
|
* receiving side this is the *sink* ID.
|
||||||
* @param initiationEntropy additional randomness to seed the initiated flow's deduplication ID.
|
|
||||||
* @param initiatorFlowClassName the class name to be used to determine the initiating-initiated mapping on the receiver
|
* @param initiatorFlowClassName the class name to be used to determine the initiating-initiated mapping on the receiver
|
||||||
* side.
|
* side.
|
||||||
* @param flowVersion the version of the initiating flow.
|
* @param flowVersion the version of the initiating flow.
|
||||||
@ -61,7 +60,6 @@ data class SessionId(val value: BigInteger) {
|
|||||||
*/
|
*/
|
||||||
data class InitialSessionMessage(
|
data class InitialSessionMessage(
|
||||||
val initiatorSessionId: SessionId,
|
val initiatorSessionId: SessionId,
|
||||||
val initiationEntropy: Long,
|
|
||||||
val initiatorFlowClassName: String,
|
val initiatorFlowClassName: String,
|
||||||
val flowVersion: Int,
|
val flowVersion: Int,
|
||||||
val appName: String,
|
val appName: String,
|
||||||
@ -69,7 +67,6 @@ data class InitialSessionMessage(
|
|||||||
) : SessionMessage() {
|
) : SessionMessage() {
|
||||||
override fun toString() = "InitialSessionMessage(" +
|
override fun toString() = "InitialSessionMessage(" +
|
||||||
"initiatorSessionId=$initiatorSessionId, " +
|
"initiatorSessionId=$initiatorSessionId, " +
|
||||||
"initiationEntropy=$initiationEntropy, " +
|
|
||||||
"initiatorFlowClassName=$initiatorFlowClassName, " +
|
"initiatorFlowClassName=$initiatorFlowClassName, " +
|
||||||
"appName=$appName, " +
|
"appName=$appName, " +
|
||||||
"firstPayload=${firstPayload?.javaClass}" +
|
"firstPayload=${firstPayload?.javaClass}" +
|
||||||
|
@ -271,8 +271,6 @@ data class CheckpointState(
|
|||||||
*/
|
*/
|
||||||
sealed class SessionState {
|
sealed class SessionState {
|
||||||
|
|
||||||
abstract val deduplicationSeed: String
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the sender UUID last seen in this session, if there was one.
|
* the sender UUID last seen in this session, if there was one.
|
||||||
*/
|
*/
|
||||||
@ -328,15 +326,12 @@ sealed class SessionState {
|
|||||||
val destination: Destination,
|
val destination: Destination,
|
||||||
val initiatingSubFlow: SubFlow.Initiating,
|
val initiatingSubFlow: SubFlow.Initiating,
|
||||||
val sourceSessionId: SessionId,
|
val sourceSessionId: SessionId,
|
||||||
val additionalEntropy: Long,
|
|
||||||
val hasBeenAcknowledged: Pair<Party, ConfirmSessionMessage>?,
|
val hasBeenAcknowledged: Pair<Party, ConfirmSessionMessage>?,
|
||||||
val hasBeenRejected: RejectSessionMessage?,
|
val hasBeenRejected: RejectSessionMessage?,
|
||||||
override val receivedMessages: Map<Int, ExistingSessionMessagePayload>,
|
override val receivedMessages: Map<Int, ExistingSessionMessagePayload>,
|
||||||
override val lastSenderUUID: String?,
|
override val lastSenderUUID: String?,
|
||||||
override val lastSenderSeqNo: Long?
|
override val lastSenderSeqNo: Long?
|
||||||
) : SessionState() {
|
) : SessionState()
|
||||||
override val deduplicationSeed: String get() = "R-${sourceSessionId.value}-$additionalEntropy"
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We have sent the initialisation message but have not yet received a confirmation.
|
* We have sent the initialisation message but have not yet received a confirmation.
|
||||||
@ -348,7 +343,6 @@ sealed class SessionState {
|
|||||||
data class Initiating(
|
data class Initiating(
|
||||||
val bufferedMessages: List<Pair<MessageIdentifier, ExistingSessionMessagePayload>>,
|
val bufferedMessages: List<Pair<MessageIdentifier, ExistingSessionMessagePayload>>,
|
||||||
val rejectionError: FlowError?,
|
val rejectionError: FlowError?,
|
||||||
override val deduplicationSeed: String,
|
|
||||||
val nextSendingSeqNumber: Int,
|
val nextSendingSeqNumber: Int,
|
||||||
val shardId: String,
|
val shardId: String,
|
||||||
override val receivedMessages: Map<Int, ExistingSessionMessagePayload>,
|
override val receivedMessages: Map<Int, ExistingSessionMessagePayload>,
|
||||||
@ -384,7 +378,6 @@ sealed class SessionState {
|
|||||||
val peerFlowInfo: FlowInfo,
|
val peerFlowInfo: FlowInfo,
|
||||||
val otherSideErrored: Boolean,
|
val otherSideErrored: Boolean,
|
||||||
val peerSinkSessionId: SessionId,
|
val peerSinkSessionId: SessionId,
|
||||||
override val deduplicationSeed: String,
|
|
||||||
val nextSendingSeqNumber: Int,
|
val nextSendingSeqNumber: Int,
|
||||||
val lastProcessedSeqNumber: Int,
|
val lastProcessedSeqNumber: Int,
|
||||||
val shardId: String,
|
val shardId: String,
|
||||||
|
@ -90,7 +90,6 @@ class DeliverSessionMessageTransition(
|
|||||||
peerFlowInfo = message.initiatedFlowInfo,
|
peerFlowInfo = message.initiatedFlowInfo,
|
||||||
receivedMessages = emptyMap(),
|
receivedMessages = emptyMap(),
|
||||||
peerSinkSessionId = message.initiatedSessionId,
|
peerSinkSessionId = message.initiatedSessionId,
|
||||||
deduplicationSeed = sessionState.deduplicationSeed,
|
|
||||||
otherSideErrored = false,
|
otherSideErrored = false,
|
||||||
nextSendingSeqNumber = sessionState.nextSendingSeqNumber,
|
nextSendingSeqNumber = sessionState.nextSendingSeqNumber,
|
||||||
lastProcessedSeqNumber = 0,
|
lastProcessedSeqNumber = 0,
|
||||||
|
@ -292,11 +292,10 @@ class StartedFlowTransition(
|
|||||||
}
|
}
|
||||||
val shardId = generateShardId(context.id.toString())
|
val shardId = generateShardId(context.id.toString())
|
||||||
val counterpartySessionId = sourceSessionId.calculateInitiatedSessionId()
|
val counterpartySessionId = sourceSessionId.calculateInitiatedSessionId()
|
||||||
val initialMessage = createInitialSessionMessage(sessionState.initiatingSubFlow, sourceSessionId, sessionState.additionalEntropy, null)
|
val initialMessage = createInitialSessionMessage(sessionState.initiatingSubFlow, sourceSessionId, null)
|
||||||
val newSessionState = SessionState.Initiating(
|
val newSessionState = SessionState.Initiating(
|
||||||
bufferedMessages = emptyList(),
|
bufferedMessages = emptyList(),
|
||||||
rejectionError = null,
|
rejectionError = null,
|
||||||
deduplicationSeed = sessionState.deduplicationSeed,
|
|
||||||
nextSendingSeqNumber = 1,
|
nextSendingSeqNumber = 1,
|
||||||
shardId = shardId,
|
shardId = shardId,
|
||||||
receivedMessages = emptyMap(),
|
receivedMessages = emptyMap(),
|
||||||
@ -342,7 +341,6 @@ class StartedFlowTransition(
|
|||||||
receivedMessages = emptyMap(),
|
receivedMessages = emptyMap(),
|
||||||
otherSideErrored = false,
|
otherSideErrored = false,
|
||||||
peerSinkSessionId = sessionState.hasBeenAcknowledged.second.initiatedSessionId,
|
peerSinkSessionId = sessionState.hasBeenAcknowledged.second.initiatedSessionId,
|
||||||
deduplicationSeed = sessionState.deduplicationSeed,
|
|
||||||
nextSendingSeqNumber = 1,
|
nextSendingSeqNumber = 1,
|
||||||
lastProcessedSeqNumber = 0,
|
lastProcessedSeqNumber = 0,
|
||||||
shardId = shardId,
|
shardId = shardId,
|
||||||
@ -354,14 +352,13 @@ class StartedFlowTransition(
|
|||||||
newSessions[sourceSessionId] = SessionState.Initiating(
|
newSessions[sourceSessionId] = SessionState.Initiating(
|
||||||
bufferedMessages = emptyList(),
|
bufferedMessages = emptyList(),
|
||||||
rejectionError = null,
|
rejectionError = null,
|
||||||
deduplicationSeed = sessionState.deduplicationSeed,
|
|
||||||
nextSendingSeqNumber = 1,
|
nextSendingSeqNumber = 1,
|
||||||
shardId = shardId,
|
shardId = shardId,
|
||||||
receivedMessages = emptyMap(),
|
receivedMessages = emptyMap(),
|
||||||
lastSenderUUID = null,
|
lastSenderUUID = null,
|
||||||
lastSenderSeqNo = null
|
lastSenderSeqNo = null
|
||||||
)
|
)
|
||||||
val initialMessage = createInitialSessionMessage(uninitiatedSessionState.initiatingSubFlow, sourceSessionId, uninitiatedSessionState.additionalEntropy, message)
|
val initialMessage = createInitialSessionMessage(uninitiatedSessionState.initiatingSubFlow, sourceSessionId, message)
|
||||||
val messageType = MessageType.inferFromMessage(initialMessage)
|
val messageType = MessageType.inferFromMessage(initialMessage)
|
||||||
val messageIdentifier = MessageIdentifier(messageType, shardId, sourceSessionId.calculateInitiatedSessionId(), 0, checkpoint.checkpointState.suspensionTime)
|
val messageIdentifier = MessageIdentifier(messageType, shardId, sourceSessionId.calculateInitiatedSessionId(), 0, checkpoint.checkpointState.suspensionTime)
|
||||||
Action.SendInitial(uninitiatedSessionState.destination, initialMessage, SenderDeduplicationInfo(messageIdentifier, startingState.senderUUID))
|
Action.SendInitial(uninitiatedSessionState.destination, initialMessage, SenderDeduplicationInfo(messageIdentifier, startingState.senderUUID))
|
||||||
@ -527,13 +524,10 @@ class StartedFlowTransition(
|
|||||||
private fun createInitialSessionMessage(
|
private fun createInitialSessionMessage(
|
||||||
initiatingSubFlow: SubFlow.Initiating,
|
initiatingSubFlow: SubFlow.Initiating,
|
||||||
sourceSessionId: SessionId,
|
sourceSessionId: SessionId,
|
||||||
additionalEntropy: Long,
|
|
||||||
payload: SerializedBytes<Any>?
|
payload: SerializedBytes<Any>?
|
||||||
): InitialSessionMessage {
|
): InitialSessionMessage {
|
||||||
return InitialSessionMessage(
|
return InitialSessionMessage(
|
||||||
initiatorSessionId = sourceSessionId,
|
initiatorSessionId = sourceSessionId,
|
||||||
// We add additional entropy to add to the initiated side's deduplication seed.
|
|
||||||
initiationEntropy = additionalEntropy,
|
|
||||||
initiatorFlowClassName = initiatingSubFlow.classToInitiateWith.name,
|
initiatorFlowClassName = initiatingSubFlow.classToInitiateWith.name,
|
||||||
flowVersion = initiatingSubFlow.flowInfo.flowVersion,
|
flowVersion = initiatingSubFlow.flowInfo.flowVersion,
|
||||||
appName = initiatingSubFlow.flowInfo.appName,
|
appName = initiatingSubFlow.flowInfo.appName,
|
||||||
|
@ -318,7 +318,7 @@ class TopLevelTransition(
|
|||||||
}
|
}
|
||||||
val sourceSessionId = SessionId.createRandom(context.secureRandom)
|
val sourceSessionId = SessionId.createRandom(context.secureRandom)
|
||||||
val sessionImpl = FlowSessionImpl(event.destination, event.wellKnownParty, sourceSessionId)
|
val sessionImpl = FlowSessionImpl(event.destination, event.wellKnownParty, sourceSessionId)
|
||||||
val newSessions = checkpoint.checkpointState.sessions + (sourceSessionId to SessionState.Uninitiated(event.destination, initiatingSubFlow, sourceSessionId, context.secureRandom.nextLong(), null, null, emptyMap(), null, null))
|
val newSessions = checkpoint.checkpointState.sessions + (sourceSessionId to SessionState.Uninitiated(event.destination, initiatingSubFlow, sourceSessionId, null, null, emptyMap(), null, null))
|
||||||
currentState = currentState.copy(checkpoint = checkpoint.setSessions(newSessions))
|
currentState = currentState.copy(checkpoint = checkpoint.setSessions(newSessions))
|
||||||
actions.add(Action.AddSessionBinding(context.id, sourceSessionId))
|
actions.add(Action.AddSessionBinding(context.id, sourceSessionId))
|
||||||
FlowContinuation.Resume(sessionImpl)
|
FlowContinuation.Resume(sessionImpl)
|
||||||
|
@ -55,7 +55,6 @@ class UnstartedFlowTransition(
|
|||||||
} else {
|
} else {
|
||||||
mapOf(0 to DataSessionMessage(initiatingMessage.firstPayload))
|
mapOf(0 to DataSessionMessage(initiatingMessage.firstPayload))
|
||||||
},
|
},
|
||||||
deduplicationSeed = "D-${initiatingMessage.initiatorSessionId.value}-${initiatingMessage.initiationEntropy}",
|
|
||||||
otherSideErrored = false,
|
otherSideErrored = false,
|
||||||
nextSendingSeqNumber = 1,
|
nextSendingSeqNumber = 1,
|
||||||
lastProcessedSeqNumber = if (initiatingMessage.firstPayload == null) {
|
lastProcessedSeqNumber = if (initiatingMessage.firstPayload == null) {
|
||||||
|
@ -574,7 +574,7 @@ class FlowFrameworkTests {
|
|||||||
|
|
||||||
@Test(timeout=300_000)
|
@Test(timeout=300_000)
|
||||||
fun `session init with unknown class is sent to the flow hospital, from where we then drop it`() {
|
fun `session init with unknown class is sent to the flow hospital, from where we then drop it`() {
|
||||||
aliceNode.sendSessionMessage(InitialSessionMessage(SessionId.createRandom(SecureRandom()), 0, "not.a.real.Class", 1, "", null), bob)
|
aliceNode.sendSessionMessage(InitialSessionMessage(SessionId.createRandom(SecureRandom()), "not.a.real.Class", 1, "", null), bob)
|
||||||
mockNet.runNetwork()
|
mockNet.runNetwork()
|
||||||
assertThat(receivedSessionMessages).hasSize(1) // Only the session-init is expected as the session-reject is blocked by the flow hospital
|
assertThat(receivedSessionMessages).hasSize(1) // Only the session-init is expected as the session-reject is blocked by the flow hospital
|
||||||
val medicalRecords = bobNode.smm.flowHospital.track().apply { updates.notUsed() }.snapshot
|
val medicalRecords = bobNode.smm.flowHospital.track().apply { updates.notUsed() }.snapshot
|
||||||
@ -590,7 +590,7 @@ class FlowFrameworkTests {
|
|||||||
|
|
||||||
@Test(timeout=300_000)
|
@Test(timeout=300_000)
|
||||||
fun `non-flow class in session init`() {
|
fun `non-flow class in session init`() {
|
||||||
aliceNode.sendSessionMessage(InitialSessionMessage(SessionId.createRandom(SecureRandom()), 0, String::class.java.name, 1, "", null), bob)
|
aliceNode.sendSessionMessage(InitialSessionMessage(SessionId.createRandom(SecureRandom()), String::class.java.name, 1, "", null), bob)
|
||||||
mockNet.runNetwork()
|
mockNet.runNetwork()
|
||||||
assertThat(receivedSessionMessages).hasSize(2) // Only the session-init and session-reject are expected
|
assertThat(receivedSessionMessages).hasSize(2) // Only the session-init and session-reject are expected
|
||||||
val lastMessage = receivedSessionMessages.last().message as ExistingSessionMessage
|
val lastMessage = receivedSessionMessages.last().message as ExistingSessionMessage
|
||||||
@ -1049,7 +1049,7 @@ internal inline fun <reified P : FlowLogic<*>> TestStartedNode.getSingleFlow():
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun sanitise(message: SessionMessage) = when (message) {
|
private fun sanitise(message: SessionMessage) = when (message) {
|
||||||
is InitialSessionMessage -> message.copy(initiatorSessionId = SessionId(BigInteger.valueOf(0)), initiationEntropy = 0, appName = "")
|
is InitialSessionMessage -> message.copy(initiatorSessionId = SessionId(BigInteger.valueOf(0)), appName = "")
|
||||||
is ExistingSessionMessage -> {
|
is ExistingSessionMessage -> {
|
||||||
val payload = message.payload
|
val payload = message.payload
|
||||||
message.copy(
|
message.copy(
|
||||||
@ -1107,7 +1107,7 @@ internal data class SessionTransfer(val from: Int, val message: SessionMessage,
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal fun sessionInit(clientFlowClass: KClass<out FlowLogic<*>>, flowVersion: Int = 1, payload: Any? = null): InitialSessionMessage {
|
internal fun sessionInit(clientFlowClass: KClass<out FlowLogic<*>>, flowVersion: Int = 1, payload: Any? = null): InitialSessionMessage {
|
||||||
return InitialSessionMessage(SessionId(BigInteger.valueOf(0)), 0, clientFlowClass.java.name, flowVersion, "", payload?.serialize())
|
return InitialSessionMessage(SessionId(BigInteger.valueOf(0)), clientFlowClass.java.name, flowVersion, "", payload?.serialize())
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun sessionData(payload: Any) = ExistingSessionMessage(SessionId(BigInteger.valueOf(0)), DataSessionMessage(payload.serialize()))
|
internal fun sessionData(payload: Any) = ExistingSessionMessage(SessionId(BigInteger.valueOf(0)), DataSessionMessage(payload.serialize()))
|
||||||
|
Loading…
Reference in New Issue
Block a user