Skip to content

Commit

Permalink
Moved DamlSubmission* into separate proto file [KVL-980] (#10362)
Browse files Browse the repository at this point in the history
CHANGELOG_BEGIN
[Integration Kit] Moved definitions of `DamlSubmission` and `DamlSubmissionBatch` to a separate proto file under the package `com.daml.ledger.participant.state.kvutils.wire`. In case you are directly referencing these messages you will have to update your imports.
CHANGELOG_END
  • Loading branch information
miklos-da authored Jul 27, 2021
1 parent 0da814d commit b5e9d86
Show file tree
Hide file tree
Showing 36 changed files with 89 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,30 +51,6 @@ message Envelope {
bytes message = 4;
}

// A submission to the ledger: a payload and its inputs if any.
// Produced by [[KeyValueSubmission]].
// Transformed into `DamlLogEntry` when committed.
message DamlSubmission {
repeated DamlStateKey input_daml_state = 1;
oneof payload {
DamlTransactionEntry transaction_entry = 2;
DamlPackageUploadEntry package_upload_entry = 3;
DamlConfigurationSubmission configuration_submission = 4;
DamlPartyAllocationEntry party_allocation_entry = 5;
}
bytes submission_seed = 6;
}

// A batch of enveloped [[DamlSubmission]]'s.
message DamlSubmissionBatch {
message CorrelatedSubmission {
bytes submission = 1;
string correlation_id = 2;
}

repeated CorrelatedSubmission submissions = 2;
}

// A log entry for a committed Daml submission.
// Produced by [[KeyValueCommitting]] from the `DamlSubmission` message.
// Each entry can be converted into a participant state `Update` event
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

syntax = "proto3";
package com.daml.ledger.participant.state.kvutils.wire;
option java_package = "com.daml.ledger.participant.state.kvutils.wire";
option java_multiple_files = true;
option csharp_namespace = "Com.Daml.Ledger.Participant.State.KVUtils.Wire";

import "com/daml/ledger/participant/state/kvutils/daml_kvutils.proto";

// A submission to the ledger: a payload and its inputs if any.
// Produced by [[KeyValueSubmission]].
// Transformed into `DamlLogEntry` when committed.
message DamlSubmission {
repeated DamlStateKey input_daml_state = 1;
oneof payload {
DamlTransactionEntry transaction_entry = 2;
DamlPackageUploadEntry package_upload_entry = 3;
DamlConfigurationSubmission configuration_submission = 4;
DamlPartyAllocationEntry party_allocation_entry = 5;
}
bytes submission_seed = 6;
}

// A batch of enveloped [[DamlSubmission]]'s.
message DamlSubmissionBatch {
message CorrelatedSubmission {
bytes submission = 1;
string correlation_id = 2;
}

repeated CorrelatedSubmission submissions = 2;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ object Envelope {

sealed trait Message extends Product with Serializable

final case class SubmissionMessage(submission: Proto.DamlSubmission) extends Message
final case class SubmissionMessage(submission: wire.DamlSubmission) extends Message

final case class LogEntryMessage(logEntry: Proto.DamlLogEntry) extends Message

final case class StateValueMessage(value: Proto.DamlStateValue) extends Message

final case class SubmissionBatchMessage(value: Proto.DamlSubmissionBatch) extends Message
final case class SubmissionBatchMessage(value: wire.DamlSubmissionBatch) extends Message

private val DefaultCompression = true

Expand All @@ -47,10 +47,10 @@ object Envelope {
.build
)

def enclose(sub: Proto.DamlSubmission): Raw.Envelope =
def enclose(sub: wire.DamlSubmission): Raw.Envelope =
enclose(sub, compression = DefaultCompression)

def enclose(sub: Proto.DamlSubmission, compression: Boolean): Raw.Envelope =
def enclose(sub: wire.DamlSubmission, compression: Boolean): Raw.Envelope =
enclose(Proto.Envelope.MessageKind.SUBMISSION, sub.toByteString, compression)

def enclose(logEntry: Proto.DamlLogEntry): Raw.Envelope =
Expand All @@ -65,7 +65,7 @@ object Envelope {
def enclose(stateValue: Proto.DamlStateValue, compression: Boolean): Raw.Envelope =
enclose(Proto.Envelope.MessageKind.STATE_VALUE, stateValue.toByteString, compression)

def enclose(batch: Proto.DamlSubmissionBatch): Raw.Envelope =
def enclose(batch: wire.DamlSubmissionBatch): Raw.Envelope =
enclose(Proto.Envelope.MessageKind.SUBMISSION_BATCH, batch.toByteString, compression = false)

def open(envelopeBytes: Raw.Envelope): Either[String, Message] =
Expand Down Expand Up @@ -95,13 +95,13 @@ object Envelope {
parseMessageSafe(() => Proto.DamlLogEntry.parseFrom(uncompressedMessage))
.map(LogEntryMessage)
case Proto.Envelope.MessageKind.SUBMISSION =>
parseMessageSafe(() => Proto.DamlSubmission.parseFrom(uncompressedMessage))
parseMessageSafe(() => wire.DamlSubmission.parseFrom(uncompressedMessage))
.map(SubmissionMessage)
case Proto.Envelope.MessageKind.STATE_VALUE =>
parseMessageSafe(() => Proto.DamlStateValue.parseFrom(uncompressedMessage))
.map(StateValueMessage)
case Proto.Envelope.MessageKind.SUBMISSION_BATCH =>
parseMessageSafe(() => Proto.DamlSubmissionBatch.parseFrom(uncompressedMessage))
parseMessageSafe(() => wire.DamlSubmissionBatch.parseFrom(uncompressedMessage))
.map(SubmissionBatchMessage)
case Proto.Envelope.MessageKind.UNRECOGNIZED =>
Left(s"Unrecognized message kind: ${envelope.getKind}")
Expand All @@ -114,13 +114,13 @@ object Envelope {
case msg => Left(s"Expected log entry, got ${msg.getClass}")
}

def openSubmission(envelopeBytes: Raw.Envelope): Either[String, Proto.DamlSubmission] =
def openSubmission(envelopeBytes: Raw.Envelope): Either[String, wire.DamlSubmission] =
open(envelopeBytes).flatMap {
case SubmissionMessage(entry) => Right(entry)
case msg => Left(s"Expected submission, got ${msg.getClass}")
}

def openSubmission(envelopeBytes: Array[Byte]): Either[String, Proto.DamlSubmission] =
def openSubmission(envelopeBytes: Array[Byte]): Either[String, wire.DamlSubmission] =
open(envelopeBytes).flatMap {
case SubmissionMessage(entry) => Right(entry)
case msg => Left(s"Expected submission, got ${msg.getClass}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.daml.ledger.participant.state.kvutils.committer.{
PartyAllocationCommitter,
SubmissionExecutor,
}
import com.daml.ledger.participant.state.kvutils.wire.DamlSubmission
import com.daml.lf.data.Ref
import com.daml.lf.data.Time.Timestamp
import com.daml.lf.engine.Engine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.daml.daml_lf_dev.DamlLf.Archive
import com.daml.ledger.configuration.Configuration
import com.daml.ledger.participant.state.kvutils.Conversions._
import com.daml.ledger.participant.state.kvutils.DamlKvutils._
import com.daml.ledger.participant.state.kvutils.wire.DamlSubmission
import com.daml.ledger.participant.state.v1.{SubmitterInfo, TransactionMeta}
import com.daml.lf.data.Ref
import com.daml.lf.data.Time.Timestamp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ package com.daml.ledger.participant.state.kvutils

import com.daml.lf.data.BackStack
import com.daml.lf.data.Ref.Party
import com.daml.lf.transaction.BlindingInfo
import com.daml.lf.transaction.{NodeId, Transaction}
import com.daml.lf.transaction.{BlindingInfo, NodeId, Transaction}

final case class ProjectionRoots(
party: Party,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import java.util.UUID

import akka.stream.Materializer
import com.daml.ledger.api.health.HealthStatus
import com.daml.ledger.participant.state.kvutils.DamlKvutils.DamlSubmissionBatch
import com.daml.ledger.participant.state.kvutils.wire.DamlSubmissionBatch
import com.daml.ledger.participant.state.kvutils.{Envelope, Raw}
import com.daml.ledger.participant.state.v1.SubmissionResult
import com.daml.lf.data.Ref
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import java.util.concurrent.atomic.AtomicReference
import akka.stream.scaladsl.{Sink, Source, SourceQueueWithComplete}
import akka.stream.{Materializer, OverflowStrategy, QueueOfferResult}
import com.daml.dec.DirectExecutionContext
import com.daml.ledger.participant.state.kvutils.DamlKvutils.DamlSubmissionBatch
import com.daml.ledger.participant.state.kvutils.wire.DamlSubmissionBatch
import com.daml.ledger.participant.state.v1.SubmissionResult

import scala.concurrent.Future
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package com.daml.ledger.participant.state.kvutils.api

import com.daml.ledger.participant.state.kvutils.DamlKvutils.DamlSubmission
import com.daml.ledger.participant.state.kvutils.wire.DamlSubmission
import com.daml.ledger.participant.state.kvutils.{KeyValueCommitting, Raw}
import com.daml.ledger.validator.StateKeySerializationStrategy

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import com.daml.daml_lf_dev.DamlLf
import com.daml.ledger.api.health.HealthStatus
import com.daml.ledger.configuration.Configuration
import com.daml.ledger.offset.Offset
import com.daml.ledger.participant.state.kvutils.DamlKvutils.DamlSubmission
import com.daml.ledger.participant.state.kvutils.wire.DamlSubmission
import com.daml.ledger.participant.state.kvutils.{Envelope, KeyValueSubmission}
import com.daml.ledger.participant.state.v1.{
PruningResult,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import com.daml.ledger.participant.state.kvutils.DamlKvutils.{
DamlOutOfTimeBoundsEntry,
DamlStateKey,
DamlStateValue,
DamlSubmission,
}
import com.daml.ledger.participant.state.kvutils.KeyValueCommitting.PreExecutionResult
import com.daml.ledger.participant.state.kvutils._
import com.daml.ledger.participant.state.kvutils.wire.DamlSubmission
import com.daml.lf.data.Time.Timestamp
import com.daml.lf.data.{Ref, Time}
import com.daml.logging.LoggingContext.withEnrichedLoggingContextFrom
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.daml.ledger.participant.state.kvutils.Conversions.{
}
import com.daml.ledger.participant.state.kvutils.DamlKvutils._
import com.daml.ledger.participant.state.kvutils.committer.Committer._
import com.daml.ledger.participant.state.kvutils.wire.DamlSubmission
import com.daml.lf.data.Time.Timestamp
import com.daml.logging.entries.LoggingEntries
import com.daml.logging.{ContextualizedLogger, LoggingContext}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.daml.ledger.participant.state.kvutils.Conversions.packageUploadDedupK
import com.daml.ledger.participant.state.kvutils.DamlKvutils
import com.daml.ledger.participant.state.kvutils.DamlKvutils._
import com.daml.ledger.participant.state.kvutils.committer.Committer.buildLogEntryWithOptionalRecordTime
import com.daml.ledger.participant.state.kvutils.wire.DamlSubmission
import com.daml.lf
import com.daml.lf.data.Ref
import com.daml.lf.data.Ref.PackageId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package com.daml.ledger.participant.state.kvutils.committer
import com.daml.ledger.participant.state.kvutils.Conversions.partyAllocationDedupKey
import com.daml.ledger.participant.state.kvutils.DamlKvutils._
import com.daml.ledger.participant.state.kvutils.committer.Committer.buildLogEntryWithOptionalRecordTime
import com.daml.ledger.participant.state.kvutils.wire.DamlSubmission
import com.daml.lf.data.Ref
import com.daml.lf.data.Time.Timestamp
import com.daml.logging.entries.LoggingEntries
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import com.daml.ledger.participant.state.kvutils.DamlKvutils.{
DamlLogEntry,
DamlStateKey,
DamlStateValue,
DamlSubmission,
}
import com.daml.ledger.participant.state.kvutils.DamlStateMap
import com.daml.ledger.participant.state.kvutils.KeyValueCommitting.PreExecutionResult
import com.daml.ledger.participant.state.kvutils.wire.DamlSubmission
import com.daml.lf.data.{Ref, Time}
import com.daml.logging.LoggingContext

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.daml.ledger.participant.state.kvutils.committer.transaction.validatio
ModelConformanceValidator,
TransactionConsistencyValidator,
}
import com.daml.ledger.participant.state.kvutils.wire.DamlSubmission
import com.daml.ledger.participant.state.kvutils.{Conversions, Err}
import com.daml.lf.data.Ref.Party
import com.daml.lf.engine.{Blinding, Engine}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package com.daml.ledger.participant.state.kvutils.committer.transaction.validation

import com.daml.ledger.participant.state.kvutils.committer.transaction.{Step, Rejections}
import com.daml.ledger.participant.state.kvutils.committer.transaction.{Rejections, Step}

private[transaction] trait TransactionValidator {
def createValidationStep(rejections: Rejections): Step
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import java.util.concurrent.atomic.AtomicBoolean

import com.codahale.metrics.Timer
import com.daml.ledger.participant.state.kvutils.DamlKvutils._
import com.daml.ledger.participant.state.kvutils.wire._
import com.daml.ledger.participant.state.kvutils.api.LedgerReader
import com.daml.ledger.participant.state.kvutils.{DamlStateMap, Envelope, KeyValueCommitting, Raw}
import com.daml.ledger.validator.SubmissionValidator._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import akka.NotUsed
import akka.stream.Materializer
import akka.stream.scaladsl.{Sink, Source}
import com.daml.ledger.participant.state.kvutils.DamlKvutils._
import com.daml.ledger.participant.state.kvutils.wire._
import com.daml.ledger.participant.state.kvutils.api.LedgerReader
import com.daml.ledger.participant.state.kvutils.export.{
LedgerDataExporter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

package com.daml.ledger.validator.preexecution

import com.daml.ledger.participant.state.kvutils.DamlKvutils.{DamlStateKey, DamlSubmission}
import com.daml.ledger.participant.state.kvutils.DamlKvutils.DamlStateKey
import com.daml.ledger.participant.state.kvutils.wire.DamlSubmission
import com.daml.ledger.participant.state.kvutils.api.LedgerReader
import com.daml.ledger.participant.state.kvutils.{Envelope, KeyValueCommitting, Raw}
import com.daml.ledger.validator.reading.StateReader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.daml.daml_lf_dev.DamlLf
import com.daml.ledger.configuration.Configuration
import com.daml.ledger.participant.state.kvutils.DamlKvutils._
import com.daml.ledger.participant.state.kvutils.KeyValueCommitting.PreExecutionResult
import com.daml.ledger.participant.state.kvutils.wire.DamlSubmission
import com.daml.ledger.participant.state.v1.{SubmitterInfo, TransactionMeta}
import com.daml.ledger.test.SimplePackagePartyTestDar
import com.daml.lf.command.{ApiCommand, Commands}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import java.util.UUID

import com.daml.ledger.participant.state.kvutils.DamlKvutils._
import com.daml.ledger.participant.state.kvutils.Raw
import com.daml.ledger.participant.state.kvutils.wire.DamlSubmission
import com.daml.lf.data.Ref
import com.daml.lf.value.ValueOuterClass.Identifier
import com.google.protobuf.{ByteString, Empty}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

package com.daml.ledger.participant.state.kvutils

import com.daml.ledger.participant.state.kvutils.wire._
import com.daml.ledger.participant.state.kvutils.{DamlKvutils => Proto}
import com.google.protobuf.ByteString
import org.scalatest.matchers.should.Matchers
Expand All @@ -12,7 +13,7 @@ class EnvelopeSpec extends AnyWordSpec with Matchers {
"envelope" should {

"be able to enclose and open" in {
val submission = Proto.DamlSubmission.getDefaultInstance
val submission = DamlSubmission.getDefaultInstance

Envelope.open(Envelope.enclose(submission)) shouldEqual
Right(Envelope.SubmissionMessage(submission))
Expand All @@ -27,9 +28,9 @@ class EnvelopeSpec extends AnyWordSpec with Matchers {
}

"be able to enclose and open batch submission batch message" in {
val submissionBatch = Proto.DamlSubmissionBatch.newBuilder
val submissionBatch = DamlSubmissionBatch.newBuilder
.addSubmissions(
Proto.DamlSubmissionBatch.CorrelatedSubmission.newBuilder
DamlSubmissionBatch.CorrelatedSubmission.newBuilder
.setCorrelationId("anId")
.setSubmission(ByteString.copyFromUtf8("a submission"))
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ package com.daml.ledger.participant.state.kvutils

import com.daml.ledger.participant.state.kvutils.DamlKvutils.{
DamlLogEntry,
DamlSubmission,
DamlTransactionRejectionEntry,
}
import com.daml.ledger.participant.state.kvutils.TestHelpers._
import com.daml.ledger.participant.state.kvutils.wire.DamlSubmission
import com.daml.ledger.participant.state.v1.Update
import com.daml.ledger.test.{
SimplePackageListTestDar,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ package com.daml.ledger.participant.state.kvutils
import java.time.Instant

import com.codahale.metrics.MetricRegistry
import com.daml.ledger.participant.state.kvutils.DamlKvutils.{
DamlCommandDedupKey,
DamlStateKey,
DamlSubmission,
}
import com.daml.ledger.participant.state.kvutils.DamlKvutils.{DamlCommandDedupKey, DamlStateKey}
import com.daml.ledger.participant.state.kvutils.wire.DamlSubmission
import com.daml.ledger.participant.state.v1.{SubmitterInfo, TransactionMeta}
import com.daml.lf.crypto
import com.daml.lf.data.{ImmArray, Ref, Time}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package com.daml.ledger.participant.state.kvutils.api
import akka.stream.Materializer
import com.daml.ledger.api.health.HealthStatus
import com.daml.ledger.api.testing.utils.AkkaBeforeAndAfterAll
import com.daml.ledger.participant.state.kvutils.DamlKvutils.DamlSubmissionBatch
import com.daml.ledger.participant.state.kvutils.wire.DamlSubmissionBatch
import com.daml.ledger.participant.state.kvutils.{Envelope, Raw}
import com.daml.ledger.participant.state.v1.SubmissionResult
import com.daml.lf.data.Ref
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package com.daml.ledger.participant.state.kvutils.api

import com.daml.ledger.api.testing.utils.AkkaBeforeAndAfterAll
import com.daml.ledger.participant.state.kvutils.DamlKvutils.DamlSubmissionBatch.CorrelatedSubmission
import com.daml.ledger.participant.state.kvutils.wire.DamlSubmissionBatch.CorrelatedSubmission
import com.daml.ledger.participant.state.v1.SubmissionResult
import com.google.protobuf.ByteString
import org.mockito.ArgumentMatchers.any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import java.util.UUID

import com.codahale.metrics.MetricRegistry
import com.daml.ledger.configuration.{Configuration, LedgerTimeModel}
import com.daml.ledger.participant.state.kvutils.DamlKvutils.DamlSubmission
import com.daml.ledger.participant.state.kvutils.wire.DamlSubmission
import com.daml.ledger.participant.state.kvutils.{Envelope, Raw}
import com.daml.ledger.participant.state.v1.{SubmissionResult, SubmitterInfo, TransactionMeta}
import com.daml.ledger.validator.{
Expand Down
Loading

0 comments on commit b5e9d86

Please sign in to comment.