From 7127bde2f8bf7b561a4e006d59e73432a38fb09a Mon Sep 17 00:00:00 2001 From: Remy Haemmerle Date: Tue, 5 Oct 2021 10:04:55 +0200 Subject: [PATCH] LF: Create special case class for VersionedContractInstance To replace usage of ContractInstance[VersionedValue] CHANGELOG_BEGIN CHANGELOG_END --- .../digitalasset/daml/lf/engine/Result.scala | 6 +- .../daml/lf/engine/ValueEnricher.scala | 6 +- .../daml/lf/engine/EngineTest.scala | 176 +++++++++--------- .../daml/lf/engine/LargeTransactionTest.scala | 2 +- .../daml/lf/engine/ReinterpretTest.scala | 16 +- .../daml/lf/scenario/ScenarioLedger.scala | 2 +- .../daml/lf/speedy/SBuiltin.scala | 4 +- .../digitalasset/daml/lf/speedy/SResult.scala | 4 +- .../digitalasset/daml/lf/ScenarioRunner.scala | 8 +- .../lf/speedy/perf/CollectAuthority.scala | 12 +- .../transaction/test/TransactionBuilder.scala | 22 ++- .../scala/lf/value/test/ValueGenerators.scala | 4 +- .../daml/lf/transaction/Node.scala | 4 +- .../daml/lf/transaction/Transaction.scala | 3 +- .../lf/transaction/TransactionCoder.scala | 13 +- .../daml/lf/transaction/Util.scala | 7 +- .../digitalasset/daml/lf/value/Value.scala | 21 +++ .../lf/transaction/TransactionCoderSpec.scala | 16 +- .../ledgerinteraction/IdeLedgerClient.scala | 13 +- .../V26_1__Fill_create_argument.scala | 2 +- .../translation/ContractSerializer.scala | 10 +- .../apiserver/SpannedIndexService.scala | 2 +- .../apiserver/TimedIndexService.scala | 2 +- .../index/LedgerBackedIndexService.scala | 5 +- .../index/MeteredReadOnlyLedger.scala | 7 +- .../platform/store/ActiveLedgerState.scala | 2 +- .../scala/platform/store/BaseLedger.scala | 5 +- .../main/scala/platform/store/Contract.scala | 8 +- .../scala/platform/store/ReadOnlyLedger.scala | 7 +- .../store/appendonlydao/events/package.scala | 4 +- .../store/backend/UpdateToDbDto.scala | 2 +- .../MutableCacheBackedContractStore.scala | 2 +- .../scala/platform/store/cache/package.scala | 2 +- .../dao/events/TransactionIndexing.scala | 2 +- .../platform/store/dao/events/package.scala | 4 +- .../interfaces/LedgerDaoContractsReader.scala | 2 +- .../dao/JdbcLedgerDaoContractsSpec.scala | 6 +- .../dao/JdbcLedgerDaoDivulgenceSpec.scala | 10 +- .../store/dao/JdbcLedgerDaoSuite.scala | 4 +- .../state/index/v2/ContractStore.scala | 5 +- .../state/kvutils/Conversions.scala | 10 +- .../ModelConformanceValidator.scala | 2 +- .../ModelConformanceValidatorSpec.scala | 16 +- .../kvutils/tools/engine/replay/Adapter.scala | 7 +- .../kvutils/tools/engine/replay/Replay.scala | 5 +- .../state/v1/DivulgedContract.scala | 2 +- .../state/v2/DivulgedContract.scala | 2 +- .../ledger/inmemory/InMemoryLedger.scala | 7 +- 48 files changed, 258 insertions(+), 225 deletions(-) diff --git a/daml-lf/engine/src/main/scala/com/digitalasset/daml/lf/engine/Result.scala b/daml-lf/engine/src/main/scala/com/digitalasset/daml/lf/engine/Result.scala index 3e4aa1e7b52a..c815508a6b1f 100644 --- a/daml-lf/engine/src/main/scala/com/digitalasset/daml/lf/engine/Result.scala +++ b/daml-lf/engine/src/main/scala/com/digitalasset/daml/lf/engine/Result.scala @@ -41,7 +41,7 @@ sealed trait Result[+A] extends Product with Serializable { } def consume( - pcs: ContractId => Option[ContractInst[VersionedValue]], + pcs: ContractId => Option[VersionedContractInstance], packages: PackageId => Option[Package], keys: GlobalKeyWithMaintainers => Option[ContractId], ): Either[Error, A] = { @@ -86,7 +86,7 @@ object ResultError { */ final case class ResultNeedContract[A]( acoid: ContractId, - resume: Option[ContractInst[VersionedValue]] => Result[A], + resume: Option[VersionedContractInstance] => Result[A], ) extends Result[A] /** Intermediate result indicating that a [[Package]] is required to complete the computation. @@ -121,7 +121,7 @@ object Result { private[lf] def needContract[A]( acoid: ContractId, - resume: ContractInst[VersionedValue] => Result[A], + resume: VersionedContractInstance => Result[A], ) = ResultNeedContract( acoid, diff --git a/daml-lf/engine/src/main/scala/com/digitalasset/daml/lf/engine/ValueEnricher.scala b/daml-lf/engine/src/main/scala/com/digitalasset/daml/lf/engine/ValueEnricher.scala index be3fb712c9d6..4d605a33649f 100644 --- a/daml-lf/engine/src/main/scala/com/digitalasset/daml/lf/engine/ValueEnricher.scala +++ b/daml-lf/engine/src/main/scala/com/digitalasset/daml/lf/engine/ValueEnricher.scala @@ -50,10 +50,10 @@ final class ValueEnricher( } yield contract.copy(arg = arg) def enrichVersionedContract( - contract: Value.ContractInst[VersionedValue] - ): Result[Value.ContractInst[VersionedValue]] = + contract: Value.VersionedContractInstance + ): Result[Value.VersionedContractInstance] = for { - arg <- enrichVersionedValue(Ast.TTyCon(contract.template), contract.arg) + arg <- enrichValue(Ast.TTyCon(contract.template), contract.arg) } yield contract.copy(arg = arg) def enrichContract(tyCon: Identifier, value: Value): Result[Value] = diff --git a/daml-lf/engine/src/test/scala/com/digitalasset/daml/lf/engine/EngineTest.scala b/daml-lf/engine/src/test/scala/com/digitalasset/daml/lf/engine/EngineTest.scala index 55003bb23350..911a3def2997 100644 --- a/daml-lf/engine/src/test/scala/com/digitalasset/daml/lf/engine/EngineTest.scala +++ b/daml-lf/engine/src/test/scala/com/digitalasset/daml/lf/engine/EngineTest.scala @@ -32,7 +32,7 @@ import com.daml.lf.speedy.SValue._ import com.daml.lf.command._ import com.daml.lf.engine.Error.Interpretation import com.daml.lf.transaction.Node.{GenActionNode, GenNode} -import com.daml.lf.transaction.test.TransactionBuilder.assertAsVersionedValue +import com.daml.lf.transaction.test.TransactionBuilder.assertAsVersionedContract import org.scalactic.Equality import org.scalatest.prop.TableDrivenPropertyChecks import org.scalatest.EitherValues @@ -73,47 +73,47 @@ class EngineTest val withKeyTemplate = "BasicTests:WithKey" val BasicTests_WithKey = Identifier(basicTestsPkgId, withKeyTemplate) - val withKeyContractInst: ContractInst[Value.VersionedValue] = - ContractInst( - TypeConName(basicTestsPkgId, withKeyTemplate), - assertAsVersionedValue( + val withKeyContractInst: VersionedContractInstance = + assertAsVersionedContract( + ContractInst( + TypeConName(basicTestsPkgId, withKeyTemplate), ValueRecord( Some(BasicTests_WithKey), ImmArray( (Some[Ref.Name]("p"), ValueParty(alice)), (Some[Ref.Name]("k"), ValueInt64(42)), ), - ) - ), - "", + ), + "", + ) ) - val defaultContracts: Map[ContractId, ContractInst[Value.VersionedValue]] = + val defaultContracts: Map[ContractId, VersionedContractInstance] = Map( toContractId("BasicTests:Simple:1") -> - ContractInst( - TypeConName(basicTestsPkgId, "BasicTests:Simple"), - assertAsVersionedValue( + assertAsVersionedContract( + ContractInst( + TypeConName(basicTestsPkgId, "BasicTests:Simple"), ValueRecord( Some(Identifier(basicTestsPkgId, "BasicTests:Simple")), ImmArray((Some[Name]("p"), ValueParty(party))), - ) - ), - "", + ), + "", + ) ), toContractId("BasicTests:CallablePayout:1") -> - ContractInst( - TypeConName(basicTestsPkgId, "BasicTests:CallablePayout"), - assertAsVersionedValue( + assertAsVersionedContract( + ContractInst( + TypeConName(basicTestsPkgId, "BasicTests:CallablePayout"), ValueRecord( Some(Identifier(basicTestsPkgId, "BasicTests:CallablePayout")), ImmArray( (Some[Ref.Name]("giver"), ValueParty(alice)), (Some[Ref.Name]("receiver"), ValueParty(bob)), ), - ) - ), - "", + ), + "", + ) ), toContractId("BasicTests:WithKey:1") -> withKeyContractInst, @@ -1170,13 +1170,15 @@ class EngineTest tid: Ref.QualifiedName, targs: ImmArray[(Option[Name], Value)], ) = - ContractInst( - TypeConName(basicTestsPkgId, tid), - assertAsVersionedValue(ValueRecord(Some(Identifier(basicTestsPkgId, tid)), targs)), - "", + assertAsVersionedContract( + ContractInst( + TypeConName(basicTestsPkgId, tid), + ValueRecord(Some(Identifier(basicTestsPkgId, tid)), targs), + "", + ) ) - def lookupContract(id: ContractId): Option[ContractInst[Value.VersionedValue]] = { + def lookupContract(id: ContractId): Option[VersionedContractInstance] = { id match { case `fetchedCid` => Some(makeContract(fetchedStrTid, fetchedTArgs)) case `fetcher1Cid` => Some(makeContract(fetcherStrTid, fetcher1TArgs)) @@ -1285,22 +1287,23 @@ class EngineTest val fetchedStrTid = "BasicTests:Fetched" val fetchedTid = Identifier(basicTestsPkgId, fetchedStrTid) - val fetchedContract = ContractInst( - TypeConName(basicTestsPkgId, fetchedStrTid), - assertAsVersionedValue( - ValueRecord( - Some(Identifier(basicTestsPkgId, fetchedStrTid)), - ImmArray( - (Some[Name]("sig1"), ValueParty(alice)), - (Some[Name]("sig2"), ValueParty(bob)), - (Some[Name]("obs"), ValueParty(clara)), + val fetchedContract = + assertAsVersionedContract( + ContractInst( + TypeConName(basicTestsPkgId, fetchedStrTid), + ValueRecord( + Some(Identifier(basicTestsPkgId, fetchedStrTid)), + ImmArray( + (Some[Name]("sig1"), ValueParty(alice)), + (Some[Name]("sig2"), ValueParty(bob)), + (Some[Name]("obs"), ValueParty(clara)), + ), ), + "", ) - ), - "", - ) + ) - def lookupContract(id: ContractId): Option[ContractInst[Value.VersionedValue]] = { + def lookupContract(id: ContractId): Option[VersionedContractInstance] = { id match { case `fetchedCid` => Some(fetchedContract) case _ => None @@ -1341,13 +1344,14 @@ class EngineTest val lookerUpTemplate = "BasicTests:LookerUpByKey" val lookerUpTemplateId = Identifier(basicTestsPkgId, lookerUpTemplate) val lookerUpCid = toContractId("2") - val lookerUpInst = ContractInst( - TypeConName(basicTestsPkgId, lookerUpTemplate), - assertAsVersionedValue( - ValueRecord(Some(lookerUpTemplateId), ImmArray((Some[Name]("p"), ValueParty(alice)))) - ), - "", - ) + val lookerUpInst = + assertAsVersionedContract( + ContractInst( + TypeConName(basicTestsPkgId, lookerUpTemplate), + ValueRecord(Some(lookerUpTemplateId), ImmArray((Some[Name]("p"), ValueParty(alice)))), + "", + ) + ) def lookupKey(key: GlobalKeyWithMaintainers): Option[ContractId] = { (key.globalKey.templateId, key.globalKey.key) match { @@ -1589,12 +1593,12 @@ class EngineTest val fetcherTemplate = "BasicTests:FetcherByKey" val fetcherTemplateId = Identifier(basicTestsPkgId, fetcherTemplate) val fetcherCid = toContractId("2") - val fetcherInst = ContractInst( - TypeConName(basicTestsPkgId, fetcherTemplate), - assertAsVersionedValue( - ValueRecord(Some(fetcherTemplateId), ImmArray((Some[Name]("p"), ValueParty(alice)))) - ), - "", + val fetcherInst = assertAsVersionedContract( + ContractInst( + TypeConName(basicTestsPkgId, fetcherTemplate), + ValueRecord(Some(fetcherTemplateId), ImmArray((Some[Name]("p"), ValueParty(alice)))), + "", + ) ) def lookupKey(key: GlobalKeyWithMaintainers): Option[ContractId] = { @@ -1666,15 +1670,19 @@ class EngineTest val fetcherId = Identifier(basicTestsPkgId, "BasicTests:Fetcher") val cid = toContractId("BasicTests:WithKey:1") val fetcherCid = toContractId("42") - val fetcherInst = ContractInst( - fetcherId, - assertAsVersionedValue( + val fetcherInst = assertAsVersionedContract( + ContractInst( + fetcherId, ValueRecord( None, - ImmArray((None, ValueParty(alice)), (None, ValueParty(alice)), (None, ValueParty(alice))), - ) - ), - "", + ImmArray( + (None, ValueParty(alice)), + (None, ValueParty(alice)), + (None, ValueParty(alice)), + ), + ), + "", + ) ) val contracts = defaultContracts + (fetcherCid -> fetcherInst) val lookupContract = contracts.get(_) @@ -1950,10 +1958,12 @@ class EngineTest val cid1 = toContractId("1") val cid2 = toContractId("2") - val keyedInst = ContractInst( - TypeConName(multiKeysPkgId, "MultiKeys:Keyed"), - assertAsVersionedValue(ValueRecord(None, ImmArray((None, ValueParty(party))))), - "", + val keyedInst = assertAsVersionedContract( + ContractInst( + TypeConName(multiKeysPkgId, "MultiKeys:Keyed"), + ValueRecord(None, ImmArray((None, ValueParty(party)))), + "", + ) ) val contracts = Map(cid1 -> keyedInst, cid2 -> keyedInst) val lookupContract = contracts.get(_) @@ -2074,12 +2084,12 @@ class EngineTest val seeding = Engine.initialSeeding(submissionSeed, participant, let) val cid = toContractId("1") val contracts = Map( - cid -> ContractInst( - TypeConName(exceptionsPkgId, "Exceptions:K"), - assertAsVersionedValue( - ValueRecord(None, ImmArray((None, ValueParty(party)), (None, ValueInt64(0)))) - ), - "", + cid -> assertAsVersionedContract( + ContractInst( + TypeConName(exceptionsPkgId, "Exceptions:K"), + ValueRecord(None, ImmArray((None, ValueParty(party)), (None, ValueInt64(0)))), + "", + ) ) ) val lookupContract = contracts.get(_) @@ -2184,12 +2194,12 @@ class EngineTest val seeding = Engine.initialSeeding(submissionSeed, participant, let) val cid = toContractId("1") val contracts = Map( - cid -> ContractInst( - TypeConName(exceptionsPkgId, "Exceptions:K"), - assertAsVersionedValue( - ValueRecord(None, ImmArray((None, ValueParty(party)), (None, ValueInt64(0)))) - ), - "", + cid -> assertAsVersionedContract( + ContractInst( + TypeConName(exceptionsPkgId, "Exceptions:K"), + ValueRecord(None, ImmArray((None, ValueParty(party)), (None, ValueInt64(0)))), + "", + ) ) ) val lookupContract = contracts.get(_) @@ -2261,12 +2271,12 @@ class EngineTest val seeding = Engine.initialSeeding(submissionSeed, participant, let) val cid = toContractId("1") val contracts = Map( - cid -> ContractInst( - TypeConName(exceptionsPkgId, "Exceptions:K"), - assertAsVersionedValue( - ValueRecord(None, ImmArray((None, ValueParty(party)), (None, ValueInt64(0)))) - ), - "", + cid -> assertAsVersionedContract( + ContractInst( + TypeConName(exceptionsPkgId, "Exceptions:K"), + ValueRecord(None, ImmArray((None, ValueParty(party)), (None, ValueInt64(0)))), + "", + ) ) ) val lookupContract = contracts.get(_) @@ -2453,7 +2463,7 @@ object EngineTest { data.assertRight(tx.suffixCid(_ => dummySuffix)) private[this] case class ReinterpretState( - contracts: Map[ContractId, ContractInst[Value.VersionedValue]], + contracts: Map[ContractId, VersionedContractInstance], keys: Map[GlobalKey, ContractId], nodes: HashMap[NodeId, GenNode] = HashMap.empty, roots: BackStack[NodeId] = BackStack.empty, @@ -2497,7 +2507,7 @@ object EngineTest { txMeta: Tx.Metadata, ledgerEffectiveTime: Time.Timestamp, lookupPackages: PackageId => Option[Package], - contracts: Map[ContractId, ContractInst[Value.VersionedValue]] = Map.empty, + contracts: Map[ContractId, VersionedContractInstance] = Map.empty, keys: Map[GlobalKey, ContractId] = Map.empty, ): Either[Error, (Tx.Transaction, Tx.Metadata)] = { diff --git a/daml-lf/engine/src/test/scala/com/digitalasset/daml/lf/engine/LargeTransactionTest.scala b/daml-lf/engine/src/test/scala/com/digitalasset/daml/lf/engine/LargeTransactionTest.scala index c4f54e58c727..3f4d6057b24f 100644 --- a/daml-lf/engine/src/test/scala/com/digitalasset/daml/lf/engine/LargeTransactionTest.scala +++ b/daml-lf/engine/src/test/scala/com/digitalasset/daml/lf/engine/LargeTransactionTest.scala @@ -62,7 +62,7 @@ class LargeTransactionTest extends AnyWordSpec with Matchers with BazelRunfiles def get(submitter: Party, effectiveAt: Time.Timestamp)( id: ContractId - ): Option[ContractInst[VersionedValue]] = { + ): Option[VersionedContractInstance] = { ledger.lookupGlobalContract( ParticipantView(Set(submitter), Set.empty), effectiveAt, diff --git a/daml-lf/engine/src/test/scala/com/digitalasset/daml/lf/engine/ReinterpretTest.scala b/daml-lf/engine/src/test/scala/com/digitalasset/daml/lf/engine/ReinterpretTest.scala index c9286517383d..01354f2eb405 100644 --- a/daml-lf/engine/src/test/scala/com/digitalasset/daml/lf/engine/ReinterpretTest.scala +++ b/daml-lf/engine/src/test/scala/com/digitalasset/daml/lf/engine/ReinterpretTest.scala @@ -20,7 +20,7 @@ import com.daml.lf.transaction.{ import com.daml.lf.transaction.Node.{NodeRollback, NodeExercises, NodeCreate} import com.daml.lf.value.Value._ import com.daml.lf.command._ -import com.daml.lf.transaction.test.TransactionBuilder.assertAsVersionedValue +import com.daml.lf.transaction.test.TransactionBuilder.{assertAsVersionedContract} import org.scalatest.prop.TableDrivenPropertyChecks import org.scalatest.EitherValues import org.scalatest.wordspec.AnyWordSpec @@ -50,18 +50,18 @@ class ReinterpretTest "daml-lf/tests/ReinterpretTests.dar" ) - private val defaultContracts: Map[ContractId, ContractInst[VersionedValue]] = + private val defaultContracts: Map[ContractId, VersionedContractInstance] = Map( toContractId("ReinterpretTests:MySimple:1") -> - ContractInst( - TypeConName(miniTestsPkgId, "ReinterpretTests:MySimple"), - assertAsVersionedValue( + assertAsVersionedContract( + ContractInst( + TypeConName(miniTestsPkgId, "ReinterpretTests:MySimple"), ValueRecord( Some(Identifier(miniTestsPkgId, "ReinterpretTests:MySimple")), ImmArray((Some[Name]("p"), ValueParty(party))), - ) - ), - "", + ), + "", + ) ) ) diff --git a/daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/scenario/ScenarioLedger.scala b/daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/scenario/ScenarioLedger.scala index aed63486382f..44cc3b4c3bf2 100644 --- a/daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/scenario/ScenarioLedger.scala +++ b/daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/scenario/ScenarioLedger.scala @@ -204,7 +204,7 @@ object ScenarioLedger { final case class LookupOk( coid: ContractId, - coinst: ContractInst[Value.VersionedValue], + coinst: VersionedContractInstance, stakeholders: Set[Party], ) extends LookupResult final case class LookupContractNotFound(coid: ContractId) extends LookupResult diff --git a/daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/speedy/SBuiltin.scala b/daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/speedy/SBuiltin.scala index a240c3ba1979..b53acd3eebb5 100644 --- a/daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/speedy/SBuiltin.scala +++ b/daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/speedy/SBuiltin.scala @@ -1040,7 +1040,7 @@ private[lf] object SBuiltin { coid, templateId, onLedger.committers, - { case V.ContractInst(actualTmplId, V.VersionedValue(_, arg), _) => + { case V.VersionedContractInstance(_, actualTmplId, arg, _) => if (actualTmplId != templateId) { machine.ctrl = SEDamlException(IE.WronglyTypedContract(coid, templateId, actualTmplId)) @@ -1090,7 +1090,7 @@ private[lf] object SBuiltin { coid, ifaceId, // not actually used, maybe this param should be dropped from SResultNeedContract onLedger.committers, - { case V.ContractInst(actualTmplId, V.VersionedValue(_, arg), _) => + { case V.VersionedContractInstance(_, actualTmplId, arg, _) => val keyExpr = SEApp(SEVal(KeyDefRef(actualTmplId)), Array(SELocS(1))) machine.pushKont(KCacheContract(machine, actualTmplId, coid)) machine.ctrl = SELet1( diff --git a/daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/speedy/SResult.scala b/daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/speedy/SResult.scala index 1696dc6fe183..a841e8efe09a 100644 --- a/daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/speedy/SResult.scala +++ b/daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/speedy/SResult.scala @@ -4,12 +4,12 @@ package com.daml.lf package speedy -import com.daml.lf.value.Value.{ContractId, ContractInst} import com.daml.lf.data.Ref._ import com.daml.lf.data.Time import com.daml.lf.transaction.GlobalKeyWithMaintainers import com.daml.lf.speedy.SError._ import com.daml.lf.value.Value +import com.daml.lf.value.Value.ContractId /** The result from small-step evaluation. * If the result is not Done or Continue, then the machine @@ -36,7 +36,7 @@ object SResult { // Callback // returns the next expression to evaluate. // In case of failure the call back does not throw but returns a SErrorDamlException - callback: ContractInst[Value.VersionedValue] => Unit, + callback: Value.VersionedContractInstance => Unit, ) extends SResult /** Machine needs a definition that was not present when the machine was diff --git a/daml-lf/scenario-interpreter/src/main/scala/com/digitalasset/daml/lf/ScenarioRunner.scala b/daml-lf/scenario-interpreter/src/main/scala/com/digitalasset/daml/lf/ScenarioRunner.scala index 963b7ac64d9f..b494aecb14d8 100644 --- a/daml-lf/scenario-interpreter/src/main/scala/com/digitalasset/daml/lf/ScenarioRunner.scala +++ b/daml-lf/scenario-interpreter/src/main/scala/com/digitalasset/daml/lf/ScenarioRunner.scala @@ -10,7 +10,7 @@ import com.daml.lf.engine.{Engine, ValueEnricher, Result, ResultDone, ResultErro import com.daml.lf.engine.preprocessing.ValueTranslator import com.daml.lf.language.{Ast, LookupError} import com.daml.lf.transaction.{GlobalKey, NodeId, SubmittedTransaction} -import com.daml.lf.value.Value.{ContractId, ContractInst} +import com.daml.lf.value.Value.{ContractId, VersionedContractInstance} import com.daml.lf.speedy._ import com.daml.lf.speedy.SResult._ import com.daml.lf.transaction.IncompleteTransaction @@ -225,7 +225,7 @@ object ScenarioRunner { coid: ContractId, actAs: Set[Party], readAs: Set[Party], - cbPresent: ContractInst[Value.VersionedValue] => Unit, + cbPresent: VersionedContractInstance => Unit, ): Either[Error, Unit] def lookupKey( machine: Speedy.Machine, @@ -251,7 +251,7 @@ object ScenarioRunner { acoid: ContractId, actAs: Set[Party], readAs: Set[Party], - callback: ContractInst[Value.VersionedValue] => Unit, + callback: VersionedContractInstance => Unit, ): Either[Error, Unit] = handleUnsafe(lookupContractUnsafe(acoid, actAs, readAs, callback)) @@ -259,7 +259,7 @@ object ScenarioRunner { acoid: ContractId, actAs: Set[Party], readAs: Set[Party], - callback: ContractInst[Value.VersionedValue] => Unit, + callback: VersionedContractInstance => Unit, ) = { val effectiveAt = ledger.currentTime diff --git a/daml-lf/scenario-interpreter/src/perf/benches/scala/com/digitalasset/daml/lf/speedy/perf/CollectAuthority.scala b/daml-lf/scenario-interpreter/src/perf/benches/scala/com/digitalasset/daml/lf/speedy/perf/CollectAuthority.scala index 57572f89d439..b54238c414d7 100644 --- a/daml-lf/scenario-interpreter/src/perf/benches/scala/com/digitalasset/daml/lf/speedy/perf/CollectAuthority.scala +++ b/daml-lf/scenario-interpreter/src/perf/benches/scala/com/digitalasset/daml/lf/speedy/perf/CollectAuthority.scala @@ -13,7 +13,7 @@ import com.daml.lf.language.Ast.EVal import com.daml.lf.speedy.SResult._ import com.daml.lf.transaction.{NodeId, GlobalKey, SubmittedTransaction} import com.daml.lf.value.Value -import com.daml.lf.value.Value.{ContractId, ContractInst} +import com.daml.lf.value.Value.ContractId import com.daml.lf.scenario.{ScenarioLedger, ScenarioRunner} import com.daml.lf.speedy.Speedy.Machine import java.io.File @@ -66,7 +66,7 @@ class CollectAuthorityState { // The maps are indexed by step number. private var cachedParty: Map[Int, Party] = Map() private var cachedCommit: Map[Int, SValue] = Map() - private var cachedContract: Map[Int, ContractInst[Value.VersionedValue]] = Map() + private var cachedContract: Map[Int, Value.VersionedContractInstance] = Map() // This is function that we benchmark def run(): Unit = { @@ -158,12 +158,12 @@ class CollectAuthorityState { class CachedLedgerApi(initStep: Int, ledger: ScenarioLedger) extends ScenarioRunner.ScenarioLedgerApi(ledger) { var step = initStep - var cachedContract: Map[Int, ContractInst[Value.VersionedValue]] = Map() + var cachedContract: Map[Int, Value.VersionedContractInstance] = Map() override def lookupContract( coid: ContractId, actAs: Set[Party], readAs: Set[Party], - callback: ContractInst[Value.VersionedValue] => Unit, + callback: Value.VersionedContractInstance => Unit, ): Either[scenario.Error, Unit] = { step += 1 super.lookupContract( @@ -177,14 +177,14 @@ class CachedLedgerApi(initStep: Int, ledger: ScenarioLedger) class CannedLedgerApi( initStep: Int, - cachedContract: Map[Int, ContractInst[Value.VersionedValue]], + cachedContract: Map[Int, Value.VersionedContractInstance], ) extends ScenarioRunner.LedgerApi[Unit] { var step = initStep override def lookupContract( coid: ContractId, actAs: Set[Party], readAs: Set[Party], - callback: ContractInst[Value.VersionedValue] => Unit, + callback: Value.VersionedContractInstance => Unit, ): Either[scenario.Error, Unit] = { step += 1 val coinst = cachedContract(step) diff --git a/daml-lf/transaction-test-lib/src/main/scala/lf/transaction/test/TransactionBuilder.scala b/daml-lf/transaction-test-lib/src/main/scala/lf/transaction/test/TransactionBuilder.scala index 43b0917625ab..c04d657a4e01 100644 --- a/daml-lf/transaction-test-lib/src/main/scala/lf/transaction/test/TransactionBuilder.scala +++ b/daml-lf/transaction-test-lib/src/main/scala/lf/transaction/test/TransactionBuilder.scala @@ -9,7 +9,7 @@ import com.daml.lf.data._ import com.daml.lf.language.LanguageVersion import com.daml.lf.transaction.{Transaction => Tx} import com.daml.lf.value.Value -import com.daml.lf.value.Value.ContractId +import com.daml.lf.value.Value.{ContractId, ContractInst, VersionedContractInstance} import scala.Ordering.Implicits.infixOrderingOps import scala.annotation.tailrec @@ -77,11 +77,8 @@ final class TransactionBuilder(pkgTxVersion: Ref.PackageId => TransactionVersion def newCid: ContractId = TransactionBuilder.newV1Cid - def versionContract(contract: Value.ContractInst[Value]): value.Value.ContractInst[TxValue] = - contract.map(transactionValue(contract.template)) - - private[this] def transactionValue(templateId: Ref.TypeConName): Value => TxValue = - value.Value.VersionedValue(pkgTxVersion(templateId.packageId), _) + def versionContract(contract: Value.ContractInst[Value]): value.Value.VersionedContractInstance = + VersionedContractInstance(pkgTxVersion(contract.template.packageId), contract) def create( id: ContractId, @@ -322,6 +319,19 @@ object TransactionBuilder { ): TxValue = data.assertRight(asVersionedValue(value, supportedVersions)) + def asVersionedContract( + contract: ContractInst[Value], + supportedVersions: VersionRange[TransactionVersion] = TransactionVersion.DevVersions, + ): Either[String, VersionedContractInstance] = + assignVersion(contract.arg, supportedVersions) + .map(VersionedContractInstance(_, contract)) + + def assertAsVersionedContract( + contract: ContractInst[Value], + supportedVersions: VersionRange[TransactionVersion] = TransactionVersion.DevVersions, + ): VersionedContractInstance = + data.assertRight(asVersionedContract(contract, supportedVersions)) + object Implicits { implicit def toContractId(s: String): ContractId = diff --git a/daml-lf/transaction-test-lib/src/main/scala/lf/value/test/ValueGenerators.scala b/daml-lf/transaction-test-lib/src/main/scala/lf/value/test/ValueGenerators.scala index 0ed9a5fbd9cf..c17402887088 100644 --- a/daml-lf/transaction-test-lib/src/main/scala/lf/value/test/ValueGenerators.scala +++ b/daml-lf/transaction-test-lib/src/main/scala/lf/value/test/ValueGenerators.scala @@ -275,12 +275,12 @@ object ValueGenerators { } yield ContractInst(template, arg, agreement) } - val versionedContractInstanceGen: Gen[ContractInst[Value.VersionedValue]] = + val versionedContractInstanceGen: Gen[Value.VersionedContractInstance] = for { template <- idGen arg <- versionedValueGen agreement <- Arbitrary.arbitrary[String] - } yield ContractInst(template, arg, agreement) + } yield Value.VersionedContractInstance(arg.version, template, arg.value, agreement) val keyWithMaintainersGen: Gen[KeyWithMaintainers[Value]] = { for { diff --git a/daml-lf/transaction/src/main/scala/com/digitalasset/daml/lf/transaction/Node.scala b/daml-lf/transaction/src/main/scala/com/digitalasset/daml/lf/transaction/Node.scala index 9bc7e4c894ae..93ea88879cc0 100644 --- a/daml-lf/transaction/src/main/scala/com/digitalasset/daml/lf/transaction/Node.scala +++ b/daml-lf/transaction/src/main/scala/com/digitalasset/daml/lf/transaction/Node.scala @@ -89,8 +89,8 @@ object Node { def coinst: Value.ContractInst[Value] = Value.ContractInst(templateId, arg, agreementText) - def versionedCoinst: Value.ContractInst[Value.VersionedValue] = - Value.ContractInst(templateId, versionedArg, agreementText) + def versionedCoinst: Value.VersionedContractInstance = + Value.VersionedContractInstance(version, templateId, arg, agreementText) def versionedKey: Option[KeyWithMaintainers[Value.VersionedValue]] = key.map(_.map(versionValue)) diff --git a/daml-lf/transaction/src/main/scala/com/digitalasset/daml/lf/transaction/Transaction.scala b/daml-lf/transaction/src/main/scala/com/digitalasset/daml/lf/transaction/Transaction.scala index 16126d6ca603..b27e14bc54c7 100644 --- a/daml-lf/transaction/src/main/scala/com/digitalasset/daml/lf/transaction/Transaction.scala +++ b/daml-lf/transaction/src/main/scala/com/digitalasset/daml/lf/transaction/Transaction.scala @@ -784,7 +784,8 @@ object Transaction { type Value = Value.VersionedValue - type ContractInst = Value.ContractInst[Value] + @deprecated("use com.daml.value.Value.VersionedContractInstance", since = "1.8.0") + type ContractInst = Value.VersionedContractInstance /** Transaction nodes */ type Node = Node.GenNode diff --git a/daml-lf/transaction/src/main/scala/com/digitalasset/daml/lf/transaction/TransactionCoder.scala b/daml-lf/transaction/src/main/scala/com/digitalasset/daml/lf/transaction/TransactionCoder.scala index 9a4b0270f16e..17d7fc8e995c 100644 --- a/daml-lf/transaction/src/main/scala/com/digitalasset/daml/lf/transaction/TransactionCoder.scala +++ b/daml-lf/transaction/src/main/scala/com/digitalasset/daml/lf/transaction/TransactionCoder.scala @@ -113,10 +113,10 @@ object TransactionCoder { */ def encodeContractInstance( encodeCid: ValueCoder.EncodeCid, - coinst: Value.ContractInst[Value.VersionedValue], + coinst: Value.VersionedContractInstance, ): Either[EncodeError, TransactionOuterClass.ContractInstance] = ValueCoder - .encodeVersionedValue(encodeCid, coinst.arg) + .encodeVersionedValue(encodeCid, coinst.version, coinst.arg) .map( TransactionOuterClass.ContractInstance .newBuilder() @@ -170,11 +170,16 @@ object TransactionCoder { def decodeVersionedContractInstance( decodeCid: ValueCoder.DecodeCid, protoCoinst: TransactionOuterClass.ContractInstance, - ): Either[DecodeError, Value.ContractInst[Value.VersionedValue]] = + ): Either[DecodeError, Value.VersionedContractInstance] = for { id <- ValueCoder.decodeIdentifier(protoCoinst.getTemplateId) value <- ValueCoder.decodeVersionedValue(decodeCid, protoCoinst.getArgVersioned) - } yield Value.ContractInst(id, value, (protoCoinst.getAgreement)) + } yield Value.VersionedContractInstance( + value.version, + id, + value.value, + protoCoinst.getAgreement, + ) private[this] def encodeKeyWithMaintainers( encodeCid: ValueCoder.EncodeCid, diff --git a/daml-lf/transaction/src/main/scala/com/digitalasset/daml/lf/transaction/Util.scala b/daml-lf/transaction/src/main/scala/com/digitalasset/daml/lf/transaction/Util.scala index 99c1ab856559..8b194b157add 100644 --- a/daml-lf/transaction/src/main/scala/com/digitalasset/daml/lf/transaction/Util.scala +++ b/daml-lf/transaction/src/main/scala/com/digitalasset/daml/lf/transaction/Util.scala @@ -82,9 +82,10 @@ object Util { normalizeValue(value.value, value.version).map(normalized => value.copy(value = normalized)) def normalizeContract( - contract: ContractInst[VersionedValue] - ): Either[String, ContractInst[VersionedValue]] = - normalizeVersionedValue(contract.arg).map(normalized => contract.copy(arg = normalized)) + contract: VersionedContractInstance + ): Either[String, VersionedContractInstance] = + normalizeValue(contract.arg, contract.version) + .map(normalized => contract.copy(arg = normalized)) def normalizeKey( key: Node.KeyWithMaintainers[Value], diff --git a/daml-lf/transaction/src/main/scala/com/digitalasset/daml/lf/value/Value.scala b/daml-lf/transaction/src/main/scala/com/digitalasset/daml/lf/value/Value.scala index 770913fcceb1..d044dfc982c4 100644 --- a/daml-lf/transaction/src/main/scala/com/digitalasset/daml/lf/value/Value.scala +++ b/daml-lf/transaction/src/main/scala/com/digitalasset/daml/lf/value/Value.scala @@ -225,6 +225,27 @@ object Value { } } + final case class VersionedContractInstance( + version: TransactionVersion, + template: Identifier, + arg: Value, + agreementText: String, + ) { + def coinst = ContractInst(template, arg, agreementText) + def versionedArg = VersionedValue(version, arg) + } + + object VersionedContractInstance { + def apply(version: TransactionVersion, coinst: ContractInst[Value]): VersionedContractInstance = + VersionedContractInstance(version, coinst.template, coinst.arg, coinst.agreementText) + def apply( + template: Identifier, + arg: VersionedValue, + agreementText: String, + ): VersionedContractInstance = + VersionedContractInstance(arg.version, template, arg.value, agreementText) + } + type NodeIdx = Int sealed abstract class ContractId extends Product with Serializable { diff --git a/daml-lf/transaction/src/test/scala/com/digitalasset/daml/lf/transaction/TransactionCoderSpec.scala b/daml-lf/transaction/src/test/scala/com/digitalasset/daml/lf/transaction/TransactionCoderSpec.scala index a1982a1a530f..50ad5fed7774 100644 --- a/daml-lf/transaction/src/test/scala/com/digitalasset/daml/lf/transaction/TransactionCoderSpec.scala +++ b/daml-lf/transaction/src/test/scala/com/digitalasset/daml/lf/transaction/TransactionCoderSpec.scala @@ -9,7 +9,7 @@ import com.daml.lf.data.ImmArray import com.daml.lf.data.Ref.{Identifier, Party} import com.daml.lf.transaction.Node._ import com.daml.lf.transaction.{TransactionOuterClass => proto} -import com.daml.lf.value.Value.{ContractId, ContractInst, ValueParty} +import com.daml.lf.value.Value.ContractId import com.daml.lf.value.ValueCoder.{DecodeError, EncodeError} import com.daml.lf.value.{Value, ValueCoder} import org.scalacheck.{Arbitrary, Gen} @@ -226,7 +226,7 @@ class TransactionCoderSpec NodeCreate( coid = absCid("#test-cid"), templateId = Identifier.assertFromString("pkg-id:Test:Name"), - arg = ValueParty(Party.assertFromString("francesco")), + arg = Value.ValueParty(Party.assertFromString("francesco")), agreementText = "agreement", signatories = Set(Party.assertFromString("alice")), stakeholders = Set(Party.assertFromString("alice"), Party.assertFromString("bob")), @@ -947,16 +947,8 @@ class TransactionCoderSpec key.copy(key = normalize(key.key, version)) } - private[this] def normalizeContract( - contract: ContractInst[Value.VersionedValue] - ) = { - contract.copy(arg = normalizeValue(contract.arg)) - } - - private[this] def normalizeValue(versionedValue: Value.VersionedValue) = { - val Value.VersionedValue(version, value) = versionedValue - Value.VersionedValue(version, normalize(value, version)) - } + private[this] def normalizeContract(contract: Value.VersionedContractInstance) = + contract.copy(arg = normalize(contract.arg, contract.version)) private[this] def normalize( value0: Value, diff --git a/daml-script/runner/src/main/scala/com/digitalasset/daml/lf/engine/script/ledgerinteraction/IdeLedgerClient.scala b/daml-script/runner/src/main/scala/com/digitalasset/daml/lf/engine/script/ledgerinteraction/IdeLedgerClient.scala index aecb37effae3..a899c8f581a9 100644 --- a/daml-script/runner/src/main/scala/com/digitalasset/daml/lf/engine/script/ledgerinteraction/IdeLedgerClient.scala +++ b/daml-script/runner/src/main/scala/com/digitalasset/daml/lf/engine/script/ledgerinteraction/IdeLedgerClient.scala @@ -67,12 +67,15 @@ class IdeLedgerClient( effectiveAt = ledger.currentTime, ) val filtered = acs.collect { - case ScenarioLedger.LookupOk(cid, Value.ContractInst(tpl, arg, _), stakeholders) - if tpl == templateId && parties.any(stakeholders.contains(_)) => + case ScenarioLedger.LookupOk( + cid, + Value.VersionedContractInstance(_, tpl, arg, _), + stakeholders, + ) if tpl == templateId && parties.any(stakeholders.contains(_)) => (cid, arg) } Future.successful(filtered.map { case (cid, c) => - ScriptLedgerClient.ActiveContract(templateId, cid, c.value) + ScriptLedgerClient.ActiveContract(templateId, cid, c) }) } @@ -89,9 +92,9 @@ class IdeLedgerClient( effectiveAt = ledger.currentTime, cid, ) match { - case ScenarioLedger.LookupOk(_, Value.ContractInst(_, arg, _), stakeholders) + case ScenarioLedger.LookupOk(_, Value.VersionedContractInstance(_, _, arg, _), stakeholders) if parties.any(stakeholders.contains(_)) => - Future.successful(Some(ScriptLedgerClient.ActiveContract(templateId, cid, arg.value))) + Future.successful(Some(ScriptLedgerClient.ActiveContract(templateId, cid, arg))) case _ => // Note that contrary to `fetch` in a scenario, we do not // abort on any of the error cases. This makes sense if you diff --git a/ledger/participant-integration-api/src/main/scala/db/migration/postgres/V26_1__Fill_create_argument.scala b/ledger/participant-integration-api/src/main/scala/db/migration/postgres/V26_1__Fill_create_argument.scala index ce6392800883..bf3000b2ef46 100644 --- a/ledger/participant-integration-api/src/main/scala/db/migration/postgres/V26_1__Fill_create_argument.scala +++ b/ledger/participant-integration-api/src/main/scala/db/migration/postgres/V26_1__Fill_create_argument.scala @@ -41,7 +41,7 @@ private[migration] class V26_1__Fill_create_argument extends BaseJavaMigration { ContractSerializer .deserializeContractInstance(contractBytes) .getOrElse(sys.error(s"failed to deserialize contract $contractId")) - val createArgument = contract.arg + val createArgument = contract.versionedArg val templateId = contract.template val createArgumentBytes = new ByteArrayInputStream( diff --git a/ledger/participant-integration-api/src/main/scala/db/migration/translation/ContractSerializer.scala b/ledger/participant-integration-api/src/main/scala/db/migration/translation/ContractSerializer.scala index d33bc3d716d2..2cdfacacd321 100644 --- a/ledger/participant-integration-api/src/main/scala/db/migration/translation/ContractSerializer.scala +++ b/ledger/participant-integration-api/src/main/scala/db/migration/translation/ContractSerializer.scala @@ -6,17 +6,17 @@ package com.daml.platform.db.migration.translation import java.io.InputStream import com.daml.lf.transaction.{TransactionCoder, TransactionOuterClass} -import com.daml.lf.value.Value.{ContractInst, VersionedValue} +import com.daml.lf.value.Value.VersionedContractInstance import com.daml.lf.value.ValueCoder private[migration] trait ContractSerializer { def serializeContractInstance( - coinst: ContractInst[VersionedValue] + coinst: VersionedContractInstance ): Either[ValueCoder.EncodeError, Array[Byte]] def deserializeContractInstance( stream: InputStream - ): Either[ValueCoder.DecodeError, ContractInst[VersionedValue]] + ): Either[ValueCoder.DecodeError, VersionedContractInstance] } /** This is a preliminary serializer using protobuf as a payload type. Our goal on the long run is to use JSON as a payload. @@ -24,7 +24,7 @@ private[migration] trait ContractSerializer { private[migration] object ContractSerializer extends ContractSerializer { override def serializeContractInstance( - coinst: ContractInst[VersionedValue] + coinst: VersionedContractInstance ): Either[ValueCoder.EncodeError, Array[Byte]] = TransactionCoder .encodeContractInstance(ValueCoder.CidEncoder, coinst) @@ -32,7 +32,7 @@ private[migration] object ContractSerializer extends ContractSerializer { override def deserializeContractInstance( stream: InputStream - ): Either[ValueCoder.DecodeError, ContractInst[VersionedValue]] = + ): Either[ValueCoder.DecodeError, VersionedContractInstance] = ValueSerializer.handleDeprecatedValueVersions( TransactionCoder .decodeVersionedContractInstance( 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 345bfc33e753..bbb3366c3d34 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 @@ -133,7 +133,7 @@ private[daml] final class SpannedIndexService(delegate: IndexService) extends In contractId: Value.ContractId, )(implicit loggingContext: LoggingContext - ): Future[Option[Value.ContractInst[Value.VersionedValue]]] = + ): Future[Option[Value.VersionedContractInstance]] = delegate.lookupActiveContract(readers, contractId) override def lookupContractKey( 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 8fef8321ac72..c18d9d4354af 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 @@ -142,7 +142,7 @@ private[daml] final class TimedIndexService(delegate: IndexService, metrics: Met contractId: Value.ContractId, )(implicit loggingContext: LoggingContext - ): Future[Option[Value.ContractInst[Value.VersionedValue]]] = + ): Future[Option[Value.VersionedContractInstance]] = Timed.future( metrics.daml.services.index.lookupActiveContract, delegate.lookupActiveContract(readers, contractId), 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 75bf0219cedc..687057344633 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 @@ -38,8 +38,7 @@ import com.daml.lf.data.Ref import com.daml.lf.data.Ref.{Identifier, PackageId, Party} import com.daml.lf.language.Ast import com.daml.lf.transaction.GlobalKey -import com.daml.lf.value.Value -import com.daml.lf.value.Value.{ContractId, ContractInst} +import com.daml.lf.value.Value.{ContractId, VersionedContractInstance} import com.daml.logging.LoggingContext import com.daml.platform.ApiOffset import com.daml.platform.ApiOffset.ApiOffsetConverter @@ -214,7 +213,7 @@ private[platform] final class LedgerBackedIndexService( contractId: ContractId, )(implicit loggingContext: LoggingContext - ): Future[Option[ContractInst[Value.VersionedValue]]] = + ): Future[Option[VersionedContractInstance]] = ledger.lookupContract(contractId, readers) override def lookupMaximumLedgerTime(ids: Set[ContractId])(implicit 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 8899c3bf1019..7a93e5956a8e 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 @@ -24,8 +24,7 @@ import com.daml.ledger.participant.state.index.v2.{CommandDeduplicationResult, P import com.daml.lf.data.Ref import com.daml.lf.language.Ast import com.daml.lf.transaction.GlobalKey -import com.daml.lf.value.Value -import com.daml.lf.value.Value.{ContractId, ContractInst} +import com.daml.lf.value.Value.{ContractId, VersionedContractInstance} import com.daml.logging.LoggingContext import com.daml.metrics.{Metrics, Timed} import com.daml.platform.store.ReadOnlyLedger @@ -77,11 +76,11 @@ private[platform] class MeteredReadOnlyLedger(ledger: ReadOnlyLedger, metrics: M ledger.activeContracts(filter, verbose) override def lookupContract( - contractId: Value.ContractId, + contractId: ContractId, forParties: Set[Ref.Party], )(implicit loggingContext: LoggingContext - ): Future[Option[ContractInst[Value.VersionedValue]]] = + ): Future[Option[VersionedContractInstance]] = Timed.future(metrics.daml.index.lookupContract, ledger.lookupContract(contractId, forParties)) override def lookupKey(key: GlobalKey, forParties: Set[Ref.Party])(implicit 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 e70d7bf0bc7b..3659b0b0b411 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 @@ -80,6 +80,6 @@ private[platform] trait ActiveLedgerState[ALS <: ActiveLedgerState[ALS]] { object ActiveLedgerState { type ReferencedContracts = - List[(Value.ContractId, Value.ContractInst[Value.VersionedValue])] + List[(Value.ContractId, Value.VersionedContractInstance)] } 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 aad1f5392b31..a9b2c4a16829 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 @@ -28,8 +28,7 @@ import com.daml.lf.archive.Decode import com.daml.lf.data.Ref import com.daml.lf.language.Ast import com.daml.lf.transaction.GlobalKey -import com.daml.lf.value.Value -import com.daml.lf.value.Value.{ContractId, ContractInst} +import com.daml.lf.value.Value.{ContractId, VersionedContractInstance} import com.daml.logging.LoggingContext import com.daml.platform.PruneBuffers import com.daml.platform.akkastreams.dispatcher.Dispatcher @@ -116,7 +115,7 @@ private[platform] abstract class BaseLedger( forParties: Set[Ref.Party], )(implicit loggingContext: LoggingContext - ): Future[Option[ContractInst[Value.VersionedValue]]] = + ): Future[Option[VersionedContractInstance]] = contractStore.lookupActiveContract(forParties, contractId) override def lookupFlatTransactionById( diff --git a/ledger/participant-integration-api/src/main/scala/platform/store/Contract.scala b/ledger/participant-integration-api/src/main/scala/platform/store/Contract.scala index bd21664f3159..4a2cd11f3a54 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/store/Contract.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/store/Contract.scala @@ -9,7 +9,7 @@ import com.daml.lf.data.Ref import com.daml.lf.transaction.Node.KeyWithMaintainers import com.daml.lf.transaction.NodeId import com.daml.lf.value.Value -import com.daml.lf.value.Value.{ContractId, ContractInst, VersionedValue} +import com.daml.lf.value.Value.{ContractId, VersionedContractInstance, VersionedValue} /** A contract that is part of the [[ActiveLedgerState]]. * Depending on where the contract came from, other metadata may be available. @@ -17,7 +17,7 @@ import com.daml.lf.value.Value.{ContractId, ContractInst, VersionedValue} private[platform] sealed abstract class Contract { def id: ContractId - def contract: ContractInst[VersionedValue] + def contract: VersionedContractInstance /** For each party, the transaction id at which the contract was divulged */ def divulgences: Map[Ref.Party, Ref.TransactionId] @@ -39,7 +39,7 @@ private[platform] object Contract { */ final case class DivulgedContract( id: Value.ContractId, - contract: ContractInst[VersionedValue], + contract: VersionedContractInstance, divulgences: Map[Ref.Party, Ref.TransactionId], ) extends Contract @@ -51,7 +51,7 @@ private[platform] object Contract { transactionId: Ref.TransactionId, // transaction id where the contract originates nodeId: NodeId, workflowId: Option[Ref.WorkflowId], // workflow id from where the contract originates - contract: ContractInst[VersionedValue], + contract: VersionedContractInstance, witnesses: Set[Ref.Party], divulgences: Map[ Ref.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 bfa928d4c705..738c8573652e 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 @@ -24,8 +24,7 @@ import com.daml.ledger.participant.state.index.v2.{CommandDeduplicationResult, P import com.daml.lf.data.Ref import com.daml.lf.language.Ast import com.daml.lf.transaction.GlobalKey -import com.daml.lf.value.Value -import com.daml.lf.value.Value.{ContractId, ContractInst} +import com.daml.lf.value.Value.{ContractId, VersionedContractInstance} import com.daml.logging.LoggingContext import com.daml.platform.store.entries.{ConfigurationEntry, PackageLedgerEntry, PartyLedgerEntry} @@ -65,11 +64,11 @@ private[platform] trait ReadOnlyLedger extends ReportsHealth with AutoCloseable )(implicit loggingContext: LoggingContext): (Source[GetActiveContractsResponse, NotUsed], Offset) def lookupContract( - contractId: Value.ContractId, + contractId: ContractId, forParties: Set[Ref.Party], )(implicit loggingContext: LoggingContext - ): Future[Option[ContractInst[Value.VersionedValue]]] + ): Future[Option[VersionedContractInstance]] def lookupMaximumLedgerTime( contractIds: Set[ContractId] diff --git a/ledger/participant-integration-api/src/main/scala/platform/store/appendonlydao/events/package.scala b/ledger/participant-integration-api/src/main/scala/platform/store/appendonlydao/events/package.scala index bb5f4c8c4bc1..f596a3ea5af3 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/store/appendonlydao/events/package.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/store/appendonlydao/events/package.scala @@ -15,8 +15,8 @@ package object events { type ContractId = lfval.ContractId val ContractId = com.daml.lf.value.Value.ContractId type Value = lfval.VersionedValue - type Contract = lfval.ContractInst[Value] - val Contract = lfval.ContractInst + type Contract = lfval.VersionedContractInstance + val Contract = lfval.VersionedContractInstance import com.daml.lf.{transaction => lftx} type NodeId = lftx.NodeId 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 213bee98ec20..d05f24f18f7e 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 @@ -245,7 +245,7 @@ object UpdateToDbDto { template_id = contractInst.map(_.template.toString), tree_event_witnesses = visibleToParties.map(_.toString), create_argument = contractInst - .map(_.arg) + .map(_.versionedArg) .map(translation.serialize(contractId, _)) .map(compressionStrategy.createArgumentCompression.compress), create_argument_compression = compressionStrategy.createArgumentCompression.id, diff --git a/ledger/participant-integration-api/src/main/scala/platform/store/cache/MutableCacheBackedContractStore.scala b/ledger/participant-integration-api/src/main/scala/platform/store/cache/MutableCacheBackedContractStore.scala index 8638e2895def..c3045d71ce4a 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/store/cache/MutableCacheBackedContractStore.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/store/cache/MutableCacheBackedContractStore.scala @@ -180,7 +180,7 @@ private[platform] class MutableCacheBackedContractStore( contractsReader.lookupActiveContractWithCachedArgument( forParties, contractId, - contract.arg, + contract.versionedArg, ) case _: Archived | NotFound => // We need to fetch the contract here since the contract creation or archival diff --git a/ledger/participant-integration-api/src/main/scala/platform/store/cache/package.scala b/ledger/participant-integration-api/src/main/scala/platform/store/cache/package.scala index 81a0c9bea331..45d86ecb8154 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/store/cache/package.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/store/cache/package.scala @@ -8,7 +8,7 @@ package object cache { private[cache] type ContractId = lfval.ContractId private[cache] val ContractId = com.daml.lf.value.Value.ContractId private[cache] type Value = lfval.VersionedValue - private[cache] type Contract = lfval.ContractInst[Value] + private[cache] type Contract = lfval.VersionedContractInstance import com.daml.lf.{transaction => lftx} private[cache] type Key = lftx.GlobalKey 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 c84926027c5e..59d16f5e25a9 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 @@ -51,7 +51,7 @@ object TransactionIndexing { } for (state.DivulgedContract(contractId, contractInst) <- divulgence) { - val serializedCreateArgument = translation.serialize(contractId, contractInst.arg) + val serializedCreateArgument = translation.serialize(contractId, contractInst.versionedArg) divulgedContracts += ((contractId, serializedCreateArgument)) } diff --git a/ledger/participant-integration-api/src/main/scala/platform/store/dao/events/package.scala b/ledger/participant-integration-api/src/main/scala/platform/store/dao/events/package.scala index cfe7c21d1ee2..2efe52ee84bb 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/store/dao/events/package.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/store/dao/events/package.scala @@ -17,8 +17,8 @@ package object events { private[events] type ContractId = lfval.ContractId private[events] val ContractId = com.daml.lf.value.Value.ContractId private[events] type Value = lfval.VersionedValue - private[events] type Contract = lfval.ContractInst[Value] - private[events] val Contract = lfval.ContractInst + private[events] type Contract = lfval.VersionedContractInstance + private[events] val Contract = lfval.VersionedContractInstance import com.daml.lf.{transaction => lftx} private[events] type NodeId = lftx.NodeId diff --git a/ledger/participant-integration-api/src/main/scala/platform/store/interfaces/LedgerDaoContractsReader.scala b/ledger/participant-integration-api/src/main/scala/platform/store/interfaces/LedgerDaoContractsReader.scala index 60440d22f18c..ebdd18b8f47b 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/store/interfaces/LedgerDaoContractsReader.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/store/interfaces/LedgerDaoContractsReader.scala @@ -85,7 +85,7 @@ object LedgerDaoContractsReader { import com.daml.lf.value.{Value => lfval} private type ContractId = lfval.ContractId private type Value = lfval.VersionedValue - private type Contract = lfval.ContractInst[Value] + private type Contract = lfval.VersionedContractInstance sealed trait ContractState extends Product with Serializable { def stakeholders: Set[Party] diff --git a/ledger/participant-integration-api/src/test/lib/scala/platform/store/dao/JdbcLedgerDaoContractsSpec.scala b/ledger/participant-integration-api/src/test/lib/scala/platform/store/dao/JdbcLedgerDaoContractsSpec.scala index 5f721a83443d..9a58da11302c 100644 --- a/ledger/participant-integration-api/src/test/lib/scala/platform/store/dao/JdbcLedgerDaoContractsSpec.scala +++ b/ledger/participant-integration-api/src/test/lib/scala/platform/store/dao/JdbcLedgerDaoContractsSpec.scala @@ -8,7 +8,7 @@ import java.util.UUID import com.daml.lf.transaction.GlobalKey import com.daml.lf.transaction.Node.KeyWithMaintainers -import com.daml.lf.value.Value.{ContractId, ContractInst, ValueText} +import com.daml.lf.value.Value.{ContractId, VersionedContractInstance, ValueText} import org.scalatest.flatspec.AsyncFlatSpec import org.scalatest.matchers.should.Matchers import org.scalatest.{Inside, LoneElement, OptionValues} @@ -86,7 +86,7 @@ private[dao] trait JdbcLedgerDaoContractsSpec extends LoneElement with Inside wi contractId = nonTransient(tx).loneElement result <- contractsReader.lookupActiveContractAndLoadArgument(Set(charlie, emma), contractId) } yield { - result.value shouldBe a[ContractInst[_]] + result.value shouldBe a[VersionedContractInstance] } } @@ -105,7 +105,7 @@ private[dao] trait JdbcLedgerDaoContractsSpec extends LoneElement with Inside wi ) result <- contractsReader.lookupActiveContractAndLoadArgument(Set(david, emma), contractId) } yield { - result.value shouldBe a[ContractInst[_]] + result.value shouldBe a[VersionedContractInstance] } } diff --git a/ledger/participant-integration-api/src/test/lib/scala/platform/store/dao/JdbcLedgerDaoDivulgenceSpec.scala b/ledger/participant-integration-api/src/test/lib/scala/platform/store/dao/JdbcLedgerDaoDivulgenceSpec.scala index 056566edf583..391eefdc9ba2 100644 --- a/ledger/participant-integration-api/src/test/lib/scala/platform/store/dao/JdbcLedgerDaoDivulgenceSpec.scala +++ b/ledger/participant-integration-api/src/test/lib/scala/platform/store/dao/JdbcLedgerDaoDivulgenceSpec.scala @@ -10,7 +10,7 @@ import com.daml.lf.data.ImmArray import com.daml.lf.transaction.Node.{KeyWithMaintainers, NodeCreate, NodeExercises, NodeFetch} import com.daml.lf.transaction.TransactionVersion import com.daml.lf.transaction.test.TransactionBuilder -import com.daml.lf.value.Value.{ContractInst, ValueParty, VersionedValue} +import com.daml.lf.value.Value.{VersionedContractInstance, ValueParty} import com.daml.platform.store.entries.LedgerEntry import org.scalatest.{Inside, LoneElement} import org.scalatest.flatspec.AsyncFlatSpec @@ -135,13 +135,11 @@ private[dao] trait JdbcLedgerDaoDivulgenceSpec extends LoneElement with Inside { } val someVersionedContractInstance = - ContractInst( + VersionedContractInstance( + version = TransactionVersion.V10, template = someContractInstance.template, agreementText = someContractInstance.agreementText, - arg = VersionedValue( - version = TransactionVersion.V10, - value = someContractInstance.arg, - ), + arg = someContractInstance.arg, ) val t1 = Instant.now() 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 bb3fd4e5b0d1..2c2fe6042fd6 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 @@ -22,7 +22,7 @@ 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, VersionedValue} +import com.daml.lf.value.Value.{ContractId, ContractInst, ValueText, VersionedContractInstance} import com.daml.lf.value.{Value => LfValue} import com.daml.logging.LoggingContext import com.daml.platform.indexer.{CurrentOffset, IncrementalOffsetStep, OffsetStep} @@ -914,7 +914,7 @@ private[dao] trait JdbcLedgerDaoSuite extends JdbcLedgerDaoBackend { object JdbcLedgerDaoSuite { private type DivulgedContracts = - Map[(ContractId, ContractInst[VersionedValue]), Set[Party]] + Map[(ContractId, VersionedContractInstance), Set[Party]] implicit final class `TraverseFM Ops`[T[_], A](private val self: T[A]) extends AnyVal { diff --git a/ledger/participant-state-index/src/main/scala/com/daml/ledger/participant/state/index/v2/ContractStore.scala b/ledger/participant-state-index/src/main/scala/com/daml/ledger/participant/state/index/v2/ContractStore.scala index daddc9dc117d..8e05c498d572 100644 --- a/ledger/participant-state-index/src/main/scala/com/daml/ledger/participant/state/index/v2/ContractStore.scala +++ b/ledger/participant-state-index/src/main/scala/com/daml/ledger/participant/state/index/v2/ContractStore.scala @@ -8,8 +8,7 @@ import java.time.Instant import com.daml.lf.data.Ref import com.daml.lf.data.Ref.Party import com.daml.lf.transaction.GlobalKey -import com.daml.lf.value.Value -import com.daml.lf.value.Value.{ContractId, ContractInst} +import com.daml.lf.value.Value.{ContractId, VersionedContractInstance} import com.daml.logging.LoggingContext import scala.concurrent.Future @@ -22,7 +21,7 @@ trait ContractStore { contractId: ContractId, )(implicit loggingContext: LoggingContext - ): Future[Option[ContractInst[Value.VersionedValue]]] + ): Future[Option[VersionedContractInstance]] def lookupContractKey(readers: Set[Party], key: GlobalKey)(implicit loggingContext: LoggingContext diff --git a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/Conversions.scala b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/Conversions.scala index 8b8d4772a8a9..23e49378df6b 100644 --- a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/Conversions.scala +++ b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/Conversions.scala @@ -260,7 +260,7 @@ private[state] object Conversions { def decodeContractInstance( coinst: TransactionOuterClass.ContractInstance - ): Value.ContractInst[VersionedValue] = + ): Value.VersionedContractInstance = assertDecode( "ContractInstance", TransactionCoder @@ -268,7 +268,7 @@ private[state] object Conversions { ) def encodeContractInstance( - coinst: Value.ContractInst[VersionedValue] + coinst: Value.VersionedContractInstance ): TransactionOuterClass.ContractInstance = assertEncode( "ContractInstance", @@ -332,14 +332,14 @@ private[state] object Conversions { def extractDivulgedContracts( damlTransactionBlindingInfo: DamlTransactionBlindingInfo - ): Either[Seq[String], Map[ContractId, Value.ContractInst[VersionedValue]]] = { + ): Either[Seq[String], Map[ContractId, Value.VersionedContractInstance]] = { val divulgences = damlTransactionBlindingInfo.getDivulgencesList.asScala.toVector if (divulgences.isEmpty) { Right(Map.empty) } else { val resultAccumulator: Either[Seq[String], mutable.Builder[ - (ContractId, Value.ContractInst[VersionedValue]), - Map[ContractId, Value.ContractInst[VersionedValue]], + (ContractId, Value.VersionedContractInstance), + Map[ContractId, Value.VersionedContractInstance], ]] = Right(Map.newBuilder) divulgences .foldLeft(resultAccumulator) { diff --git a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/committer/transaction/validation/ModelConformanceValidator.scala b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/committer/transaction/validation/ModelConformanceValidator.scala index 267ef3c816c7..50e1387f017c 100644 --- a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/committer/transaction/validation/ModelConformanceValidator.scala +++ b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/committer/transaction/validation/ModelConformanceValidator.scala @@ -143,7 +143,7 @@ private[transaction] class ModelConformanceValidator(engine: Engine, metrics: Me commitContext: CommitContext )( contractId: Value.ContractId - ): Option[Value.ContractInst[Value.VersionedValue]] = + ): Option[Value.VersionedContractInstance] = commitContext .read(contractIdToStateKey(contractId)) .map(_.getContractState) diff --git a/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/committer/transaction/validation/ModelConformanceValidatorSpec.scala b/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/committer/transaction/validation/ModelConformanceValidatorSpec.scala index 81284970e233..f33ba6bf7c56 100644 --- a/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/committer/transaction/validation/ModelConformanceValidatorSpec.scala +++ b/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/committer/transaction/validation/ModelConformanceValidatorSpec.scala @@ -96,7 +96,7 @@ class ModelConformanceValidatorSpec when( mockValidationResult.consume( any[Value.ContractId => Option[ - Value.ContractInst[Value.VersionedValue] + Value.VersionedContractInstance ]], any[Ref.PackageId => Option[Ast.Package]], any[GlobalKeyWithMaintainers => Option[Value.ContractId]], @@ -201,7 +201,7 @@ class ModelConformanceValidatorSpec when( mockValidationResult.consume( any[Value.ContractId => Option[ - Value.ContractInst[Value.VersionedValue] + Value.VersionedContractInstance ]], any[Ref.PackageId => Option[Ast.Package]], any[GlobalKeyWithMaintainers => Option[Value.ContractId]], @@ -434,11 +434,13 @@ object ModelConformanceValidatorSpec { .build() } - private val aContractInst = Value.ContractInst( - aTemplateId, - Value.VersionedValue(txVersion, ValueText("dummyValue")), - "", - ) + private val aContractInst = + Value.VersionedContractInstance( + txVersion, + aTemplateId, + ValueText("dummyValue"), + "", + ) private val anArchive: DamlLf.Archive = { val pkg = Ast.GenPackage[Expr]( diff --git a/ledger/participant-state/kvutils/tools/engine-replay/src/replay/scala/ledger/participant/state/kvutils/tools/engine/replay/Adapter.scala b/ledger/participant-state/kvutils/tools/engine-replay/src/replay/scala/ledger/participant/state/kvutils/tools/engine/replay/Adapter.scala index 7ac829aa383f..7ce9eb4e3ad0 100644 --- a/ledger/participant-state/kvutils/tools/engine-replay/src/replay/scala/ledger/participant/state/kvutils/tools/engine/replay/Adapter.scala +++ b/ledger/participant-state/kvutils/tools/engine-replay/src/replay/scala/ledger/participant/state/kvutils/tools/engine/replay/Adapter.scala @@ -62,11 +62,8 @@ private[replay] final class Adapter( ): Node.KeyWithMaintainers[Value] = k.copy(adapt(k.key)) - def adapt(coinst: Tx.ContractInst): Tx.ContractInst = - coinst.copy( - template = adapt(coinst.template), - arg = coinst.arg.copy(value = adapt(coinst.arg.value)), - ) + def adapt(coinst: Value.VersionedContractInstance): Value.VersionedContractInstance = + coinst.copy(template = adapt(coinst.template), arg = adapt(coinst.arg)) def adapt(gkey: GlobalKey): GlobalKey = GlobalKey.assertBuild(adapt(gkey.templateId), adapt(gkey.key)) diff --git a/ledger/participant-state/kvutils/tools/engine-replay/src/replay/scala/ledger/participant/state/kvutils/tools/engine/replay/Replay.scala b/ledger/participant-state/kvutils/tools/engine-replay/src/replay/scala/ledger/participant/state/kvutils/tools/engine/replay/Replay.scala index 30e461ea812f..9869f1aa8231 100644 --- a/ledger/participant-state/kvutils/tools/engine-replay/src/replay/scala/ledger/participant/state/kvutils/tools/engine/replay/Replay.scala +++ b/ledger/participant-state/kvutils/tools/engine-replay/src/replay/scala/ledger/participant/state/kvutils/tools/engine/replay/Replay.scala @@ -23,7 +23,6 @@ import com.daml.lf.transaction.{ GlobalKeyWithMaintainers, Node, SubmittedTransaction, - Transaction => Tx, TransactionCoder => TxCoder, } import com.daml.lf.value.Value.ContractId @@ -45,7 +44,7 @@ final case class TxEntry( final case class BenchmarkState( name: String, transaction: TxEntry, - contracts: Map[ContractId, Tx.ContractInst], + contracts: Map[ContractId, Value.VersionedContractInstance], contractKeys: Map[GlobalKey, ContractId], ) { @@ -185,7 +184,7 @@ private[replay] object Replay { } ) - val allContracts: Map[ContractId, Value.ContractInst[Tx.Value]] = + val allContracts: Map[ContractId, Value.VersionedContractInstance] = createsNodes.map(node => node.coid -> node.versionedCoinst).toMap val allContractsWithKey = createsNodes.flatMap { node => 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 fde80c682fb5..e3f1a6d62f02 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: Value.ContractInst[Value.VersionedValue], + contractInst: Value.VersionedContractInstance, ) 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 bf3dc33b1e76..16b50622cc01 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: Value.ContractInst[Value.VersionedValue], + contractInst: Value.VersionedContractInstance, ) 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 c3427ba2db0f..69e15b535b74 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 @@ -50,8 +50,7 @@ import com.daml.lf.transaction.{ SubmittedTransaction, TransactionCommitter, } -import com.daml.lf.value.Value -import com.daml.lf.value.Value.{ContractId, ContractInst} +import com.daml.lf.value.Value.{ContractId, VersionedContractInstance} import com.daml.logging.{ContextualizedLogger, LoggingContext} import com.daml.platform.index.TransactionConversion import com.daml.platform.packages.InMemoryPackageStore @@ -296,7 +295,7 @@ private[sandbox] final class InMemoryLedger( LfEngineToApi.assertOrRuntimeEx( "converting stored contract", LfEngineToApi - .lfValueToApiRecord(verbose = verbose, contractInst.arg.value), + .lfValueToApiRecord(verbose = verbose, contractInst.arg), ) ), contract.signatories.union(contract.observers).intersect(filter.keySet).toSeq, @@ -316,7 +315,7 @@ private[sandbox] final class InMemoryLedger( forParties: Set[Ref.Party], )(implicit loggingContext: LoggingContext - ): Future[Option[ContractInst[Value.VersionedValue]]] = + ): Future[Option[VersionedContractInstance]] = Future.successful(this.synchronized { acs.activeContracts .get(contractId)