diff --git a/ledger/participant-integration-api/src/main/scala/db/migration/postgres/V2_1__Rebuild_Acs.scala b/ledger/participant-integration-api/src/main/scala/db/migration/postgres/V2_1__Rebuild_Acs.scala index ad9583d8182d..13b1620ee91b 100644 --- a/ledger/participant-integration-api/src/main/scala/db/migration/postgres/V2_1__Rebuild_Acs.scala +++ b/ledger/participant-integration-api/src/main/scala/db/migration/postgres/V2_1__Rebuild_Acs.scala @@ -13,26 +13,25 @@ import akka.NotUsed import akka.stream.scaladsl.Source import anorm.SqlParser._ import anorm.{BatchSql, Macro, NamedParameter, RowParser, SQL, SqlParser} -import com.daml.ledger.participant.state.v1.{ContractInst, TransactionId} +import com.daml.ledger.api.domain.RejectionReason +import com.daml.ledger.api.domain.RejectionReason._ +import com.daml.ledger.participant.state.v1.TransactionId +import com.daml.ledger.{ApplicationId, CommandId, WorkflowId} import com.daml.lf.data.Ref.Party import com.daml.lf.data.Relation.Relation import com.daml.lf.engine.Blinding import com.daml.lf.transaction.GlobalKey -import com.daml.lf.value.Value import com.daml.lf.value.Value.ContractId -import com.daml.ledger.api.domain.RejectionReason -import com.daml.ledger.api.domain.RejectionReason._ -import com.daml.ledger.{ApplicationId, CommandId, WorkflowId} -import com.daml.platform.store.Contract.ActiveContract -import com.daml.platform.store.Conversions._ -import com.daml.platform.store.entries.LedgerEntry -import com.daml.platform.store.serialization.KeyHasher -import com.daml.platform.store.{ActiveLedgerState, ActiveLedgerStateManager, Let, LetLookup} import com.daml.platform.db.migration.translation.{ ContractSerializer, TransactionSerializer, ValueSerializer, } +import com.daml.platform.store.Contract.ActiveContract +import com.daml.platform.store.Conversions._ +import com.daml.platform.store.entries.LedgerEntry +import com.daml.platform.store.serialization.KeyHasher +import com.daml.platform.store.{ActiveLedgerState, ActiveLedgerStateManager, Let, LetLookup} import org.flywaydb.core.api.migration.{BaseJavaMigration, Context} import org.slf4j.LoggerFactory @@ -328,7 +327,7 @@ private[migration] class V2_1__Rebuild_Acs extends BaseJavaMigration { override def divulgeAlreadyCommittedContracts( transactionId: TransactionId, global: Relation[ContractId, Party], - referencedContracts: List[(Value.ContractId, ContractInst)], + referencedContracts: ActiveLedgerState.ReferencedContracts, ) = { val divulgenceParams = global .flatMap { case (cid, parties) => diff --git a/ledger/participant-integration-api/src/main/scala/platform/store/ActiveLedgerState.scala b/ledger/participant-integration-api/src/main/scala/platform/store/ActiveLedgerState.scala index cb79d4a2f292..d36ca4f3d262 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/store/ActiveLedgerState.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/store/ActiveLedgerState.scala @@ -5,13 +5,13 @@ package com.daml.platform.store import java.time.Instant -import com.daml.ledger.participant.state.v1.ContractInst +import com.daml.ledger.TransactionId import com.daml.lf.data.Ref.Party import com.daml.lf.data.Relation.Relation import com.daml.lf.transaction.GlobalKey import com.daml.lf.value.Value import com.daml.lf.value.Value.ContractId -import com.daml.ledger.TransactionId +import com.daml.platform.store.ActiveLedgerState._ import com.daml.platform.store.Contract.ActiveContract private[platform] sealed abstract class LetLookup @@ -68,12 +68,19 @@ private[platform] trait ActiveLedgerState[ALS <: ActiveLedgerState[ALS]] { def divulgeAlreadyCommittedContracts( transactionId: TransactionId, global: Relation[ContractId, Party], - referencedContracts: List[(Value.ContractId, ContractInst)], + referencedContracts: ReferencedContracts, ): ALS /** Clone the current active ledger state. The new state starts out * being identical to the old one but writes to the cloned - * state will not affect the original state and the other way around. + * state will not affect the original state and the other way around. */ def cloneState(): ALS } + +object ActiveLedgerState { + + type ReferencedContracts = + List[(Value.ContractId, Value.ContractInst[Value.VersionedValue[Value.ContractId]])] + +} diff --git a/ledger/participant-integration-api/src/main/scala/platform/store/ActiveLedgerStateManager.scala b/ledger/participant-integration-api/src/main/scala/platform/store/ActiveLedgerStateManager.scala index 2283aee5764f..9a81f54c8ee4 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/store/ActiveLedgerStateManager.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/store/ActiveLedgerStateManager.scala @@ -7,13 +7,10 @@ import java.time.Instant import com.daml.ledger.api.domain.RejectionReason import com.daml.ledger.api.domain.RejectionReason.{Inconsistent, InvalidLedgerTime} -import com.daml.ledger.participant.state.v1.ContractInst import com.daml.ledger.{TransactionId, WorkflowId} import com.daml.lf.data.Ref.Party import com.daml.lf.data.Relation.Relation -import com.daml.lf.transaction.GlobalKey -import com.daml.lf.transaction.{CommittedTransaction, NodeId, Node => N} -import com.daml.lf.value.Value +import com.daml.lf.transaction.{CommittedTransaction, GlobalKey, NodeId, Node => N} import com.daml.lf.value.Value.ContractId import com.daml.platform.store.Contract.ActiveContract @@ -64,8 +61,8 @@ private[platform] class ActiveLedgerStateManager[ALS <: ActiveLedgerState[ALS]]( copy(currentState = currentState.mapAcs(f), rollbackStates = rollbackStates.map(_.mapAcs(f))) def result: Either[Set[RejectionReason], ALS] = { - if (!rollbackStates.isEmpty) { - sys.error(s"IMPOSSIBLE finished transaction but rollback states is not empty") + if (rollbackStates.nonEmpty) { + sys.error("IMPOSSIBLE finished transaction but rollback states is not empty") } currentState.als match { case None => @@ -104,7 +101,7 @@ private[platform] class ActiveLedgerStateManager[ALS <: ActiveLedgerState[ALS]]( transaction: CommittedTransaction, disclosure: Relation[NodeId, Party], divulgence: Relation[ContractId, Party], - divulgedContracts: List[(Value.ContractId, ContractInst)], + divulgedContracts: ActiveLedgerState.ReferencedContracts, ): Either[Set[RejectionReason], ALS] = { // If some node requires a contract, check that we have that contract, and check that that contract is not // created after the current let. @@ -217,7 +214,7 @@ private[platform] class ActiveLedgerStateManager[ALS <: ActiveLedgerState[ALS]]( } else { state.copy( errs = state.errs + Inconsistent( - s"Contract key lookup with different results: expected [${nlkup.result}], actual [${currentResult}]" + s"Contract key lookup with different results: expected [${nlkup.result}], actual [$currentResult]" ) ) } 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 1be3c1aff8d3..2866f2f0e91e 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 @@ -25,7 +25,7 @@ import com.daml.ledger.{TransactionId, WorkflowId} import com.daml.lf.archive.ArchiveParser import com.daml.lf.data.{Ref, Time} import com.daml.lf.engine.ValueEnricher -import com.daml.lf.transaction.BlindingInfo +import com.daml.lf.transaction.{BlindingInfo, CommittedTransaction} import com.daml.logging.LoggingContext.withEnrichedLoggingContext import com.daml.logging.entries.LoggingEntry import com.daml.logging.{ContextualizedLogger, LoggingContext} diff --git a/ledger/participant-integration-api/src/main/scala/platform/store/appendonlydao/events/PostCommitValidation.scala b/ledger/participant-integration-api/src/main/scala/platform/store/appendonlydao/events/PostCommitValidation.scala index 229736cd8f0f..c6d05da80c8c 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/store/appendonlydao/events/PostCommitValidation.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/store/appendonlydao/events/PostCommitValidation.scala @@ -6,7 +6,8 @@ package com.daml.platform.store.appendonlydao.events import java.sql.Connection import java.time.Instant -import com.daml.ledger.participant.state.v1.{CommittedTransaction, RejectionReasonV0} +import com.daml.ledger.participant.state.v1.RejectionReasonV0 +import com.daml.lf.transaction.CommittedTransaction import com.daml.platform.store.backend.{ContractStorageBackend, PartyStorageBackend} /** Performs post-commit validation on transactions for Sandbox Classic. 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 15b258e4fc15..e5f83f540c18 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 @@ -40,7 +40,7 @@ import com.daml.lf.archive.ArchiveParser import com.daml.lf.data.Ref import com.daml.lf.data.Ref.{PackageId, Party} import com.daml.lf.engine.ValueEnricher -import com.daml.lf.transaction.BlindingInfo +import com.daml.lf.transaction.{BlindingInfo, CommittedTransaction} import com.daml.logging.LoggingContext.withEnrichedLoggingContext import com.daml.logging.entries.LoggingEntry import com.daml.logging.{ContextualizedLogger, LoggingContext} 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 21056498b775..496c6f276224 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 @@ -25,7 +25,7 @@ import com.daml.ledger.participant.state.v1._ import com.daml.ledger.{ApplicationId, WorkflowId} import com.daml.lf.data.Ref import com.daml.lf.data.Ref.{PackageId, Party} -import com.daml.lf.transaction.BlindingInfo +import com.daml.lf.transaction.{BlindingInfo, CommittedTransaction} import com.daml.logging.LoggingContext import com.daml.platform.indexer.OffsetStep import com.daml.platform.store.dao.events.TransactionsWriter.PreparedInsert 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 e3ce0dc1774f..c1b2580baf48 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 @@ -17,7 +17,7 @@ import com.daml.ledger.participant.state.v1._ import com.daml.ledger.{TransactionId, WorkflowId} import com.daml.lf.data.Ref import com.daml.lf.data.Ref.{PackageId, Party} -import com.daml.lf.transaction.BlindingInfo +import com.daml.lf.transaction.{BlindingInfo, CommittedTransaction} import com.daml.logging.LoggingContext import com.daml.metrics.{Metrics, Timed} import com.daml.platform.indexer.OffsetStep diff --git a/ledger/participant-integration-api/src/main/scala/platform/store/dao/events/PostCommitValidation.scala b/ledger/participant-integration-api/src/main/scala/platform/store/dao/events/PostCommitValidation.scala index 7c4028d595a5..e704406316d4 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/store/dao/events/PostCommitValidation.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/store/dao/events/PostCommitValidation.scala @@ -6,7 +6,8 @@ package com.daml.platform.store.dao.events import java.sql.Connection import java.time.Instant -import com.daml.ledger.participant.state.v1.{CommittedTransaction, RejectionReasonV0} +import com.daml.ledger.participant.state.v1.RejectionReasonV0 +import com.daml.lf.transaction.CommittedTransaction /** Performs post-commit validation on transactions for Sandbox Classic. * This is intended exclusively as a temporary replacement for diff --git a/ledger/participant-integration-api/src/main/scala/platform/store/dao/events/TransactionIndexing.scala b/ledger/participant-integration-api/src/main/scala/platform/store/dao/events/TransactionIndexing.scala index 25247db07c81..29972300cdeb 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/store/dao/events/TransactionIndexing.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/store/dao/events/TransactionIndexing.scala @@ -6,10 +6,10 @@ package com.daml.platform.store.dao.events import java.time.Instant import com.daml.ledger.offset.Offset +import com.daml.ledger.participant.state.v1.{DivulgedContract, SubmitterInfo} import com.daml.ledger.{TransactionId, WorkflowId} -import com.daml.ledger.participant.state.v1.{CommittedTransaction, DivulgedContract, SubmitterInfo} import com.daml.lf.ledger.EventId -import com.daml.lf.transaction.BlindingInfo +import com.daml.lf.transaction.{BlindingInfo, CommittedTransaction} import com.daml.platform.store.serialization.Compression import scala.collection.compat._ diff --git a/ledger/participant-integration-api/src/main/scala/platform/store/dao/events/TransactionsWriter.scala b/ledger/participant-integration-api/src/main/scala/platform/store/dao/events/TransactionsWriter.scala index 091744e4e9ec..c7db75f32896 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/store/dao/events/TransactionsWriter.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/store/dao/events/TransactionsWriter.scala @@ -8,10 +8,10 @@ import java.time.Instant import anorm.{Row, SimpleSql} import com.daml.ledger.offset.Offset -import com.daml.ledger.participant.state.v1.{CommittedTransaction, DivulgedContract, SubmitterInfo} +import com.daml.ledger.participant.state.v1.{DivulgedContract, SubmitterInfo} import com.daml.ledger.{TransactionId, WorkflowId} import com.daml.lf.engine.Blinding -import com.daml.lf.transaction.BlindingInfo +import com.daml.lf.transaction.{BlindingInfo, CommittedTransaction} import com.daml.metrics.{Metrics, Timed} import com.daml.platform.store.DbType 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 13d5da2ef52f..6a274e84d461 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 @@ -23,10 +23,11 @@ import com.daml.lf.data.{FrontStack, ImmArray, Ref, Time} import com.daml.lf.transaction.Node._ import com.daml.lf.transaction._ import com.daml.lf.transaction.test.TransactionBuilder -import com.daml.lf.value.Value.{ContractId, ContractInst, ValueText} +import com.daml.lf.value.Value.{ContractId, ContractInst, ValueText, VersionedValue} 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.JdbcLedgerDaoSuite._ import com.daml.platform.store.dao.events.TransactionsWriter import com.daml.platform.store.entries.LedgerEntry import org.scalatest.AsyncTestSuite @@ -652,7 +653,7 @@ private[dao] trait JdbcLedgerDaoSuite extends JdbcLedgerDaoBackend { ) protected final def store( - divulgedContracts: Map[(ContractId, v1.ContractInst), Set[Party]], + divulgedContracts: DivulgedContracts, blindingInfo: Option[BlindingInfo], offsetAndTx: (Offset, LedgerEntry.Transaction), ): Future[(Offset, LedgerEntry.Transaction)] = @@ -663,7 +664,7 @@ private[dao] trait JdbcLedgerDaoSuite extends JdbcLedgerDaoBackend { ) protected final def storeOffsetStepAndTx( - divulgedContracts: Map[(ContractId, v1.ContractInst), Set[Party]], + divulgedContracts: DivulgedContracts, blindingInfo: Option[BlindingInfo], offsetStepAndTx: (OffsetStep, LedgerEntry.Transaction), ): Future[(Offset, LedgerEntry.Transaction)] = { @@ -885,16 +886,19 @@ private[dao] trait JdbcLedgerDaoSuite extends JdbcLedgerDaoBackend { object JdbcLedgerDaoSuite { - import scalaz.syntax.traverse._ - import scalaz.{Free, Monad, NaturalTransformation, Traverse} + private type DivulgedContracts = + Map[(ContractId, ContractInst[VersionedValue[ContractId]]), Set[Party]] implicit final class `TraverseFM Ops`[T[_], A](private val self: T[A]) extends AnyVal { + import scalaz.syntax.traverse._ + import scalaz.{Free, Monad, NaturalTransformation, Traverse} + /** Like `traverse`, but guarantees that * * - `f` is evaluated left-to-right, and * - `B` from the preceding element is evaluated before `f` is invoked for - * the subsequent `A`. + * the subsequent `A`. */ def traverseFM[F[_]: Monad, B](f: A => F[B])(implicit T: Traverse[T]): F[T[B]] = self diff --git a/ledger/participant-integration-api/src/test/suite/scala/platform/indexer/ExecuteUpdateSpec.scala b/ledger/participant-integration-api/src/test/suite/scala/platform/indexer/ExecuteUpdateSpec.scala index f5ed2b832053..d016fc6942c9 100644 --- a/ledger/participant-integration-api/src/test/suite/scala/platform/indexer/ExecuteUpdateSpec.scala +++ b/ledger/participant-integration-api/src/test/suite/scala/platform/indexer/ExecuteUpdateSpec.scala @@ -17,7 +17,13 @@ import com.daml.ledger.participant.state.v1.Update.{ import com.daml.ledger.participant.state.v1._ import com.daml.ledger.resources.TestResourceContext import com.daml.lf.data.{Bytes, ImmArray, Ref, Time} -import com.daml.lf.transaction.{BlindingInfo, NodeId, TransactionVersion, VersionedTransaction} +import com.daml.lf.transaction.{ + BlindingInfo, + CommittedTransaction, + NodeId, + TransactionVersion, + VersionedTransaction, +} import com.daml.lf.value.Value.ContractId import com.daml.lf.{crypto, transaction} import com.daml.logging.LoggingContext 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 e5ad54708914..ac0e6f978a04 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 @@ -11,6 +11,7 @@ import com.daml.ledger.configuration.Configuration import com.daml.ledger.offset.Offset import com.daml.ledger.participant.state.v1._ import com.daml.lf.data.{Ref, Time} +import com.daml.lf.transaction.SubmittedTransaction import com.daml.metrics.{Metrics, Timed} import com.daml.telemetry.TelemetryContext 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 fd4986e81243..4ac4e7fff080 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 @@ -10,6 +10,7 @@ import com.daml.ledger.participant.state.kvutils.DamlKvutils._ import com.daml.ledger.participant.state.v1._ import com.daml.lf.data.Ref import com.daml.lf.data.Time.Timestamp +import com.daml.lf.transaction.SubmittedTransaction import com.daml.lf.value.Value.ContractId import com.daml.metrics.Metrics import com.google.protobuf.ByteString 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 778b6b99ddfd..e9a0050ab3d4 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 @@ -13,6 +13,7 @@ import com.daml.ledger.configuration.{Configuration, LedgerInitialConditions} import com.daml.ledger.offset.Offset import com.daml.ledger.participant.state.v1._ import com.daml.lf.data.{Ref, Time} +import com.daml.lf.transaction.SubmittedTransaction import com.daml.metrics.Metrics import com.daml.telemetry.TelemetryContext 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 2eab95dd2087..4c2b43aa0454 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 @@ -14,6 +14,7 @@ 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._ import com.daml.lf.data.{Ref, Time} +import com.daml.lf.transaction.SubmittedTransaction import com.daml.metrics.Metrics import com.daml.telemetry.TelemetryContext 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 da6fa1097291..f760c7c9aa3d 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 @@ -18,7 +18,7 @@ import com.daml.lf.data.Time.Timestamp import com.daml.lf.data.{ImmArray, Ref} import com.daml.lf.engine.Engine import com.daml.lf.language.Ast -import com.daml.lf.transaction.Transaction +import com.daml.lf.transaction.{SubmittedTransaction, Transaction} import com.daml.logging.LoggingContext import com.daml.metrics.Metrics import scalaz.std.list._ diff --git a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/DivulgedContract.scala b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/DivulgedContract.scala index d22a963359f4..431724512846 100644 --- a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/DivulgedContract.scala +++ b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/DivulgedContract.scala @@ -16,5 +16,5 @@ import com.daml.lf.value.Value */ final case class DivulgedContract( contractId: Value.ContractId, - contractInst: ContractInst, + contractInst: Value.ContractInst[Value.VersionedValue[Value.ContractId]], ) diff --git a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/TransactionMeta.scala b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/TransactionMeta.scala index 9646812f0471..9db01b3737bc 100644 --- a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/TransactionMeta.scala +++ b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/TransactionMeta.scala @@ -5,6 +5,7 @@ package com.daml.ledger.participant.state.v1 import com.daml.lf.crypto import com.daml.lf.data.{ImmArray, Ref, Time} +import com.daml.lf.transaction.NodeId /** Meta-data of a transaction visible to all parties that can see a part of * the transaction. 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 c7d4f88260b7..ab6adb848584 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 @@ -8,7 +8,7 @@ import com.daml.daml_lf_dev.DamlLf import com.daml.ledger.configuration.Configuration import com.daml.lf.data.Ref import com.daml.lf.data.Time.Timestamp -import com.daml.lf.transaction.BlindingInfo +import com.daml.lf.transaction.{BlindingInfo, CommittedTransaction} /** An update to the (abstract) participant state. * diff --git a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/WriteService.scala b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/WriteService.scala index b7932d3e2cf5..2425f10dc0b5 100644 --- a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/WriteService.scala +++ b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/WriteService.scala @@ -6,6 +6,7 @@ package com.daml.ledger.participant.state.v1 import java.util.concurrent.CompletionStage import com.daml.ledger.api.health.ReportsHealth +import com.daml.lf.transaction.SubmittedTransaction import com.daml.telemetry.TelemetryContext /** An interface to change a ledger via a participant. 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 06a27371d546..e35a93ab2df0 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 @@ -4,8 +4,6 @@ package com.daml.ledger.participant.state import com.daml.lf.data.Ref -import com.daml.lf.transaction -import com.daml.lf.value.Value /** Interfaces to read from and write to an (abstract) participant state. * @@ -76,24 +74,4 @@ package object v1 { val SubmissionId: Ref.LedgerString.type = Ref.LedgerString type SubmissionId = Ref.LedgerString - /** Identifiers for nodes in a transaction. */ - type NodeId = transaction.NodeId - - /** A transaction with contract IDs that may require suffixing. - * - * See the Contract Id specification for more detail daml-lf/spec/contract-id.rst - */ - type SubmittedTransaction = transaction.SubmittedTransaction - - /** A transaction with globally unique contract IDs. - * - * Used to communicate transactions that have been accepted to the ledger. - * See the Contract Id specification for more detail daml-lf/spec/contract-id.rst - */ - type CommittedTransaction = transaction.CommittedTransaction - - /** A contract instance. */ - type ContractInst = - Value.ContractInst[Value.VersionedValue[Value.ContractId]] - } 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 5ab15088da52..ad6db64a1253 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 @@ -12,6 +12,7 @@ import com.daml.ledger.configuration.Configuration import com.daml.ledger.offset.Offset import com.daml.ledger.participant.state.v1 import com.daml.lf.data.{Ref, Time} +import com.daml.lf.transaction.SubmittedTransaction import com.daml.telemetry.TelemetryContext import com.google.rpc.code.Code import com.google.rpc.error_details.ErrorInfo diff --git a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/DivulgedContract.scala b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/DivulgedContract.scala index 83acce87844b..2e4c7672cd58 100644 --- a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/DivulgedContract.scala +++ b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/DivulgedContract.scala @@ -16,5 +16,5 @@ import com.daml.lf.value.Value */ final case class DivulgedContract( contractId: Value.ContractId, - contractInst: ContractInst, + contractInst: Value.ContractInst[Value.VersionedValue[Value.ContractId]], ) diff --git a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/TransactionMeta.scala b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/TransactionMeta.scala index ebe104f36aa0..2cc67f909802 100644 --- a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/TransactionMeta.scala +++ b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/TransactionMeta.scala @@ -5,6 +5,7 @@ package com.daml.ledger.participant.state.v2 import com.daml.lf.crypto import com.daml.lf.data.{ImmArray, Ref, Time} +import com.daml.lf.transaction.NodeId /** Meta-data of a transaction visible to all parties that can see a part of * the transaction. 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 b9b7cce91136..f84b55de82f9 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 @@ -7,7 +7,7 @@ import com.daml.daml_lf_dev.DamlLf import com.daml.ledger.configuration.Configuration import com.daml.lf.data.Ref import com.daml.lf.data.Time.Timestamp -import com.daml.lf.transaction.BlindingInfo +import com.daml.lf.transaction.{BlindingInfo, CommittedTransaction} /** An update to the (abstract) participant state. * diff --git a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/WriteService.scala b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/WriteService.scala index 7fc0ec6ac245..fd992c0c039d 100644 --- a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/WriteService.scala +++ b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v2/WriteService.scala @@ -7,6 +7,7 @@ import java.util.concurrent.CompletionStage import com.daml.ledger.api.health.ReportsHealth import com.daml.lf.data.Time +import com.daml.lf.transaction.SubmittedTransaction import com.daml.telemetry.TelemetryContext /** An interface to change a ledger via a participant. 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 5ebc1ace2bd3..52a481ac5919 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 @@ -4,8 +4,6 @@ package com.daml.ledger.participant.state import com.daml.lf.data.Ref -import com.daml.lf.transaction -import com.daml.lf.value.Value /** Interfaces to read from and write to an (abstract) participant state. * @@ -69,24 +67,4 @@ package object v2 { val SubmissionId: Ref.LedgerString.type = Ref.LedgerString type SubmissionId = Ref.LedgerString - /** Identifiers for nodes in a transaction. */ - type NodeId = transaction.NodeId - - /** A transaction with contract IDs that may require suffixing. - * - * See the Contract Id specification for more detail daml-lf/spec/contract-id.rst - */ - type SubmittedTransaction = transaction.SubmittedTransaction - - /** A transaction with globally unique contract IDs. - * - * Used to communicate transactions that have been accepted to the ledger. - * See the Contract Id specification for more detail daml-lf/spec/contract-id.rst - */ - type CommittedTransaction = transaction.CommittedTransaction - - /** A contract instance. */ - type ContractInst = - Value.ContractInst[Value.VersionedValue[Value.ContractId]] - } diff --git a/ledger/sandbox-classic/src/main/scala/platform/sandbox/stores/InMemoryActiveLedgerState.scala b/ledger/sandbox-classic/src/main/scala/platform/sandbox/stores/InMemoryActiveLedgerState.scala index ebf088f1711e..5b2e21cd4089 100644 --- a/ledger/sandbox-classic/src/main/scala/platform/sandbox/stores/InMemoryActiveLedgerState.scala +++ b/ledger/sandbox-classic/src/main/scala/platform/sandbox/stores/InMemoryActiveLedgerState.scala @@ -6,13 +6,10 @@ package com.daml.platform.sandbox.stores import java.time.Instant import com.daml.ledger.api.domain.{PartyDetails, RejectionReason} -import com.daml.ledger.participant.state.v1.ContractInst import com.daml.ledger.{TransactionId, WorkflowId} import com.daml.lf.data.Ref.Party import com.daml.lf.data.Relation.Relation -import com.daml.lf.transaction.GlobalKey -import com.daml.lf.transaction.{CommittedTransaction, NodeId} -import com.daml.lf.value.Value +import com.daml.lf.transaction.{CommittedTransaction, GlobalKey, NodeId} import com.daml.lf.value.Value.ContractId import com.daml.platform.store.Contract.{ActiveContract, DivulgedContract} import com.daml.platform.store._ @@ -100,7 +97,7 @@ private[sandbox] case class InMemoryActiveLedgerState( override def divulgeAlreadyCommittedContracts( transactionId: TransactionId, global: Relation[ContractId, Party], - referencedContracts: List[(Value.ContractId, ContractInst)], + referencedContracts: ActiveLedgerState.ReferencedContracts, ): InMemoryActiveLedgerState = if (global.nonEmpty) { val referencedContractsM = referencedContracts.toMap @@ -158,7 +155,7 @@ private[sandbox] case class InMemoryActiveLedgerState( transaction: CommittedTransaction, disclosure: Relation[NodeId, Party], divulgence: Relation[ContractId, Party], - referencedContracts: List[(Value.ContractId, ContractInst)], + referencedContracts: ActiveLedgerState.ReferencedContracts, ): Either[Set[RejectionReason], InMemoryActiveLedgerState] = acManager.addTransaction( let, 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 c5eeb075ba26..7ae638e6ae4a 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 @@ -14,13 +14,13 @@ import com.daml.ledger.participant.state.v1.{ PruningResult, SubmissionId, SubmissionResult, - SubmittedTransaction, SubmitterInfo, TransactionMeta, WriteService, } import com.daml.lf.data.Ref.Party import com.daml.lf.data.Time +import com.daml.lf.transaction.SubmittedTransaction import com.daml.logging.LoggingContext import com.daml.logging.LoggingContext.withEnrichedLoggingContext import com.daml.platform.sandbox.stores.ledger.{Ledger, PartyIdGenerator} 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 4c5a909c5315..9bdc49462a76 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 @@ -12,7 +12,12 @@ import com.daml.lf.data.Ref.Party import com.daml.lf.data.Relation.Relation import com.daml.lf.data.Time.Timestamp import com.daml.lf.engine.Blinding -import com.daml.lf.transaction.{NodeId, TransactionCommitter} +import com.daml.lf.transaction.{ + CommittedTransaction, + NodeId, + SubmittedTransaction, + TransactionCommitter, +} import com.daml.lf.value.Value.ContractId 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 168174d3c004..7adf64433a9a 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 @@ -10,6 +10,7 @@ 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 +import com.daml.lf.transaction.SubmittedTransaction import com.daml.logging.LoggingContext import com.daml.metrics.{Metrics, Timed} import com.daml.platform.index.MeteredReadOnlyLedger 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 caaf779ff7b3..f663ae101a53 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 @@ -44,7 +44,7 @@ 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 -import com.daml.lf.transaction.{GlobalKey, TransactionCommitter} +import com.daml.lf.transaction.{GlobalKey, SubmittedTransaction, TransactionCommitter} import com.daml.lf.value.Value import com.daml.lf.value.Value.{ContractId, ContractInst} import com.daml.logging.{ContextualizedLogger, LoggingContext} 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 ef6d849d95c1..5d56ce80b786 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 @@ -24,7 +24,7 @@ import com.daml.ledger.resources.{Resource, ResourceContext, ResourceOwner} import com.daml.lf.data.Ref.Party import com.daml.lf.data.{ImmArray, Ref, Time} import com.daml.lf.engine.{Engine, ValueEnricher} -import com.daml.lf.transaction.TransactionCommitter +import com.daml.lf.transaction.{SubmittedTransaction, TransactionCommitter} import com.daml.logging.{ContextualizedLogger, LoggingContext} import com.daml.metrics.Metrics import com.daml.platform.ApiOffset.ApiOffsetConverter 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 8e7947494487..9ee860af8c20 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 @@ -20,8 +20,9 @@ import com.daml.ledger.configuration.{ import com.daml.ledger.offset.Offset import com.daml.ledger.participant.state.v1._ import com.daml.lf.data.Ref.Party -import com.daml.lf.data.{Ref, Time} import com.daml.lf.data.Time.Timestamp +import com.daml.lf.data.{Ref, Time} +import com.daml.lf.transaction.{CommittedTransaction, SubmittedTransaction} import com.daml.logging.{ContextualizedLogger, LoggingContext} import com.daml.telemetry.TelemetryContext import com.google.common.primitives.Longs