Skip to content

Commit

Permalink
[Sandbox-on-X] Source record time once and pass downstream (digital-a…
Browse files Browse the repository at this point in the history
…sset#12722)

changelog_begin
changelog_end
  • Loading branch information
tudor-da authored Feb 3, 2022
1 parent 6ff7dc2 commit c11d4a7
Showing 1 changed file with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private[validate] class SequenceImpl(
val updateO = in match {
case Left(rejection) => Some(rejection.toCommandRejectedUpdate(recordTime))
case Right((_, NoOpPreparedSubmission(submission))) =>
processNonTransactionSubmission(submission)
processNonTransactionSubmission(recordTime, submission)
case Right((noConflictUpTo, txSubmission: PreparedTransactionSubmission)) =>
Some(
sequentialTransactionValidation(
Expand All @@ -83,19 +83,22 @@ private[validate] class SequenceImpl(
)
}

private val processNonTransactionSubmission: Submission => Option[Update] = {
case s: Submission.AllocateParty => validatedPartyAllocation(s)
private def processNonTransactionSubmission(
recordTime: Time.Timestamp,
submission: Submission,
): Option[Update] = submission match {
case s: Submission.AllocateParty => validatedPartyAllocation(s, recordTime)
case s @ Submission.Config(maxRecordTime, submissionId, config) =>
Some(validatedConfigUpload(s, maxRecordTime, submissionId, config))
Some(validatedConfigUpload(s, recordTime, maxRecordTime, submissionId, config))
case s: Submission.UploadPackages =>
Some(packageUploadSuccess(s, timeProvider.getCurrentTimestamp))
Some(packageUploadSuccess(s, recordTime))
case _: Submission.Transaction =>
throw new RuntimeException("Unexpected Submission.Transaction")
}

private def validatedPartyAllocation(allocateParty: AllocateParty) = {
private def validatedPartyAllocation(allocateParty: AllocateParty, recordTime: Time.Timestamp) = {
val partyAllocation =
partyAllocationSuccess(allocateParty, participantId, timeProvider.getCurrentTimestamp)
partyAllocationSuccess(allocateParty, participantId, recordTime)

val party = partyAllocation.party

Expand All @@ -113,11 +116,11 @@ private[validate] class SequenceImpl(

private def validatedConfigUpload(
c: Config,
maxRecordTime: Timestamp,
recordTime: Time.Timestamp,
maxRecordTime: Time.Timestamp,
submissionId: SubmissionId,
config: Configuration,
) = {
val recordTime = timeProvider.getCurrentTimestamp
) =
if (recordTime > maxRecordTime)
Update.ConfigurationChangeRejected(
recordTime = recordTime,
Expand All @@ -130,7 +133,7 @@ private[validate] class SequenceImpl(
val expectedGeneration = ledgerConfiguration.map(_.generation).map(_ + 1L)
if (expectedGeneration.forall(_ == config.generation)) {
ledgerConfiguration = Some(config)
configChangedSuccess(c, participantId, timeProvider.getCurrentTimestamp)
configChangedSuccess(c, participantId, recordTime)
} else
Update.ConfigurationChangeRejected(
recordTime = recordTime,
Expand All @@ -141,7 +144,6 @@ private[validate] class SequenceImpl(
s"Generation mismatch: expected=$expectedGeneration, actual=${config.generation}",
)
}
}

private def sequentialTransactionValidation(
noConflictUpTo: Offset,
Expand Down Expand Up @@ -171,7 +173,6 @@ private[validate] class SequenceImpl(
inputContracts = txSubmission.inputContracts,
completionInfo = completionInfo,
)
recordTime = timeProvider.getCurrentTimestamp
updatedDeduplicationState <- deduplicate(
changeId = ChangeId(
submitterInfo.applicationId,
Expand Down

0 comments on commit c11d4a7

Please sign in to comment.