diff --git a/daml-lf/engine/src/main/scala/com/digitalasset/daml/lf/engine/Error.scala b/daml-lf/engine/src/main/scala/com/digitalasset/daml/lf/engine/Error.scala index 687ee65cbbf3..08ba87fe2fa5 100644 --- a/daml-lf/engine/src/main/scala/com/digitalasset/daml/lf/engine/Error.scala +++ b/daml-lf/engine/src/main/scala/com/digitalasset/daml/lf/engine/Error.scala @@ -153,7 +153,7 @@ object Error { final case class DamlException(error: interpretation.Error) extends Error { override def message: String = error match { case interpretation.Error.ContractNotFound(cid) => - s"Contract could not be found with id $cid" + s"Contract could not be found with id ${cid.coid}" case interpretation.Error.ContractKeyNotFound(key) => s"dependency error: couldn't find key: $key" case _ => diff --git a/daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/speedy/Pretty.scala b/daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/speedy/Pretty.scala index 5c0761dc1daf..0562482da1b7 100644 --- a/daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/speedy/Pretty.scala +++ b/daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/speedy/Pretty.scala @@ -97,11 +97,11 @@ private[lf] object Pretty { case NonComparableValues => text("functions are not comparable") case ContractIdComparability(globalCid) => - text(s"The global contract ID $globalCid conflicts with a local contract ID") + text(s"The global contract ID") & prettyContractId(globalCid) & + text("conflicts with a local contract ID") case ContractIdInContractKey(key) => - text( - s"Contract IDs are not supported in contract keys: ${key.ensureNoCid.left.toOption.get}" - ) + text("Contract IDs are not supported in contract keys:") & + prettyContractId(key.ensureNoCid.left.toOption.get) case ValueExceedsMaxNesting => text(s"Value exceeds maximum nesting value of 100") } 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 72ef80a7721e..33eed9b2a7a6 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 @@ -975,7 +975,10 @@ private[lf] object SBuiltin { val chosenValue = onLedger.ptx.normValue(templateId, args.get(0)) val coid = getSContractId(args, 1) val cached = - onLedger.cachedContracts.getOrElse(coid, crash(s"Contract $coid is missing from cache")) + onLedger.cachedContracts.getOrElse( + coid, + crash(s"Contract ${coid.coid} is missing from cache"), + ) val sigs = cached.signatories val templateObservers = cached.observers val ctrls = extractParties(NameOf.qualifiedNameOfCurrentFunc, args.get(2)) @@ -1024,7 +1027,7 @@ private[lf] object SBuiltin { if (cached.templateId != templateId) { if (onLedger.ptx.localContracts.contains(coid)) { // This should be prevented by the type checker so it’s an internal error. - crash(s"contract $coid ($templateId) not found from partial transaction") + crash(s"contract ${coid.coid} ($templateId) not found from partial transaction") } else { // This is a user-error. machine.ctrl = SEDamlException( @@ -1192,7 +1195,10 @@ private[lf] object SBuiltin { ): Unit = { val coid = getSContractId(args, 0) val cached = - onLedger.cachedContracts.getOrElse(coid, crash(s"Contract $coid is missing from cache")) + onLedger.cachedContracts.getOrElse( + coid, + crash(s"Contract ${coid.coid} is missing from cache"), + ) val signatories = cached.signatories val observers = cached.observers val key = cached.key @@ -1335,7 +1341,7 @@ private[lf] object SBuiltin { case Some(PartialTransaction.KeyActive(coid)) if onLedger.ptx.localContracts.contains(coid) => val cachedContract = onLedger.cachedContracts - .getOrElse(coid, crash(s"Local contract $coid not in cachedContracts")) + .getOrElse(coid, crash(s"Local contract ${coid.coid} not in cachedContracts")) val stakeholders = cachedContract.signatories union cachedContract.observers onLedger.visibleToStakeholders(stakeholders) match { case SVisibleToStakeholders.Visible => 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 9ccea079ef8c..0db4ca9eff03 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 @@ -261,7 +261,7 @@ object ScenarioRunner { case ScenarioLedger.LookupContractNotFound(coid) => // This should never happen, hence we don't have a specific // error for this. - throw Error.Internal(s"contract $coid not found") + throw Error.Internal(s"contract ${coid.coid} not found") case ScenarioLedger.LookupContractNotEffective(coid, tid, effectiveAt) => throw Error.ContractNotEffective(coid, tid, effectiveAt) diff --git a/daml-lf/tests/scenario/stable/no-contract-ids-in-keys/EXPECTED.ledger b/daml-lf/tests/scenario/stable/no-contract-ids-in-keys/EXPECTED.ledger index 2faef10f8356..fb56b710893e 100644 --- a/daml-lf/tests/scenario/stable/no-contract-ids-in-keys/EXPECTED.ledger +++ b/daml-lf/tests/scenario/stable/no-contract-ids-in-keys/EXPECTED.ledger @@ -1 +1 @@ -Error: Contract IDs are not supported in contract keys: ContractId(00fa6dbc32b678ec8a97ed0de226e397a4e2d521097b879d0146979556e7cd3e58) +Error: Contract IDs are not supported in contract keys: 00fa6dbc32b678ec8a97ed0de226e397a4e2d521097b879d0146979556e7cd3e58 diff --git a/ledger-service/http-json/src/itlib/scala/http/AbstractHttpServiceIntegrationTest.scala b/ledger-service/http-json/src/itlib/scala/http/AbstractHttpServiceIntegrationTest.scala index 1df31de3f9d8..e2080c2d8cb6 100644 --- a/ledger-service/http-json/src/itlib/scala/http/AbstractHttpServiceIntegrationTest.scala +++ b/ledger-service/http-json/src/itlib/scala/http/AbstractHttpServiceIntegrationTest.scala @@ -1141,7 +1141,7 @@ abstract class AbstractHttpServiceIntegrationTest status shouldBe StatusCodes.Conflict assertStatus(output, StatusCodes.Conflict) expectedOneErrorMessage(output) should include( - s"Contract could not be found with id ContractId($contractIdString)" + s"Contract could not be found with id $contractIdString" ) }: Future[Assertion] } diff --git a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/suites/ContractIdIT.scala b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/suites/ContractIdIT.scala index 4fcc5a3706e6..5b684c4b46b3 100644 --- a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/suites/ContractIdIT.scala +++ b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/suites/ContractIdIT.scala @@ -91,7 +91,7 @@ final class ContractIdIT extends LedgerTestSuite { // Assert V1 error code case Failure(GrpcException(GrpcStatus(Status.Code.ABORTED, Some(msg)), _)) if !alpha.features.selfServiceErrorCodes && msg.contains( - s"Contract could not be found with id ContractId($testedCid)" + s"Contract could not be found with id $testedCid" ) => Success(()) 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 1a9cf25af908..2f8c5a87fa71 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 @@ -111,7 +111,7 @@ private[platform] class ActiveLedgerStateManager[ALS <: ActiveLedgerState[ALS]]( if (otherContractLet.isAfter(let)) { Some( InvalidLedgerTime( - s"Encountered contract [$cid] with LET [$otherContractLet] greater than the LET of the transaction [$let]" + s"Encountered contract [${cid.coid}] with LET [$otherContractLet] greater than the LET of the transaction [$let]" ) ) } else { @@ -125,7 +125,7 @@ private[platform] class ActiveLedgerStateManager[ALS <: ActiveLedgerState[ALS]]( None case None => // Contract not known - Some(Inconsistent(s"Could not lookup contract $cid")) + Some(Inconsistent(s"Could not lookup contract ${cid.coid}")) } def handleLeaf( @@ -160,7 +160,7 @@ private[platform] class ActiveLedgerStateManager[ALS <: ActiveLedgerState[ALS]]( // A contract starts its life without being divulged at all. divulgences = Map.empty, key = nc.versionedKey.map( - _.assertNoCid(coid => s"Contract ID $coid found in contract key") + _.assertNoCid(coid => s"Contract ID ${coid.coid} found in contract key") ), signatories = nc.signatories, observers = nc.stakeholders.diff(nc.signatories), @@ -196,7 +196,10 @@ private[platform] class ActiveLedgerStateManager[ALS <: ActiveLedgerState[ALS]]( case nlkup: N.NodeLookupByKey => // Check that the stored lookup result matches the current result val key = nlkup.key.key.ensureNoCid.fold( - coid => throw new IllegalStateException(s"Contract ID $coid found in contract key"), + coid => + throw new IllegalStateException( + s"Contract ID ${coid.coid} found in contract key" + ), identity, ) val gk = GlobalKey(nlkup.templateId, key) diff --git a/ledger/participant-integration-api/src/main/scala/platform/store/appendonlydao/events/TransactionLogUpdatesConversions.scala b/ledger/participant-integration-api/src/main/scala/platform/store/appendonlydao/events/TransactionLogUpdatesConversions.scala index f2854cde8e95..547bf54b8d82 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/store/appendonlydao/events/TransactionLogUpdatesConversions.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/store/appendonlydao/events/TransactionLogUpdatesConversions.scala @@ -77,8 +77,9 @@ private[events] object TransactionLogUpdatesConversions { contractIds + event.contractId case (contractIds, event: ExercisedEvent) if event.consuming => contractIds - event.contractId - case (contractId, _) => - throw new RuntimeException(s"Unexpected non-consuming event for contractId $contractId") + case (contractIds, _) => + val prettyCids = contractIds.iterator.map(_.coid).mkString(", ") + throw new RuntimeException(s"Unexpected non-consuming event for contractIds $prettyCids") } aux.filter(ev => permanent(ev.contractId)) } 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 952d2538b9fe..cfc3859d14f9 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 @@ -163,7 +163,7 @@ private[platform] class MutableCacheBackedContractStore( // (the contract might have been divulged to the readers) // OR the contract was not found in the index // - logger.debug(s"Checking divulgence for contractId=$contractId and readers=$readers") + logger.debug(s"Checking divulgence for contractId=${contractId.coid} and readers=$readers") resolveDivulgenceLookup(contractStateValue, contractId, readers) } @@ -281,7 +281,7 @@ private[platform] class MutableCacheBackedContractStore( eventSequentialId, ) => logger.debug( - s"State events update: Created(contractId=$contractId, globalKey=$globalKey, offset=$eventOffset, eventSequentialId=$eventSequentialId)" + s"State events update: Created(contractId=${contractId.coid}, globalKey=$globalKey, offset=$eventOffset, eventSequentialId=$eventSequentialId)" ) case ContractStateEvent.Archived( contractId, @@ -291,7 +291,7 @@ private[platform] class MutableCacheBackedContractStore( eventSequentialId, ) => logger.debug( - s"State events update: Archived(contractId=$contractId, globalKey=$globalKey, offset=$eventOffset, eventSequentialId=$eventSequentialId)" + s"State events update: Archived(contractId=${contractId.coid}, globalKey=$globalKey, offset=$eventOffset, eventSequentialId=$eventSequentialId)" ) case LedgerEndMarker(eventOffset, eventSequentialId) => logger.debug( @@ -390,7 +390,7 @@ private[platform] object MutableCacheBackedContractStore { final case class ContractReadThroughNotFound(contractId: ContractId) extends NoStackTrace { override def getMessage: String = - s"Contract not found for contract id $contractId. Hint: this could be due racing with a concurrent archival." + s"Contract not found for contract id ${contractId.coid}. Hint: this could be due racing with a concurrent archival." } private[cache] class CacheIndex(initValue: (Offset, Long)) {