package canton
- Alphabetic
- By Inheritance
- canton
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Package Members
- package admin
- package auth
- package buildinfo
- package caching
- package cli
- package common
- package concurrent
- package config
- package connection
- package console
General
console
utilities - package crypto
- package daml
- package data
- package demo
- package discard
- package driver
- package environment
- package error
- package examples
- package fetchcontracts
- package grpc
- package health
- package http
- package interactive
- package ledger
- package lifecycle
- package logging
- package mediator
- package metrics
- package microbench
- package networking
- package participant
- package pekkostreams
- package performance
- package platform
Type aliases used throughout the package
- package protocol
Provides shorthands for general purpose types.
Provides shorthands for general purpose types.
Most notably, it provides a facade for Daml-LF transactions and nodes. By default, code should access Daml-LF transaction and nodes types through this facade.
- package pruning
- package pureconfigutils
- package replica
- package resource
- package scheduler
- package sequencer
- package sequencing
- package serialization
- package store
- package synchronizer
- package telemetry
- package time
- package topology
- package tracing
- package util
- package v30
- package version
- package watchdog
Type Members
- class AcsCommitmentBenchmarkCaching extends AcsCommitmentBenchmark
This benchmark measures the impact of caching, "x3" and "x3withManyStakeholders" have the same amount of counter participants, but x3 have one stakeholder group with many parties whereas x3withManyStakeholders has many stakeholders with one party.
This benchmark measures the impact of caching, "x3" and "x3withManyStakeholders" have the same amount of counter participants, but x3 have one stakeholder group with many parties whereas x3withManyStakeholders has many stakeholders with one party. we should see an improvement in performance for x3WithManyStakeholders when caching is turned on, compared to x3.
- Annotations
- @SuppressWarnings()
- class AcsCommitmentBenchmarkContractTypes extends AcsCommitmentBenchmark
This benchmark measures the impact on performance when the amount of active and passive contracts increases.
This benchmark measures the impact on performance when the amount of active and passive contracts increases. active contracts should show an increasement in runtime, however an increase in passive contracts should have a minimal impact.
- Annotations
- @SuppressWarnings()
- final class AllowTraverseSingleContainer extends Annotation with StaticAnnotation
- abstract class CantonAppDriver extends App with NamedLogging with NoTracing
The Canton main application.
The Canton main application.
Starts a set of synchronizers and participant nodes.
- sealed trait CantonScript extends AnyRef
- final case class CantonScriptFromFile(scriptPath: File) extends CantonScript with Product with Serializable
- final case class CommandId(id: LfLedgerString) extends PrettyPrinting with Product with Serializable
Command identifier for tracking ledger commands
Command identifier for tracking ledger commands
- id
ledger string representing command
- class ConsoleInteractiveRunner extends Runner
- class ConsoleScriptRunner extends Runner
- final class DoNotDiscardLikeFuture extends Annotation with StaticAnnotation
Annotated type constructors will be treated like a scala.concurrent.Future when looking for discarded futures.
- final class DoNotReturnFromSynchronizedLikeFuture extends Annotation with StaticAnnotation
Annotated type constructors will be treated like a scala.concurrent.Future when looking at the return types of synchronized blocks.
- final class DoNotTraverseLikeFuture extends Annotation with StaticAnnotation
Annotated type constructors will be treated like a scala.concurrent.Future when looking for traverse-like calls with such an applicative instance.
- final case class FutureTransformer(transformedTypeArgumentPosition: Int) extends Annotation with StaticAnnotation with Product with Serializable
Annotation for computation transformer type constructors (e.g., a monad transformer) so that if it will be treated future-like when applied to a future-like computation type.
Annotation for computation transformer type constructors (e.g., a monad transformer) so that if it will be treated future-like when applied to a future-like computation type.
- transformedTypeArgumentPosition
The type argument position for the computation type that is transformed
- final class GrpcServiceInvocationMethod extends Annotation with StaticAnnotation
Annotation for methods and constructors.
Annotation for methods and constructors. Implementations of such method (and any overrides) are not checked. Neither are the arguments to calls of such a method.
- type LedgerCommandId = LedgerString
- type LedgerParticipantId = ParticipantId
- type LedgerSubmissionId = LedgerString
- type LedgerTransactionId = LedgerString
- type LedgerUserId = daml.lf.data.IdString.UserId
- type LfChoiceName = Name
- type LfCommand = ReplayCommand
- type LfCommandId = LedgerString
- type LfCreateCommand = Create
- type LfExerciseByKeyCommand = ExerciseByKey
- type LfExerciseCommand = Exercise
- type LfFetchByKeyCommand = FetchByKey
- type LfFetchCommand = Fetch
- type LfInterfaceId = Identifier
- type LfKeyResolver = Map[GlobalKey, KeyMapping]
- type LfLedgerString = LedgerString
- type LfLookupByKeyCommand = LookupByKey
- type LfPackageId = PackageId
- type LfPackageName = PackageName
- type LfPackageRef = PackageRef
- type LfPackageVersion = PackageVersion
- type LfPartyId = Party
- type LfSubmissionId = LedgerString
- type LfTimestamp = Timestamp
- type LfValue = Value
- type LfVersioned[T] = Versioned[T]
- type LfWorkflowId = LedgerString
- sealed trait ProtoDeserializationError extends Product with Serializable
- type ReassignmentCounter = Counter[ReassignmentDiscriminator]
- abstract type ReassignmentDiscriminator
The counter assigned to a contract to count the number of its reassignments
- type RepairCounter = Counter[RepairCounterDiscriminator]
- abstract type RepairCounterDiscriminator
The counter assigned to a contract to track different repair changes.
The counter assigned to a contract to track different repair changes. The counter is relative to a sequenced request timestamp.
- type RequestCounter = Counter[RequestCounterDiscriminator]
- abstract type RequestCounterDiscriminator
The counter assigned by the transaction processor to confirmation and reassignment requests.
- implicit final class RichGeneratedMessage extends AnyVal
- trait Runner extends NamedLogging
Result for exposing the process exit code.
Result for exposing the process exit code. All logging is expected to take place inside the runner.
- final case class SequencerAlias extends LengthLimitedStringWrapper with PrettyPrinting with Product with Serializable
Class representing a SequencerAlias.
Class representing a SequencerAlias.
A SequencerAlias serves as a shorthand, or 'nickname', for a particular sequencer or group of Highly Available (HA) replicas of a sequencer within a specific node.
Note:
- SequencerAlias is a node-local concept. This means that two different participants may assign different aliases to the same sequencer or group of HA sequencer replicas.
- The uniqueness of a SequencerAlias is only enforced within a given synchronizer id. This means a node can use the same sequencer alias for different sequencers as long as these sequencers belong to different synchronizers.
- type SequencerCounter = Counter[SequencerCounterDiscriminator]
- abstract type SequencerCounterDiscriminator
The counter assigned by the sequencer to messages sent to the participant.
The counter assigned by the sequencer to messages sent to the participant. The counter is specific to every participant.
- class ServerRunner extends Runner with NoTracing
- final case class SynchronizerAlias(str: String255) extends LengthLimitedStringWrapper with PrettyPrinting with Product with Serializable
Participant local identifier used to refer to a synchronizer without the need to fetch identifying information from a synchronizer.
Participant local identifier used to refer to a synchronizer without the need to fetch identifying information from a synchronizer. This does not need to be globally unique. Only unique for the participant using it.
- str
String with given alias
- abstract type Uninhabited <: Nothing
Use this type when scalac struggles to infer
Nothing
due to it being treated specially.Use this type when scalac struggles to infer
Nothing
due to it being treated specially.see https://www.reddit.com/r/scala/comments/73791p/nothings_twin_brother_the_better_one/
- final case class UserId(id: LedgerUserId) extends PrettyPrinting with Product with Serializable
User identifier for identifying customer users in the ledger api
User identifier for identifying customer users in the ledger api
- id
ledger string representing user
- final case class WorkflowId(id: LfWorkflowId) extends PrettyPrinting with Product with Serializable
Workflow identifier for identifying customer workflows, i.e.
Workflow identifier for identifying customer workflows, i.e. individual requests, in the ledger api
- id
ledger string representing workflow
Value Members
- val LedgerCommandId: daml.lf.data.Ref.CommandId.type
- val LedgerParticipantId: ParticipantId.type
- val LedgerSubmissionId: SubmissionId.type
- val LedgerTransactionId: TransactionId.type
- val LedgerUserId: daml.lf.data.Ref.UserId.type
- val LfChoiceName: ChoiceName.type
- val LfCommand: ReplayCommand.type
- val LfCommandId: daml.lf.data.Ref.CommandId.type
- val LfCreateCommand: Create.type
- val LfExerciseByKeyCommand: ExerciseByKey.type
- val LfExerciseCommand: Exercise.type
- val LfFetchByKeyCommand: FetchByKey.type
- val LfFetchCommand: Fetch.type
- val LfInterfaceId: TypeConName.type
- val LfLedgerString: LedgerString.type
- val LfLookupByKeyCommand: LookupByKey.type
- val LfPackageId: PackageId.type
- val LfPackageName: PackageName.type
- val LfPackageRef: PackageRef.type
- val LfPackageVersion: PackageVersion.type
- val LfPartyId: Party.type
- val LfSubmissionId: SubmissionId.type
- val LfTimestamp: Timestamp.type
- val LfValue: Value.type
- val LfVersioned: Versioned.type
- val LfWorkflowId: daml.lf.data.Ref.WorkflowId.type
- val SequencerCounter: CounterCompanion[SequencerCounterDiscriminator]
- def checked[A](x: => A): A
Wrap a method call with this method to document that the caller is sure that the callee's preconditions are met.
- def checkedToByteString(proto: GeneratedMessage): ByteString
We should not call
toByteString
directly on a proto message.We should not call
toByteString
directly on a proto message. Rather, we should use the versioning tooling which ensures that the correct version of the proto message is used (based on the protocol version). However, in some cases (e.g., when we are sure that the message is not versioned), we can invoke this method directly.- Annotations
- @SuppressWarnings()
- implicit val lfPartyOrdering: Ordering[LfPartyId]
- object CantonAppDriver
- object CantonCommunityApp extends CantonAppDriver
- object CantonEnterpriseApp extends CantonAppDriver
- object CommandId extends Serializable
- object ConsoleScriptRunner extends NoTracing
- object DirectGrpcServiceInvocation extends WartTraverser
This wart warns when methods for a gRPC service stub are called directly.
This wart warns when methods for a gRPC service stub are called directly. Instead, the wrapper methods from
CantonGrpcUtil
and others should be used. This ensures in particular the following aspects:- The current trace context is set in the gRPC context prior to the call so that the gRPC stub implementation picks it up.
- Error handling is done consistently across gRPC calls.
Such helper methods are annotated
@GrpcServiceInvocationMethod
. The wart does not check any arguments at any call site, nor the implementation of such a method or any of its overrides. It is the responsibility of the developer to ensure that typical usage patterns of this method are safe w.r.t. the above aspects. Primary constructors can be annotated via their class.For example, instead of
myServiceStub.myMethod(request)
, you should useCantonGrpcUtil.sendGrpcRequest(myServiceStub, ...)(_.myMethod(request))
. - object DiscardedFuture extends WartTraverser
Flags statements that return a scala.concurrent.Future.
Flags statements that return a scala.concurrent.Future. Typically, we should not discard scala.concurrent.Future because exceptions inside the future may not get logged. Use
FutureUtil.doNotAwait
to log exceptions and discard the future where necessary.Also detects discarded cats.data.EitherT
[
scala.concurrent.Future, ..., ...]
and cats.data.OptionT[
scala.concurrent.Future, ...]
and arbitrary nestings of those. Custom type constructors can be registered to take the same role as scala.concurrent.Future by annotating the type definition with DoNotDiscardLikeFuture.Also flags usages of scala.collection.IterableOnceOps.foreach and scala.collection.IterableOnceOps.tapEach where the function returns a future-like type.
This wart is a special case of the warts
NonUnitStatements
and NonUnitForEach and scalac's-Wnonunit-statement
flag, in that it warns only if the return type is future-like. Additionally, this wart uses a different set of exceptions when no warning is issued. We keep this specialized wart for two reasons:- It is not practically feasible to use
-Wnonunit-statement
and NonUnitForEach in scalatest because it would flag many of the assertions of the formx should be >= y
in statement positions. Yet, it is important to check for discarded futures in tests because a discarded future may hide an exception. - In some production code, it is convenient to suppress the warnings coming from
-Wnonunit-statement
and NonUnitForEach, just due to how the code is written. In such places, we still want to benefit from the explicit checks against discarded futures.
This wart does not look at futures that are discarded at the end of a unit-type expression. These cases are caught by
-Ywarn-value-discard
. We do not implement a specialized version for future-like values because we do not expect to suppress the warnings coming from-Ywarn-value-discard
. - It is not practically feasible to use
- object EnforceVisibleForTesting extends WartTraverser
Wart such that we avoid using vals, defs, objects, classes, etc...
Wart such that we avoid using vals, defs, objects, classes, etc... that are marked with com.google.common.annotations.VisibleForTesting in production code.
Notice that usage of such definitions is allowed in the private or protected scope.
- object FutureAndThen extends WartTraverser
Wart such that we avoid using scala.concurrent.Future.andThen
Wart such that we avoid using scala.concurrent.Future.andThen
Using scala.concurrent.Future.andThen seems to be a bad idea because it swallows the exceptions in the
andThen
part.Better use our own implementation in
Thereafter
. - object FutureLikeTester
- object FutureTraverse extends WartTraverser
Cats' traverse and sequence methods do not specify the evaluation behaviour and this behaviour has changed between minor versions (e.g., 2.6 and 2.7).
Cats' traverse and sequence methods do not specify the evaluation behaviour and this behaviour has changed between minor versions (e.g., 2.6 and 2.7). When we traverse over containers, we should therefore be explicit whether the traversal is parallel or sequential. This wart flags all usages of Cats' syntax extensions for future-like applicatives, except when used with the singleton containers scala.Option and scala.Either.
Limitations:
- It does not flag traverse calls whose applicative instance is more general and can be instantiated with a future-like instance.
- object GlobalExecutionContext extends WartTraverser
The global execution context scala.concurrent.ExecutionContext.global should be avoided because it is integrated with neither of the following:
The global execution context scala.concurrent.ExecutionContext.global should be avoided because it is integrated with neither of the following:
- Canton's error reporting
- execution context supervision
- thread count configuration
- the workarounds for the bugs in the ForkJoinPool Moreover, if it is used in tests, the tests may interfere in unexpected ways.
For unit tests, mix in the traits
com.daml.resources.HasExecutionContext
orcom.digitalasset.canton.HasExecutorService
, which provide a suitably configured scala.concurrent.ExecutionContext. For integration tests, an execution context should already be in scope. In production code, properly pass the right scala.concurrent.ExecutionContext into where it is needed. Create a new one usingcom.digitalasset.canton.concurrent.Threading
if absolutely necessary.For similar reasons, the scala.concurrent.ExecutionContext.parasitic should not be used. Use
com.digitalasset.canton.concurrent.DirectExecutionContext
instead.scala.concurrent.ExecutionContext.opportunistic should be avoided as well, but given that scala.concurrent.ExecutionContext.opportunistic is private to the scala package, this wart does not check for it.
- object NonUnitForEach extends WartTraverser
This wart warns when methods scala.collection.IterableOnceOps.foreach and scala.collection.IterableOnceOps.tapEach are used with non-unit valued functions.
This wart warns when methods scala.collection.IterableOnceOps.foreach and scala.collection.IterableOnceOps.tapEach are used with non-unit valued functions. This is needed because these methods' signature accepts any-valued functions. So
-Ywarn-value-discard
does not warn about such discarded values.scala.collection.IterableOnceOps.foreach is also used in
for
loops without yield and therefore also covers cases such asfor { x <- 1 to 10 } { x + 5 }
.Builder operations such as
b += ...
are identified by their return typethis.type
and ignored when checking for non-unit return values. This allows common usages such asfor { x <- 1 to 10 } { b += x }
andfor { x <- 1 to 10 } { if (x % 2 == 0) b += x }
. This does not work for all usages though; you can force aUnit
type by specifying the type argument of scala.collection.IterableOnceOps.foreach and scala.collection.IterableOnceOps.tapEach as in(1 to 10).foreach[Unit] { ... }
, or by ascribingUnit
as in(1 to 10).foreach { x => f(x): Unit }
, or by explicitly discarding the result:(1 to 10).foreach { x => f(x).discard }
. - object ProtoDeserializationError extends ProtoDeserializationErrorGroup with Serializable
- object ProtobufToByteString extends WartTraverser
Detects calls to
toByteString
on generated protobuf messages.Detects calls to
toByteString
on generated protobuf messages.- See also
https://github.com/DACH-NY/canton/blob/main/contributing/backwards-incompatible-changes.md
- object ReassignmentCounter extends CounterCompanion[ReassignmentDiscriminator]
- object RepairCounter extends CounterCompanion[RepairCounterDiscriminator]
- object RequestCounter extends CounterCompanion[RequestCounterDiscriminator]
- object RequireBlocking extends WartTraverser
All blocking method calls should be wrapped in scala.concurrent.blocking so that the execution context knows that it may have to spawn a new process.
All blocking method calls should be wrapped in scala.concurrent.blocking so that the execution context knows that it may have to spawn a new process.
This wart checks that all @{code synchronized} calls are surrounded immediately by a scala.concurrent.blocking call. It also complains about calls to java.lang.Thread
.sleep
asThreading.sleep
should be used instead.The logic can currently be fooled by renaming
synchronized
andsleep
. - object SequencerAlias extends LengthLimitedStringWrapperCompanion[String255, SequencerAlias] with Serializable
- object SynchronizedFuture extends WartTraverser
When a
synchronized
block returns a scala.concurrent.Future, then the synchronization typically does not extend to the computations performed inside the future.When a
synchronized
block returns a scala.concurrent.Future, then the synchronization typically does not extend to the computations performed inside the future. This often hides a concurrency bug that is hard to spot during review because the computation's code is lexically inside the synchronized block and it may not be obvious that scala.concurrent.Futures are in play.For example,
synchronized
blocks are often used to read and update the state of an object atomically. When the update operation involves a scala.concurrent.Future like below, then the write to the state is actually not guarded by the synchronized call and the update is not atomic.synchronized { val x = this.atomicRef.get() futureComputation(x).map { y => this.atomicRef.set(y) y } }
The proper approach in the above example is to use a semaphore instead of a
synchronized
block.blocking { this.semaphore.acquire() } val x = this.atomicRef.get() futureComputation(x).map { y => this.atomicRef.set(y) y }.thereafter { _ => this.semaphore.release() }
If the synchronization intentionally does not have to extend over the scala.concurrent.Future computation, it usually helps with readability to move the future out of the synchronized block. For example,
blocking(synchronized { val x = criticalSection() Future { nonCriticalSection(x) } })
should be written as follows:
val x = blocking(synchronized { criticalSection() }) Future { nonCriticalSection(x) }
There are cases where the
synchronized
block is supposed to return a scala.concurrent.Future, for example when dealing with the promise of a future. In such a case, the warning should simply be suppressed locally. - object SynchronizerAlias extends LengthLimitedStringWrapperCompanion[String255, SynchronizerAlias] with Serializable
- object TryFailed extends WartTraverser
Wart such that we avoid using Try.failed
Wart such that we avoid using Try.failed
Using Try.failed seems to be a bad idea because it will create an UnsupportedOperationException for each Success, which constantly builds a stack trace and then throws it away. Seems to be quite expensive in particular in tight loops.
Better match on a Try. If you need failed.foreach, use TryUtil.forFailed instead.
- object UserId extends Serializable
- object WorkflowId extends Serializable