From a9a0b70b856468c8a2064586a72420f1d3058d40 Mon Sep 17 00:00:00 2001 From: Samir Talwar Date: Thu, 15 Jul 2021 15:03:19 +0200 Subject: [PATCH] ledger-configuration: Extract the configuration from participant-state. [KVL-1002] (#10279) * ledger-configuration: Extract configuration from participant-state. The configuration is often used without the state, and doesn't need to be versioned in the same way. CHANGELOG_BEGIN - [Integration Kit] The ledger configuration classes, ``Configuration``, ``LedgerInitialConditions``, and ``TimeModel``, have been moved from *participant-state* to a separate package named *ledger-configuration*, in the Java package ``com.daml.ledger.configuration``. You will need to update your dependencies and imports. CHANGELOG_END * participant-state: Remove the `LedgerId` aliases. * ledger-configuration: Rename `TimeModel` to `LedgerTimeModel`. This avoids confusion with the protobuf-generated `TimeModel` classes. CHANGELOG_BEGIN - [Integration Kit] ``TimeModel`` has been renamed to ``LedgerTimeModel``. If you are using the ledger configuration classes directly, you may need to update your code. CHANGELOG_END * ledger-configuration: Remove colons in LedgerInitialConditions' docs. * kvutils: Restore a missing compat import. * participant-integration-api: Add ledger-configuration to Oracle tests. * sandbox-common: Fix `--max-ledger-time-skew` docs. Co-authored-by: Miklos <57664299+miklos-da@users.noreply.github.com> Co-authored-by: Miklos <57664299+miklos-da@users.noreply.github.com> --- ledger/indexer-benchmark/BUILD.bazel | 2 + .../scala/ledger/indexerbenchmark/Main.scala | 7 +- .../indexerbenchmark/IndexerBenchmark.scala | 12 +--- ledger/ledger-api-domain/BUILD.bazel | 2 +- .../com/digitalasset/ledger/api/domain.scala | 2 +- ledger/ledger-configuration/BUILD.bazel | 52 ++++++++++++++ .../protobuf/BUILD.bazel | 5 +- .../state/ledger_configuration.proto | 0 .../protobuf/ledger_configuration.rst | 7 +- .../ledger/configuration}/Configuration.scala | 16 ++--- .../LedgerInitialConditions.scala | 8 +-- .../configuration/LedgerTimeModel.scala} | 41 ++++++----- .../daml/ledger/configuration/package.scala | 11 +++ .../configuration/LedgerTimeModelSpec.scala} | 21 +++--- ledger/ledger-on-memory/BUILD.bazel | 3 + .../on/memory/InMemoryLedgerReader.scala | 3 +- .../memory/InMemoryLedgerReaderWriter.scala | 3 +- ...oryLedgerReaderWriterIntegrationSpec.scala | 3 +- ledger/ledger-on-sql/BUILD.bazel | 4 ++ .../ledger/on/sql/SqlLedgerReaderWriter.scala | 1 + .../ledger/on/sql/queries/H2Queries.scala | 2 +- .../on/sql/queries/PostgresqlQueries.scala | 2 +- .../ledger/on/sql/queries/SqliteQueries.scala | 2 +- .../ledger/on/sql/queries/TimedQueries.scala | 2 +- .../ledger/on/sql/queries/WriteQueries.scala | 2 +- ...edgerReaderWriterIntegrationSpecBase.scala | 3 +- .../participant-integration-api/BUILD.bazel | 4 ++ .../apiserver/SpannedIndexService.scala | 1 + .../apiserver/StandaloneApiServer.scala | 3 +- .../apiserver/TimedIndexService.scala | 3 +- .../services/ApiCommandService.scala | 2 +- .../services/ApiSubmissionService.scala | 3 +- .../services/LedgerConfigProvider.scala | 8 +-- .../admin/ApiConfigManagementService.scala | 15 ++-- .../configuration/LedgerConfiguration.scala | 4 +- .../index/LedgerBackedIndexService.scala | 3 +- .../index/MeteredReadOnlyLedger.scala | 3 +- .../scala/platform/store/BaseLedger.scala | 3 +- .../scala/platform/store/ReadOnlyLedger.scala | 3 +- .../store/appendonlydao/JdbcLedgerDao.scala | 1 + .../store/backend/StorageBackend.scala | 3 +- .../store/backend/UpdateToDbDto.scala | 3 +- .../backend/common/CommonStorageBackend.scala | 3 +- .../platform/store/dao/JdbcLedgerDao.scala | 1 + .../scala/platform/store/dao/LedgerDao.scala | 4 +- .../platform/store/dao/MeteredLedgerDao.scala | 1 + .../platform/store/dao/ParametersTable.scala | 3 +- .../store/entries/ConfigurationEntry.scala | 2 +- .../dao/JdbcLedgerDaoConfigurationSpec.scala | 3 +- .../store/dao/JdbcLedgerDaoSuite.scala | 11 +-- .../ApiConfigManagementServiceSpec.scala | 11 +-- .../services/ApiSubmissionServiceSpec.scala | 3 +- .../services/LedgerConfigProviderSpec.scala | 11 +-- .../platform/indexer/JdbcIndexerSpec.scala | 14 ++-- .../store/backend/UpdateToDbDtoSpec.scala | 5 +- ledger/participant-state-index/BUILD.bazel | 1 + .../v2/IndexConfigManagementService.scala | 2 +- ledger/participant-state-metrics/BUILD.bazel | 1 + .../state/v1/metrics/TimedReadService.scala | 3 +- .../state/v1/metrics/TimedWriteService.scala | 1 + ledger/participant-state/BUILD.bazel | 5 +- ledger/participant-state/kvutils/BUILD.bazel | 9 ++- .../participant-state/kvutils/app/BUILD.bazel | 1 + .../state/kvutils/KeyValueCommitting.scala | 3 +- .../state/kvutils/KeyValueConsumption.scala | 1 + .../state/kvutils/KeyValueSubmission.scala | 1 + .../api/KeyValueParticipantState.scala | 1 + .../api/KeyValueParticipantStateReader.scala | 1 + .../api/KeyValueParticipantStateWriter.scala | 1 + .../state/kvutils/api/LedgerReader.scala | 5 +- .../state/kvutils/api/package.scala | 5 +- .../state/kvutils/committer/Committer.scala | 3 +- .../kvutils/committer/ConfigCommitter.scala | 2 +- .../transaction/TransactionCommitter.scala | 3 +- .../validation/LedgerTimeValidator.scala | 7 +- .../participant/state/kvutils/KVTest.scala | 1 + .../ParticipantStateIntegrationSpecBase.scala | 7 +- .../state/kvutils/TestHelpers.scala | 5 +- .../state/kvutils/KVUtilsConfigSpec.scala | 2 +- .../kvutils/KeyValueConsumptionSpec.scala | 5 +- .../KeyValueParticipantStateWriterSpec.scala | 3 +- .../kvutils/committer/CommitterSpec.scala | 4 +- .../committer/ConfigCommitterSpec.scala | 2 +- .../validation/LedgerTimeValidatorSpec.scala | 2 +- .../PreExecutingSubmissionValidatorSpec.scala | 2 +- .../kvutils/tools/BUILD.bazel | 4 ++ .../LogAppendingReadServiceFactory.scala | 3 +- ...reExecutingCommitStrategySupportSpec.scala | 16 ++--- .../StateUpdateComparisonSpec.scala | 4 +- .../StateUpdateExporterSpec.scala | 3 +- ledger/participant-state/protobuf/README.md | 6 -- .../state/v1/LedgerInitialConditions.scala | 18 ----- .../participant/state/v1/ReadService.scala | 33 ++++----- .../ledger/participant/state/v1/Update.scala | 51 ++++++------- .../state/v1/WriteConfigService.scala | 1 + .../ledger/participant/state/v1/package.scala | 5 +- .../state/v2/AdaptedV1ReadService.scala | 32 ++------- .../state/v2/AdaptedV1WriteService.scala | 17 +---- .../participant/state/v2/Configuration.scala | 34 --------- .../participant/state/v2/ReadService.scala | 29 ++++---- .../participant/state/v2/SubmitterInfo.scala | 27 ++++--- .../participant/state/v2/TimeModel.scala | 72 ------------------- .../ledger/participant/state/v2/Update.scala | 1 + .../state/v2/WriteConfigService.scala | 1 + .../ledger/participant/state/v2/package.scala | 3 - .../BUILD.bazel | 1 + .../RecoveringIndexerIntegrationSpec.scala | 3 +- ledger/sandbox-classic/BUILD.bazel | 2 + .../stores/LedgerBackedWriteService.scala | 2 +- .../sandbox/stores/ledger/Ledger.scala | 3 +- .../sandbox/stores/ledger/MeteredLedger.scala | 1 + .../ledger/inmemory/InMemoryLedger.scala | 8 +-- .../sandbox/stores/ledger/sql/SqlLedger.scala | 1 + .../TransactionTimeModelComplianceIT.scala | 17 ++--- ledger/sandbox-common/BUILD.bazel | 2 + .../platform/sandbox/cli/CommonCliBase.scala | 3 +- .../sandbox/services/TimeModelHelpers.scala | 4 +- ledger/sandbox-on-x/BUILD.bazel | 1 + .../sandbox/ReadWriteServiceBridge.scala | 8 ++- ledger/sandbox/BUILD.bazel | 2 + .../scala/platform/sandboxnext/Runner.scala | 3 +- release/artifacts.yaml | 10 +-- 122 files changed, 409 insertions(+), 461 deletions(-) create mode 100644 ledger/ledger-configuration/BUILD.bazel rename ledger/{participant-state => ledger-configuration}/protobuf/BUILD.bazel (77%) rename ledger/{participant-state => ledger-configuration}/protobuf/com/daml/ledger/participant/state/ledger_configuration.proto (100%) rename ledger/{participant-state => ledger-configuration}/protobuf/ledger_configuration.rst (93%) rename ledger/{participant-state/src/main/scala/com/daml/ledger/participant/state/v1 => ledger-configuration/src/main/scala/com/daml/ledger/configuration}/Configuration.scala (91%) rename ledger/{participant-state/src/main/scala/com/daml/ledger/participant/state/v2 => ledger-configuration/src/main/scala/com/daml/ledger/configuration}/LedgerInitialConditions.scala (62%) rename ledger/{participant-state/src/main/scala/com/daml/ledger/participant/state/v1/TimeModel.scala => ledger-configuration/src/main/scala/com/daml/ledger/configuration/LedgerTimeModel.scala} (63%) create mode 100644 ledger/ledger-configuration/src/main/scala/com/daml/ledger/configuration/package.scala rename ledger/{participant-state/src/test/suite/scala/com/daml/ledger/participant/state/v1/TimeModelSpec.scala => ledger-configuration/src/test/suite/scala/com/daml/ledger/configuration/LedgerTimeModelSpec.scala} (91%) delete mode 100644 ledger/participant-state/protobuf/README.md delete mode 100644 ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/LedgerInitialConditions.scala delete mode 100644 ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/Configuration.scala delete mode 100644 ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/TimeModel.scala diff --git a/ledger/indexer-benchmark/BUILD.bazel b/ledger/indexer-benchmark/BUILD.bazel index 743d29e63f4..81f34685d78 100644 --- a/ledger/indexer-benchmark/BUILD.bazel +++ b/ledger/indexer-benchmark/BUILD.bazel @@ -32,6 +32,7 @@ da_scala_library( "//language-support/scala/bindings", "//ledger/ledger-api-common", "//ledger/ledger-api-health", + "//ledger/ledger-configuration", "//ledger/ledger-resources", "//ledger/metrics", "//ledger/participant-integration-api", @@ -61,6 +62,7 @@ da_scala_library( "//language-support/scala/bindings", "//ledger/ledger-api-common", "//ledger/ledger-api-health", + "//ledger/ledger-configuration", "//ledger/metrics", "//ledger/participant-state", "//ledger/participant-state/kvutils", diff --git a/ledger/indexer-benchmark/src/app/scala/ledger/indexerbenchmark/Main.scala b/ledger/indexer-benchmark/src/app/scala/ledger/indexerbenchmark/Main.scala index aa9f65844c2..27c3a3a100f 100644 --- a/ledger/indexer-benchmark/src/app/scala/ledger/indexerbenchmark/Main.scala +++ b/ledger/indexer-benchmark/src/app/scala/ledger/indexerbenchmark/Main.scala @@ -13,14 +13,15 @@ import akka.stream.scaladsl.{Sink, Source} import com.codahale.metrics.MetricRegistry import com.daml.dec.DirectExecutionContext import com.daml.ledger.api.health.HealthStatus -import com.daml.ledger.participant.state.kvutils.{OffsetBuilder, Raw} -import com.daml.ledger.participant.state.kvutils.`export`.ProtobufBasedLedgerDataImporter +import com.daml.ledger.configuration.LedgerId import com.daml.ledger.participant.state.kvutils.api.{ KeyValueParticipantStateReader, LedgerReader, LedgerRecord, } -import com.daml.ledger.participant.state.v1.{LedgerId, Offset, Update} +import com.daml.ledger.participant.state.kvutils.export.ProtobufBasedLedgerDataImporter +import com.daml.ledger.participant.state.kvutils.{OffsetBuilder, Raw} +import com.daml.ledger.participant.state.v1.{Offset, Update} import com.daml.metrics.Metrics import scala.concurrent.Future diff --git a/ledger/indexer-benchmark/src/main/scala/ledger/indexerbenchmark/IndexerBenchmark.scala b/ledger/indexer-benchmark/src/main/scala/ledger/indexerbenchmark/IndexerBenchmark.scala index f521c630ca4..0ccc18dfce2 100644 --- a/ledger/indexer-benchmark/src/main/scala/ledger/indexerbenchmark/IndexerBenchmark.scala +++ b/ledger/indexer-benchmark/src/main/scala/ledger/indexerbenchmark/IndexerBenchmark.scala @@ -12,14 +12,8 @@ import akka.stream.scaladsl.Source import com.codahale.metrics.{MetricRegistry, Snapshot} import com.daml.dec.DirectExecutionContext import com.daml.ledger.api.health.HealthStatus -import com.daml.ledger.participant.state.v1.{ - Configuration, - LedgerInitialConditions, - Offset, - ReadService, - TimeModel, - Update, -} +import com.daml.ledger.configuration.{Configuration, LedgerInitialConditions, LedgerTimeModel} +import com.daml.ledger.participant.state.v1.{Offset, ReadService, Update} import com.daml.ledger.resources.{Resource, ResourceContext, ResourceOwner} import com.daml.lf.data.Time import com.daml.logging.LoggingContext.newLoggingContext @@ -174,7 +168,7 @@ class IndexerBenchmark() { IndexerBenchmark.LedgerId, Configuration( generation = 0, - timeModel = TimeModel.reasonableDefault, + timeModel = LedgerTimeModel.reasonableDefault, maxDeduplicationTime = java.time.Duration.ofDays(1), ), Time.Timestamp.Epoch, diff --git a/ledger/ledger-api-domain/BUILD.bazel b/ledger/ledger-api-domain/BUILD.bazel index 82c0671fbe9..e40cd467a17 100644 --- a/ledger/ledger-api-domain/BUILD.bazel +++ b/ledger/ledger-api-domain/BUILD.bazel @@ -19,7 +19,7 @@ da_scala_library( deps = [ "//daml-lf/data", "//daml-lf/transaction", - "//ledger/participant-state", + "//ledger/ledger-configuration", "//libs-scala/logging-entries", "@maven//:io_zipkin_brave_brave", ], diff --git a/ledger/ledger-api-domain/src/main/scala/com/digitalasset/ledger/api/domain.scala b/ledger/ledger-api-domain/src/main/scala/com/digitalasset/ledger/api/domain.scala index c608d8b612a..7f87a78b64b 100644 --- a/ledger/ledger-api-domain/src/main/scala/com/digitalasset/ledger/api/domain.scala +++ b/ledger/ledger-api-domain/src/main/scala/com/digitalasset/ledger/api/domain.scala @@ -7,7 +7,7 @@ import java.time.Instant import brave.propagation.TraceContext import com.daml.ledger.api.domain.Event.{CreateOrArchiveEvent, CreateOrExerciseEvent} -import com.daml.ledger.participant.state.v1.Configuration +import com.daml.ledger.configuration.Configuration import com.daml.lf.command.{Commands => LfCommands} import com.daml.lf.data.Ref import com.daml.lf.data.Ref.LedgerString.ordering diff --git a/ledger/ledger-configuration/BUILD.bazel b/ledger/ledger-configuration/BUILD.bazel new file mode 100644 index 00000000000..ed43e5b31cb --- /dev/null +++ b/ledger/ledger-configuration/BUILD.bazel @@ -0,0 +1,52 @@ +# Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +load( + "//bazel_tools:scala.bzl", + "da_scala_library", + "da_scala_test_suite", +) + +da_scala_library( + name = "ledger-configuration", + srcs = glob(["src/main/scala/**/*.scala"]), + resources = glob(["src/main/resources/**/*"]), + tags = ["maven_coordinates=com.daml:ledger-configuration:__VERSION__"], + visibility = [ + "//visibility:public", + ], + exports = [ + "//ledger/ledger-configuration/protobuf:ledger_configuration_proto_java", + ], + runtime_deps = [], + deps = [ + "//daml-lf/data", + "//language-support/scala/bindings", + "//ledger/ledger-configuration/protobuf:ledger_configuration_proto_java", + "@maven//:com_google_protobuf_protobuf_java", + ], +) + +filegroup( + name = "sources", + srcs = glob(["src/main/scala/**/*.scala"]), + visibility = ["//visibility:public"], +) + +da_scala_test_suite( + name = "ledger-configuration-tests", + size = "small", + srcs = glob(["src/test/suite/scala/**/*.scala"]), + resources = glob(["src/test/resources/*"]), + scala_deps = [ + "@maven//:org_scalatest_scalatest", + "@maven//:org_scalaz_scalaz_core", + "@maven//:org_scala_lang_modules_scala_collection_compat", + ], + deps = [ + ":ledger-configuration", + "//daml-lf/data", + "//daml-lf/transaction", + "//ledger-api/grpc-definitions:ledger_api_proto_scala", + ], +) diff --git a/ledger/participant-state/protobuf/BUILD.bazel b/ledger/ledger-configuration/protobuf/BUILD.bazel similarity index 77% rename from ledger/participant-state/protobuf/BUILD.bazel rename to ledger/ledger-configuration/protobuf/BUILD.bazel index f4e465a1e35..1ba2611c844 100644 --- a/ledger/participant-state/protobuf/BUILD.bazel +++ b/ledger/ledger-configuration/protobuf/BUILD.bazel @@ -8,7 +8,10 @@ proto_jars( srcs = ["com/daml/ledger/participant/state/ledger_configuration.proto"], maven_artifact_prefix = "participant-state-ledger-configuration", maven_group = "com.daml", - visibility = ["//ledger/participant-state:__subpackages__"], + visibility = [ + "//ledger/ledger-configuration:__subpackages__", + "//ledger/participant-state:__subpackages__", + ], deps = [ "@com_google_protobuf//:duration_proto", ], diff --git a/ledger/participant-state/protobuf/com/daml/ledger/participant/state/ledger_configuration.proto b/ledger/ledger-configuration/protobuf/com/daml/ledger/participant/state/ledger_configuration.proto similarity index 100% rename from ledger/participant-state/protobuf/com/daml/ledger/participant/state/ledger_configuration.proto rename to ledger/ledger-configuration/protobuf/com/daml/ledger/participant/state/ledger_configuration.proto diff --git a/ledger/participant-state/protobuf/ledger_configuration.rst b/ledger/ledger-configuration/protobuf/ledger_configuration.rst similarity index 93% rename from ledger/participant-state/protobuf/ledger_configuration.rst rename to ledger/ledger-configuration/protobuf/ledger_configuration.rst index c7a171725ed..277c0ab55d4 100644 --- a/ledger/participant-state/protobuf/ledger_configuration.rst +++ b/ledger/ledger-configuration/protobuf/ledger_configuration.rst @@ -16,8 +16,11 @@ Please read ``daml-lf/spec/transaction.rst`` to understand the rules we follow for evolving the ledger configuration. The canonical specification compliant implementation for encoding and -decoding ledger configurations is part of the participant-state package -in ``ledger/participant-state``. +decoding ledger configurations is part of the ledger-configuration +package in ``ledger/ledger-configuration``. + +For historical reasons, we have kept the package name as +``com.daml.ledger.participant.state``. Version history ^^^^^^^^^^^^^^^ diff --git a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/Configuration.scala b/ledger/ledger-configuration/src/main/scala/com/daml/ledger/configuration/Configuration.scala similarity index 91% rename from ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/Configuration.scala rename to ledger/ledger-configuration/src/main/scala/com/daml/ledger/configuration/Configuration.scala index 873280d09a5..7b4917ffc0d 100644 --- a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/Configuration.scala +++ b/ledger/ledger-configuration/src/main/scala/com/daml/ledger/configuration/Configuration.scala @@ -1,7 +1,7 @@ // Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. // SPDX-License-Identifier: Apache-2.0 -package com.daml.ledger.participant.state.v1 +package com.daml.ledger.configuration import java.time.Duration @@ -10,13 +10,13 @@ import scala.util.Try /** Ledger configuration describing the ledger's time model. * Emitted in [[com.daml.ledger.participant.state.v1.Update.ConfigurationChanged]]. * - * @param generation The configuration generation. Monotonically increasing. - * @param timeModel The time model of the ledger. Specifying the time-to-live bounds for Ledger API commands. + * @param generation The configuration generation. Monotonically increasing. + * @param timeModel The time model of the ledger. Specifying the time-to-live bounds for Ledger API commands. * @param maxDeduplicationTime The maximum time window during which commands can be deduplicated. */ final case class Configuration( generation: Long, - timeModel: TimeModel, + timeModel: LedgerTimeModel, maxDeduplicationTime: Duration, ) @@ -58,8 +58,8 @@ object Configuration { ) } - def decodeTimeModel(tm: protobuf.LedgerTimeModel): Either[String, TimeModel] = - TimeModel( + def decodeTimeModel(tm: protobuf.LedgerTimeModel): Either[String, LedgerTimeModel] = + LedgerTimeModel( avgTransactionLatency = parseDuration(tm.getAvgTransactionLatency), minSkew = parseDuration(tm.getMinSkew), maxSkew = parseDuration(tm.getMaxSkew), @@ -88,8 +88,8 @@ object Configuration { ) } - def decodeTimeModel(tm: protobuf.LedgerTimeModel): Either[String, TimeModel] = - TimeModel( + def decodeTimeModel(tm: protobuf.LedgerTimeModel): Either[String, LedgerTimeModel] = + LedgerTimeModel( avgTransactionLatency = parseDuration(tm.getAvgTransactionLatency), minSkew = parseDuration(tm.getMinSkew), maxSkew = parseDuration(tm.getMaxSkew), diff --git a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/LedgerInitialConditions.scala b/ledger/ledger-configuration/src/main/scala/com/daml/ledger/configuration/LedgerInitialConditions.scala similarity index 62% rename from ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/LedgerInitialConditions.scala rename to ledger/ledger-configuration/src/main/scala/com/daml/ledger/configuration/LedgerInitialConditions.scala index ead21b464cc..0ca0b010947 100644 --- a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/LedgerInitialConditions.scala +++ b/ledger/ledger-configuration/src/main/scala/com/daml/ledger/configuration/LedgerInitialConditions.scala @@ -1,15 +1,15 @@ // Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. // SPDX-License-Identifier: Apache-2.0 -package com.daml.ledger.participant.state.v2 +package com.daml.ledger.configuration import com.daml.lf.data.Time.Timestamp /** The initial conditions of the ledger before anything has been committed. * - * @param ledgerId: The static ledger identifier. - * @param config: The initial ledger configuration - * @param initialRecordTime: The initial record time prior to any [[Update]] event. + * @param ledgerId The static ledger identifier. + * @param config The initial ledger configuration + * @param initialRecordTime The initial record time prior to any update event. */ final case class LedgerInitialConditions( ledgerId: LedgerId, diff --git a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/TimeModel.scala b/ledger/ledger-configuration/src/main/scala/com/daml/ledger/configuration/LedgerTimeModel.scala similarity index 63% rename from ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/TimeModel.scala rename to ledger/ledger-configuration/src/main/scala/com/daml/ledger/configuration/LedgerTimeModel.scala index 6ee5c9590b3..c61af0de710 100644 --- a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/TimeModel.scala +++ b/ledger/ledger-configuration/src/main/scala/com/daml/ledger/configuration/LedgerTimeModel.scala @@ -1,22 +1,25 @@ // Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. // SPDX-License-Identifier: Apache-2.0 -package com.daml.ledger.participant.state.v1 +package com.daml.ledger.configuration import java.time.{Duration, Instant} import scala.util.Try -/** The ledger time model and associated validations. Some values are given by constructor args; others are derived. - * @param avgTransactionLatency The expected average latency of a transaction, i.e., the average time - * from submitting the transaction to a [[WriteService]] and the transaction - * being assigned a record time. - * @param minSkew The minimimum skew between ledger time and record time: lt_TX >= rt_TX - minSkew - * @param maxSkew The maximum skew between ledger time and record time: lt_TX <= rt_TX + maxSkew +/** The ledger time model and associated validations. Some values are given by constructor args; + * others are derived. * + * @param avgTransactionLatency The expected average latency of a transaction, i.e., the average + * time from submitting the transaction to a write service and the + * transaction being assigned a record time. + * @param minSkew The minimimum skew between ledger time and record time: + * lt_TX >= rt_TX - minSkew + * @param maxSkew The maximum skew between ledger time and record time: + * lt_TX <= rt_TX + maxSkew * @throws IllegalArgumentException if the parameters aren't valid */ -case class TimeModel private ( +case class LedgerTimeModel private ( avgTransactionLatency: Duration, minSkew: Duration, maxSkew: Duration, @@ -37,36 +40,40 @@ case class TimeModel private ( Right(()) } - private[state] def minLedgerTime(recordTime: Instant): Instant = + private[ledger] def minLedgerTime(recordTime: Instant): Instant = recordTime.minus(minSkew) - private[state] def maxLedgerTime(recordTime: Instant): Instant = + private[ledger] def maxLedgerTime(recordTime: Instant): Instant = recordTime.plus(maxSkew) - private[state] def minRecordTime(ledgerTime: Instant): Instant = + private[ledger] def minRecordTime(ledgerTime: Instant): Instant = ledgerTime.minus(maxSkew) - private[state] def maxRecordTime(ledgerTime: Instant): Instant = + private[ledger] def maxRecordTime(ledgerTime: Instant): Instant = ledgerTime.plus(minSkew) } -object TimeModel { +object LedgerTimeModel { /** A default TimeModel that's reasonable for a test or sandbox ledger application. * Serious applications (viz. ledger) should probably specify their own TimeModel. */ - val reasonableDefault: TimeModel = - TimeModel( + val reasonableDefault: LedgerTimeModel = + LedgerTimeModel( avgTransactionLatency = Duration.ofSeconds(0L), minSkew = Duration.ofSeconds(30L), maxSkew = Duration.ofSeconds(30L), ).get - def apply(avgTransactionLatency: Duration, minSkew: Duration, maxSkew: Duration): Try[TimeModel] = + def apply( + avgTransactionLatency: Duration, + minSkew: Duration, + maxSkew: Duration, + ): Try[LedgerTimeModel] = Try { require(!avgTransactionLatency.isNegative, "Negative average transaction latency") require(!minSkew.isNegative, "Negative min skew") require(!maxSkew.isNegative, "Negative max skew") - new TimeModel(avgTransactionLatency, minSkew, maxSkew) + new LedgerTimeModel(avgTransactionLatency, minSkew, maxSkew) } } diff --git a/ledger/ledger-configuration/src/main/scala/com/daml/ledger/configuration/package.scala b/ledger/ledger-configuration/src/main/scala/com/daml/ledger/configuration/package.scala new file mode 100644 index 00000000000..4d125d90a3b --- /dev/null +++ b/ledger/ledger-configuration/src/main/scala/com/daml/ledger/configuration/package.scala @@ -0,0 +1,11 @@ +// Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +package com.daml.ledger + +package object configuration { + + /** Identifier for the ledger, MUST match regexp [a-zA-Z0-9-]. */ + type LedgerId = String + +} diff --git a/ledger/participant-state/src/test/suite/scala/com/daml/ledger/participant/state/v1/TimeModelSpec.scala b/ledger/ledger-configuration/src/test/suite/scala/com/daml/ledger/configuration/LedgerTimeModelSpec.scala similarity index 91% rename from ledger/participant-state/src/test/suite/scala/com/daml/ledger/participant/state/v1/TimeModelSpec.scala rename to ledger/ledger-configuration/src/test/suite/scala/com/daml/ledger/configuration/LedgerTimeModelSpec.scala index e03dc3e10f5..f44a76d4319 100644 --- a/ledger/participant-state/src/test/suite/scala/com/daml/ledger/participant/state/v1/TimeModelSpec.scala +++ b/ledger/ledger-configuration/src/test/suite/scala/com/daml/ledger/configuration/LedgerTimeModelSpec.scala @@ -1,19 +1,19 @@ // Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. // SPDX-License-Identifier: Apache-2.0 -package com.daml.ledger.participant.state.v1 +package com.daml.ledger.configuration import java.time._ import org.scalatest.matchers.should.Matchers import org.scalatest.wordspec.AnyWordSpec -class TimeModelSpec extends AnyWordSpec with Matchers { +class LedgerTimeModelSpec extends AnyWordSpec with Matchers { private val referenceTime = Instant.EPOCH private val epsilon = Duration.ofMillis(10L) private val timeModel = - TimeModel( + LedgerTimeModel( avgTransactionLatency = Duration.ZERO, minSkew = Duration.ofSeconds(30L), maxSkew = Duration.ofSeconds(30L), @@ -92,12 +92,11 @@ class TimeModelSpec extends AnyWordSpec with Matchers { } "produce a valid error message" in { - val timeModel = - TimeModel( - avgTransactionLatency = Duration.ZERO, - minSkew = Duration.ofSeconds(10L), - maxSkew = Duration.ofSeconds(20L), - ).get + val timeModel = LedgerTimeModel( + avgTransactionLatency = Duration.ZERO, + minSkew = Duration.ofSeconds(10L), + maxSkew = Duration.ofSeconds(20L), + ).get val ledgerTime = "2000-01-01T12:00:00Z" val recordTime = "2000-01-01T12:30:00Z" val lowerBound = "2000-01-01T12:29:50Z" @@ -112,8 +111,8 @@ class TimeModelSpec extends AnyWordSpec with Matchers { } } - private def createAsymmetricTimeModel(minSkew: Duration, maxSkew: Duration): TimeModel = - TimeModel( + private def createAsymmetricTimeModel(minSkew: Duration, maxSkew: Duration): LedgerTimeModel = + LedgerTimeModel( avgTransactionLatency = Duration.ZERO, minSkew = minSkew, maxSkew = maxSkew, diff --git a/ledger/ledger-on-memory/BUILD.bazel b/ledger/ledger-on-memory/BUILD.bazel index cb369ed036a..68e0652f600 100644 --- a/ledger/ledger-on-memory/BUILD.bazel +++ b/ledger/ledger-on-memory/BUILD.bazel @@ -29,6 +29,7 @@ da_scala_library( "//ledger/caching", "//ledger/ledger-api-common", "//ledger/ledger-api-health", + "//ledger/ledger-configuration", "//ledger/ledger-resources", "//ledger/metrics", "//ledger/participant-state", @@ -69,6 +70,7 @@ da_scala_test_suite( "//ledger/caching", "//ledger/ledger-api-common", "//ledger/ledger-api-health", + "//ledger/ledger-configuration", "//ledger/ledger-resources", "//ledger/ledger-resources:ledger-resources-test-lib", "//ledger/metrics", @@ -104,6 +106,7 @@ da_scala_library( "//ledger/ledger-api-auth", "//ledger/ledger-api-common", "//ledger/ledger-api-health", + "//ledger/ledger-configuration", "//ledger/ledger-resources", "//ledger/metrics", "//ledger/participant-integration-api", diff --git a/ledger/ledger-on-memory/src/main/scala/com/daml/ledger/on/memory/InMemoryLedgerReader.scala b/ledger/ledger-on-memory/src/main/scala/com/daml/ledger/on/memory/InMemoryLedgerReader.scala index 9c6d34bd280..e529eced467 100644 --- a/ledger/ledger-on-memory/src/main/scala/com/daml/ledger/on/memory/InMemoryLedgerReader.scala +++ b/ledger/ledger-on-memory/src/main/scala/com/daml/ledger/on/memory/InMemoryLedgerReader.scala @@ -6,9 +6,10 @@ package com.daml.ledger.on.memory import akka.NotUsed import akka.stream.scaladsl.Source import com.daml.ledger.api.health.{HealthStatus, Healthy} +import com.daml.ledger.configuration.LedgerId import com.daml.ledger.participant.state.kvutils.OffsetBuilder import com.daml.ledger.participant.state.kvutils.api.{LedgerReader, LedgerRecord} -import com.daml.ledger.participant.state.v1.{LedgerId, Offset} +import com.daml.ledger.participant.state.v1.Offset import com.daml.metrics.{Metrics, Timed} import com.daml.platform.akkastreams.dispatcher.Dispatcher import com.daml.platform.akkastreams.dispatcher.SubSource.RangeSource diff --git a/ledger/ledger-on-memory/src/main/scala/com/daml/ledger/on/memory/InMemoryLedgerReaderWriter.scala b/ledger/ledger-on-memory/src/main/scala/com/daml/ledger/on/memory/InMemoryLedgerReaderWriter.scala index d2f7cc3d5ac..dd4eddecca3 100644 --- a/ledger/ledger-on-memory/src/main/scala/com/daml/ledger/on/memory/InMemoryLedgerReaderWriter.scala +++ b/ledger/ledger-on-memory/src/main/scala/com/daml/ledger/on/memory/InMemoryLedgerReaderWriter.scala @@ -5,8 +5,9 @@ package com.daml.ledger.on.memory import com.daml.api.util.TimeProvider import com.daml.caching.Cache +import com.daml.ledger.configuration.LedgerId import com.daml.ledger.participant.state.kvutils.api._ -import com.daml.ledger.participant.state.v1.{LedgerId, ParticipantId} +import com.daml.ledger.participant.state.v1.ParticipantId import com.daml.ledger.resources.{Resource, ResourceContext, ResourceOwner} import com.daml.ledger.validator.StateKeySerializationStrategy import com.daml.lf.engine.Engine diff --git a/ledger/ledger-on-memory/src/test/suite/scala/com/daml/ledger/on/memory/InMemoryLedgerReaderWriterIntegrationSpec.scala b/ledger/ledger-on-memory/src/test/suite/scala/com/daml/ledger/on/memory/InMemoryLedgerReaderWriterIntegrationSpec.scala index d1636769ff8..6751fba3bef 100644 --- a/ledger/ledger-on-memory/src/test/suite/scala/com/daml/ledger/on/memory/InMemoryLedgerReaderWriterIntegrationSpec.scala +++ b/ledger/ledger-on-memory/src/test/suite/scala/com/daml/ledger/on/memory/InMemoryLedgerReaderWriterIntegrationSpec.scala @@ -5,10 +5,11 @@ package com.daml.ledger.on.memory import java.util.concurrent.Executors +import com.daml.ledger.configuration.LedgerId import com.daml.ledger.participant.state.kvutils.ParticipantStateIntegrationSpecBase import com.daml.ledger.participant.state.kvutils.ParticipantStateIntegrationSpecBase.ParticipantState import com.daml.ledger.participant.state.kvutils.api.KeyValueParticipantState -import com.daml.ledger.participant.state.v1.{LedgerId, ParticipantId} +import com.daml.ledger.participant.state.v1.ParticipantId import com.daml.ledger.resources.ResourceOwner import com.daml.ledger.validator.StateKeySerializationStrategy import com.daml.lf.engine.Engine diff --git a/ledger/ledger-on-sql/BUILD.bazel b/ledger/ledger-on-sql/BUILD.bazel index f5fa4563ba7..fa7dca9a9c6 100644 --- a/ledger/ledger-on-sql/BUILD.bazel +++ b/ledger/ledger-on-sql/BUILD.bazel @@ -102,6 +102,7 @@ da_scala_library( "//ledger/ledger-api-common", "//ledger/ledger-api-domain", "//ledger/ledger-api-health", + "//ledger/ledger-configuration", "//ledger/ledger-resources", "//ledger/metrics", "//ledger/participant-state", @@ -136,6 +137,7 @@ da_scala_library( "//ledger/caching", "//ledger/ledger-api-auth", "//ledger/ledger-api-health", + "//ledger/ledger-configuration", "//ledger/ledger-resources", "//ledger/metrics", "//ledger/participant-integration-api", @@ -185,6 +187,7 @@ da_scala_library( "//ledger/caching", "//ledger/ledger-api-auth", "//ledger/ledger-api-health", + "//ledger/ledger-configuration", "//ledger/ledger-resources", "//ledger/metrics", "//ledger/participant-integration-api", @@ -227,6 +230,7 @@ da_scala_test_suite( "//ledger-api/testing-utils", "//ledger/ledger-api-common", "//ledger/ledger-api-health", + "//ledger/ledger-configuration", "//ledger/ledger-resources", "//ledger/ledger-resources:ledger-resources-test-lib", "//ledger/metrics", diff --git a/ledger/ledger-on-sql/src/main/scala/com/daml/ledger/on/sql/SqlLedgerReaderWriter.scala b/ledger/ledger-on-sql/src/main/scala/com/daml/ledger/on/sql/SqlLedgerReaderWriter.scala index 5f59aff74c2..f4f134c6e12 100644 --- a/ledger/ledger-on-sql/src/main/scala/com/daml/ledger/on/sql/SqlLedgerReaderWriter.scala +++ b/ledger/ledger-on-sql/src/main/scala/com/daml/ledger/on/sql/SqlLedgerReaderWriter.scala @@ -13,6 +13,7 @@ import com.daml.caching.Cache import com.daml.concurrent.{ExecutionContext, Future} import com.daml.ledger.api.domain import com.daml.ledger.api.health.{HealthStatus, Healthy} +import com.daml.ledger.configuration.LedgerId import com.daml.ledger.on.sql.SqlLedgerReaderWriter._ import com.daml.ledger.on.sql.queries.Queries import com.daml.ledger.participant.state.kvutils.api.{ diff --git a/ledger/ledger-on-sql/src/main/scala/com/daml/ledger/on/sql/queries/H2Queries.scala b/ledger/ledger-on-sql/src/main/scala/com/daml/ledger/on/sql/queries/H2Queries.scala index 8218bb4bfec..2e3bc4e358a 100644 --- a/ledger/ledger-on-sql/src/main/scala/com/daml/ledger/on/sql/queries/H2Queries.scala +++ b/ledger/ledger-on-sql/src/main/scala/com/daml/ledger/on/sql/queries/H2Queries.scala @@ -7,10 +7,10 @@ import java.sql.Connection import anorm.SqlParser._ import anorm._ +import com.daml.ledger.configuration.LedgerId import com.daml.ledger.on.sql.Index import com.daml.ledger.on.sql.queries.Queries._ import com.daml.ledger.participant.state.kvutils.Raw -import com.daml.ledger.participant.state.v1.LedgerId import scala.util.Try diff --git a/ledger/ledger-on-sql/src/main/scala/com/daml/ledger/on/sql/queries/PostgresqlQueries.scala b/ledger/ledger-on-sql/src/main/scala/com/daml/ledger/on/sql/queries/PostgresqlQueries.scala index 5e31d78a581..8e17f1897c1 100644 --- a/ledger/ledger-on-sql/src/main/scala/com/daml/ledger/on/sql/queries/PostgresqlQueries.scala +++ b/ledger/ledger-on-sql/src/main/scala/com/daml/ledger/on/sql/queries/PostgresqlQueries.scala @@ -7,10 +7,10 @@ import java.sql.Connection import anorm.SqlParser._ import anorm._ +import com.daml.ledger.configuration.LedgerId import com.daml.ledger.on.sql.Index import com.daml.ledger.on.sql.queries.Queries._ import com.daml.ledger.participant.state.kvutils.Raw -import com.daml.ledger.participant.state.v1.LedgerId import scala.util.Try diff --git a/ledger/ledger-on-sql/src/main/scala/com/daml/ledger/on/sql/queries/SqliteQueries.scala b/ledger/ledger-on-sql/src/main/scala/com/daml/ledger/on/sql/queries/SqliteQueries.scala index a7278e48ac0..5b84287c881 100644 --- a/ledger/ledger-on-sql/src/main/scala/com/daml/ledger/on/sql/queries/SqliteQueries.scala +++ b/ledger/ledger-on-sql/src/main/scala/com/daml/ledger/on/sql/queries/SqliteQueries.scala @@ -7,10 +7,10 @@ import java.sql.Connection import anorm.SqlParser._ import anorm._ +import com.daml.ledger.configuration.LedgerId import com.daml.ledger.on.sql.Index import com.daml.ledger.on.sql.queries.Queries._ import com.daml.ledger.participant.state.kvutils.Raw -import com.daml.ledger.participant.state.v1.LedgerId import scala.util.Try diff --git a/ledger/ledger-on-sql/src/main/scala/com/daml/ledger/on/sql/queries/TimedQueries.scala b/ledger/ledger-on-sql/src/main/scala/com/daml/ledger/on/sql/queries/TimedQueries.scala index 1f3514ad10f..a4ebde89af2 100644 --- a/ledger/ledger-on-sql/src/main/scala/com/daml/ledger/on/sql/queries/TimedQueries.scala +++ b/ledger/ledger-on-sql/src/main/scala/com/daml/ledger/on/sql/queries/TimedQueries.scala @@ -3,10 +3,10 @@ package com.daml.ledger.on.sql.queries +import com.daml.ledger.configuration.LedgerId import com.daml.ledger.on.sql.Index import com.daml.ledger.participant.state.kvutils.Raw import com.daml.ledger.participant.state.kvutils.api.LedgerRecord -import com.daml.ledger.participant.state.v1.LedgerId import com.daml.metrics.{Metrics, Timed} import scala.collection.immutable diff --git a/ledger/ledger-on-sql/src/main/scala/com/daml/ledger/on/sql/queries/WriteQueries.scala b/ledger/ledger-on-sql/src/main/scala/com/daml/ledger/on/sql/queries/WriteQueries.scala index 3fe554ce13a..87db1fa2960 100644 --- a/ledger/ledger-on-sql/src/main/scala/com/daml/ledger/on/sql/queries/WriteQueries.scala +++ b/ledger/ledger-on-sql/src/main/scala/com/daml/ledger/on/sql/queries/WriteQueries.scala @@ -3,9 +3,9 @@ package com.daml.ledger.on.sql.queries +import com.daml.ledger.configuration.LedgerId import com.daml.ledger.on.sql.Index import com.daml.ledger.participant.state.kvutils.Raw -import com.daml.ledger.participant.state.v1.LedgerId import scala.util.Try diff --git a/ledger/ledger-on-sql/src/test/lib/scala/com/daml/ledger/on/sql/SqlLedgerReaderWriterIntegrationSpecBase.scala b/ledger/ledger-on-sql/src/test/lib/scala/com/daml/ledger/on/sql/SqlLedgerReaderWriterIntegrationSpecBase.scala index 615b254d382..e0b230905af 100644 --- a/ledger/ledger-on-sql/src/test/lib/scala/com/daml/ledger/on/sql/SqlLedgerReaderWriterIntegrationSpecBase.scala +++ b/ledger/ledger-on-sql/src/test/lib/scala/com/daml/ledger/on/sql/SqlLedgerReaderWriterIntegrationSpecBase.scala @@ -3,10 +3,11 @@ package com.daml.ledger.on.sql +import com.daml.ledger.configuration.LedgerId import com.daml.ledger.participant.state.kvutils.ParticipantStateIntegrationSpecBase import com.daml.ledger.participant.state.kvutils.ParticipantStateIntegrationSpecBase.ParticipantState import com.daml.ledger.participant.state.kvutils.api.KeyValueParticipantState -import com.daml.ledger.participant.state.v1.{LedgerId, ParticipantId} +import com.daml.ledger.participant.state.v1.ParticipantId import com.daml.ledger.resources.ResourceOwner import com.daml.lf.engine.Engine import com.daml.logging.LoggingContext diff --git a/ledger/participant-integration-api/BUILD.bazel b/ledger/participant-integration-api/BUILD.bazel index 8eff36c6f9a..abf4ac6ab9d 100644 --- a/ledger/participant-integration-api/BUILD.bazel +++ b/ledger/participant-integration-api/BUILD.bazel @@ -35,6 +35,7 @@ compile_deps = [ "//ledger/ledger-api-common", "//ledger/ledger-api-domain", "//ledger/ledger-api-health", + "//ledger/ledger-configuration", "//ledger/ledger-resources", "//ledger/metrics", "//ledger/participant-state", @@ -168,6 +169,7 @@ da_scala_library( "//ledger/ledger-api-common", "//ledger/ledger-api-domain", "//ledger/ledger-api-health", + "//ledger/ledger-configuration", "//ledger/ledger-resources", "//ledger/metrics", "//ledger/participant-state", @@ -249,6 +251,7 @@ da_scala_test_suite( "//ledger/ledger-api-common:ledger-api-common-scala-tests-lib", "//ledger/ledger-api-domain", "//ledger/ledger-api-health", + "//ledger/ledger-configuration", "//ledger/ledger-resources", "//ledger/ledger-resources:ledger-resources-test-lib", "//ledger/metrics", @@ -324,6 +327,7 @@ da_scala_test_suite( "//ledger/ledger-api-common", "//ledger/ledger-api-domain", "//ledger/ledger-api-health", + "//ledger/ledger-configuration", "//ledger/ledger-resources", "//ledger/participant-state", "//ledger/participant-state-index", diff --git a/ledger/participant-integration-api/src/main/scala/platform/apiserver/SpannedIndexService.scala b/ledger/participant-integration-api/src/main/scala/platform/apiserver/SpannedIndexService.scala index 11733ac890f..3f65b6ab58a 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/apiserver/SpannedIndexService.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/apiserver/SpannedIndexService.scala @@ -26,6 +26,7 @@ import com.daml.ledger.api.v1.transaction_service.{ GetTransactionsResponse, } import com.daml.ledger.api.{TraceIdentifiers, domain} +import com.daml.ledger.configuration.Configuration import com.daml.ledger.participant.state.index.v2 import com.daml.ledger.participant.state.index.v2.IndexService import com.daml.ledger.participant.state.v1._ diff --git a/ledger/participant-integration-api/src/main/scala/platform/apiserver/StandaloneApiServer.scala b/ledger/participant-integration-api/src/main/scala/platform/apiserver/StandaloneApiServer.scala index dfbfb953c92..186f26223ed 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/apiserver/StandaloneApiServer.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/apiserver/StandaloneApiServer.scala @@ -14,7 +14,8 @@ import com.daml.ledger.api.auth.interceptor.AuthorizationInterceptor import com.daml.ledger.api.auth.{AuthService, Authorizer} import com.daml.ledger.api.domain import com.daml.ledger.api.health.HealthChecks -import com.daml.ledger.participant.state.v1.{LedgerId, ParticipantId, WriteService} +import com.daml.ledger.configuration.LedgerId +import com.daml.ledger.participant.state.v1.{ParticipantId, WriteService} import com.daml.ledger.resources.{Resource, ResourceContext, ResourceOwner} import com.daml.lf.engine.{Engine, ValueEnricher} import com.daml.logging.{ContextualizedLogger, LoggingContext} diff --git a/ledger/participant-integration-api/src/main/scala/platform/apiserver/TimedIndexService.scala b/ledger/participant-integration-api/src/main/scala/platform/apiserver/TimedIndexService.scala index 3f05a0310d6..0f4d0f3d4e0 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/apiserver/TimedIndexService.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/apiserver/TimedIndexService.scala @@ -26,9 +26,10 @@ import com.daml.ledger.api.v1.transaction_service.{ GetTransactionTreesResponse, GetTransactionsResponse, } +import com.daml.ledger.configuration.Configuration import com.daml.ledger.participant.state.index.v2 import com.daml.ledger.participant.state.index.v2.IndexService -import com.daml.ledger.participant.state.v1.{Configuration, Offset, PackageId, ParticipantId, Party} +import com.daml.ledger.participant.state.v1.{Offset, PackageId, ParticipantId, Party} import com.daml.lf.data.Ref import com.daml.lf.language.Ast import com.daml.lf.transaction.GlobalKey diff --git a/ledger/participant-integration-api/src/main/scala/platform/apiserver/services/ApiCommandService.scala b/ledger/participant-integration-api/src/main/scala/platform/apiserver/services/ApiCommandService.scala index 3b6a05a9007..c615e77d38f 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/apiserver/services/ApiCommandService.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/apiserver/services/ApiCommandService.scala @@ -26,7 +26,7 @@ import com.daml.ledger.api.v1.transaction_service.{ } import com.daml.ledger.api.validation.CommandsValidator import com.daml.ledger.client.services.commands.{CommandCompletionSource, CommandTrackerFlow} -import com.daml.ledger.participant.state.v1.{Configuration => LedgerConfiguration} +import com.daml.ledger.configuration.{Configuration => LedgerConfiguration} import com.daml.logging.LoggingContext.withEnrichedLoggingContext import com.daml.logging.{ContextualizedLogger, LoggingContext} import com.daml.metrics.Metrics diff --git a/ledger/participant-integration-api/src/main/scala/platform/apiserver/services/ApiSubmissionService.scala b/ledger/participant-integration-api/src/main/scala/platform/apiserver/services/ApiSubmissionService.scala index ac35cb1b210..237d9252d54 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/apiserver/services/ApiSubmissionService.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/apiserver/services/ApiSubmissionService.scala @@ -9,6 +9,7 @@ import java.util.UUID import com.daml.api.util.TimeProvider import com.daml.ledger.api.domain.{LedgerId, Commands => ApiCommands} import com.daml.ledger.api.messages.command.submission.SubmitRequest +import com.daml.ledger.configuration.Configuration import com.daml.ledger.participant.state.index.v2._ import com.daml.ledger.participant.state.v1 import com.daml.ledger.participant.state.v1.SubmissionResult.{ @@ -18,7 +19,7 @@ import com.daml.ledger.participant.state.v1.SubmissionResult.{ Overloaded, SynchronousReject, } -import com.daml.ledger.participant.state.v1.{Configuration, SubmissionResult, WriteService} +import com.daml.ledger.participant.state.v1.{SubmissionResult, WriteService} import com.daml.lf.crypto import com.daml.lf.data.Ref.Party import com.daml.lf.engine.{Error => LfError} diff --git a/ledger/participant-integration-api/src/main/scala/platform/apiserver/services/LedgerConfigProvider.scala b/ledger/participant-integration-api/src/main/scala/platform/apiserver/services/LedgerConfigProvider.scala index 0906347134c..9ca2e29e57f 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/apiserver/services/LedgerConfigProvider.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/apiserver/services/LedgerConfigProvider.scala @@ -12,13 +12,9 @@ import akka.{Done, NotUsed} import com.daml.api.util.TimeProvider import com.daml.ledger.api.domain import com.daml.ledger.api.domain.LedgerOffset +import com.daml.ledger.configuration.Configuration import com.daml.ledger.participant.state.index.v2.IndexConfigManagementService -import com.daml.ledger.participant.state.v1.{ - Configuration, - SubmissionId, - SubmissionResult, - WriteConfigService, -} +import com.daml.ledger.participant.state.v1.{SubmissionId, SubmissionResult, WriteConfigService} import com.daml.ledger.resources.ResourceOwner import com.daml.lf.data.Time.Timestamp import com.daml.logging.{ContextualizedLogger, LoggingContext} diff --git a/ledger/participant-integration-api/src/main/scala/platform/apiserver/services/admin/ApiConfigManagementService.scala b/ledger/participant-integration-api/src/main/scala/platform/apiserver/services/admin/ApiConfigManagementService.scala index 9cb426b7795..f92e756c31e 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/apiserver/services/admin/ApiConfigManagementService.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/apiserver/services/admin/ApiConfigManagementService.scala @@ -12,14 +12,9 @@ import com.daml.ledger.api.domain import com.daml.ledger.api.domain.{ConfigurationEntry, LedgerOffset} import com.daml.ledger.api.v1.admin.config_management_service.ConfigManagementServiceGrpc.ConfigManagementService import com.daml.ledger.api.v1.admin.config_management_service._ +import com.daml.ledger.configuration.{Configuration, LedgerTimeModel} import com.daml.ledger.participant.state.index.v2.IndexConfigManagementService -import com.daml.ledger.participant.state.v1 -import com.daml.ledger.participant.state.v1.{ - Configuration, - SubmissionId, - SubmissionResult, - WriteConfigService, -} +import com.daml.ledger.participant.state.v1.{SubmissionId, SubmissionResult, WriteConfigService} import com.daml.lf.data.Time import com.daml.logging.LoggingContext.withEnrichedLoggingContext import com.daml.logging.{ContextualizedLogger, LoggingContext} @@ -27,8 +22,8 @@ import com.daml.platform.api.grpc.GrpcApiService import com.daml.platform.apiserver.services.admin.ApiConfigManagementService._ import com.daml.platform.apiserver.services.logging import com.daml.platform.configuration.LedgerConfiguration -import com.daml.platform.server.api.{ValidationLogger, validation} import com.daml.platform.server.api.validation.ErrorFactories +import com.daml.platform.server.api.{ValidationLogger, validation} import com.daml.telemetry.{DefaultTelemetry, TelemetryContext} import io.grpc.{ServerServiceDefinition, StatusRuntimeException} @@ -147,7 +142,7 @@ private[apiserver] final class ApiConfigManagementService private ( } private case class SetTimeModelParameters( - newTimeModel: v1.TimeModel, + newTimeModel: LedgerTimeModel, maximumRecordTime: Time.Timestamp, timeToLive: FiniteDuration, ) @@ -164,7 +159,7 @@ private[apiserver] final class ApiConfigManagementService private ( ) pMinSkew <- requirePresence(pTimeModel.minSkew, "min_skew") pMaxSkew <- requirePresence(pTimeModel.maxSkew, "max_skew") - newTimeModel <- v1.TimeModel( + newTimeModel <- LedgerTimeModel( avgTransactionLatency = DurationConversion.fromProto(pAvgTransactionLatency), minSkew = DurationConversion.fromProto(pMinSkew), maxSkew = DurationConversion.fromProto(pMaxSkew), diff --git a/ledger/participant-integration-api/src/main/scala/platform/configuration/LedgerConfiguration.scala b/ledger/participant-integration-api/src/main/scala/platform/configuration/LedgerConfiguration.scala index aac7ce26a4b..ea44e25dd85 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/configuration/LedgerConfiguration.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/configuration/LedgerConfiguration.scala @@ -5,7 +5,7 @@ package com.daml.platform.configuration import java.time.Duration -import com.daml.ledger.participant.state.v1.{Configuration, TimeModel} +import com.daml.ledger.configuration.{Configuration, LedgerTimeModel} /** Configuration surrounding ledger parameters. * @@ -35,7 +35,7 @@ object LedgerConfiguration { private val reasonableInitialConfiguration: Configuration = Configuration( generation = StartingGeneration, - timeModel = TimeModel.reasonableDefault, + timeModel = LedgerTimeModel.reasonableDefault, maxDeduplicationTime = Duration.ofDays(1), ) diff --git a/ledger/participant-integration-api/src/main/scala/platform/index/LedgerBackedIndexService.scala b/ledger/participant-integration-api/src/main/scala/platform/index/LedgerBackedIndexService.scala index 45e0e750cc2..3fe6b6fda61 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/index/LedgerBackedIndexService.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/index/LedgerBackedIndexService.scala @@ -31,8 +31,9 @@ import com.daml.ledger.api.v1.transaction_service.{ GetTransactionTreesResponse, GetTransactionsResponse, } +import com.daml.ledger.configuration.Configuration import com.daml.ledger.participant.state.index.v2._ -import com.daml.ledger.participant.state.v1.{Configuration, Offset, ParticipantId} +import com.daml.ledger.participant.state.v1.{Offset, ParticipantId} import com.daml.lf.data.Ref import com.daml.lf.data.Ref.{Identifier, PackageId, Party} import com.daml.lf.language.Ast diff --git a/ledger/participant-integration-api/src/main/scala/platform/index/MeteredReadOnlyLedger.scala b/ledger/participant-integration-api/src/main/scala/platform/index/MeteredReadOnlyLedger.scala index 829851b5f15..d70796ae0c7 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/index/MeteredReadOnlyLedger.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/index/MeteredReadOnlyLedger.scala @@ -19,8 +19,9 @@ import com.daml.ledger.api.v1.transaction_service.{ GetTransactionTreesResponse, GetTransactionsResponse, } +import com.daml.ledger.configuration.Configuration import com.daml.ledger.participant.state.index.v2.{CommandDeduplicationResult, PackageDetails} -import com.daml.ledger.participant.state.v1.{Configuration, Offset} +import com.daml.ledger.participant.state.v1.Offset import com.daml.lf.data.Ref import com.daml.lf.data.Ref.{Identifier, PackageId, Party} import com.daml.lf.language.Ast diff --git a/ledger/participant-integration-api/src/main/scala/platform/store/BaseLedger.scala b/ledger/participant-integration-api/src/main/scala/platform/store/BaseLedger.scala index 9c1e19a228f..40352708d48 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/store/BaseLedger.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/store/BaseLedger.scala @@ -21,9 +21,10 @@ import com.daml.ledger.api.v1.transaction_service.{ GetTransactionTreesResponse, GetTransactionsResponse, } +import com.daml.ledger.configuration.Configuration import com.daml.ledger.participant.state.index.v2 import com.daml.ledger.participant.state.index.v2.{CommandDeduplicationResult, ContractStore} -import com.daml.ledger.participant.state.v1.{Configuration, Offset} +import com.daml.ledger.participant.state.v1.Offset import com.daml.lf.archive.Decode import com.daml.lf.data.Ref import com.daml.lf.data.Ref.{Identifier, PackageId, Party} diff --git a/ledger/participant-integration-api/src/main/scala/platform/store/ReadOnlyLedger.scala b/ledger/participant-integration-api/src/main/scala/platform/store/ReadOnlyLedger.scala index c48385f24e7..53ccfad768c 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/store/ReadOnlyLedger.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/store/ReadOnlyLedger.scala @@ -19,8 +19,9 @@ import com.daml.ledger.api.v1.transaction_service.{ GetTransactionTreesResponse, GetTransactionsResponse, } +import com.daml.ledger.configuration.Configuration import com.daml.ledger.participant.state.index.v2.{CommandDeduplicationResult, PackageDetails} -import com.daml.ledger.participant.state.v1.{Configuration, Offset} +import com.daml.ledger.participant.state.v1.Offset import com.daml.lf.data.Ref import com.daml.lf.data.Ref.{Identifier, PackageId, Party} import com.daml.lf.language.Ast diff --git a/ledger/participant-integration-api/src/main/scala/platform/store/appendonlydao/JdbcLedgerDao.scala b/ledger/participant-integration-api/src/main/scala/platform/store/appendonlydao/JdbcLedgerDao.scala index 367a6a298de..854210cd87f 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/store/appendonlydao/JdbcLedgerDao.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/store/appendonlydao/JdbcLedgerDao.scala @@ -11,6 +11,7 @@ import com.daml.daml_lf_dev.DamlLf.Archive import com.daml.ledger.api.domain import com.daml.ledger.api.domain.{LedgerId, ParticipantId, PartyDetails} import com.daml.ledger.api.health.HealthStatus +import com.daml.ledger.configuration.Configuration import com.daml.ledger.participant.state.index.v2.{ CommandDeduplicationDuplicate, CommandDeduplicationNew, diff --git a/ledger/participant-integration-api/src/main/scala/platform/store/backend/StorageBackend.scala b/ledger/participant-integration-api/src/main/scala/platform/store/backend/StorageBackend.scala index ac9a2c87da5..a18da98aca5 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/store/backend/StorageBackend.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/store/backend/StorageBackend.scala @@ -10,8 +10,9 @@ import java.time.Instant import com.daml.ledger.{ApplicationId, TransactionId} import com.daml.ledger.api.domain.{LedgerId, ParticipantId, PartyDetails} import com.daml.ledger.api.v1.command_completion_service.CompletionStreamResponse +import com.daml.ledger.configuration.Configuration import com.daml.ledger.participant.state.index.v2.PackageDetails -import com.daml.ledger.participant.state.v1.{Configuration, Offset} +import com.daml.ledger.participant.state.v1.Offset import com.daml.lf.data.Ref import com.daml.lf.data.Ref.PackageId import com.daml.lf.ledger.EventId diff --git a/ledger/participant-integration-api/src/main/scala/platform/store/backend/UpdateToDbDto.scala b/ledger/participant-integration-api/src/main/scala/platform/store/backend/UpdateToDbDto.scala index e750ffb1c02..6ae44bd0c25 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/store/backend/UpdateToDbDto.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/store/backend/UpdateToDbDto.scala @@ -6,7 +6,8 @@ package com.daml.platform.store.backend import java.util.UUID import com.daml.ledger.api.domain -import com.daml.ledger.participant.state.v1.{Configuration, Offset, ParticipantId, Update} +import com.daml.ledger.configuration.Configuration +import com.daml.ledger.participant.state.v1.{Offset, ParticipantId, Update} import com.daml.lf.engine.Blinding import com.daml.lf.ledger.EventId import com.daml.platform.store.appendonlydao.JdbcLedgerDao diff --git a/ledger/participant-integration-api/src/main/scala/platform/store/backend/common/CommonStorageBackend.scala b/ledger/participant-integration-api/src/main/scala/platform/store/backend/common/CommonStorageBackend.scala index f017a7939c3..5b977245d25 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/store/backend/common/CommonStorageBackend.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/store/backend/common/CommonStorageBackend.scala @@ -10,6 +10,7 @@ import java.util.Date import anorm.SqlParser.{array, binaryStream, bool, byteArray, date, flatten, get, int, long, str} import anorm.{Macro, Row, RowParser, SQL, SimpleSql, SqlParser, SqlStringInterpolation, ~} import com.daml.ledger.api.domain.{LedgerId, ParticipantId, PartyDetails} +import com.daml.ledger.configuration.Configuration import com.daml.ledger.participant.state.index.v2.PackageDetails import com.daml.platform.store.Conversions.{ contractId, @@ -21,7 +22,7 @@ import com.daml.platform.store.Conversions.{ offset, party, } -import com.daml.ledger.participant.state.v1.{Configuration, Offset} +import com.daml.ledger.participant.state.v1.Offset import com.daml.lf.data.Ref import com.daml.lf.data.Ref.PackageId import com.daml.platform.store.Conversions diff --git a/ledger/participant-integration-api/src/main/scala/platform/store/dao/JdbcLedgerDao.scala b/ledger/participant-integration-api/src/main/scala/platform/store/dao/JdbcLedgerDao.scala index 7a0079e0d89..21d6a1729b0 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/store/dao/JdbcLedgerDao.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/store/dao/JdbcLedgerDao.scala @@ -25,6 +25,7 @@ import com.daml.daml_lf_dev.DamlLf.Archive import com.daml.ledger.api.domain import com.daml.ledger.api.domain.{LedgerId, ParticipantId, PartyDetails} import com.daml.ledger.api.health.HealthStatus +import com.daml.ledger.configuration.Configuration import com.daml.ledger.participant.state.index.v2.{ CommandDeduplicationDuplicate, CommandDeduplicationNew, diff --git a/ledger/participant-integration-api/src/main/scala/platform/store/dao/LedgerDao.scala b/ledger/participant-integration-api/src/main/scala/platform/store/dao/LedgerDao.scala index b5b4ffbf421..acd84dbf599 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/store/dao/LedgerDao.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/store/dao/LedgerDao.scala @@ -18,6 +18,7 @@ import com.daml.ledger.api.v1.transaction_service.{ GetTransactionTreesResponse, GetTransactionsResponse, } +import com.daml.ledger.configuration.Configuration import com.daml.ledger.participant.state.index.v2.{CommandDeduplicationResult, PackageDetails} import com.daml.ledger.participant.state.v1._ import com.daml.ledger.{ApplicationId, WorkflowId} @@ -26,9 +27,8 @@ import com.daml.lf.data.Ref.{PackageId, Party} import com.daml.lf.transaction.BlindingInfo import com.daml.logging.LoggingContext import com.daml.platform.indexer.OffsetStep -import com.daml.platform.store.dao.events.ContractStateEvent import com.daml.platform.store.dao.events.TransactionsWriter.PreparedInsert -import com.daml.platform.store.dao.events.{FilterRelation, TransactionsWriter} +import com.daml.platform.store.dao.events.{ContractStateEvent, FilterRelation, TransactionsWriter} import com.daml.platform.store.entries.{ ConfigurationEntry, LedgerEntry, diff --git a/ledger/participant-integration-api/src/main/scala/platform/store/dao/MeteredLedgerDao.scala b/ledger/participant-integration-api/src/main/scala/platform/store/dao/MeteredLedgerDao.scala index e79962876c3..d9d7ef2a784 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/store/dao/MeteredLedgerDao.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/store/dao/MeteredLedgerDao.scala @@ -10,6 +10,7 @@ import akka.stream.scaladsl.Source import com.daml.daml_lf_dev.DamlLf.Archive import com.daml.ledger.api.domain.{CommandId, LedgerId, ParticipantId, PartyDetails} import com.daml.ledger.api.health.HealthStatus +import com.daml.ledger.configuration.Configuration import com.daml.ledger.participant.state.index.v2.{CommandDeduplicationResult, PackageDetails} import com.daml.ledger.participant.state.v1._ import com.daml.ledger.{TransactionId, WorkflowId} diff --git a/ledger/participant-integration-api/src/main/scala/platform/store/dao/ParametersTable.scala b/ledger/participant-integration-api/src/main/scala/platform/store/dao/ParametersTable.scala index c6c11444d6b..8f1bd397da0 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/store/dao/ParametersTable.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/store/dao/ParametersTable.scala @@ -8,7 +8,8 @@ import java.sql.Connection import anorm.SqlParser.byteArray import anorm.{Row, RowParser, SimpleSql, SqlStringInterpolation, ~} import com.daml.ledger.api.domain.{LedgerId, ParticipantId} -import com.daml.ledger.participant.state.v1.{Configuration, Offset} +import com.daml.ledger.configuration.Configuration +import com.daml.ledger.participant.state.v1.Offset import com.daml.platform.indexer.{CurrentOffset, IncrementalOffsetStep, OffsetStep} import com.daml.platform.store.Conversions.{OffsetToStatement, ledgerString, offset, participantId} import com.daml.scalautil.Statement.discard diff --git a/ledger/participant-integration-api/src/main/scala/platform/store/entries/ConfigurationEntry.scala b/ledger/participant-integration-api/src/main/scala/platform/store/entries/ConfigurationEntry.scala index 1124f207222..8e715b3db9f 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/store/entries/ConfigurationEntry.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/store/entries/ConfigurationEntry.scala @@ -4,7 +4,7 @@ package com.daml.platform.store.entries import com.daml.ledger.api.domain -import com.daml.ledger.participant.state.v1.Configuration +import com.daml.ledger.configuration.Configuration private[platform] sealed abstract class ConfigurationEntry extends Product with Serializable { def toDomain: domain.ConfigurationEntry diff --git a/ledger/participant-integration-api/src/test/lib/scala/platform/store/dao/JdbcLedgerDaoConfigurationSpec.scala b/ledger/participant-integration-api/src/test/lib/scala/platform/store/dao/JdbcLedgerDaoConfigurationSpec.scala index e734659f8ae..e2d63fc44c2 100644 --- a/ledger/participant-integration-api/src/test/lib/scala/platform/store/dao/JdbcLedgerDaoConfigurationSpec.scala +++ b/ledger/participant-integration-api/src/test/lib/scala/platform/store/dao/JdbcLedgerDaoConfigurationSpec.scala @@ -9,7 +9,8 @@ import com.daml.platform.store.entries.ConfigurationEntry import org.scalatest.flatspec.AsyncFlatSpec import org.scalatest.matchers.should.Matchers -trait JdbcLedgerDaoConfigurationSpec { this: AsyncFlatSpec with Matchers with JdbcLedgerDaoSuite => +trait JdbcLedgerDaoConfigurationSpec { + this: AsyncFlatSpec with Matchers with JdbcLedgerDaoSuite => behavior of "JdbcLedgerDao (configuration)" diff --git a/ledger/participant-integration-api/src/test/lib/scala/platform/store/dao/JdbcLedgerDaoSuite.scala b/ledger/participant-integration-api/src/test/lib/scala/platform/store/dao/JdbcLedgerDaoSuite.scala index 7db107f1b6b..c7c3439d5f2 100644 --- a/ledger/participant-integration-api/src/test/lib/scala/platform/store/dao/JdbcLedgerDaoSuite.scala +++ b/ledger/participant-integration-api/src/test/lib/scala/platform/store/dao/JdbcLedgerDaoSuite.scala @@ -11,18 +11,19 @@ import java.util.concurrent.atomic.{AtomicLong, AtomicReference} import akka.stream.scaladsl.Sink import com.daml.bazeltools.BazelRunfiles.rlocation import com.daml.daml_lf_dev.DamlLf +import com.daml.ledger.configuration.{Configuration, LedgerTimeModel} import com.daml.ledger.participant.state.index.v2 import com.daml.ledger.participant.state.v1 -import com.daml.ledger.participant.state.v1.{Configuration, DivulgedContract, Offset, SubmitterInfo} +import com.daml.ledger.participant.state.v1.{DivulgedContract, Offset, SubmitterInfo} import com.daml.ledger.test.ModelTestDar import com.daml.lf.archive.DarParser import com.daml.lf.data.Ref.{Identifier, Party} import com.daml.lf.data.{FrontStack, ImmArray, Ref, Time} import com.daml.lf.transaction.Node._ -import com.daml.lf.transaction.test.TransactionBuilder import com.daml.lf.transaction._ -import com.daml.lf.value.{Value => LfValue} +import com.daml.lf.transaction.test.TransactionBuilder import com.daml.lf.value.Value.{ContractId, ContractInst, ValueText} +import com.daml.lf.value.{Value => LfValue} import com.daml.logging.LoggingContext import com.daml.platform.indexer.{CurrentOffset, IncrementalOffsetStep, OffsetStep} import com.daml.platform.store.dao.events.TransactionsWriter @@ -155,9 +156,9 @@ private[dao] trait JdbcLedgerDaoSuite extends JdbcLedgerDaoBackend { ), ) - protected final val defaultConfig = v1.Configuration( + protected final val defaultConfig = Configuration( generation = 0, - timeModel = v1.TimeModel.reasonableDefault, + timeModel = LedgerTimeModel.reasonableDefault, Duration.ofDays(1), ) diff --git a/ledger/participant-integration-api/src/test/suite/scala/db/migration/translation/apiserver/services/admin/ApiConfigManagementServiceSpec.scala b/ledger/participant-integration-api/src/test/suite/scala/db/migration/translation/apiserver/services/admin/ApiConfigManagementServiceSpec.scala index 86015a4a6f3..84351287e23 100644 --- a/ledger/participant-integration-api/src/test/suite/scala/db/migration/translation/apiserver/services/admin/ApiConfigManagementServiceSpec.scala +++ b/ledger/participant-integration-api/src/test/suite/scala/db/migration/translation/apiserver/services/admin/ApiConfigManagementServiceSpec.scala @@ -12,14 +12,9 @@ import com.daml.ledger.api.domain import com.daml.ledger.api.domain.LedgerOffset.Absolute import com.daml.ledger.api.testing.utils.AkkaBeforeAndAfterAll import com.daml.ledger.api.v1.admin.config_management_service.{SetTimeModelRequest, TimeModel} +import com.daml.ledger.configuration.{Configuration, LedgerTimeModel} import com.daml.ledger.participant.state.index.v2.IndexConfigManagementService -import com.daml.ledger.participant.state.v1 -import com.daml.ledger.participant.state.v1.{ - Configuration, - SubmissionId, - SubmissionResult, - WriteConfigService, -} +import com.daml.ledger.participant.state.v1.{SubmissionId, SubmissionResult, WriteConfigService} import com.daml.lf.data.{Ref, Time} import com.daml.logging.LoggingContext import com.daml.platform.configuration.LedgerConfiguration @@ -107,7 +102,7 @@ object ApiConfigManagementServiceSpec { aSubmissionId, Configuration( aConfigurationGeneration, - v1.TimeModel.reasonableDefault, + LedgerTimeModel.reasonableDefault, jDuration.ZERO, ), ) diff --git a/ledger/participant-integration-api/src/test/suite/scala/platform/apiserver/services/ApiSubmissionServiceSpec.scala b/ledger/participant-integration-api/src/test/suite/scala/platform/apiserver/services/ApiSubmissionServiceSpec.scala index 56b3a37965a..6b704b583f6 100644 --- a/ledger/participant-integration-api/src/test/suite/scala/platform/apiserver/services/ApiSubmissionServiceSpec.scala +++ b/ledger/participant-integration-api/src/test/suite/scala/platform/apiserver/services/ApiSubmissionServiceSpec.scala @@ -15,6 +15,7 @@ import com.daml.ledger.api.domain.LedgerOffset.Absolute import com.daml.ledger.api.domain.{CommandId, Commands, LedgerId, PartyDetails} import com.daml.ledger.api.messages.command.submission.SubmitRequest import com.daml.ledger.api.testing.utils.AkkaBeforeAndAfterAll +import com.daml.ledger.configuration.{Configuration, LedgerTimeModel} import com.daml.ledger.participant.state.index.v2.{ CommandDeduplicationNew, IndexConfigManagementService, @@ -295,7 +296,7 @@ class ApiSubmissionServiceSpec val mockMetricRegistry = mock[MetricRegistry] val mockIndexSubmissionService = mock[IndexSubmissionService] val mockConfigManagementService = mock[IndexConfigManagementService] - val configuration = Configuration(0L, TimeModel.reasonableDefault, Duration.ZERO) + val configuration = Configuration(0L, LedgerTimeModel.reasonableDefault, Duration.ZERO) when(mockMetricRegistry.meter(any[String])).thenReturn(new Meter()) when( mockIndexSubmissionService.deduplicateCommand( diff --git a/ledger/participant-integration-api/src/test/suite/scala/platform/apiserver/services/LedgerConfigProviderSpec.scala b/ledger/participant-integration-api/src/test/suite/scala/platform/apiserver/services/LedgerConfigProviderSpec.scala index aebee6a933f..f8ae9f32e51 100644 --- a/ledger/participant-integration-api/src/test/suite/scala/platform/apiserver/services/LedgerConfigProviderSpec.scala +++ b/ledger/participant-integration-api/src/test/suite/scala/platform/apiserver/services/LedgerConfigProviderSpec.scala @@ -12,14 +12,9 @@ import akka.stream.{Materializer, OverflowStrategy} import com.daml.api.util.TimeProvider import com.daml.ledger.api.domain.{ConfigurationEntry, LedgerOffset} import com.daml.ledger.api.testing.utils.AkkaBeforeAndAfterAll +import com.daml.ledger.configuration.{Configuration, LedgerTimeModel} import com.daml.ledger.participant.state.index.v2.IndexConfigManagementService -import com.daml.ledger.participant.state.v1.{ - Configuration, - SubmissionId, - SubmissionResult, - TimeModel, - WriteConfigService, -} +import com.daml.ledger.participant.state.v1.{SubmissionId, SubmissionResult, WriteConfigService} import com.daml.ledger.resources.ResourceContext import com.daml.lf.data.Ref import com.daml.lf.data.Time.Timestamp @@ -144,7 +139,7 @@ object LedgerConfigProviderSpec { } private def configurationWith(generation: Long): Configuration = { - Configuration(generation, TimeModel.reasonableDefault, Duration.ofDays(1)) + Configuration(generation, LedgerTimeModel.reasonableDefault, Duration.ofDays(1)) } private final class FakeWriteConfigService( diff --git a/ledger/participant-integration-api/src/test/suite/scala/platform/indexer/JdbcIndexerSpec.scala b/ledger/participant-integration-api/src/test/suite/scala/platform/indexer/JdbcIndexerSpec.scala index f8af21f3690..c7728be93ec 100644 --- a/ledger/participant-integration-api/src/test/suite/scala/platform/indexer/JdbcIndexerSpec.scala +++ b/ledger/participant-integration-api/src/test/suite/scala/platform/indexer/JdbcIndexerSpec.scala @@ -10,15 +10,9 @@ import akka.stream.scaladsl.{Flow, Source} import ch.qos.logback.classic.Level import com.codahale.metrics.MetricRegistry import com.daml.ledger.api.testing.utils.AkkaBeforeAndAfterAll +import com.daml.ledger.configuration.{Configuration, LedgerInitialConditions, LedgerTimeModel} import com.daml.ledger.participant.state.v1 -import com.daml.ledger.participant.state.v1.{ - Configuration, - LedgerInitialConditions, - Offset, - ReadService, - TimeModel, - Update, -} +import com.daml.ledger.participant.state.v1.{Offset, ReadService, Update} import com.daml.ledger.resources.{ResourceOwner, TestResourceContext} import com.daml.lf.data.Bytes import com.daml.lf.data.Time.Timestamp @@ -27,8 +21,8 @@ import com.daml.metrics.Metrics import com.daml.platform.common.MismatchException import com.daml.platform.configuration.ServerRole import com.daml.platform.indexer -import com.daml.platform.store.{DbType, FlywayMigrations, IndexMetadata, LfValueTranslationCache} import com.daml.platform.store.dao.LedgerDao +import com.daml.platform.store.{DbType, FlywayMigrations, IndexMetadata, LfValueTranslationCache} import com.daml.platform.testing.LogCollector import com.daml.testing.postgresql.PostgresAroundEach import org.mockito.{ArgumentMatchersSugar, MockitoSugar} @@ -59,7 +53,7 @@ final class JdbcIndexerSpec ledgerId = "ledger-id", config = Configuration( generation = 0, - timeModel = TimeModel.reasonableDefault, + timeModel = LedgerTimeModel.reasonableDefault, maxDeduplicationTime = Duration.ofDays(1), ), initialRecordTime = Timestamp.Epoch, diff --git a/ledger/participant-integration-api/src/test/suite/scala/platform/store/backend/UpdateToDbDtoSpec.scala b/ledger/participant-integration-api/src/test/suite/scala/platform/store/backend/UpdateToDbDtoSpec.scala index 24117359ca7..9ee0defd026 100644 --- a/ledger/participant-integration-api/src/test/suite/scala/platform/store/backend/UpdateToDbDtoSpec.scala +++ b/ledger/participant-integration-api/src/test/suite/scala/platform/store/backend/UpdateToDbDtoSpec.scala @@ -8,10 +8,10 @@ import java.time.{Duration, Instant} import com.daml.daml_lf_dev.DamlLf import com.daml.ledger.api.domain import com.daml.ledger.api.v1.event.{CreatedEvent, ExercisedEvent} +import com.daml.ledger.configuration.{Configuration, LedgerTimeModel} import com.daml.ledger.participant.state.v1.{ ApplicationId, CommandId, - Configuration, DivulgedContract, Offset, ParticipantId, @@ -19,7 +19,6 @@ import com.daml.ledger.participant.state.v1.{ RejectionReasonV0, SubmissionId, SubmitterInfo, - TimeModel, TransactionId, TransactionMeta, Update, @@ -1246,7 +1245,7 @@ object UpdateToDbDtoSpec { SubmissionId.assertFromString("UpdateToDbDtoSpecSubmissionId") val someWorkflowId = WorkflowId.assertFromString("UpdateToDbDtoSpecWorkflowId") val someConfiguration = - Configuration(1, TimeModel.reasonableDefault, Duration.ofHours(23)) + Configuration(1, LedgerTimeModel.reasonableDefault, Duration.ofHours(23)) val someParty = Party.assertFromString("UpdateToDbDtoSpecParty") val someHash = crypto.Hash.assertFromString("01cf85cfeb36d628ca2e6f583fa2331be029b6b28e877e1008fb3f862306c086") diff --git a/ledger/participant-state-index/BUILD.bazel b/ledger/participant-state-index/BUILD.bazel index 7f403a1f444..4c9fc902467 100644 --- a/ledger/participant-state-index/BUILD.bazel +++ b/ledger/participant-state-index/BUILD.bazel @@ -28,6 +28,7 @@ da_scala_library( "//ledger-api/grpc-definitions:ledger_api_proto_scala", "//ledger/ledger-api-domain", "//ledger/ledger-api-health", + "//ledger/ledger-configuration", "//ledger/participant-state", "//libs-scala/contextualized-logging", "@maven//:com_google_protobuf_protobuf_java", diff --git a/ledger/participant-state-index/src/main/scala/com/daml/ledger/participant/state/index/v2/IndexConfigManagementService.scala b/ledger/participant-state-index/src/main/scala/com/daml/ledger/participant/state/index/v2/IndexConfigManagementService.scala index 7a147501482..1336c2b2a5f 100644 --- a/ledger/participant-state-index/src/main/scala/com/daml/ledger/participant/state/index/v2/IndexConfigManagementService.scala +++ b/ledger/participant-state-index/src/main/scala/com/daml/ledger/participant/state/index/v2/IndexConfigManagementService.scala @@ -5,8 +5,8 @@ package com.daml.ledger.participant.state.index.v2 import akka.NotUsed import akka.stream.scaladsl.Source -import com.daml.ledger.participant.state.v1.Configuration import com.daml.ledger.api.domain.{ConfigurationEntry, LedgerOffset} +import com.daml.ledger.configuration.Configuration import com.daml.logging.LoggingContext import scala.concurrent.Future diff --git a/ledger/participant-state-metrics/BUILD.bazel b/ledger/participant-state-metrics/BUILD.bazel index 2a5719adb60..8dedc18547b 100644 --- a/ledger/participant-state-metrics/BUILD.bazel +++ b/ledger/participant-state-metrics/BUILD.bazel @@ -24,6 +24,7 @@ da_scala_library( "//daml-lf/data", "//daml-lf/transaction", "//ledger/ledger-api-health", + "//ledger/ledger-configuration", "//ledger/metrics", "//ledger/participant-state", "@maven//:com_google_protobuf_protobuf_java", diff --git a/ledger/participant-state-metrics/src/main/scala/com/daml/ledger/participant/state/v1/metrics/TimedReadService.scala b/ledger/participant-state-metrics/src/main/scala/com/daml/ledger/participant/state/v1/metrics/TimedReadService.scala index 224a9a8ecea..79f3a83dc1e 100644 --- a/ledger/participant-state-metrics/src/main/scala/com/daml/ledger/participant/state/v1/metrics/TimedReadService.scala +++ b/ledger/participant-state-metrics/src/main/scala/com/daml/ledger/participant/state/v1/metrics/TimedReadService.scala @@ -6,7 +6,8 @@ package com.daml.ledger.participant.state.v1.metrics import akka.NotUsed import akka.stream.scaladsl.Source import com.daml.ledger.api.health.HealthStatus -import com.daml.ledger.participant.state.v1.{LedgerInitialConditions, Offset, ReadService, Update} +import com.daml.ledger.configuration.LedgerInitialConditions +import com.daml.ledger.participant.state.v1.{Offset, ReadService, Update} import com.daml.metrics.{Metrics, Timed} final class TimedReadService(delegate: ReadService, metrics: Metrics) extends ReadService { diff --git a/ledger/participant-state-metrics/src/main/scala/com/daml/ledger/participant/state/v1/metrics/TimedWriteService.scala b/ledger/participant-state-metrics/src/main/scala/com/daml/ledger/participant/state/v1/metrics/TimedWriteService.scala index c14bd6d49e2..d10176e6b32 100644 --- a/ledger/participant-state-metrics/src/main/scala/com/daml/ledger/participant/state/v1/metrics/TimedWriteService.scala +++ b/ledger/participant-state-metrics/src/main/scala/com/daml/ledger/participant/state/v1/metrics/TimedWriteService.scala @@ -7,6 +7,7 @@ import java.util.concurrent.CompletionStage import com.daml.daml_lf_dev.DamlLf import com.daml.ledger.api.health.HealthStatus +import com.daml.ledger.configuration.Configuration import com.daml.ledger.participant.state.v1._ import com.daml.lf.data.Time import com.daml.metrics.{Metrics, Timed} diff --git a/ledger/participant-state/BUILD.bazel b/ledger/participant-state/BUILD.bazel index f4273c808ae..fe18dfe94e9 100644 --- a/ledger/participant-state/BUILD.bazel +++ b/ledger/participant-state/BUILD.bazel @@ -20,7 +20,7 @@ da_scala_library( "//visibility:public", ], exports = [ - "//ledger/participant-state/protobuf:ledger_configuration_proto_java", + "//ledger/ledger-configuration/protobuf:ledger_configuration_proto_java", ], runtime_deps = [], deps = [ @@ -30,8 +30,9 @@ da_scala_library( "//language-support/scala/bindings", "//ledger-api/grpc-definitions:ledger_api_proto_scala", "//ledger/ledger-api-health", + "//ledger/ledger-configuration", + "//ledger/ledger-configuration/protobuf:ledger_configuration_proto_java", "//ledger/metrics", - "//ledger/participant-state/protobuf:ledger_configuration_proto_java", "//libs-scala/logging-entries", "@maven//:com_google_protobuf_protobuf_java", ], diff --git a/ledger/participant-state/kvutils/BUILD.bazel b/ledger/participant-state/kvutils/BUILD.bazel index 2d2ad0b5a61..6f4cfc46ccc 100644 --- a/ledger/participant-state/kvutils/BUILD.bazel +++ b/ledger/participant-state/kvutils/BUILD.bazel @@ -53,10 +53,11 @@ da_scala_library( "//ledger/caching", "//ledger/ledger-api-common", "//ledger/ledger-api-health", + "//ledger/ledger-configuration", + "//ledger/ledger-configuration/protobuf:ledger_configuration_proto_java", "//ledger/ledger-resources", "//ledger/metrics", "//ledger/participant-state", - "//ledger/participant-state/protobuf:ledger_configuration_proto_java", "//libs-scala/concurrent", "//libs-scala/contextualized-logging", "//libs-scala/logging-entries", @@ -111,6 +112,7 @@ da_scala_library( "//ledger/ledger-api-common", "//ledger/ledger-api-domain", "//ledger/ledger-api-health", + "//ledger/ledger-configuration", "//ledger/ledger-resources", "//ledger/metrics", "//ledger/participant-state", @@ -170,10 +172,11 @@ da_scala_test_suite( "//ledger/caching", "//ledger/ledger-api-common", "//ledger/ledger-api-health", + "//ledger/ledger-configuration", + "//ledger/ledger-configuration/protobuf:ledger_configuration_proto_java", "//ledger/metrics", "//ledger/participant-state", "//ledger/participant-state/kvutils:dar-files-1.dev-lib", - "//ledger/participant-state/protobuf:ledger_configuration_proto_java", "//ledger/test-common", "//ledger/test-common:dar-files-stable-lib", "//libs-scala/contextualized-logging", @@ -211,7 +214,7 @@ proto_jars( "//daml-lf/archive:daml_lf_dev_archive_proto", "//daml-lf/transaction:transaction_proto", "//daml-lf/transaction:value_proto", - "//ledger/participant-state/protobuf:ledger_configuration_proto", + "//ledger/ledger-configuration/protobuf:ledger_configuration_proto", ], strip_import_prefix = "src/main/protobuf", visibility = ["//visibility:public"], diff --git a/ledger/participant-state/kvutils/app/BUILD.bazel b/ledger/participant-state/kvutils/app/BUILD.bazel index fe9d7f3795c..baca79b2501 100644 --- a/ledger/participant-state/kvutils/app/BUILD.bazel +++ b/ledger/participant-state/kvutils/app/BUILD.bazel @@ -40,6 +40,7 @@ da_scala_library( "//ledger/ledger-api-auth", "//ledger/ledger-api-common", "//ledger/ledger-api-health", + "//ledger/ledger-configuration", "//ledger/ledger-resources", "//ledger/metrics", "//ledger/participant-integration-api", diff --git a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/KeyValueCommitting.scala b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/KeyValueCommitting.scala index 4b715235dc0..29cae5d4616 100644 --- a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/KeyValueCommitting.scala +++ b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/KeyValueCommitting.scala @@ -4,6 +4,7 @@ package com.daml.ledger.participant.state.kvutils import com.daml.daml_lf_dev.DamlLf +import com.daml.ledger.configuration.Configuration import com.daml.ledger.participant.state.kvutils.Conversions._ import com.daml.ledger.participant.state.kvutils.DamlKvutils._ import com.daml.ledger.participant.state.kvutils.KeyValueCommitting.PreExecutionResult @@ -14,7 +15,7 @@ import com.daml.ledger.participant.state.kvutils.committer.{ PartyAllocationCommitter, SubmissionExecutor, } -import com.daml.ledger.participant.state.v1.{Configuration, ParticipantId} +import com.daml.ledger.participant.state.v1.ParticipantId import com.daml.lf.data.Time.Timestamp import com.daml.lf.engine.Engine import com.daml.lf.transaction.{GlobalKey, TransactionCoder, TransactionOuterClass} diff --git a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/KeyValueConsumption.scala b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/KeyValueConsumption.scala index d1f5b8c6290..97ccc6d1dec 100644 --- a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/KeyValueConsumption.scala +++ b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/KeyValueConsumption.scala @@ -3,6 +3,7 @@ package com.daml.ledger.participant.state.kvutils +import com.daml.ledger.configuration.Configuration import com.daml.ledger.participant.state.kvutils.Conversions._ import com.daml.ledger.participant.state.kvutils.DamlKvutils._ import com.daml.ledger.participant.state.v1._ diff --git a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/KeyValueSubmission.scala b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/KeyValueSubmission.scala index bad1dff13db..36f0e8a40d8 100644 --- a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/KeyValueSubmission.scala +++ b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/KeyValueSubmission.scala @@ -4,6 +4,7 @@ package com.daml.ledger.participant.state.kvutils import com.daml.daml_lf_dev.DamlLf.Archive +import com.daml.ledger.configuration.Configuration import com.daml.ledger.participant.state.kvutils.Conversions._ import com.daml.ledger.participant.state.kvutils.DamlKvutils._ import com.daml.ledger.participant.state.v1._ diff --git a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/api/KeyValueParticipantState.scala b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/api/KeyValueParticipantState.scala index 312ddd99dd2..3cfc3c99639 100644 --- a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/api/KeyValueParticipantState.scala +++ b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/api/KeyValueParticipantState.scala @@ -9,6 +9,7 @@ import akka.NotUsed import akka.stream.scaladsl.Source import com.daml.daml_lf_dev.DamlLf import com.daml.ledger.api.health.HealthStatus +import com.daml.ledger.configuration.{Configuration, LedgerInitialConditions} import com.daml.ledger.participant.state.v1._ import com.daml.lf.data.Time import com.daml.metrics.Metrics diff --git a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/api/KeyValueParticipantStateReader.scala b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/api/KeyValueParticipantStateReader.scala index 2cf027801b9..99fa284252c 100644 --- a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/api/KeyValueParticipantStateReader.scala +++ b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/api/KeyValueParticipantStateReader.scala @@ -6,6 +6,7 @@ package com.daml.ledger.participant.state.kvutils.api import akka.NotUsed import akka.stream.scaladsl.Source import com.daml.ledger.api.health.HealthStatus +import com.daml.ledger.configuration.LedgerInitialConditions import com.daml.ledger.participant.state.kvutils.DamlKvutils.{DamlLogEntry, DamlLogEntryId} import com.daml.ledger.participant.state.kvutils.{Envelope, KeyValueConsumption, OffsetBuilder} import com.daml.ledger.participant.state.v1._ diff --git a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/api/KeyValueParticipantStateWriter.scala b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/api/KeyValueParticipantStateWriter.scala index c8786af7b70..5ab78e6cc2e 100644 --- a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/api/KeyValueParticipantStateWriter.scala +++ b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/api/KeyValueParticipantStateWriter.scala @@ -8,6 +8,7 @@ import java.util.concurrent.{CompletableFuture, CompletionStage} import com.daml.daml_lf_dev.DamlLf import com.daml.ledger.api.health.HealthStatus +import com.daml.ledger.configuration.Configuration import com.daml.ledger.participant.state.kvutils.DamlKvutils.DamlSubmission import com.daml.ledger.participant.state.kvutils.{Envelope, KeyValueSubmission} import com.daml.ledger.participant.state.v1._ diff --git a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/api/LedgerReader.scala b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/api/LedgerReader.scala index c0aeac5a7d4..ce0197e8495 100644 --- a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/api/LedgerReader.scala +++ b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/api/LedgerReader.scala @@ -7,8 +7,9 @@ import java.time.Duration import akka.NotUsed import akka.stream.scaladsl.Source -import com.daml.ledger.participant.state.v1.{Configuration, LedgerId, Offset, TimeModel} import com.daml.ledger.api.health.ReportsHealth +import com.daml.ledger.configuration.{Configuration, LedgerId, LedgerTimeModel} +import com.daml.ledger.participant.state.v1.Offset /** Defines how a participant's state is read from the ledger. * @@ -45,7 +46,7 @@ object LedgerReader { */ val DefaultConfiguration: Configuration = Configuration( generation = 0, - timeModel = TimeModel.reasonableDefault, + timeModel = LedgerTimeModel.reasonableDefault, maxDeduplicationTime = Duration.ofDays(1), ) } diff --git a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/api/package.scala b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/api/package.scala index afdee9b0e65..68f19b5197b 100644 --- a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/api/package.scala +++ b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/api/package.scala @@ -6,7 +6,8 @@ package com.daml.ledger.participant.state.kvutils import akka.NotUsed import akka.stream.scaladsl.Source import com.daml.ledger.api.health.HealthStatus -import com.daml.ledger.participant.state.v1.{LedgerId, Offset, ParticipantId, SubmissionResult} +import com.daml.ledger.configuration.LedgerId +import com.daml.ledger.participant.state.v1.{Offset, ParticipantId, SubmissionResult} import com.daml.telemetry.TelemetryContext import scala.concurrent.Future @@ -16,7 +17,7 @@ import scala.concurrent.Future * =Interfaces= * The main interfaces that you need to implement to be able to run a participant server are as follows: * - [[com.daml.ledger.participant.state.kvutils.api.LedgerWriter]]: Defines how you submit requests to the ledger - * as opaque bytes. + * as opaque bytes. * - [[com.daml.ledger.participant.state.kvutils.api.LedgerReader]]: Defines how you read committed key-value pairs * from the ledger as opaque bytes. * diff --git a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/committer/Committer.scala b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/committer/Committer.scala index 36c749a155b..f25798d8f08 100644 --- a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/committer/Committer.scala +++ b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/committer/Committer.scala @@ -4,6 +4,7 @@ package com.daml.ledger.participant.state.kvutils.committer import com.codahale.metrics.Timer +import com.daml.ledger.configuration.Configuration import com.daml.ledger.participant.state.kvutils.Conversions.buildTimestamp import com.daml.ledger.participant.state.kvutils.DamlKvutils.{ DamlConfigurationEntry, @@ -15,7 +16,7 @@ import com.daml.ledger.participant.state.kvutils.DamlKvutils.{ } import com.daml.ledger.participant.state.kvutils.KeyValueCommitting.PreExecutionResult import com.daml.ledger.participant.state.kvutils._ -import com.daml.ledger.participant.state.v1.{Configuration, ParticipantId} +import com.daml.ledger.participant.state.v1.ParticipantId import com.daml.lf.data.Time import com.daml.lf.data.Time.Timestamp import com.daml.logging.LoggingContext.withEnrichedLoggingContextFrom diff --git a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/committer/ConfigCommitter.scala b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/committer/ConfigCommitter.scala index 32af1dfc942..fad128e24be 100644 --- a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/committer/ConfigCommitter.scala +++ b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/committer/ConfigCommitter.scala @@ -3,6 +3,7 @@ package com.daml.ledger.participant.state.kvutils.committer +import com.daml.ledger.configuration.Configuration import com.daml.ledger.participant.state.kvutils.Conversions.{ buildTimestamp, configDedupKey, @@ -10,7 +11,6 @@ import com.daml.ledger.participant.state.kvutils.Conversions.{ } import com.daml.ledger.participant.state.kvutils.DamlKvutils._ import com.daml.ledger.participant.state.kvutils.committer.Committer._ -import com.daml.ledger.participant.state.v1.Configuration import com.daml.lf.data.Time.Timestamp import com.daml.logging.entries.LoggingEntries import com.daml.logging.{ContextualizedLogger, LoggingContext} diff --git a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/committer/transaction/TransactionCommitter.scala b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/committer/transaction/TransactionCommitter.scala index 617e571f222..243c4fbfee4 100644 --- a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/committer/transaction/TransactionCommitter.scala +++ b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/committer/transaction/TransactionCommitter.scala @@ -5,6 +5,7 @@ package com.daml.ledger.participant.state.kvutils.committer.transaction import java.time.Instant +import com.daml.ledger.configuration.Configuration import com.daml.ledger.participant.state.kvutils.Conversions._ import com.daml.ledger.participant.state.kvutils.DamlKvutils._ import com.daml.ledger.participant.state.kvutils.committer.Committer._ @@ -15,7 +16,7 @@ import com.daml.ledger.participant.state.kvutils.committer.transaction.validatio ModelConformanceValidator, } import com.daml.ledger.participant.state.kvutils.{Conversions, Err} -import com.daml.ledger.participant.state.v1.{Configuration, RejectionReasonV0} +import com.daml.ledger.participant.state.v1.RejectionReasonV0 import com.daml.lf.data.Ref.Party import com.daml.lf.engine.{Blinding, Engine} import com.daml.lf.transaction.{BlindingInfo, TransactionOuterClass} diff --git a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/committer/transaction/validation/LedgerTimeValidator.scala b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/committer/transaction/validation/LedgerTimeValidator.scala index 0a042bb0cdb..66ccecad18b 100644 --- a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/committer/transaction/validation/LedgerTimeValidator.scala +++ b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/committer/transaction/validation/LedgerTimeValidator.scala @@ -5,6 +5,7 @@ package com.daml.ledger.participant.state.kvutils.committer.transaction.validati import java.time.Instant +import com.daml.ledger.configuration.{Configuration, LedgerTimeModel} import com.daml.ledger.participant.state.kvutils.Conversions.{commandDedupKey, parseTimestamp} import com.daml.ledger.participant.state.kvutils.DamlKvutils.DamlLogEntry import com.daml.ledger.participant.state.kvutils.committer.Committer.getCurrentConfiguration @@ -14,7 +15,7 @@ import com.daml.ledger.participant.state.kvutils.committer.transaction.{ Step, } import com.daml.ledger.participant.state.kvutils.committer.{CommitContext, StepContinue, StepResult} -import com.daml.ledger.participant.state.v1.{Configuration, RejectionReasonV0, TimeModel} +import com.daml.ledger.participant.state.v1.RejectionReasonV0 import com.daml.lf.data.Time.Timestamp import com.daml.logging.LoggingContext @@ -84,7 +85,7 @@ private[transaction] class LedgerTimeValidator(defaultConfig: Configuration) submissionTime: Instant, ledgerTime: Instant, maybeDeduplicateUntil: Option[Instant], - timeModel: TimeModel, + timeModel: LedgerTimeModel, ): Instant = List( maybeDeduplicateUntil @@ -98,7 +99,7 @@ private[transaction] class LedgerTimeValidator(defaultConfig: Configuration) private def transactionMaxRecordTime( submissionTime: Instant, ledgerTime: Instant, - timeModel: TimeModel, + timeModel: LedgerTimeModel, ): Instant = List(timeModel.maxRecordTime(ledgerTime), timeModel.maxRecordTime(submissionTime)).min diff --git a/ledger/participant-state/kvutils/src/test/lib/scala/com/daml/ledger/participant/state/kvutils/KVTest.scala b/ledger/participant-state/kvutils/src/test/lib/scala/com/daml/ledger/participant/state/kvutils/KVTest.scala index 656eb88f1e5..67a48ceb0eb 100644 --- a/ledger/participant-state/kvutils/src/test/lib/scala/com/daml/ledger/participant/state/kvutils/KVTest.scala +++ b/ledger/participant-state/kvutils/src/test/lib/scala/com/daml/ledger/participant/state/kvutils/KVTest.scala @@ -7,6 +7,7 @@ import java.time.Duration import com.codahale.metrics.MetricRegistry import com.daml.daml_lf_dev.DamlLf +import com.daml.ledger.configuration.Configuration import com.daml.ledger.participant.state.kvutils.DamlKvutils._ import com.daml.ledger.participant.state.kvutils.KeyValueCommitting.PreExecutionResult import com.daml.ledger.participant.state.v1._ diff --git a/ledger/participant-state/kvutils/src/test/lib/scala/com/daml/ledger/participant/state/kvutils/ParticipantStateIntegrationSpecBase.scala b/ledger/participant-state/kvutils/src/test/lib/scala/com/daml/ledger/participant/state/kvutils/ParticipantStateIntegrationSpecBase.scala index 6255a167d85..b0e7f6e33f2 100644 --- a/ledger/participant-state/kvutils/src/test/lib/scala/com/daml/ledger/participant/state/kvutils/ParticipantStateIntegrationSpecBase.scala +++ b/ledger/participant-state/kvutils/src/test/lib/scala/com/daml/ledger/participant/state/kvutils/ParticipantStateIntegrationSpecBase.scala @@ -11,6 +11,7 @@ import akka.stream.scaladsl.Sink import com.codahale.metrics.MetricRegistry import com.daml.daml_lf_dev.DamlLf import com.daml.ledger.api.testing.utils.AkkaBeforeAndAfterAll +import com.daml.ledger.configuration.{LedgerId, LedgerTimeModel} import com.daml.ledger.participant.state.kvutils.OffsetBuilder.{fromLong => toOffset} import com.daml.ledger.participant.state.kvutils.ParticipantStateIntegrationSpecBase._ import com.daml.ledger.participant.state.v1.Update._ @@ -26,17 +27,17 @@ import com.daml.lf.transaction.test.TransactionBuilder import com.daml.logging.LoggingContext import com.daml.logging.LoggingContext.newLoggingContext import com.daml.metrics.Metrics -import com.daml.telemetry.{NoOpTelemetryContext, TelemetryContext} import com.daml.platform.common.MismatchException import com.daml.platform.testing.TestDarReader +import com.daml.telemetry.{NoOpTelemetryContext, TelemetryContext} import org.scalatest.Inside._ import org.scalatest.matchers.should.Matchers._ import org.scalatest.wordspec.AsyncWordSpec import org.scalatest.{Assertion, BeforeAndAfterEach} import scala.collection.compat._ -import scala.collection.mutable import scala.collection.immutable.SortedSet +import scala.collection.mutable import scala.compat.java8.FutureConverters._ import scala.concurrent.duration.{DurationInt, FiniteDuration} import scala.concurrent.{ExecutionContext, Future, TimeoutException} @@ -498,7 +499,7 @@ abstract class ParticipantStateIntegrationSpecBase(implementationName: String)(i submissionId = newSubmissionId(), config = lic.config.copy( generation = lic.config.generation + 1, - timeModel = TimeModel( + timeModel = LedgerTimeModel( Duration.ofSeconds(123), Duration.ofSeconds(123), Duration.ofSeconds(123), diff --git a/ledger/participant-state/kvutils/src/test/lib/scala/com/daml/ledger/participant/state/kvutils/TestHelpers.scala b/ledger/participant-state/kvutils/src/test/lib/scala/com/daml/ledger/participant/state/kvutils/TestHelpers.scala index 2682a92081b..260a3072245 100644 --- a/ledger/participant-state/kvutils/src/test/lib/scala/com/daml/ledger/participant/state/kvutils/TestHelpers.scala +++ b/ledger/participant-state/kvutils/src/test/lib/scala/com/daml/ledger/participant/state/kvutils/TestHelpers.scala @@ -7,6 +7,7 @@ import java.time.Duration import java.util.UUID import com.daml.daml_lf_dev.DamlLf +import com.daml.ledger.configuration.{Configuration, LedgerTimeModel} import com.daml.ledger.participant.state.kvutils.DamlKvutils.{ DamlLogEntryId, DamlSubmitterInfo, @@ -15,7 +16,7 @@ import com.daml.ledger.participant.state.kvutils.DamlKvutils.{ } import com.daml.ledger.participant.state.kvutils.committer.transaction.DamlTransactionEntrySummary import com.daml.ledger.participant.state.kvutils.committer.{CommitContext, StepResult, StepStop} -import com.daml.ledger.participant.state.v1.{Configuration, ParticipantId, TimeModel} +import com.daml.ledger.participant.state.v1.ParticipantId import com.daml.lf.data.Ref import com.daml.lf.data.Time.Timestamp import com.daml.lf.transaction.SubmittedTransaction @@ -37,7 +38,7 @@ object TestHelpers { val theRecordTime: Timestamp = Timestamp.Epoch val theDefaultConfig: Configuration = Configuration( generation = 0, - timeModel = TimeModel.reasonableDefault, + timeModel = LedgerTimeModel.reasonableDefault, maxDeduplicationTime = Duration.ofDays(1), ) diff --git a/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/KVUtilsConfigSpec.scala b/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/KVUtilsConfigSpec.scala index a16424603b4..cd8602f8354 100644 --- a/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/KVUtilsConfigSpec.scala +++ b/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/KVUtilsConfigSpec.scala @@ -6,8 +6,8 @@ package com.daml.ledger.participant.state.kvutils import java.time.Duration import com.codahale.metrics.MetricRegistry +import com.daml.ledger.configuration.Configuration import com.daml.ledger.participant.state.kvutils.DamlKvutils._ -import com.daml.ledger.participant.state.v1.Configuration import com.daml.lf.data.Ref import com.daml.logging.LoggingContext import com.daml.metrics.Metrics diff --git a/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/KeyValueConsumptionSpec.scala b/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/KeyValueConsumptionSpec.scala index 9050c4f6e35..606656d4783 100644 --- a/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/KeyValueConsumptionSpec.scala +++ b/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/KeyValueConsumptionSpec.scala @@ -5,6 +5,7 @@ package com.daml.ledger.participant.state.kvutils import java.time.Instant +import com.daml.ledger.configuration.Configuration import com.daml.ledger.participant.state.kvutils.Conversions.buildTimestamp import com.daml.ledger.participant.state.kvutils.DamlKvutils.DamlLogEntry.PayloadCase._ import com.daml.ledger.participant.state.kvutils.DamlKvutils._ @@ -14,13 +15,13 @@ import com.daml.ledger.participant.state.kvutils.KeyValueConsumption.{ outOfTimeBoundsEntryToUpdate, } import com.daml.ledger.participant.state.kvutils.api.LedgerReader -import com.daml.ledger.participant.state.v1.{Configuration, RejectionReasonV0, Update} +import com.daml.ledger.participant.state.v1.{RejectionReasonV0, Update} import com.daml.lf.data.Time.Timestamp import com.google.protobuf.Empty +import org.scalatest.matchers.should.Matchers import org.scalatest.prop.TableDrivenPropertyChecks._ import org.scalatest.prop.TableFor4 import org.scalatest.prop.Tables.Table -import org.scalatest.matchers.should.Matchers import org.scalatest.wordspec.AnyWordSpec class KeyValueConsumptionSpec extends AnyWordSpec with Matchers { diff --git a/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/api/KeyValueParticipantStateWriterSpec.scala b/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/api/KeyValueParticipantStateWriterSpec.scala index 0d4c97014f7..fecf4943e8f 100644 --- a/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/api/KeyValueParticipantStateWriterSpec.scala +++ b/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/api/KeyValueParticipantStateWriterSpec.scala @@ -7,6 +7,7 @@ import java.time.{Clock, Duration} import java.util.UUID import com.codahale.metrics.MetricRegistry +import com.daml.ledger.configuration.{Configuration, LedgerTimeModel} import com.daml.ledger.participant.state.kvutils.DamlKvutils.DamlSubmission import com.daml.ledger.participant.state.kvutils.{Envelope, Raw} import com.daml.ledger.participant.state.v1 @@ -139,7 +140,7 @@ object KeyValueParticipantStateWriterSpec { private val aConfiguration: Configuration = Configuration( generation = 1, - timeModel = TimeModel.reasonableDefault, + timeModel = LedgerTimeModel.reasonableDefault, maxDeduplicationTime = Duration.ofDays(1), ) diff --git a/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/committer/CommitterSpec.scala b/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/committer/CommitterSpec.scala index c9a95b450cc..4b9f6f97062 100644 --- a/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/committer/CommitterSpec.scala +++ b/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/committer/CommitterSpec.scala @@ -6,13 +6,13 @@ package com.daml.ledger.participant.state.kvutils.committer import java.time.{Duration, Instant} import com.codahale.metrics.MetricRegistry +import com.daml.ledger.configuration.{Configuration, LedgerTimeModel} import com.daml.ledger.participant.state.kvutils.Conversions.{buildTimestamp, configurationStateKey} import com.daml.ledger.participant.state.kvutils.DamlKvutils._ import com.daml.ledger.participant.state.kvutils.TestHelpers.{createCommitContext, theDefaultConfig} import com.daml.ledger.participant.state.kvutils.committer.CommitterSpec._ import com.daml.ledger.participant.state.kvutils.{DamlKvutils, Err} import com.daml.ledger.participant.state.protobuf.LedgerConfiguration -import com.daml.ledger.participant.state.v1.{Configuration, TimeModel} import com.daml.lf.data.Time.Timestamp import com.daml.logging.LoggingContext import com.daml.logging.entries.LoggingEntries @@ -277,7 +277,7 @@ object CommitterSpec { .build private val aConfig: Configuration = Configuration( generation = 1, - timeModel = TimeModel.reasonableDefault, + timeModel = LedgerTimeModel.reasonableDefault, maxDeduplicationTime = Duration.ofMinutes(1), ) diff --git a/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/committer/ConfigCommitterSpec.scala b/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/committer/ConfigCommitterSpec.scala index 7b8bd99eb3e..3ddc1325a14 100644 --- a/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/committer/ConfigCommitterSpec.scala +++ b/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/committer/ConfigCommitterSpec.scala @@ -4,11 +4,11 @@ package com.daml.ledger.participant.state.kvutils.committer import com.codahale.metrics.MetricRegistry +import com.daml.ledger.configuration.Configuration import com.daml.ledger.participant.state.kvutils.Conversions.buildTimestamp import com.daml.ledger.participant.state.kvutils.DamlKvutils.DamlConfigurationSubmission import com.daml.ledger.participant.state.kvutils.TestHelpers import com.daml.ledger.participant.state.kvutils.TestHelpers._ -import com.daml.ledger.participant.state.v1.Configuration import com.daml.lf.data.Time.Timestamp import com.daml.logging.LoggingContext import com.daml.metrics.Metrics diff --git a/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/committer/transaction/validation/LedgerTimeValidatorSpec.scala b/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/committer/transaction/validation/LedgerTimeValidatorSpec.scala index 1c525513fe3..325e7f7d8f4 100644 --- a/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/committer/transaction/validation/LedgerTimeValidatorSpec.scala +++ b/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/committer/transaction/validation/LedgerTimeValidatorSpec.scala @@ -6,6 +6,7 @@ package com.daml.ledger.participant.state.kvutils.committer.transaction.validati import java.time.Instant import com.codahale.metrics.MetricRegistry +import com.daml.ledger.configuration.Configuration import com.daml.ledger.participant.state.kvutils.Conversions import com.daml.ledger.participant.state.kvutils.Conversions.configurationStateKey import com.daml.ledger.participant.state.kvutils.DamlKvutils.{ @@ -23,7 +24,6 @@ import com.daml.ledger.participant.state.kvutils.committer.transaction.{ Rejections, } import com.daml.ledger.participant.state.kvutils.committer.{StepContinue, StepStop} -import com.daml.ledger.participant.state.v1.Configuration import com.daml.lf.data.Time.Timestamp import com.daml.logging.LoggingContext import com.daml.metrics.Metrics diff --git a/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/validator/preexecution/PreExecutingSubmissionValidatorSpec.scala b/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/validator/preexecution/PreExecutingSubmissionValidatorSpec.scala index 12f1ad9886f..c1f02a57eef 100644 --- a/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/validator/preexecution/PreExecutingSubmissionValidatorSpec.scala +++ b/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/validator/preexecution/PreExecutingSubmissionValidatorSpec.scala @@ -6,6 +6,7 @@ package com.daml.ledger.validator.preexecution import java.time.Instant import com.codahale.metrics.MetricRegistry +import com.daml.ledger.configuration.Configuration import com.daml.ledger.participant.state.kvutils.DamlKvutils.DamlSubmissionBatch.CorrelatedSubmission import com.daml.ledger.participant.state.kvutils.DamlKvutils._ import com.daml.ledger.participant.state.kvutils.KeyValueCommitting.PreExecutionResult @@ -16,7 +17,6 @@ import com.daml.ledger.participant.state.kvutils.{ Raw, TestHelpers, } -import com.daml.ledger.participant.state.v1.Configuration import com.daml.ledger.validator.HasDamlStateValue import com.daml.ledger.validator.TestHelper._ import com.daml.ledger.validator.ValidationFailed.ValidationError diff --git a/ledger/participant-state/kvutils/tools/BUILD.bazel b/ledger/participant-state/kvutils/tools/BUILD.bazel index f53ad324e35..744d8715f1d 100644 --- a/ledger/participant-state/kvutils/tools/BUILD.bazel +++ b/ledger/participant-state/kvutils/tools/BUILD.bazel @@ -33,6 +33,7 @@ da_scala_library( "//daml-lf/kv-transaction-support", "//daml-lf/transaction", "//ledger/ledger-api-health", + "//ledger/ledger-configuration", "//ledger/ledger-resources", "//ledger/metrics", "//ledger/participant-integration-api", @@ -68,6 +69,7 @@ da_scala_test( "//daml-lf/transaction", "//daml-lf/transaction-test-lib", "//ledger/ledger-api-health", + "//ledger/ledger-configuration", "//ledger/metrics", "//ledger/participant-integration-api", "//ledger/participant-state", @@ -97,6 +99,7 @@ da_scala_binary( "//daml-lf/data", "//daml-lf/engine", "//ledger/ledger-api-health", + "//ledger/ledger-configuration", "//ledger/ledger-on-memory", "//ledger/metrics", "//ledger/participant-state", @@ -122,6 +125,7 @@ da_scala_test( "//ledger-api/rs-grpc-bridge", "//ledger-api/testing-utils", "//ledger/ledger-api-health", + "//ledger/ledger-configuration", "//ledger/metrics", "//ledger/participant-state", "//ledger/participant-state/kvutils", diff --git a/ledger/participant-state/kvutils/tools/integrity-check/src/main/scala/ledger/participant/state/kvutils/tools/integritycheck/LogAppendingReadServiceFactory.scala b/ledger/participant-state/kvutils/tools/integrity-check/src/main/scala/ledger/participant/state/kvutils/tools/integritycheck/LogAppendingReadServiceFactory.scala index 0b380af5455..4a67b9eeca2 100644 --- a/ledger/participant-state/kvutils/tools/integrity-check/src/main/scala/ledger/participant/state/kvutils/tools/integritycheck/LogAppendingReadServiceFactory.scala +++ b/ledger/participant-state/kvutils/tools/integrity-check/src/main/scala/ledger/participant/state/kvutils/tools/integritycheck/LogAppendingReadServiceFactory.scala @@ -7,6 +7,7 @@ import akka.NotUsed import akka.stream.Materializer import akka.stream.scaladsl.Source import com.daml.ledger.api.health.HealthStatus +import com.daml.ledger.configuration.{LedgerId, LedgerInitialConditions} import com.daml.ledger.participant.state.kvutils.api.{ KeyValueParticipantStateReader, LedgerReader, @@ -14,7 +15,7 @@ import com.daml.ledger.participant.state.kvutils.api.{ } import com.daml.ledger.participant.state.kvutils.export.WriteSet import com.daml.ledger.participant.state.kvutils.{OffsetBuilder, Raw} -import com.daml.ledger.participant.state.v1.{LedgerId, LedgerInitialConditions, Offset, Update} +import com.daml.ledger.participant.state.v1.{Offset, Update} import com.daml.metrics.Metrics import scala.collection.immutable diff --git a/ledger/participant-state/kvutils/tools/integrity-check/src/test/scala/ledger/participant/state/kvutils/tools/integritycheck/RawPreExecutingCommitStrategySupportSpec.scala b/ledger/participant-state/kvutils/tools/integrity-check/src/test/scala/ledger/participant/state/kvutils/tools/integritycheck/RawPreExecutingCommitStrategySupportSpec.scala index b5542c47590..4c15fb9a5c0 100644 --- a/ledger/participant-state/kvutils/tools/integrity-check/src/test/scala/ledger/participant/state/kvutils/tools/integritycheck/RawPreExecutingCommitStrategySupportSpec.scala +++ b/ledger/participant-state/kvutils/tools/integrity-check/src/test/scala/ledger/participant/state/kvutils/tools/integritycheck/RawPreExecutingCommitStrategySupportSpec.scala @@ -7,6 +7,7 @@ import java.time.{Duration, Instant, ZoneOffset, ZonedDateTime} import com.codahale.metrics.MetricRegistry import com.daml.ledger.api.testing.utils.AkkaBeforeAndAfterAll +import com.daml.ledger.configuration.{Configuration, LedgerTimeModel} import com.daml.ledger.participant.state.kvutils.DamlKvutils.{ DamlConfigurationSubmission, DamlLogEntry, @@ -15,8 +16,7 @@ import com.daml.ledger.participant.state.kvutils.DamlKvutils.{ DamlSubmission, DamlSubmissionDedupKey, } -import com.daml.ledger.participant.state.kvutils.`export`.WriteSet -import com.daml.ledger.participant.state.kvutils.export.SubmissionInfo +import com.daml.ledger.participant.state.kvutils.export.{SubmissionInfo, WriteSet} import com.daml.ledger.participant.state.kvutils.tools.integritycheck.RawPreExecutingCommitStrategySupportSpec._ import com.daml.ledger.participant.state.kvutils.{Envelope, Raw} import com.daml.ledger.participant.state.v1 @@ -84,9 +84,9 @@ class RawPreExecutingCommitStrategySupportSpec submissionId = "update-1", correlationId = "update-1", maximumRecordTime = baseTime.plusSeconds(60), - configuration = v1.Configuration( + configuration = Configuration( generation = 1, - timeModel = v1.TimeModel.reasonableDefault, + timeModel = LedgerTimeModel.reasonableDefault, maxDeduplicationTime = Duration.ofMinutes(1), ), ) @@ -96,9 +96,9 @@ class RawPreExecutingCommitStrategySupportSpec submissionId = "update-2", correlationId = "update-2", maximumRecordTime = baseTime.minusSeconds(60), - configuration = v1.Configuration( + configuration = Configuration( generation = 2, - timeModel = v1.TimeModel.reasonableDefault, + timeModel = LedgerTimeModel.reasonableDefault, maxDeduplicationTime = Duration.ofMinutes(1), ), ) @@ -178,7 +178,7 @@ object RawPreExecutingCommitStrategySupportSpec { submissionId: String, correlationId: String, maximumRecordTime: Instant, - configuration: v1.Configuration, + configuration: Configuration, ): SubmissionInfo = { val submissionInfo = SubmissionInfo( participantId = participantId, @@ -199,7 +199,7 @@ object RawPreExecutingCommitStrategySupportSpec { .setSubmissionId(submissionId) .setParticipantId(participantId) .setMaximumRecordTime(toTimestamp(maximumRecordTime)) - .setConfiguration(v1.Configuration.encode(configuration)) + .setConfiguration(Configuration.encode(configuration)) ) .build() ), diff --git a/ledger/participant-state/kvutils/tools/src/test/scala/ledger/participant/state/kvutils/tools/integritycheck/StateUpdateComparisonSpec.scala b/ledger/participant-state/kvutils/tools/src/test/scala/ledger/participant/state/kvutils/tools/integritycheck/StateUpdateComparisonSpec.scala index a3e00f93d73..49283aaf0fa 100644 --- a/ledger/participant-state/kvutils/tools/src/test/scala/ledger/participant/state/kvutils/tools/integritycheck/StateUpdateComparisonSpec.scala +++ b/ledger/participant-state/kvutils/tools/src/test/scala/ledger/participant/state/kvutils/tools/integritycheck/StateUpdateComparisonSpec.scala @@ -5,6 +5,7 @@ package com.daml.ledger.participant.state.kvutils.tools.integritycheck import java.time.{Duration, Instant} +import com.daml.ledger.configuration.{Configuration, LedgerTimeModel} import com.daml.ledger.participant.state.v1.Update.{ CommandRejected, ConfigurationChangeRejected, @@ -99,7 +100,8 @@ final class StateUpdateComparisonSpec recordTime = Time.Timestamp.now(), submissionId = SubmissionId.assertFromString("a submission ID"), participantId = ParticipantId.assertFromString("a participant ID"), - proposedConfiguration = Configuration(1L, TimeModel.reasonableDefault, Duration.ofMinutes(1)), + proposedConfiguration = + Configuration(1L, LedgerTimeModel.reasonableDefault, Duration.ofMinutes(1)), rejectionReason = "a rejection reason", ) private lazy val aCommandRejectedUpdate = CommandRejected( diff --git a/ledger/participant-state/kvutils/tools/src/test/scala/ledger/participant/state/kvutils/tools/integritycheck/StateUpdateExporterSpec.scala b/ledger/participant-state/kvutils/tools/src/test/scala/ledger/participant/state/kvutils/tools/integritycheck/StateUpdateExporterSpec.scala index 40cf6416a0c..514de8f0179 100644 --- a/ledger/participant-state/kvutils/tools/src/test/scala/ledger/participant/state/kvutils/tools/integritycheck/StateUpdateExporterSpec.scala +++ b/ledger/participant-state/kvutils/tools/src/test/scala/ledger/participant/state/kvutils/tools/integritycheck/StateUpdateExporterSpec.scala @@ -12,7 +12,8 @@ import akka.stream.Materializer import akka.stream.scaladsl.Source import akka.testkit.TestKit import com.daml.ledger.api.health.HealthStatus -import com.daml.ledger.participant.state.v1.{LedgerInitialConditions, Offset, Update} +import com.daml.ledger.configuration.LedgerInitialConditions +import com.daml.ledger.participant.state.v1.{Offset, Update} import com.daml.lf.data.Time import org.mockito.ArgumentMatchers.anyString import org.mockito.{ArgumentMatchersSugar, MockitoSugar} diff --git a/ledger/participant-state/protobuf/README.md b/ledger/participant-state/protobuf/README.md deleted file mode 100644 index 0af3e35c5b4..00000000000 --- a/ledger/participant-state/protobuf/README.md +++ /dev/null @@ -1,6 +0,0 @@ - -participant-state/protobuf --------------------------- - -Common protocol buffer definitions used across different implementations. - diff --git a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/LedgerInitialConditions.scala b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/LedgerInitialConditions.scala deleted file mode 100644 index a11a09933a0..00000000000 --- a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/LedgerInitialConditions.scala +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -package com.daml.ledger.participant.state.v1 - -import com.daml.lf.data.Time.Timestamp - -/** The initial conditions of the ledger before anything has been committed. - * - * @param ledgerId: The static ledger identifier. - * @param config: The initial ledger configuration - * @param initialRecordTime: The initial record time prior to any [[Update]] event. - */ -final case class LedgerInitialConditions( - ledgerId: LedgerId, - config: Configuration, - initialRecordTime: Timestamp, -) diff --git a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/ReadService.scala b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/ReadService.scala index 7df0be2a523..bee84eed7a0 100644 --- a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/ReadService.scala +++ b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/ReadService.scala @@ -6,6 +6,7 @@ package com.daml.ledger.participant.state.v1 import akka.NotUsed import akka.stream.scaladsl.Source import com.daml.ledger.api.health.ReportsHealth +import com.daml.ledger.configuration.LedgerInitialConditions /** An interface for reading the state of a ledger participant. * @@ -57,26 +58,26 @@ trait ReadService extends ReportsHealth { * * - *causal monotonicity*: given a [[Update.TransactionAccepted]] with an associated * ledger time `lt_tx`, it holds that `lt_tx >= lt_c` for all `c`, where `c` is a - * contract used by the transaction and `lt_c` the ledger time of the - * [[Update.TransactionAccepted]] that created the contract. - * The ledger time of a transaction is specified in the corresponding [[TransactionMeta]] - * meta-data. - * Note that the ledger time of unrelated updates is not necessarily monotonically - * increasing. + * contract used by the transaction and `lt_c` the ledger time of the + * [[Update.TransactionAccepted]] that created the contract. + * The ledger time of a transaction is specified in the corresponding [[TransactionMeta]] + * meta-data. + * Note that the ledger time of unrelated updates is not necessarily monotonically + * increasing. * * - *time skew*: given a [[Update.TransactionAccepted]] with an associated - * ledger time `lt_tx` and a record time `rt_tx`, it holds that - * `rt_TX - minSkew <= lt_TX <= rt_TX + maxSkew`, where `minSkew` and `maxSkew` - * are parameters specified in the ledger [[TimeModel]]. + * ledger time `lt_tx` and a record time `rt_tx`, it holds that + * `rt_TX - minSkew <= lt_TX <= rt_TX + maxSkew`, where `minSkew` and `maxSkew` + * are parameters specified in the ledger [[com.daml.ledger.configuration.LedgerTimeModel]]. * * - *command deduplication*: if there is a [[Update.TransactionAccepted]] with - * an associated [[SubmitterInfo]] `info1`, then for every later - * transaction with [[SubmitterInfo]] `info2` that agrees with - * `info1` on the `submitter` and `commandId` fields and - * was submitted before `info1.deduplicateUntil`, - * a transaction may be rejected without a corresponding update being issued. - * I.e., transactions may be deduplicated on the `(submitter, commandId)` tuple, - * but only until the time specified in [[SubmitterInfo.deduplicateUntil]]. + * an associated [[SubmitterInfo]] `info1`, then for every later + * transaction with [[SubmitterInfo]] `info2` that agrees with + * `info1` on the `submitter` and `commandId` fields and + * was submitted before `info1.deduplicateUntil`, + * a transaction may be rejected without a corresponding update being issued. + * I.e., transactions may be deduplicated on the `(submitter, commandId)` tuple, + * but only until the time specified in [[SubmitterInfo.deduplicateUntil]]. * * TODO (SM): we would like to weaken this requirement to allow multiple * [[Update.TransactionAccepted]] updates provided diff --git a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/Update.scala b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/Update.scala index ab17166982a..49f23942ea2 100644 --- a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/Update.scala +++ b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/Update.scala @@ -4,8 +4,9 @@ package com.daml.ledger package participant.state.v1 -import com.daml.lf.data.Time.Timestamp import com.daml.daml_lf_dev.DamlLf +import com.daml.ledger.configuration.Configuration +import com.daml.lf.data.Time.Timestamp import com.daml.lf.transaction.BlindingInfo /** An update to the (abstract) participant state. @@ -153,35 +154,25 @@ object Update { /** Signal the acceptance of a transaction. * - * @param optSubmitterInfo: - * The information provided by the submitter of the command that - * created this transaction. It must be provided if the submitter is - * hosted at this participant. It can be elided otherwise. This allows - * ledgers to implement a fine-grained privacy model. - * - * @param transactionMeta: - * The metadata of the transaction that was provided by the submitter. - * It is visible to all parties that can see the transaction. - * - * @param transaction: - * The view of the transaction that was accepted. This view must - * include at least the projection of the accepted transaction to the - * set of all parties hosted at this participant. See - * https://docs.daml.com/concepts/ledger-model/ledger-privacy.html - * on how these views are computed. - * - * Note that ledgers with weaker privacy models can decide to forgo - * projections of transactions and always show the complete - * transaction. - * - * @param recordTime: - * The ledger-provided timestamp at which the transaction was recorded. - * The last [[Configuration]] set before this [[TransactionAccepted]] - * determines how this transaction's recordTime relates to its - * [[TransactionMeta.ledgerEffectiveTime]]. - * - * @param divulgedContracts: - * List of divulged contracts. See [[DivulgedContract]] for details. + * @param optSubmitterInfo The information provided by the submitter of the command that + * created this transaction. It must be provided if the submitter is + * hosted at this participant. It can be elided otherwise. This allows + * ledgers to implement a fine-grained privacy model. + * @param transactionMeta The metadata of the transaction that was provided by the submitter. + * It is visible to all parties that can see the transaction. + * @param transaction The view of the transaction that was accepted. This view must + * include at least the projection of the accepted transaction to the + * set of all parties hosted at this participant. See + * https://docs.daml.com/concepts/ledger-model/ledger-privacy.html + * on how these views are computed. + * Note that ledgers with weaker privacy models can decide to forgo + * projections of transactions and always show the complete + * transaction. + * @param recordTime The ledger-provided timestamp at which the transaction was recorded. + * The last [[Configuration]] set before this [[TransactionAccepted]] + * determines how this transaction's recordTime relates to its + * [[TransactionMeta.ledgerEffectiveTime]]. + * @param divulgedContracts List of divulged contracts. See [[DivulgedContract]] for details. */ final case class TransactionAccepted( optSubmitterInfo: Option[SubmitterInfo], diff --git a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/WriteConfigService.scala b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/WriteConfigService.scala index 826c7053c91..edb76e2bc33 100644 --- a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/WriteConfigService.scala +++ b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/WriteConfigService.scala @@ -5,6 +5,7 @@ package com.daml.ledger.participant.state.v1 import java.util.concurrent.CompletionStage +import com.daml.ledger.configuration.Configuration import com.daml.lf.data.Time.Timestamp import com.daml.telemetry.TelemetryContext diff --git a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/package.scala b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/package.scala index 10546439bf0..d860ee0f08c 100644 --- a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/package.scala +++ b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/package.scala @@ -36,7 +36,7 @@ import com.daml.lf.value.Value * [[v1.Update]]s. * * We provide a reference implementation of a participant state in - * [[com.daml.ledger.api.server.damlonx.reference.v2.ReferenceServer]]. There we + * [[com.daml.ledger.on.memory.InMemoryLedgerReaderWriter]]. There we * model an in-memory ledger, which has by construction a single participant, * which hosts all parties. See its comments for details on how that is done, * and how its implementation can be used as a blueprint for implementing @@ -56,9 +56,6 @@ import com.daml.lf.value.Value */ package object v1 { - /** Identifier for the ledger, MUST match regexp [a-zA-Z0-9-]. */ - type LedgerId = String - /** Identifier for the participant, MUST match regexp [a-zA-Z0-9-]. */ val ParticipantId: Ref.ParticipantId.type = Ref.ParticipantId type ParticipantId = Ref.ParticipantId diff --git a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/AdaptedV1ReadService.scala b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/AdaptedV1ReadService.scala index d38857ae68e..4b8b6e0e114 100644 --- a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/AdaptedV1ReadService.scala +++ b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/AdaptedV1ReadService.scala @@ -8,6 +8,7 @@ import java.util.UUID import akka.NotUsed import akka.stream.scaladsl.Source import com.daml.ledger.api.health.HealthStatus +import com.daml.ledger.configuration.LedgerInitialConditions import com.daml.ledger.participant.state.v1 import com.daml.ledger.participant.state.v2.AdaptedV1ReadService._ import com.daml.ledger.participant.state.v2.Update.CommandRejected @@ -20,9 +21,7 @@ import com.daml.ledger.participant.state.v2.Update.CommandRejected.RejectionReas */ class AdaptedV1ReadService(delegate: v1.ReadService) extends ReadService { override def ledgerInitialConditions(): Source[LedgerInitialConditions, NotUsed] = - delegate - .getLedgerInitialConditions() - .map(adaptLedgerInitialConditions) + delegate.getLedgerInitialConditions() override def stateUpdates(beginAfter: Option[Offset]): Source[(Offset, Update), NotUsed] = delegate @@ -33,29 +32,6 @@ class AdaptedV1ReadService(delegate: v1.ReadService) extends ReadService { } private[v2] object AdaptedV1ReadService { - def adaptLedgerInitialConditions( - ledgerInitialConditions: v1.LedgerInitialConditions - ): LedgerInitialConditions = - LedgerInitialConditions( - ledgerId = ledgerInitialConditions.ledgerId, - config = adaptLedgerConfiguration(ledgerInitialConditions.config), - initialRecordTime = ledgerInitialConditions.initialRecordTime, - ) - - def adaptLedgerConfiguration(config: v1.Configuration): Configuration = - Configuration( - generation = config.generation, - timeModel = adaptTimeModel(config.timeModel), - maxDeduplicationTime = config.maxDeduplicationTime, - ) - - def adaptTimeModel(timeModel: v1.TimeModel): TimeModel = - TimeModel( - timeModel.avgTransactionLatency, - timeModel.minSkew, - timeModel.maxSkew, - ).get - def adaptUpdate(update: v1.Update): Update = update match { case v1.Update.ConfigurationChanged( recordTime, @@ -67,7 +43,7 @@ private[v2] object AdaptedV1ReadService { recordTime = recordTime, submissionId = submissionId, participantId = participantId, - newConfiguration = adaptLedgerConfiguration(newConfiguration), + newConfiguration = newConfiguration, ) case v1.Update.ConfigurationChangeRejected( recordTime, @@ -80,7 +56,7 @@ private[v2] object AdaptedV1ReadService { recordTime = recordTime, submissionId = submissionId, participantId = participantId, - proposedConfiguration = adaptLedgerConfiguration(proposedConfiguration), + proposedConfiguration = proposedConfiguration, rejectionReason = rejectionReason, ) case v1.Update.PartyAddedToParticipant( diff --git a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/AdaptedV1WriteService.scala b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/AdaptedV1WriteService.scala index 05ec7af9a99..df5dff43402 100644 --- a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/AdaptedV1WriteService.scala +++ b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/AdaptedV1WriteService.scala @@ -8,6 +8,7 @@ import java.util.concurrent.{CompletableFuture, CompletionStage} import com.daml.daml_lf_dev.DamlLf import com.daml.ledger.api.health.HealthStatus +import com.daml.ledger.configuration.Configuration import com.daml.ledger.participant.state.v1 import com.daml.lf.data.Time import com.daml.telemetry.TelemetryContext @@ -72,7 +73,7 @@ class AdaptedV1WriteService(delegate: v1.WriteService) extends WriteService { config: Configuration, )(implicit telemetryContext: TelemetryContext): CompletionStage[SubmissionResult] = delegate - .submitConfiguration(maxRecordTime, submissionId, adaptLedgerConfiguration(config)) + .submitConfiguration(maxRecordTime, submissionId, config) .thenApply(adaptSubmissionResult) override def prune( @@ -163,18 +164,4 @@ private[v2] object AdaptedV1WriteService { val errorInfo = ErrorInfo.of(failure.getLocalizedMessage, "Synchronous rejection", metadata) Seq(com.google.protobuf.any.Any.pack(errorInfo)) } - - def adaptLedgerConfiguration(config: Configuration): v1.Configuration = - v1.Configuration( - generation = config.generation, - timeModel = adaptTimeModel(config.timeModel), - maxDeduplicationTime = config.maxDeduplicationTime, - ) - - private def adaptTimeModel(timeModel: TimeModel): v1.TimeModel = - v1.TimeModel( - avgTransactionLatency = timeModel.avgTransactionLatency, - minSkew = timeModel.minSkew, - maxSkew = timeModel.maxSkew, - ).get } diff --git a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/Configuration.scala b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/Configuration.scala deleted file mode 100644 index 5913619db9b..00000000000 --- a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/Configuration.scala +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -package com.daml.ledger.participant.state.v2 - -import java.time.Duration - -import com.daml.ledger.participant.state.{protobuf, v1} - -/** Ledger configuration describing the ledger's time model. - * Emitted in [[com.daml.ledger.participant.state.v2.Update.ConfigurationChanged]]. - * - * @param generation The configuration generation. Monotonically increasing. - * @param timeModel The time model of the ledger. - * @param maxDeduplicationTime The WriteService promises to not reject submissions whose deduplication period - * extends for less than or equal to `maxDeduplicationTime` with the reason that - * the deduplication period is too long. - */ -final case class Configuration( - generation: Long, - timeModel: TimeModel, - maxDeduplicationTime: Duration, -) - -object Configuration { - def decode(bytes: Array[Byte]): Either[String, Configuration] = - v1.Configuration.decode(bytes).map(AdaptedV1ReadService.adaptLedgerConfiguration) - - def decode(config: protobuf.LedgerConfiguration): Either[String, Configuration] = - v1.Configuration.decode(config).map(AdaptedV1ReadService.adaptLedgerConfiguration) - - def encode(config: Configuration): protobuf.LedgerConfiguration = - v1.Configuration.encode(AdaptedV1WriteService.adaptLedgerConfiguration(config)) -} diff --git a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/ReadService.scala b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/ReadService.scala index a74fbc98cc2..7beac21e62a 100644 --- a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/ReadService.scala +++ b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/ReadService.scala @@ -6,6 +6,7 @@ package com.daml.ledger.participant.state.v2 import akka.NotUsed import akka.stream.scaladsl.Source import com.daml.ledger.api.health.ReportsHealth +import com.daml.ledger.configuration.LedgerInitialConditions /** An interface for reading the state of a ledger participant. * '''Please note that this interface is unstable and may significantly change.''' @@ -60,24 +61,24 @@ trait ReadService extends ReportsHealth { * ledger time `lt_tx`, it holds that `lt_tx >= lt_c` for all `c`, where `c` is a * contract used by the transaction and `lt_c` the ledger time of the * [[Update.TransactionAccepted]] that created the contract. - * The ledger time of a transaction is specified in the corresponding [[TransactionMeta]] - * meta-data. - * Note that the ledger time of unrelated updates is not necessarily monotonically - * increasing. - * The creating transaction need not have a [[Update.TransactionAccepted]] even on this participant - * if the participant does not host a stakeholder of the contract, e.g., in the case of divulgence. + * The ledger time of a transaction is specified in the corresponding [[TransactionMeta]] + * meta-data. + * Note that the ledger time of unrelated updates is not necessarily monotonically + * increasing. + * The creating transaction need not have a [[Update.TransactionAccepted]] even on this participant + * if the participant does not host a stakeholder of the contract, e.g., in the case of divulgence. * * - *time skew*: given a [[Update.TransactionAccepted]] with an associated - * ledger time `lt_tx` and a record time `rt_tx`, it holds that - * `rt_TX - minSkew <= lt_TX <= rt_TX + maxSkew`, where `minSkew` and `maxSkew` - * are parameters specified in the ledger [[com.daml.ledger.participant.state.v2.TimeModel]] - * of the last [[Update.ConfigurationChanged]] before the [[Update.TransactionAccepted]]. + * ledger time `lt_tx` and a record time `rt_tx`, it holds that + * `rt_TX - minSkew <= lt_TX <= rt_TX + maxSkew`, where `minSkew` and `maxSkew` + * are parameters specified in the ledger [[com.daml.ledger.configuration.LedgerTimeModel]] + * of the last [[Update.ConfigurationChanged]] before the [[Update.TransactionAccepted]]. * * - *command deduplication*: Let there be a [[Update.TransactionAccepted]] with [[CompletionInfo]] - * or a [[Update.CommandRejected]] with [[CompletionInfo]] and [[Update.CommandRejected.definiteAnswer]] at offset `off2` - * and let `off1` be the completion offset where the [[CompletionInfo.optDeduplicationPeriod]] starts. - * Then there is no other [[Update.TransactionAccepted]] with [[CompletionInfo]] for the same [[CompletionInfo.changeId]] - * between the offsets `off1` and `off2` inclusive. + * or a [[Update.CommandRejected]] with [[CompletionInfo]] and [[Update.CommandRejected.definiteAnswer]] at offset `off2` + * and let `off1` be the completion offset where the [[CompletionInfo.optDeduplicationPeriod]] starts. + * Then there is no other [[Update.TransactionAccepted]] with [[CompletionInfo]] for the same [[CompletionInfo.changeId]] + * between the offsets `off1` and `off2` inclusive. * * So if a command submission has resulted in a [[Update.TransactionAccepted]], * other command submissions with the same [[SubmitterInfo.changeId]] must be deduplicated diff --git a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/SubmitterInfo.scala b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/SubmitterInfo.scala index 7f0f4ffa21b..01d3f028651 100644 --- a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/SubmitterInfo.scala +++ b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/SubmitterInfo.scala @@ -3,26 +3,25 @@ package com.daml.ledger.participant.state.v2 +import com.daml.ledger.configuration.Configuration + /** Collects context information the submission. * * Note that this is used for party-originating changes only. They are * usually issued via the Ledger API. * - * @param actAs the non-empty set of parties that submitted the change. - * - * @param applicationId an identifier for the Daml application that - * submitted the command. This is used for monitoring, command deduplication, - * and to allow Daml applications subscribe to their own submissions only. - * - * @param commandId a submitter-provided identifier to identify an intended ledger change - * within all the submissions by the same parties and application. - * + * @param actAs the non-empty set of parties that submitted the change. + * @param applicationId an identifier for the Daml application that + * submitted the command. This is used for monitoring, command + * deduplication, and to allow Daml applications subscribe to their own + * submissions only. + * @param commandId a submitter-provided identifier to identify an intended ledger change + * within all the submissions by the same parties and application. * @param deduplicationPeriod The deduplication period for the command submission. - * Used for the deduplication guarantee described in the [[ReadService.stateUpdates]]. - * - * @param submissionId An identifier for the submission that allows an application - * to correlate completions to its submissions. - * + * Used for the deduplication guarantee described in the + * [[ReadService.stateUpdates]]. + * @param submissionId An identifier for the submission that allows an application to + * correlate completions to its submissions. * @param ledgerConfiguration The ledger configuration used during interpretation */ final case class SubmitterInfo( diff --git a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/TimeModel.scala b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/TimeModel.scala deleted file mode 100644 index 24bb8ae743c..00000000000 --- a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/TimeModel.scala +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -package com.daml.ledger.participant.state.v2 - -import java.time.{Duration, Instant} - -import scala.util.Try - -/** The ledger time model and associated validations. Some values are given by constructor args; others are derived. - * @param avgTransactionLatency The expected average latency of a transaction, i.e., the average time - * from submitting the transaction to a [[WriteService]] and the transaction - * being assigned a record time. - * @param minSkew The minimum skew between ledger time and record time: lt_TX >= rt_TX - minSkew - * @param maxSkew The maximum skew between ledger time and record time: lt_TX <= rt_TX + maxSkew - * - * @throws IllegalArgumentException if the parameters aren't valid - */ -case class TimeModel private ( - avgTransactionLatency: Duration, - minSkew: Duration, - maxSkew: Duration, -) { - - /** Verifies whether the given ledger time and record time are valid under the ledger time model. - * In particular, checks the skew condition: rt_TX - s_min <= lt_TX <= rt_TX + s_max. - */ - def checkTime( - ledgerTime: Instant, - recordTime: Instant, - ): Either[String, Unit] = { - val lowerBound = minLedgerTime(recordTime) - val upperBound = maxLedgerTime(recordTime) - if (ledgerTime.isBefore(lowerBound) || ledgerTime.isAfter(upperBound)) - Left(s"Ledger time $ledgerTime outside of range [$lowerBound, $upperBound]") - else - Right(()) - } - - private[state] def minLedgerTime(recordTime: Instant): Instant = - recordTime.minus(minSkew) - - private[state] def maxLedgerTime(recordTime: Instant): Instant = - recordTime.plus(maxSkew) - - private[state] def minRecordTime(ledgerTime: Instant): Instant = - ledgerTime.minus(maxSkew) - - private[state] def maxRecordTime(ledgerTime: Instant): Instant = - ledgerTime.plus(minSkew) -} - -object TimeModel { - - /** A default TimeModel that's reasonable for a test or sandbox ledger application. - * Serious applications (viz. ledger) should probably specify their own TimeModel. - */ - val reasonableDefault: TimeModel = - TimeModel( - avgTransactionLatency = Duration.ofSeconds(0L), - minSkew = Duration.ofSeconds(30L), - maxSkew = Duration.ofSeconds(30L), - ).get - - def apply(avgTransactionLatency: Duration, minSkew: Duration, maxSkew: Duration): Try[TimeModel] = - Try { - require(!avgTransactionLatency.isNegative, "Negative average transaction latency") - require(!minSkew.isNegative, "Negative min skew") - require(!maxSkew.isNegative, "Negative max skew") - new TimeModel(avgTransactionLatency, minSkew, maxSkew) - } -} diff --git a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/Update.scala b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/Update.scala index 7dba5f3d399..d94ae1db94b 100644 --- a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/Update.scala +++ b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/Update.scala @@ -4,6 +4,7 @@ package com.daml.ledger.participant.state.v2 import com.daml.daml_lf_dev.DamlLf +import com.daml.ledger.configuration.Configuration import com.daml.lf.data.Time.Timestamp import com.daml.lf.transaction.BlindingInfo diff --git a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/WriteConfigService.scala b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/WriteConfigService.scala index 02b4f496fea..f1f2535e68d 100644 --- a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/WriteConfigService.scala +++ b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/WriteConfigService.scala @@ -5,6 +5,7 @@ package com.daml.ledger.participant.state.v2 import java.util.concurrent.CompletionStage +import com.daml.ledger.configuration.Configuration import com.daml.lf.data.Time.Timestamp import com.daml.telemetry.TelemetryContext diff --git a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/package.scala b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/package.scala index fba96a8467a..4104206bf44 100644 --- a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/package.scala +++ b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/package.scala @@ -49,9 +49,6 @@ import com.daml.lf.value.Value */ package object v2 { - /** Identifier for the ledger, MUST match regexp [a-zA-Z0-9-]. */ - type LedgerId = String - /** Identifier for the participant, MUST match regexp [a-zA-Z0-9-]. */ val ParticipantId: Ref.ParticipantId.type = Ref.ParticipantId type ParticipantId = Ref.ParticipantId diff --git a/ledger/recovering-indexer-integration-tests/BUILD.bazel b/ledger/recovering-indexer-integration-tests/BUILD.bazel index d363f81150c..c1b4f2c158b 100644 --- a/ledger/recovering-indexer-integration-tests/BUILD.bazel +++ b/ledger/recovering-indexer-integration-tests/BUILD.bazel @@ -37,6 +37,7 @@ da_scala_test_suite( "//ledger/ledger-api-common", "//ledger/ledger-api-domain", "//ledger/ledger-api-health", + "//ledger/ledger-configuration", "//ledger/ledger-on-memory", "//ledger/ledger-resources", "//ledger/ledger-resources:ledger-resources-test-lib", diff --git a/ledger/recovering-indexer-integration-tests/src/test/suite/scala/com/digitalasset/platform/indexer/RecoveringIndexerIntegrationSpec.scala b/ledger/recovering-indexer-integration-tests/src/test/suite/scala/com/digitalasset/platform/indexer/RecoveringIndexerIntegrationSpec.scala index 0c8d2eac763..110a4b49132 100644 --- a/ledger/recovering-indexer-integration-tests/src/test/suite/scala/com/digitalasset/platform/indexer/RecoveringIndexerIntegrationSpec.scala +++ b/ledger/recovering-indexer-integration-tests/src/test/suite/scala/com/digitalasset/platform/indexer/RecoveringIndexerIntegrationSpec.scala @@ -13,6 +13,7 @@ import akka.stream.Materializer import akka.stream.scaladsl.Source import ch.qos.logback.classic.Level import com.codahale.metrics.MetricRegistry +import com.daml.ledger.configuration.LedgerId import com.daml.ledger.on.memory import com.daml.ledger.participant.state.kvutils.api.KeyValueParticipantState import com.daml.ledger.participant.state.v1._ @@ -26,8 +27,8 @@ import com.daml.logging.LoggingContext.newLoggingContext import com.daml.metrics.Metrics import com.daml.platform.configuration.ServerRole import com.daml.platform.indexer.RecoveringIndexerIntegrationSpec._ -import com.daml.platform.store.{DbType, LfValueTranslationCache} import com.daml.platform.store.dao.{JdbcLedgerDao, LedgerDao} +import com.daml.platform.store.{DbType, LfValueTranslationCache} import com.daml.platform.testing.LogCollector import com.daml.telemetry.{NoOpTelemetryContext, TelemetryContext} import com.daml.timer.RetryStrategy diff --git a/ledger/sandbox-classic/BUILD.bazel b/ledger/sandbox-classic/BUILD.bazel index 4a8d0b42ca6..cbc7d7bae3b 100644 --- a/ledger/sandbox-classic/BUILD.bazel +++ b/ledger/sandbox-classic/BUILD.bazel @@ -71,6 +71,7 @@ alias( "//ledger/ledger-api-common", "//ledger/ledger-api-domain", "//ledger/ledger-api-health", + "//ledger/ledger-configuration", "//ledger/ledger-resources", "//ledger/metrics", "//ledger/participant-integration-api", @@ -205,6 +206,7 @@ test_deps = [ "//ledger/ledger-api-client", "//ledger/ledger-api-domain", "//ledger/ledger-api-health", + "//ledger/ledger-configuration", "//ledger/ledger-resources", "//ledger/ledger-resources:ledger-resources-test-lib", "//ledger/metrics", diff --git a/ledger/sandbox-classic/src/main/scala/platform/sandbox/stores/LedgerBackedWriteService.scala b/ledger/sandbox-classic/src/main/scala/platform/sandbox/stores/LedgerBackedWriteService.scala index d8c240aff3e..98f3426ade0 100644 --- a/ledger/sandbox-classic/src/main/scala/platform/sandbox/stores/LedgerBackedWriteService.scala +++ b/ledger/sandbox-classic/src/main/scala/platform/sandbox/stores/LedgerBackedWriteService.scala @@ -8,8 +8,8 @@ import java.util.concurrent.{CompletableFuture, CompletionStage} import com.daml.api.util.TimeProvider import com.daml.daml_lf_dev.DamlLf import com.daml.ledger.api.health.HealthStatus +import com.daml.ledger.configuration.Configuration import com.daml.ledger.participant.state.v1.{ - Configuration, Offset, PruningResult, SubmissionId, diff --git a/ledger/sandbox-classic/src/main/scala/platform/sandbox/stores/ledger/Ledger.scala b/ledger/sandbox-classic/src/main/scala/platform/sandbox/stores/ledger/Ledger.scala index 953703520c1..4c5a909c531 100644 --- a/ledger/sandbox-classic/src/main/scala/platform/sandbox/stores/ledger/Ledger.scala +++ b/ledger/sandbox-classic/src/main/scala/platform/sandbox/stores/ledger/Ledger.scala @@ -5,6 +5,8 @@ package com.daml.platform.sandbox.stores.ledger import java.time.Instant +import com.daml.daml_lf_dev.DamlLf.Archive +import com.daml.ledger.configuration.Configuration import com.daml.ledger.participant.state.v1._ import com.daml.lf.data.Ref.Party import com.daml.lf.data.Relation.Relation @@ -12,7 +14,6 @@ import com.daml.lf.data.Time.Timestamp import com.daml.lf.engine.Blinding import com.daml.lf.transaction.{NodeId, TransactionCommitter} import com.daml.lf.value.Value.ContractId -import com.daml.daml_lf_dev.DamlLf.Archive import com.daml.logging.LoggingContext import com.daml.platform.store.ReadOnlyLedger diff --git a/ledger/sandbox-classic/src/main/scala/platform/sandbox/stores/ledger/MeteredLedger.scala b/ledger/sandbox-classic/src/main/scala/platform/sandbox/stores/ledger/MeteredLedger.scala index 3e18a6742b7..168174d3c00 100644 --- a/ledger/sandbox-classic/src/main/scala/platform/sandbox/stores/ledger/MeteredLedger.scala +++ b/ledger/sandbox-classic/src/main/scala/platform/sandbox/stores/ledger/MeteredLedger.scala @@ -6,6 +6,7 @@ package com.daml.platform.sandbox.stores.ledger import java.time.Instant import com.daml.daml_lf_dev.DamlLf.Archive +import com.daml.ledger.configuration.Configuration import com.daml.ledger.participant.state.v1._ import com.daml.lf.data.Ref.Party import com.daml.lf.data.Time diff --git a/ledger/sandbox-classic/src/main/scala/platform/sandbox/stores/ledger/inmemory/InMemoryLedger.scala b/ledger/sandbox-classic/src/main/scala/platform/sandbox/stores/ledger/inmemory/InMemoryLedger.scala index 03bbb8d7c49..9adbc62fdeb 100644 --- a/ledger/sandbox-classic/src/main/scala/platform/sandbox/stores/ledger/inmemory/InMemoryLedger.scala +++ b/ledger/sandbox-classic/src/main/scala/platform/sandbox/stores/ledger/inmemory/InMemoryLedger.scala @@ -32,18 +32,14 @@ import com.daml.ledger.api.v1.transaction_service.{ GetTransactionTreesResponse, GetTransactionsResponse, } +import com.daml.ledger.configuration.Configuration import com.daml.ledger.participant.state.index.v2.{ CommandDeduplicationDuplicate, CommandDeduplicationNew, CommandDeduplicationResult, PackageDetails, } -import com.daml.ledger.participant.state.v1.{ - ApplicationId => _, - LedgerId => _, - TransactionId => _, - _, -} +import com.daml.ledger.participant.state.v1.{ApplicationId => _, TransactionId => _, _} import com.daml.lf.data.Ref.{LedgerString, PackageId, Party} import com.daml.lf.data.{ImmArray, Ref, Time} import com.daml.lf.language.Ast diff --git a/ledger/sandbox-classic/src/main/scala/platform/sandbox/stores/ledger/sql/SqlLedger.scala b/ledger/sandbox-classic/src/main/scala/platform/sandbox/stores/ledger/sql/SqlLedger.scala index 5733a9b66cd..9e6460f46d8 100644 --- a/ledger/sandbox-classic/src/main/scala/platform/sandbox/stores/ledger/sql/SqlLedger.scala +++ b/ledger/sandbox-classic/src/main/scala/platform/sandbox/stores/ledger/sql/SqlLedger.scala @@ -16,6 +16,7 @@ import com.daml.dec.{DirectExecutionContext => DEC} import com.daml.ledger.api.domain import com.daml.ledger.api.domain.{LedgerId, ParticipantId, PartyDetails} import com.daml.ledger.api.health.HealthStatus +import com.daml.ledger.configuration.Configuration import com.daml.ledger.participant.state.index.v2.{ContractStore, PackageDetails} import com.daml.ledger.participant.state.v1._ import com.daml.ledger.resources.{Resource, ResourceContext, ResourceOwner} diff --git a/ledger/sandbox-classic/src/test/suite/scala/platform/sandbox/stores/ledger/TransactionTimeModelComplianceIT.scala b/ledger/sandbox-classic/src/test/suite/scala/platform/sandbox/stores/ledger/TransactionTimeModelComplianceIT.scala index 92901752e25..8fd4860884f 100644 --- a/ledger/sandbox-classic/src/test/suite/scala/platform/sandbox/stores/ledger/TransactionTimeModelComplianceIT.scala +++ b/ledger/sandbox-classic/src/test/suite/scala/platform/sandbox/stores/ledger/TransactionTimeModelComplianceIT.scala @@ -16,13 +16,8 @@ import com.daml.ledger.api.testing.utils.{ SuiteResourceManagementAroundEach, } import com.daml.ledger.api.v1.completion.Completion -import com.daml.ledger.participant.state.v1.{ - Configuration, - SubmissionResult, - SubmitterInfo, - TimeModel, - TransactionMeta, -} +import com.daml.ledger.configuration.{Configuration, LedgerTimeModel} +import com.daml.ledger.participant.state.v1.{SubmissionResult, SubmitterInfo, TransactionMeta} import com.daml.ledger.resources.ResourceContext import com.daml.lf.crypto import com.daml.lf.data.{Ref, Time} @@ -30,10 +25,10 @@ import com.daml.lf.transaction.test.TransactionBuilder import com.daml.platform.sandbox.stores.ledger.TransactionTimeModelComplianceIT._ import com.daml.platform.sandbox.{LedgerResource, MetricsAround} import org.scalatest.concurrent.{AsyncTimeLimitedTests, ScalaFutures} -import org.scalatest.time.Span -import org.scalatest.{Assertion, OptionValues} -import org.scalatest.wordspec.AsyncWordSpec import org.scalatest.matchers.should.Matchers +import org.scalatest.time.Span +import org.scalatest.wordspec.AsyncWordSpec +import org.scalatest.{Assertion, OptionValues} import scala.concurrent.duration._ @@ -75,7 +70,7 @@ class TransactionTimeModelComplianceIT ) = { val config = Configuration( generation = generation, - timeModel = TimeModel(JDuration.ZERO, minSkew, maxSkew).get, + timeModel = LedgerTimeModel(JDuration.ZERO, minSkew, maxSkew).get, maxDeduplicationTime = JDuration.ofSeconds(10), ) ledger.publishConfiguration( diff --git a/ledger/sandbox-common/BUILD.bazel b/ledger/sandbox-common/BUILD.bazel index 0ee902e92a1..c3a57826b6e 100644 --- a/ledger/sandbox-common/BUILD.bazel +++ b/ledger/sandbox-common/BUILD.bazel @@ -37,6 +37,7 @@ da_scala_library( "//ledger/ledger-api-auth", "//ledger/ledger-api-common", "//ledger/ledger-api-domain", + "//ledger/ledger-configuration", "//ledger/metrics", "//ledger/participant-integration-api", "//ledger/participant-state", @@ -127,6 +128,7 @@ da_scala_library( "//ledger/ledger-api-client", "//ledger/ledger-api-common", "//ledger/ledger-api-domain", + "//ledger/ledger-configuration", "//ledger/ledger-resources", "//ledger/ledger-resources:ledger-resources-test-lib", "//ledger/metrics", diff --git a/ledger/sandbox-common/src/main/scala/platform/sandbox/cli/CommonCliBase.scala b/ledger/sandbox-common/src/main/scala/platform/sandbox/cli/CommonCliBase.scala index 69115ac55dd..3efa24556d8 100644 --- a/ledger/sandbox-common/src/main/scala/platform/sandbox/cli/CommonCliBase.scala +++ b/ledger/sandbox-common/src/main/scala/platform/sandbox/cli/CommonCliBase.scala @@ -11,6 +11,7 @@ import com.daml.jwt.JwtVerifierConfigurationCli import com.daml.ledger.api.auth.AuthServiceJWT import com.daml.ledger.api.domain.LedgerId import com.daml.ledger.api.tls.TlsConfiguration +import com.daml.ledger.configuration.LedgerTimeModel import com.daml.ledger.participant.state.v1 import com.daml.lf.data.Ref import com.daml.platform.apiserver.SeedService.Seeding @@ -280,7 +281,7 @@ class CommonCliBase(name: LedgerName) { config.copy(ledgerConfig = config.ledgerConfig.copy(initialConfiguration = ledgerConfig)) }) .text( - s"Maximum skew (in seconds) between the ledger time and the record time. Default is ${v1.TimeModel.reasonableDefault.minSkew.getSeconds}." + s"Maximum skew (in seconds) between the ledger time and the record time. Default is ${LedgerTimeModel.reasonableDefault.maxSkew.getSeconds}." ) opt[Duration]("management-service-timeout") diff --git a/ledger/sandbox-common/src/test/lib/scala/platform/sandbox/services/TimeModelHelpers.scala b/ledger/sandbox-common/src/test/lib/scala/platform/sandbox/services/TimeModelHelpers.scala index f0ae1549aea..8e7d2ffbe3e 100644 --- a/ledger/sandbox-common/src/test/lib/scala/platform/sandbox/services/TimeModelHelpers.scala +++ b/ledger/sandbox-common/src/test/lib/scala/platform/sandbox/services/TimeModelHelpers.scala @@ -10,7 +10,7 @@ import com.daml.ledger.api.v1.admin.config_management_service.{ SetTimeModelRequest, TimeModel => ProtobufTimeModel, } -import com.daml.ledger.participant.state.v1.TimeModel +import com.daml.ledger.configuration.LedgerTimeModel import com.google.protobuf.timestamp.Timestamp import io.grpc.Channel @@ -22,7 +22,7 @@ object TimeModelHelpers { for { current <- configService.getTimeModel(GetTimeModelRequest()) generation = current.configurationGeneration - timeModel = TimeModel.reasonableDefault + timeModel = LedgerTimeModel.reasonableDefault _ <- configService.setTimeModel( SetTimeModelRequest( "config-submission", diff --git a/ledger/sandbox-on-x/BUILD.bazel b/ledger/sandbox-on-x/BUILD.bazel index eb3a78dd47c..8fd0ccf6d5e 100644 --- a/ledger/sandbox-on-x/BUILD.bazel +++ b/ledger/sandbox-on-x/BUILD.bazel @@ -33,6 +33,7 @@ da_scala_library( "//ledger/ledger-api-auth", "//ledger/ledger-api-common", "//ledger/ledger-api-health", + "//ledger/ledger-configuration", "//ledger/ledger-resources", "//ledger/metrics", "//ledger/participant-integration-api", diff --git a/ledger/sandbox-on-x/src/main/scala/com/daml/ledger/sandbox/ReadWriteServiceBridge.scala b/ledger/sandbox-on-x/src/main/scala/com/daml/ledger/sandbox/ReadWriteServiceBridge.scala index 25e098736ea..936b94a0280 100644 --- a/ledger/sandbox-on-x/src/main/scala/com/daml/ledger/sandbox/ReadWriteServiceBridge.scala +++ b/ledger/sandbox-on-x/src/main/scala/com/daml/ledger/sandbox/ReadWriteServiceBridge.scala @@ -11,6 +11,12 @@ import akka.stream.scaladsl.Source import akka.stream.{BoundedSourceQueue, Materializer, QueueOfferResult} import com.daml.daml_lf_dev.DamlLf.Archive import com.daml.ledger.api.health.HealthStatus +import com.daml.ledger.configuration.{ + Configuration, + LedgerId, + LedgerInitialConditions, + LedgerTimeModel, +} import com.daml.ledger.participant.state.v1._ import com.daml.lf.data.Ref.Party import com.daml.lf.data.Time @@ -102,7 +108,7 @@ case class ReadWriteServiceBridge( ledgerId = ledgerId, config = Configuration( generation = 1L, - timeModel = TimeModel.reasonableDefault, + timeModel = LedgerTimeModel.reasonableDefault, maxDeduplicationTime = java.time.Duration.ofSeconds(maxDedupSeconds.toLong), ), initialRecordTime = Timestamp.now(), diff --git a/ledger/sandbox/BUILD.bazel b/ledger/sandbox/BUILD.bazel index f94206174a0..6301405b0ef 100644 --- a/ledger/sandbox/BUILD.bazel +++ b/ledger/sandbox/BUILD.bazel @@ -50,6 +50,7 @@ alias( "//ledger/ledger-api-common", "//ledger/ledger-api-domain", "//ledger/ledger-api-health", + "//ledger/ledger-configuration", "//ledger/ledger-on-sql", "//ledger/ledger-resources", "//ledger/metrics", @@ -198,6 +199,7 @@ reset_service_pattern = "src/test/suite/**/*ResetService*.scala" "//ledger/ledger-api-common:ledger-api-common-scala-tests-lib", "//ledger/ledger-api-domain", "//ledger/ledger-api-health", + "//ledger/ledger-configuration", "//ledger/ledger-resources", "//ledger/ledger-resources:ledger-resources-test-lib", "//ledger/metrics", diff --git a/ledger/sandbox/src/main/scala/platform/sandboxnext/Runner.scala b/ledger/sandbox/src/main/scala/platform/sandboxnext/Runner.scala index b8a17bb063f..ea0595031e1 100644 --- a/ledger/sandbox/src/main/scala/platform/sandboxnext/Runner.scala +++ b/ledger/sandbox/src/main/scala/platform/sandboxnext/Runner.scala @@ -17,6 +17,7 @@ import com.daml.caching import com.daml.ledger.api.auth.{AuthServiceWildcard, Authorizer} import com.daml.ledger.api.domain import com.daml.ledger.api.health.HealthChecks +import com.daml.ledger.configuration.LedgerId import com.daml.ledger.on.sql.Database.InvalidDatabaseException import com.daml.ledger.on.sql.SqlLedgerReaderWriter import com.daml.ledger.participant.state.kvutils.api.KeyValueParticipantState @@ -58,7 +59,7 @@ import scala.concurrent.{ExecutionContext, Future, Promise} * - does not support scenarios */ class Runner(config: SandboxConfig) extends ResourceOwner[Port] { - private val specifiedLedgerId: Option[v1.LedgerId] = config.ledgerIdMode match { + private val specifiedLedgerId: Option[LedgerId] = config.ledgerIdMode match { case LedgerIdMode.Static(ledgerId) => Some(Ref.LedgerString.assertFromString(ledgerId.unwrap)) case LedgerIdMode.Dynamic => diff --git a/release/artifacts.yaml b/release/artifacts.yaml index 181773ceb6e..2ae5d62194e 100644 --- a/release/artifacts.yaml +++ b/release/artifacts.yaml @@ -127,6 +127,12 @@ type: jar-deploy - target: //ledger/ledger-api-test-tool:ledger-api-test-tool-1.dev type: jar-deploy +- target: //ledger/ledger-configuration:ledger-configuration + type: jar-scala +- target: //ledger/ledger-configuration/protobuf:ledger_configuration_proto_jar + type: jar-lib +- target: //ledger/ledger-configuration/protobuf:ledger_configuration_proto_java + type: jar-proto - target: //ledger/ledger-on-memory:ledger-on-memory type: jar-scala - target: //ledger/ledger-on-memory:ledger-on-memory-app @@ -159,10 +165,6 @@ type: jar-scala - target: //ledger/participant-state/kvutils/tools:tools type: jar-scala -- target: //ledger/participant-state/protobuf:ledger_configuration_proto_jar - type: jar-lib -- target: //ledger/participant-state/protobuf:ledger_configuration_proto_java - type: jar-proto - target: //ledger/participant-state-index:participant-state-index type: jar-scala - target: //ledger/participant-state-metrics:participant-state-metrics