Skip to content

Commit

Permalink
Update 2022-04-11.07 (#20)
Browse files Browse the repository at this point in the history
Reference commit: 0fe56b5b0

Co-authored-by: Canton <[email protected]>
  • Loading branch information
canton-machine and Canton authored Apr 11, 2022
1 parent 0589330 commit 317ed8d
Show file tree
Hide file tree
Showing 112 changed files with 1,197 additions and 874 deletions.
4 changes: 0 additions & 4 deletions community/app/src/main/resources/application.conf
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
akka {
# TODO(M98): Once akka shutdown order is fixed in daml-on-x-server reenable (https://github.com/digital-asset/daml/issues/1886)
log-dead-letters-during-shutdown = off
log-dead-letters = 0

loggers = ["akka.event.slf4j.Slf4jLogger"]
loglevel = "INFO"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ trait DomainReference
// above command needs to be def such that `Help` works.
lazy private val partiesGroup = new PartiesAdministrationGroup(this, consoleEnvironment)

private lazy val sequencer_ = new SequencerAdministrationGroup(this, consoleEnvironment)
private lazy val sequencer_ =
new SequencerAdministrationGroup(this, consoleEnvironment, loggerFactory)
@Help.Summary("Manage the sequencer")
@Help.Group("Sequencer")
override def sequencer: SequencerAdministrationGroup = sequencer_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,22 @@ import com.digitalasset.canton.admin.api.client.commands.{
EnterpriseSequencerAdminCommands,
SequencerAdminCommands,
}
import com.digitalasset.canton.console.{AdminCommandRunner, ConsoleEnvironment, Help, Helpful}
import com.digitalasset.canton.console.{
AdminCommandRunner,
ConsoleEnvironment,
FeatureFlag,
FeatureFlagFilter,
Help,
Helpful,
}
import com.digitalasset.canton.data.CantonTimestamp
import com.digitalasset.canton.domain.sequencing.sequencer.{
LedgerIdentity,
SequencerClients,
SequencerPruningStatus,
SequencerSnapshot,
}
import com.digitalasset.canton.logging.{NamedLoggerFactory, NamedLogging}
import com.digitalasset.canton.topology.Member
import com.digitalasset.canton.util.ShowUtil._

Expand All @@ -23,8 +31,11 @@ import scala.jdk.DurationConverters._

class SequencerAdministrationGroup(
runner: AdminCommandRunner,
consoleEnvironment: ConsoleEnvironment,
) extends Helpful {
val consoleEnvironment: ConsoleEnvironment,
val loggerFactory: NamedLoggerFactory,
) extends Helpful
with FeatureFlagFilter
with NamedLogging {
@Help.Summary("Pruning of the sequencer")
object pruning {
@Help.Summary("Status of the sequencer and its connected clients")
Expand Down Expand Up @@ -208,15 +219,18 @@ class SequencerAdministrationGroup(
}

@Help.Summary(
"Authorize a ledger identity (e.g. an EthereumAccount) on the underlying ledger. "
"Authorize a ledger identity (e.g. an EthereumAccount) on the underlying ledger. ",
FeatureFlag.Preview,
)
@Help.Description("""Authorize a ledger identity (e.g. an EthereumAccount) on the underlying ledger.
|Currently only implemented for the Ethereum sequencer and has no effect for other sequencer
|integrations.
| See the authorization documentation of the Ethereum sequencer integrations for more detail.
"""")
def authorize_ledger_identity(ledgerIdentity: LedgerIdentity): Unit = consoleEnvironment.run {
runner.adminCommand(EnterpriseSequencerAdminCommands.AuthorizeLedgerIdentity(ledgerIdentity))
def authorize_ledger_identity(ledgerIdentity: LedgerIdentity): Unit = check(FeatureFlag.Preview) {
consoleEnvironment.run {
runner.adminCommand(EnterpriseSequencerAdminCommands.AuthorizeLedgerIdentity(ledgerIdentity))
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ final case class DidntUseForceOnRepairMigration(name: String) extends StartupErr

final case class StartFailed(name: String, message: String) extends StartupError

final case class ShutdownDuringStartup(name: String, message: String) extends StartupError

/** Trying to start the node when the database has pending migrations
*/
final case class PendingDatabaseMigration(name: String, pendingMigrationMessage: String)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class ManagedNodes[
}
}

for {
val result = for {
_ <- migrations
.connectionCheck(failFastIfDbOut, params.processingTimeouts)
.leftMap(
Expand All @@ -240,6 +240,10 @@ class ManagedNodes[
.roundDurationForHumans(Duration.fromNanos(elapsed))}"
)
}

result.value.onShutdown(
Left(ShutdownDuringStartup(name, "DB migration check interrupted due to shutdown"))
)
}

private def checkNotRunning(name: String): Either[StartupError, Unit] =
Expand All @@ -252,6 +256,8 @@ class ManagedNodes[
.create(dbConfig, name)
.migrateDatabase()
.leftMap(FailedDatabaseMigration(name, _))
.value
.onShutdown(Left(ShutdownDuringStartup(name, "DB migration interrupted due to shutdown")))
}

private def runRepairMigration(
Expand All @@ -263,6 +269,10 @@ class ManagedNodes[
.create(dbConfig, name)
.repairFlywayMigration()
.leftMap(FailedDatabaseRepairMigration(name, _))
.value
.onShutdown(
Left(ShutdownDuringStartup(name, "DB repair migration interrupted due to shutdown"))
)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sdk-version: 2.1.0-snapshot.20220328.9630.0.66c37bad
sdk-version: 2.1.0-snapshot.20220407.9685.0.7ed507cf
sandbox-options:
- --wall-clock-time
name: contact
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sdk-version: 2.1.0-snapshot.20220328.9630.0.66c37bad
sdk-version: 2.1.0-snapshot.20220407.9685.0.7ed507cf
sandbox-options:
- --wall-clock-time
name: message
Expand Down
4 changes: 2 additions & 2 deletions community/common/src/main/daml/CantonExamples/daml.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sdk-version: 2.1.0-snapshot.20220328.9630.0.66c37bad
sdk-version: 2.1.0-snapshot.20220407.9685.0.7ed507cf
name: CantonExamples
parties:
- Alice
Expand All @@ -11,7 +11,7 @@ exposed-modules:
- Paint
- Swap
source: .
version: 2.1.0
version: 2.2.0
dependencies:
- daml-prim
- daml-stdlib
Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions community/common/src/main/scala/com/daml/lf/CantonOnly.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

package com.daml.lf

import cats.data.NonEmptyList
import com.daml.lf.data.ImmArray
import com.daml.lf.engine.{Engine, EngineConfig}
import com.daml.lf.language.LanguageVersion
Expand All @@ -16,6 +15,7 @@ import com.daml.lf.transaction.{
}
import com.daml.lf.value.Value
import com.daml.lf.value.Value.VersionedValue
import com.daml.nonempty.NonEmpty
import com.digitalasset.canton.protocol.{LfNode, LfNodeId, LfTransactionVersion}

import java.nio.file.Path
Expand Down Expand Up @@ -99,7 +99,7 @@ object CantonOnly {
): VersionedValue =
asVersionedValue(value, transactionVersion)

def maxTransactionVersion(versions: NonEmptyList[LfTransactionVersion]): LfTransactionVersion =
def maxTransactionVersion(versions: NonEmpty[Seq[LfTransactionVersion]]): LfTransactionVersion =
versions.reduceLeft[LfTransactionVersion](LfTransactionVersion.Ordering.max)

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

package com.daml.nonempty

import com.digitalasset.canton.logging.pretty.Pretty

import scala.collection.immutable

/** Additional methods for [[com.daml.nonempty.NonEmpty]].
*
* Cats instances for [[com.daml.nonempty.NonEmpty]] must be imported explicitly as
* `import `[[com.daml.nonempty.catsinstances]]`._` when necessary.
*/
object NonEmptyUtil {
def fromUnsafe[A](xs: A with immutable.Iterable[_]): NonEmpty[A] =
NonEmpty.from(xs).getOrElse(throw new NoSuchElementException)

object instances {

/** This instance is exposed as [[com.digitalasset.canton.logging.pretty.PrettyInstances.prettyNonempty]].
* It lives only here because `NonEmptyColl.Instance.subst` is private to the `nonempty` package
*/
def prettyNonEmpty[A](implicit F: Pretty[A]): Pretty[NonEmpty[A]] = {
type K[T[_]] = Pretty[T[A]]
NonEmptyColl.Instance.subst[K](F)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

package com.digitalasset.canton

import com.digitalasset.canton.ProtoDeserializationError.ProtoDeserializationFailure
import com.digitalasset.canton.error.CantonErrorGroups.ProtoDeserializationErrorGroup
import com.digitalasset.canton.error.CantonError
Expand All @@ -13,28 +14,52 @@ import com.google.protobuf.InvalidProtocolBufferException
sealed trait ProtoDeserializationError extends Product with Serializable {
def toAdminError(implicit loggingContext: ErrorLoggingContext): CantonError =
ProtoDeserializationFailure.Wrap(this)

def inField(field: String): ProtoDeserializationError.ValueDeserializationError =
ProtoDeserializationError.ValueDeserializationError(field, message)

def message: String
}

object ProtoDeserializationError extends ProtoDeserializationErrorGroup {
final case class BufferException(error: InvalidProtocolBufferException)
extends ProtoDeserializationError
extends ProtoDeserializationError {
override val message = error.getMessage
}
final case class CryptoDeserializationError(error: DeserializationError)
extends ProtoDeserializationError
extends ProtoDeserializationError {
override val message = error.message
}
final case class TransactionDeserialization(message: String) extends ProtoDeserializationError
final case class ValueDeserializationError(field: String, message: String)
extends ProtoDeserializationError
final case class StringConversionError(error: String) extends ProtoDeserializationError
final case class UnrecognizedField(error: String) extends ProtoDeserializationError
final case class UnrecognizedEnum(field: String, value: Int) extends ProtoDeserializationError
final case class FieldNotSet(field: String) extends ProtoDeserializationError
final case class NotImplementedYet(className: String) extends ProtoDeserializationError
final case class StringConversionError(message: String) extends ProtoDeserializationError
final case class UnrecognizedField(message: String) extends ProtoDeserializationError
final case class UnrecognizedEnum(field: String, value: Int) extends ProtoDeserializationError {
override val message = s"Unrecognized value `$value` in enum field `$field`"
}
final case class FieldNotSet(field: String) extends ProtoDeserializationError {
override val message = s"Field `$field` is not set"
}
final case class NotImplementedYet(className: String) extends ProtoDeserializationError {
override val message = className
}
final case class TimestampConversionError(message: String) extends ProtoDeserializationError
final case class TimeModelConversionError(message: String) extends ProtoDeserializationError
final case class ValueConversionError(field: String, error: String)
extends ProtoDeserializationError
extends ProtoDeserializationError {
override val message = s"Unable to convert field `$field`: $error"
}
final case class SubmissionIdConversionError(message: String) extends ProtoDeserializationError
final case class InvariantViolation(error: String) extends ProtoDeserializationError
final case class UnknownGrpcCodeError(error: String) extends ProtoDeserializationError
final case class OtherError(error: String) extends ProtoDeserializationError
final case class InvariantViolation(error: String) extends ProtoDeserializationError {
override def message = error
}
final case class UnknownGrpcCodeError(error: String) extends ProtoDeserializationError {
override def message = error
}
final case class OtherError(error: String) extends ProtoDeserializationError {
override def message = error
}

/** Common Deserialization error code
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ object ServiceAgreement {
id <- ServiceAgreementId.fromProtoPrimitive(agreement.id)
legalText <- String256M
.create(agreement.legalText)
.leftMap(err => ProtoDeserializationError.ValueDeserializationError("legal_text", err))
.leftMap(ProtoDeserializationError.ValueDeserializationError("legal_text", _))
} yield ServiceAgreement(id, legalText)
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ object RequireTypes {

object NonNegativeNumeric {
def tryCreate[T](t: T)(implicit num: Numeric[T]): NonNegativeNumeric[T] =
create(t).valueOr(err => throw new IllegalArgumentException(err.error))
create(t).valueOr(err => throw new IllegalArgumentException(err.message))

def create[T](
t: T
Expand Down Expand Up @@ -179,7 +179,7 @@ object RequireTypes {

object PositiveNumeric {
def tryCreate[T](t: T)(implicit num: Numeric[T]): PositiveNumeric[T] =
create(t).valueOr(err => throw new IllegalArgumentException(err.error))
create(t).valueOr(err => throw new IllegalArgumentException(err.message))

def create[T](
t: T
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ object ActionDescription {
_signatories,
_stakeholders,
_key,
_byInterface,
version,
) =>
for {
Expand All @@ -110,7 +109,6 @@ object ActionDescription {
exerciseResult,
_key,
byKey,
_byInterface,
version,
) =>
for {
Expand All @@ -135,7 +133,6 @@ object ActionDescription {
_stakeholders,
_key,
byKey,
_byInterface,
version,
) =>
for {
Expand Down
Loading

0 comments on commit 317ed8d

Please sign in to comment.