Skip to content

Commit

Permalink
Adapt code to new proto structure
Browse files Browse the repository at this point in the history
  • Loading branch information
nicu-da committed Jan 10, 2022
1 parent d93518d commit 96a26e9
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ enum CommandDeduplicationType {
// command submission, while all other duplicate commands are reported asynchronously via completions.
ASYNC_AND_CONCURRENT_SYNC = 1;
// Duplicate commands are always reported synchronously via a synchronous gRPC error on the command submission.
ONLY_SYNC = 2;
SYNC_ONLY = 2;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import com.daml.ledger.api.v1.command_service.SubmitAndWaitRequest
import com.daml.ledger.api.v1.command_submission_service.SubmitRequest
import com.daml.ledger.api.v1.commands.Commands.DeduplicationPeriod
import com.daml.ledger.api.v1.completion.Completion
import com.daml.ledger.api.v1.experimental_features.DeduplicationPeriodSupport.OffsetSupport
import com.daml.ledger.api.v1.experimental_features.CommandDeduplicationPeriodSupport.OffsetSupport
import com.daml.ledger.api.v1.ledger_offset.LedgerOffset
import com.daml.ledger.client.binding.Primitive.Party
import com.daml.ledger.test.model.DA.Types.Tuple2
Expand Down Expand Up @@ -600,9 +600,7 @@ private[testtool] abstract class CommandDeduplicationBase(
)(implicit
ec: ExecutionContext
): Future[Unit] =
if (
ledger.features.commandDeduplicationFeatures.participantDeduplicationSupport.isParticipantDeduplicationSupported
)
if (ledger.features.commandDeduplicationFeatures.deduplicationType.isSyncOnly)
submitRequestAndAssertSyncDeduplication(ledger, request, acceptedSubmissionId, acceptedOffset)
else
submitRequestAndAssertAsyncDeduplication(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,8 @@ class CommandDeduplicationParallelIT extends LedgerTestSuite {
// Canton can return ABORTED for parallel in-flight duplicate submissions
val abortedResponses = responses.getOrElse(Code.ABORTED, 0)
val duplicateResponses =
if (
ledger.features.commandDeduplicationFeatures.participantDeduplicationSupport.isParticipantDeduplicationParallelOnly
) alreadyExistsResponses + abortedResponses
if (ledger.features.commandDeduplicationFeatures.deduplicationType.isAsyncAndConcurrentSync)
alreadyExistsResponses + abortedResponses
else alreadyExistsResponses
assert(
okResponses == 1 && duplicateResponses == numberOfParallelRequests - 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import com.daml.error.ErrorCodesVersionSwitcher
import com.daml.ledger.api.health.HealthChecks
import com.daml.ledger.api.v1.experimental_features.{
CommandDeduplicationFeatures,
DeduplicationPeriodSupport,
ParticipantDeduplicationSupport,
CommandDeduplicationPeriodSupport,
CommandDeduplicationType,
}
import com.daml.ledger.participant.state.index.impl.inmemory.InMemoryUserManagementStore
import com.daml.ledger.participant.state.v2.WritePackagesService
Expand Down Expand Up @@ -201,14 +201,14 @@ final class Runner[T <: ReadWriteService, Extra](
servicesExecutionContext = servicesExecutionContext,
commandDeduplicationFeatures = CommandDeduplicationFeatures.of(
Some(
DeduplicationPeriodSupport.of(
CommandDeduplicationPeriodSupport.of(
offsetSupport =
DeduplicationPeriodSupport.OffsetSupport.OFFSET_CONVERT_TO_DURATION,
CommandDeduplicationPeriodSupport.OffsetSupport.OFFSET_CONVERT_TO_DURATION,
durationSupport =
DeduplicationPeriodSupport.DurationSupport.DURATION_NATIVE_SUPPORT,
CommandDeduplicationPeriodSupport.DurationSupport.DURATION_NATIVE_SUPPORT,
)
),
ParticipantDeduplicationSupport.PARTICIPANT_DEDUPLICATION_NOT_SUPPORTED,
CommandDeduplicationType.ASYNC_ONLY,
),
).acquire()
} yield {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import com.daml.ledger.api.domain.LedgerId
import com.daml.ledger.api.health.HealthChecks
import com.daml.ledger.api.v1.experimental_features.{
CommandDeduplicationFeatures,
DeduplicationPeriodSupport,
ParticipantDeduplicationSupport,
CommandDeduplicationPeriodSupport,
CommandDeduplicationType,
}
import com.daml.ledger.participant.state.index.impl.inmemory.InMemoryUserManagementStore
import com.daml.ledger.participant.state.v2.metrics.TimedWriteService
Expand Down Expand Up @@ -428,12 +428,13 @@ final class SandboxServer(
userManagementStore = userManagementStore,
commandDeduplicationFeatures = CommandDeduplicationFeatures.of(
Some(
DeduplicationPeriodSupport.of(
offsetSupport = DeduplicationPeriodSupport.OffsetSupport.OFFSET_NOT_SUPPORTED,
durationSupport = DeduplicationPeriodSupport.DurationSupport.DURATION_NATIVE_SUPPORT,
CommandDeduplicationPeriodSupport.of(
offsetSupport = CommandDeduplicationPeriodSupport.OffsetSupport.OFFSET_NOT_SUPPORTED,
durationSupport =
CommandDeduplicationPeriodSupport.DurationSupport.DURATION_NATIVE_SUPPORT,
)
),
ParticipantDeduplicationSupport.PARTICIPANT_DEDUPLICATION_SUPPORTED,
CommandDeduplicationType.ASYNC_ONLY,
),
)(materializer, executionSequencerFactory, loggingContext)
.map(_.withServices(List(resetService)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import com.daml.error.ErrorCodesVersionSwitcher
import com.daml.ledger.api.health.HealthChecks
import com.daml.ledger.api.v1.experimental_features.{
CommandDeduplicationFeatures,
DeduplicationPeriodSupport,
ParticipantDeduplicationSupport,
CommandDeduplicationPeriodSupport,
CommandDeduplicationType,
}
import com.daml.ledger.offset.Offset
import com.daml.ledger.participant.state.index.impl.inmemory.InMemoryUserManagementStore
Expand Down Expand Up @@ -267,12 +267,12 @@ object SandboxOnXRunner {
userManagementStore = new InMemoryUserManagementStore, // TODO persistence wiring comes here
commandDeduplicationFeatures = CommandDeduplicationFeatures.of(
Some(
DeduplicationPeriodSupport.of(
DeduplicationPeriodSupport.OffsetSupport.OFFSET_NOT_SUPPORTED,
DeduplicationPeriodSupport.DurationSupport.DURATION_NATIVE_SUPPORT,
CommandDeduplicationPeriodSupport.of(
CommandDeduplicationPeriodSupport.OffsetSupport.OFFSET_NOT_SUPPORTED,
CommandDeduplicationPeriodSupport.DurationSupport.DURATION_NATIVE_SUPPORT,
)
),
ParticipantDeduplicationSupport.PARTICIPANT_DEDUPLICATION_SUPPORTED,
CommandDeduplicationType.SYNC_ONLY,
),
)

Expand Down
12 changes: 6 additions & 6 deletions ledger/sandbox/src/main/scala/platform/sandboxnext/Runner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import com.daml.ledger.api.domain
import com.daml.ledger.api.health.HealthChecks
import com.daml.ledger.api.v1.experimental_features.{
CommandDeduplicationFeatures,
DeduplicationPeriodSupport,
ParticipantDeduplicationSupport,
CommandDeduplicationPeriodSupport,
CommandDeduplicationType,
}
import com.daml.ledger.configuration.LedgerId
import com.daml.ledger.on.sql.Database.InvalidDatabaseException
Expand Down Expand Up @@ -319,14 +319,14 @@ class Runner(config: SandboxConfig) extends ResourceOwner[Port] {
servicesExecutionContext = servicesExecutionContext,
commandDeduplicationFeatures = CommandDeduplicationFeatures.of(
Some(
DeduplicationPeriodSupport.of(
CommandDeduplicationPeriodSupport.of(
offsetSupport =
DeduplicationPeriodSupport.OffsetSupport.OFFSET_CONVERT_TO_DURATION,
CommandDeduplicationPeriodSupport.OffsetSupport.OFFSET_CONVERT_TO_DURATION,
durationSupport =
DeduplicationPeriodSupport.DurationSupport.DURATION_NATIVE_SUPPORT,
CommandDeduplicationPeriodSupport.DurationSupport.DURATION_NATIVE_SUPPORT,
)
),
ParticipantDeduplicationSupport.PARTICIPANT_DEDUPLICATION_NOT_SUPPORTED,
CommandDeduplicationType.ASYNC_ONLY,
),
)
_ = apiServerServicesClosed.completeWith(apiServer.servicesClosed())
Expand Down

0 comments on commit 96a26e9

Please sign in to comment.