Skip to content

Commit

Permalink
Update 2022-04-04.07 (#19)
Browse files Browse the repository at this point in the history
Reference commit: 52e341bea

Co-authored-by: Canton <[email protected]>
  • Loading branch information
canton-machine and Canton authored Apr 7, 2022
1 parent 04cab0f commit 0589330
Show file tree
Hide file tree
Showing 108 changed files with 1,472 additions and 1,489 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import com.digitalasset.canton.time._
import com.digitalasset.canton.tracing.TracingConfig
import com.typesafe.config.ConfigException.UnresolvedSubstitution
import com.typesafe.config.{Config, ConfigException, ConfigFactory, ConfigRenderOptions}
import com.typesafe.scalalogging.LazyLogging
import pureconfig._
import pureconfig.error.{CannotConvert, FailureReason}
import pureconfig.generic.{DerivedConfigWriter, FieldCoproductHint, ProductHint}
Expand All @@ -46,6 +47,7 @@ import scala.annotation.nowarn
import scala.concurrent.duration._
import scala.jdk.DurationConverters._
import scala.reflect.ClassTag
import monocle.macros.syntax.lens._

/** Configuration for a check */
sealed trait CheckConfig
Expand Down Expand Up @@ -120,10 +122,26 @@ final case class MonitoringConfig(
metrics: MetricsConfig = MetricsConfig(),
delayLoggingThreshold: NonNegativeFiniteDuration = NonNegativeFiniteDuration.ofSeconds(20),
tracing: TracingConfig = TracingConfig(),
logMessagePayloads: Boolean = false,
// TODO(i9014) remove (breaking change)
@Deprecated // use logging.api.messagePayloads instead
logMessagePayloads: Option[Boolean] = None,
logQueryCost: Option[QueryCostMonitoringConfig] = None,
logSlowFutures: Boolean = false,
)
logging: LoggingConfig = LoggingConfig(),
) extends LazyLogging {

// merge in backwards compatible config options
def getLoggingConfig: LoggingConfig = (logMessagePayloads, logging.api.messagePayloads) match {
case (Some(fst), _) =>
if (!logging.api.messagePayloads.forall(_ == fst))
logger.error(
"Broken config validation: logging.api.message-payloads differs from logMessagePayloads"
)
logging.focus(_.api.messagePayloads).replace(Some(fst))
case _ => logging
}

}

/** Configuration for console command timeouts
*
Expand Down Expand Up @@ -304,7 +322,7 @@ trait CantonConfig {
DomainNodeParameters(
monitoring.tracing,
monitoring.delayLoggingThreshold,
monitoring.logMessagePayloads,
monitoring.getLoggingConfig,
monitoring.logQueryCost,
parameters.enableAdditionalConsistencyChecks,
features.enablePreviewCommands,
Expand All @@ -329,7 +347,7 @@ trait CantonConfig {
ParticipantNodeParameters(
monitoring.tracing,
monitoring.delayLoggingThreshold,
monitoring.logMessagePayloads,
monitoring.getLoggingConfig,
monitoring.logQueryCost,
parameters.enableAdditionalConsistencyChecks,
features.enablePreviewCommands,
Expand Down Expand Up @@ -793,6 +811,10 @@ object CantonConfig {
lazy implicit val metricsConfigReader: ConfigReader[MetricsConfig] = deriveReader[MetricsConfig]
lazy implicit val queryCostMonitoringConfigReader: ConfigReader[QueryCostMonitoringConfig] =
deriveReader[QueryCostMonitoringConfig]
lazy implicit val apiLoggingConfigReader: ConfigReader[ApiLoggingConfig] =
deriveReader[ApiLoggingConfig]
lazy implicit val loggingConfigReader: ConfigReader[LoggingConfig] =
deriveReader[LoggingConfig]
lazy implicit val monitoringConfigReader: ConfigReader[MonitoringConfig] =
deriveReader[MonitoringConfig]
lazy implicit val consoleCommandTimeoutReader: ConfigReader[ConsoleCommandTimeout] =
Expand Down Expand Up @@ -1124,6 +1146,10 @@ object CantonConfig {
lazy implicit val metricsConfigWriter: ConfigWriter[MetricsConfig] = deriveWriter[MetricsConfig]
lazy implicit val queryCostMonitoringConfig: ConfigWriter[QueryCostMonitoringConfig] =
deriveWriter[QueryCostMonitoringConfig]
lazy implicit val apiLoggingConfigWriter: ConfigWriter[ApiLoggingConfig] =
deriveWriter[ApiLoggingConfig]
lazy implicit val loggingConfigWriter: ConfigWriter[LoggingConfig] =
deriveWriter[LoggingConfig]
lazy implicit val monitoringConfigWriter: ConfigWriter[MonitoringConfig] =
deriveWriter[MonitoringConfig]
lazy implicit val consoleCommandTimeoutWriter: ConfigWriter[ConsoleCommandTimeout] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ object CommunityConfigValidations extends ConfigValidations[CantonCommunityConfi
type Validation = CantonCommunityConfig => ValidatedNel[String, Unit]

override protected val validations: List[Validation] =
List[Validation](noDuplicateStorage, atLeastOneNode)
List[Validation](noDuplicateStorage, atLeastOneNode) ++ genericValidations[
CantonCommunityConfig
]

private[config] def genericValidations[C <: CantonConfig]: List[C => ValidatedNel[String, Unit]] =
List(backwardsCompatibleLoggingConfig)

/** Group node configs by db access to find matching db storage configs.
* Overcomplicated types used are to work around that at this point nodes could have conflicting names so we can't just
Expand Down Expand Up @@ -111,4 +116,22 @@ object CommunityConfigValidations extends ConfigValidations[CantonCommunityConfi

}

/** Check that logging configs are backwards compatible but consistent */
private def backwardsCompatibleLoggingConfig(
config: CantonConfig
): ValidatedNel[String, Unit] = {
(config.monitoring.logMessagePayloads, config.monitoring.logging.api.messagePayloads) match {
case (Some(fst), Some(snd)) =>
Validated.condNel(
fst == snd,
(),
backwardsCompatibleLoggingConfigErr,
)
case _ => Valid
}
}

