Skip to content

Commit

Permalink
participant-state: Remove the ParticipantId, PackageId, and `Part…
Browse files Browse the repository at this point in the history
…y` aliases. [KVL-1002] (#10308)

* participant-state: Remove the `ParticipantId` alias.

This alias adds nothing. By using `Ref.ParticipantId` directly, many
packages can remove their dependency on the _participant-state_ package.

CHANGELOG_BEGIN
CHANGELOG_END

* participant-state: Remove the `PackageId` and `Party` aliases.

They don't add anything. Let's just use `Ref`.

* kvutils: Restore missing compat imports.
  • Loading branch information
SamirTalwar authored Jul 19, 2021
1 parent fed4497 commit bd12170
Show file tree
Hide file tree
Showing 112 changed files with 415 additions and 451 deletions.
1 change: 0 additions & 1 deletion daml-script/runner/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ da_scala_library(
"//ledger/ledger-api-common",
"//ledger/ledger-resources",
"//ledger/participant-integration-api",
"//ledger/participant-state",
"//ledger/sandbox-classic:sandbox-classic-{}".format(edition),
"//ledger/sandbox-common",
"//libs-scala/ports",
Expand Down
1 change: 0 additions & 1 deletion daml-script/test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ da_scala_library(
"//ledger/ledger-on-memory:ledger-on-memory-app",
"//ledger/ledger-resources",
"//ledger/participant-integration-api",
"//ledger/participant-state",
"//ledger/participant-state/kvutils",
"//ledger/participant-state/kvutils/app",
"//ledger/sandbox-classic",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import com.daml.ledger.participant.state.kvutils.app.{
ParticipantRunMode,
}
import com.daml.ledger.participant.state.kvutils.{app => kvutils}
import com.daml.ledger.participant.state.v1
import com.daml.ledger.resources.ResourceContext
import com.daml.lf.data.Ref
import com.daml.lf.engine.script._
import com.daml.lf.engine.script.ledgerinteraction.ScriptTimeMode
import com.daml.ports.Port
Expand Down Expand Up @@ -46,7 +46,7 @@ trait MultiParticipantFixture
Port(Integer.parseInt(Files.readAllLines(f).stream.collect(Collectors.joining("\n"))))
}

private val participantId1 = v1.ParticipantId.assertFromString("participant1")
private val participantId1 = Ref.ParticipantId.assertFromString("participant1")
private val participant1 = ParticipantConfig(
mode = ParticipantRunMode.Combined,
participantId = participantId1,
Expand All @@ -59,7 +59,7 @@ trait MultiParticipantFixture
allowExistingSchema = false
),
)
private val participantId2 = v1.ParticipantId.assertFromString("participant2")
private val participantId2 = Ref.ParticipantId.assertFromString("participant2")
private val participant2 = ParticipantConfig(
mode = ParticipantRunMode.Combined,
participantId = participantId2,
Expand Down
1 change: 0 additions & 1 deletion language-support/java/codegen/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,6 @@ da_scala_test(
"//ledger/ledger-resources:ledger-resources-test-lib",
"//ledger/participant-integration-api",
"//ledger/participant-integration-api:participant-integration-api-tests-lib",
"//ledger/participant-state",
"//ledger/sandbox-classic",
"//ledger/sandbox-common",
"//libs-scala/ports",
Expand Down
1 change: 0 additions & 1 deletion language-support/scala/codegen-sample-app/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ da_scala_test(
"//ledger/ledger-resources",
"//ledger/metrics",
"//ledger/participant-integration-api",
"//ledger/participant-state",
"//ledger/sandbox-classic",
"//ledger/sandbox-classic:sandbox-classic-scala-tests-lib",
"//ledger/sandbox-common",
Expand Down
2 changes: 0 additions & 2 deletions ledger-service/http-json-testing/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
load(
"//bazel_tools:scala.bzl",
"da_scala_library",
"da_scala_test",
"lf_scalacopts",
"silencer_plugin",
)
Expand Down Expand Up @@ -57,7 +56,6 @@ hj_scalacopts = lf_scalacopts + [
"//ledger/ledger-api-common",
"//ledger/metrics",
"//ledger/participant-integration-api",
"//ledger/participant-state",
"//ledger/sandbox-classic",
"//ledger/sandbox-common",
"//libs-scala/auth-utils",
Expand Down
1 change: 0 additions & 1 deletion ledger-service/http-json/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,6 @@ alias(
"//ledger/ledger-resources",
"//ledger/participant-integration-api",
"//ledger/participant-integration-api:participant-integration-api-tests-lib",
"//ledger/participant-state",
"//ledger/sandbox",
"//ledger/sandbox-common",
"//ledger/sandbox-common:sandbox-common-scala-tests-lib",
Expand Down
3 changes: 0 additions & 3 deletions ledger/daml-on-sql/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ da_scala_library(
"//ledger/ledger-api-common",
"//ledger/ledger-resources",
"//ledger/participant-integration-api",
"//ledger/participant-state",
"//ledger/sandbox-classic",
"//ledger/sandbox-common:sandbox-common-ce",
"//libs-scala/ports",
Expand All @@ -52,7 +51,6 @@ da_scala_library(
"//ledger/caching",
"//ledger/ledger-api-common",
"//ledger/participant-integration-api",
"//ledger/participant-state",
"//ledger/sandbox-common",
"//libs-scala/ports",
"//libs-scala/postgresql-testing",
Expand Down Expand Up @@ -94,7 +92,6 @@ da_scala_test(
"//ledger/ledger-api-common",
"//ledger/ledger-api-domain",
"//ledger/participant-integration-api",
"//ledger/participant-state",
"//ledger/sandbox-common",
"//ledger/sandbox-common:sandbox-common-scala-tests-lib",
"//libs-scala/ports",
Expand Down
4 changes: 2 additions & 2 deletions ledger/daml-on-sql/src/main/scala/on/sql/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package com.daml.on

import com.daml.ledger.participant.state.v1
import com.daml.lf.data.Ref
import com.daml.platform.configuration.LedgerConfiguration
import com.daml.platform.sandbox.config.{LedgerName, SandboxConfig}
import scalaz.syntax.tag._
Expand All @@ -13,7 +13,7 @@ package object sql {
private[sql] val Name = LedgerName("Daml-on-SQL")

private[sql] val DefaultConfig = SandboxConfig.defaultConfig.copy(
participantId = v1.ParticipantId.assertFromString(Name.unwrap.toLowerCase()),
participantId = Ref.ParticipantId.assertFromString(Name.unwrap.toLowerCase()),
ledgerConfig = LedgerConfiguration.defaultLedgerBackedIndex,
implicitPartyAllocation = false,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ 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.ParticipantId
import com.daml.ledger.resources.{Resource, ResourceContext, ResourceOwner}
import com.daml.ledger.validator.StateKeySerializationStrategy
import com.daml.lf.data.Ref
import com.daml.lf.engine.Engine
import com.daml.metrics.Metrics
import com.daml.platform.akkastreams.dispatcher.Dispatcher
Expand All @@ -20,7 +20,7 @@ object InMemoryLedgerReaderWriter {

final class Owner(
ledgerId: LedgerId,
participantId: ParticipantId,
participantId: Ref.ParticipantId,
keySerializationStrategy: StateKeySerializationStrategy,
metrics: Metrics,
timeProvider: TimeProvider = InMemoryLedgerWriter.DefaultTimeProvider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import com.daml.ledger.participant.state.kvutils.DamlKvutils.{DamlStateKey, Daml
import com.daml.ledger.participant.state.kvutils.api.{CommitMetadata, LedgerWriter}
import com.daml.ledger.participant.state.kvutils.export.LedgerDataExporter
import com.daml.ledger.participant.state.kvutils.{KeyValueCommitting, Raw}
import com.daml.ledger.participant.state.v1.{ParticipantId, SubmissionResult}
import com.daml.ledger.participant.state.v1.SubmissionResult
import com.daml.ledger.resources.{Resource, ResourceContext, ResourceOwner}
import com.daml.ledger.validator.caching.{CachingStateReader, ImmutablesOnlyCacheUpdatePolicy}
import com.daml.ledger.validator.preexecution.{
Expand All @@ -27,16 +27,17 @@ import com.daml.ledger.validator.preexecution.{
}
import com.daml.ledger.validator.reading.{DamlLedgerStateReader, LedgerStateReader}
import com.daml.ledger.validator.{SerializingStateReader, StateKeySerializationStrategy}
import com.daml.lf.data.Ref
import com.daml.lf.engine.Engine
import com.daml.metrics.Metrics
import com.daml.telemetry.TelemetryContext
import com.daml.platform.akkastreams.dispatcher.Dispatcher
import com.daml.telemetry.TelemetryContext

import scala.concurrent.{ExecutionContext, Future}
import scala.util.Success

final class InMemoryLedgerWriter private[memory] (
override val participantId: ParticipantId,
override val participantId: Ref.ParticipantId,
dispatcher: Dispatcher[Index],
now: () => Instant,
state: InMemoryState,
Expand Down Expand Up @@ -77,7 +78,7 @@ object InMemoryLedgerWriter {
]

final class Owner(
participantId: ParticipantId,
participantId: Ref.ParticipantId,
keySerializationStrategy: StateKeySerializationStrategy,
metrics: Metrics,
timeProvider: TimeProvider = DefaultTimeProvider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ 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.ParticipantId
import com.daml.ledger.resources.ResourceOwner
import com.daml.ledger.validator.StateKeySerializationStrategy
import com.daml.lf.data.Ref
import com.daml.lf.engine.Engine
import com.daml.logging.LoggingContext
import com.daml.metrics.Metrics
Expand All @@ -25,7 +25,7 @@ class InMemoryLedgerReaderWriterIntegrationSpec

override def participantStateFactory(
ledgerId: LedgerId,
participantId: ParticipantId,
participantId: Ref.ParticipantId,
testId: String,
metrics: Metrics,
)(implicit loggingContext: LoggingContext): ResourceOwner[ParticipantState] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import com.codahale.metrics.MetricRegistry
import com.daml.ledger.api.testing.utils.AkkaBeforeAndAfterAll
import com.daml.ledger.participant.state.kvutils.Raw
import com.daml.ledger.participant.state.kvutils.api.CommitMetadata
import com.daml.ledger.participant.state.v1.{ParticipantId, SubmissionResult}
import com.daml.ledger.participant.state.v1.SubmissionResult
import com.daml.ledger.validator.LedgerStateAccess
import com.daml.lf.data.Ref
import com.daml.metrics.Metrics
Expand Down Expand Up @@ -37,7 +37,7 @@ class InMemoryLedgerWriterSpec
val mockCommitter = mock[InMemoryLedgerWriter.Committer]
when(
mockCommitter.commit(
any[ParticipantId],
any[Ref.ParticipantId],
any[String],
any[Raw.Envelope],
any[Instant],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import scala.{concurrent => sc}

final class SqlLedgerReaderWriter(
override val ledgerId: LedgerId = Ref.LedgerString.assertFromString(UUID.randomUUID.toString),
val participantId: ParticipantId,
val participantId: Ref.ParticipantId,
metrics: Metrics,
database: Database,
dispatcher: Dispatcher[Index],
Expand Down Expand Up @@ -89,7 +89,7 @@ object SqlLedgerReaderWriter {

final class Owner(
ledgerId: LedgerId,
participantId: ParticipantId,
participantId: Ref.ParticipantId,
metrics: Metrics,
engine: Engine,
jdbcUrl: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ 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.ParticipantId
import com.daml.ledger.resources.ResourceOwner
import com.daml.lf.data.Ref
import com.daml.lf.engine.Engine
import com.daml.logging.LoggingContext
import com.daml.metrics.Metrics
Expand All @@ -21,7 +21,7 @@ abstract class SqlLedgerReaderWriterIntegrationSpecBase(implementationName: Stri

override protected final def participantStateFactory(
ledgerId: LedgerId,
participantId: ParticipantId,
participantId: Ref.ParticipantId,
testId: String,
metrics: Metrics,
)(implicit loggingContext: LoggingContext): ResourceOwner[ParticipantState] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import java.nio.file.Path
import java.time.Duration

import com.daml.ledger.api.tls.TlsConfiguration
import com.daml.ledger.participant.state.v1.ParticipantId
import com.daml.lf.data.Ref
import com.daml.platform.apiserver.SeedService.Seeding
import com.daml.platform.configuration.IndexConfiguration
import com.daml.ports.Port

import scala.concurrent.duration.FiniteDuration

case class ApiServerConfig(
participantId: ParticipantId,
participantId: Ref.ParticipantId,
archiveFiles: List[File],
port: Port,
address: Option[String], // This defaults to "localhost" when set to `None`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import com.daml.ledger.configuration.Configuration
import com.daml.ledger.offset.Offset
import com.daml.ledger.participant.state.index.v2
import com.daml.ledger.participant.state.index.v2.IndexService
import com.daml.ledger.participant.state.v1._
import com.daml.lf.data.Ref
import com.daml.lf.language.Ast
import com.daml.lf.transaction.GlobalKey
Expand All @@ -44,15 +43,15 @@ private[daml] final class SpannedIndexService(delegate: IndexService) extends In

override def listLfPackages()(implicit
loggingContext: LoggingContext
): Future[Map[PackageId, v2.PackageDetails]] =
): Future[Map[Ref.PackageId, v2.PackageDetails]] =
delegate.listLfPackages()

override def getLfArchive(packageId: PackageId)(implicit
override def getLfArchive(packageId: Ref.PackageId)(implicit
loggingContext: LoggingContext
): Future[Option[DamlLf.Archive]] =
delegate.getLfArchive(packageId)

override def getLfPackage(packageId: PackageId)(implicit
override def getLfPackage(packageId: Ref.PackageId)(implicit
loggingContext: LoggingContext
): Future[Option[Ast.Package]] =
delegate.getLfPackage(packageId)
Expand All @@ -75,7 +74,7 @@ private[daml] final class SpannedIndexService(delegate: IndexService) extends In
override def getCompletions(
begin: domain.LedgerOffset,
applicationId: ApplicationId,
parties: Set[Party],
parties: Set[Ref.Party],
)(implicit loggingContext: LoggingContext): Source[CompletionStreamResponse, NotUsed] =
delegate.getCompletions(begin, applicationId, parties)

Expand Down Expand Up @@ -113,13 +112,13 @@ private[daml] final class SpannedIndexService(delegate: IndexService) extends In

override def getTransactionById(
transactionId: TransactionId,
requestingParties: Set[Party],
requestingParties: Set[Ref.Party],
)(implicit loggingContext: LoggingContext): Future[Option[GetFlatTransactionResponse]] =
delegate.getTransactionById(transactionId, requestingParties)

override def getTransactionTreeById(
transactionId: TransactionId,
requestingParties: Set[Party],
requestingParties: Set[Ref.Party],
)(implicit loggingContext: LoggingContext): Future[Option[GetTransactionResponse]] =
delegate.getTransactionTreeById(transactionId, requestingParties)

Expand All @@ -130,15 +129,15 @@ private[daml] final class SpannedIndexService(delegate: IndexService) extends In
delegate.getActiveContracts(filter, verbose)

override def lookupActiveContract(
readers: Set[Party],
readers: Set[Ref.Party],
contractId: Value.ContractId,
)(implicit
loggingContext: LoggingContext
): Future[Option[Value.ContractInst[Value.VersionedValue[Value.ContractId]]]] =
delegate.lookupActiveContract(readers, contractId)

override def lookupContractKey(
readers: Set[Party],
readers: Set[Ref.Party],
key: GlobalKey,
)(implicit loggingContext: LoggingContext): Future[Option[Value.ContractId]] =
delegate.lookupContractKey(readers, key)
Expand All @@ -151,10 +150,12 @@ private[daml] final class SpannedIndexService(delegate: IndexService) extends In
override def getLedgerId()(implicit loggingContext: LoggingContext): Future[LedgerId] =
delegate.getLedgerId()

override def getParticipantId()(implicit loggingContext: LoggingContext): Future[ParticipantId] =
override def getParticipantId()(implicit
loggingContext: LoggingContext
): Future[Ref.ParticipantId] =
delegate.getParticipantId()

override def getParties(parties: Seq[Party])(implicit
override def getParties(parties: Seq[Ref.Party])(implicit
loggingContext: LoggingContext
): Future[List[domain.PartyDetails]] =
delegate.getParties(parties)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ 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.configuration.LedgerId
import com.daml.ledger.participant.state.v1.{ParticipantId, WriteService}
import com.daml.ledger.participant.state.v1.WriteService
import com.daml.ledger.resources.{Resource, ResourceContext, ResourceOwner}
import com.daml.lf.data.Ref
import com.daml.lf.engine.{Engine, ValueEnricher}
import com.daml.logging.{ContextualizedLogger, LoggingContext}
import com.daml.metrics.Metrics
Expand Down Expand Up @@ -62,7 +63,7 @@ final class StandaloneApiServer(
private val logger = ContextualizedLogger.get(this.getClass)

// Name of this participant,
val participantId: ParticipantId = config.participantId
val participantId: Ref.ParticipantId = config.participantId

override def acquire()(implicit context: ResourceContext): Resource[ApiServer] = {
val packageStore = loadDamlPackages()
Expand Down
Loading

0 comments on commit bd12170

Please sign in to comment.