private[config] val backwardsCompatibleLoggingConfigErr =
"Inconsistent configuration of canton.monitoring.log-message-payloads and canton.monitoring.logging.api.message-payloads. Please use the latter in your configuration"

}
Original file line number Diff line number Diff line change
Expand Up @@ -973,19 +973,17 @@ trait ParticipantAdministration extends FeatureFlagFilter {
@Help.Summary(
"Test whether a participant is connected to and permissioned on a domain where we have a healthy subscription."
)
def active(domain: DomainAlias): Boolean = {
def active(domain: DomainAlias): Boolean =
list_connected().find(_.domainAlias == domain) match {
case Some(item) if item.healthy =>
topology.participant_domain_states.active(item.domainId, id)
case _ => false
}
}

@Help.Summary(
"Test whether a participant is connected to and permissioned on a domain reference",
FeatureFlag.Testing,
"Test whether a participant is connected to and permissioned on a domain reference"
)
def active(reference: DomainAdministration): Boolean = check(FeatureFlag.Testing) {
def active(reference: DomainAdministration): Boolean = {
val domainId = reference.id
list_connected().find(_.domainId == domainId) match {
case None => false
Expand All @@ -994,12 +992,10 @@ trait ParticipantAdministration extends FeatureFlagFilter {
}
}
@Help.Summary(
"Test whether a participant is connected to a domain reference",
FeatureFlag.Testing,
"Test whether a participant is connected to a domain reference"
)
def is_connected(reference: DomainAdministration): Boolean = check(FeatureFlag.Testing) {
def is_connected(reference: DomainAdministration): Boolean =
list_connected().exists(_.domainId == reference.id)
}

private def confirm_agreement(domainAlias: DomainAlias): Unit = {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,19 @@ class PartiesAdministrationGroup(runner: AdminCommandRunner, consoleEnvironment:
"List active parties, their active participants, and the participants' permissions on domains."
)
@Help.Description(
"""This command allows you to deeply inspect the topology state used for synchronisation.
|The response is built from the timestamped topology transactions of each domain.
|The filterDomain parameter is used to filter the results by domain id;
|the result only contains entries whose domain id starts with `filterDomain`."""
"""Inspect the parties known by this participant as used for synchronisation.
|The response is built from the timestamped topology transactions of each domain, excluding the
|authorized store of the given node. For each known party, the list of active
|participants and their permission on the domain for that party is given.
|
filterParty: Filter by parties starting with the given string.
filterParticipant: Filter for parties that are hosted by a participant with an id starting with the given string
filterDomain: Filter by domains whose id starts with the given string.
asOf: Optional timestamp to inspect the topology state at a given point in time.
limit: Limit on the number of parties fetched (defaults to 100).
Example: participant1.parties.list(filterParty="alice")
"""
)
def list(
filterParty: String = "",
Expand Down Expand Up @@ -81,16 +90,31 @@ class ParticipantPartiesAdministrationGroup(
consoleEnvironment: ConsoleEnvironment,
) extends PartiesAdministrationGroup(runner, consoleEnvironment) {

@Help.Summary("List parties managed by this participant")
@Help.Description("""The filterDomain parameter is used to filter the results by domain id;
|the result only contains entries whose domain id starts with `filterDomain`.
|Inactive participants hosting the party are not shown in the result.""")
@Help.Summary("List parties hosted by this participant")
@Help.Description("""Inspect the parties hosted by this participant as used for synchronisation.
|The response is built from the timestamped topology transactions of each domain, excluding the
|authorized store of the given node. The search will include all hosted parties and is equivalent
|to running the `list` method using the participant id of the invoking participant.
|
filterParty: Filter by parties starting with the given string.
filterDomain: Filter by domains whose id starts with the given string.
asOf: Optional timestamp to inspect the topology state at a given point in time.
limit: How many items to return. Defaults to 100.
Example: participant1.parties.hosted(filterParty="alice")""")
def hosted(
filterParty: String = "",
filterDomain: String = "",
asOf: Option[Instant] = None,
limit: Int = 100,
): Seq[ListPartiesResult] = {
list(filterParty, filterParticipant = participantId.filterString, filterDomain, asOf)
list(
filterParty,
filterParticipant = participantId.filterString,
filterDomain = filterDomain,
asOf = asOf,
limit = limit,
)
}

@Help.Summary("Enable/add party to participant")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ trait Environment extends NamedLogging with AutoCloseable with NoTracing {
protected def createParticipant(
name: String,
participantConfig: config.ParticipantConfigType,
): ParticipantNodeBootstrap =
): ParticipantNodeBootstrap = {
participantNodeFactory
.create(
name,
Expand All @@ -332,6 +332,7 @@ trait Environment extends NamedLogging with AutoCloseable with NoTracing {
loggerFactory,
)
.valueOr(err => throw new RuntimeException(s"Failed to create participant bootstrap: $err"))
}

@VisibleForTesting
protected def createDomain(
Expand Down
121 changes: 0 additions & 121 deletions community/app/src/pack/deployment/docker/README.md

This file was deleted.

5 changes: 0 additions & 5 deletions community/app/src/pack/deployment/docker/bin/node-console.sh

This file was deleted.

Loading

0 comments on commit 0589330

Please sign in to comment.