Skip to content

Commit

Permalink
Remove trace_context field from Ledger API [KVL-1021] (#10256)
Browse files Browse the repository at this point in the history
CHANGELOG_BEGIN
* [Integration Kit] Removed trace_context field from Ledger API and its bindings as we now have trace context propagation support via gRPC metadata. If you are constructing or consuming Ledger API requests or responses directly, you may need to update your code.
CHANGELOG_END
  • Loading branch information
miklos-da authored Jul 15, 2021
1 parent 88886be commit 0eba812
Show file tree
Hide file tree
Showing 76 changed files with 71 additions and 721 deletions.
2 changes: 0 additions & 2 deletions bazel-java-deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@ def install_java_deps():
# ---- end of grpc-protobuf-netty block
"io.reactivex.rxjava2:rxjava:2.2.1",
"io.spray:spray-json_{}:1.3.5".format(scala_major_version),
"io.zipkin.brave:brave:4.6.0",
"io.zipkin.reporter:zipkin-sender-okhttp3:1.0.4",
"javax.annotation:javax.annotation-api:1.2",
"javax.ws.rs:javax.ws.rs-api:2.1",
"junit:junit:4.12",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ object TestData {
offset = "",
eventsById = eventsById,
rootEventIds = rootEventIds,
traceContext = None,
)
}
def toCommands: (Seq[Command], TransactionTree) = {
Expand Down
5 changes: 0 additions & 5 deletions language-support/hs/bindings/src/DA/Ledger/GrpcWrapUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
{-# LANGUAGE GADTs #-}

module DA.Ledger.GrpcWrapUtils (
noTrace,
unwrap, unwrapWithNotFound, unwrapWithInvalidArgument,
sendToStream,
) where

import Prelude hiding (fail)

import Com.Daml.Ledger.Api.V1.TraceContext (TraceContext)
import Control.Exception (throwIO)
import Control.Monad.Fail (fail)
import Control.Monad.Fix (fix)
Expand All @@ -21,9 +19,6 @@ import DA.Ledger.Convert (Perhaps,runRaise)
import Network.GRPC.HighLevel (clientCallCancel)
import Network.GRPC.HighLevel.Generated

noTrace :: Maybe TraceContext
noTrace = Nothing

unwrap :: ClientResult 'Normal a -> IO a
unwrap = \case
ClientNormalResponse x _m1 _m2 _status _details -> return x
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,4 @@ mkRequest lid tf verbosity = GetActiveContractsRequest
{ getActiveContractsRequestLedgerId = unLedgerId lid
, getActiveContractsRequestFilter = Just tf
, getActiveContractsRequestVerbose = unVerbosity verbosity
, getActiveContractsRequestTraceContext = noTrace
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ completionEnd lid =
withGRPCClient config $ \client -> do
service <- commandCompletionServiceClient client
let CommandCompletionService {commandCompletionServiceCompletionEnd=rpc} = service
let request = CompletionEndRequest (unLedgerId lid) noTrace
let request = CompletionEndRequest (unLedgerId lid)
rpc (ClientNormalRequest request timeout mdm)
>>= unwrap
>>= \case
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ submitAndWait commands =
withGRPCClient config $ \client -> do
service <- LL.commandServiceClient client
let LL.CommandService{commandServiceSubmitAndWaitForTransactionId=rpc} = service
let request = LL.SubmitAndWaitRequest (Just (lowerCommands commands)) noTrace
let request = LL.SubmitAndWaitRequest (Just (lowerCommands commands))
rpc (ClientNormalRequest request timeout mdm)
>>= unwrapWithInvalidArgument
<&> fmap (\LL.SubmitAndWaitForTransactionIdResponse{} -> ())
Expand All @@ -35,7 +35,7 @@ submitAndWaitForTransactionId commands =
withGRPCClient config $ \client -> do
service <- LL.commandServiceClient client
let LL.CommandService{commandServiceSubmitAndWaitForTransactionId=rpc} = service
let request = LL.SubmitAndWaitRequest (Just (lowerCommands commands)) noTrace
let request = LL.SubmitAndWaitRequest (Just (lowerCommands commands))
rpc (ClientNormalRequest request timeout mdm)
>>= unwrapWithInvalidArgument
<&> fmap (TransactionId . LL.submitAndWaitForTransactionIdResponseTransactionId)
Expand All @@ -46,7 +46,7 @@ submitAndWaitForTransaction commands =
withGRPCClient config $ \client -> do
service <- LL.commandServiceClient client
let LL.CommandService{commandServiceSubmitAndWaitForTransaction=rpc} = service
let request = LL.SubmitAndWaitRequest (Just (lowerCommands commands)) noTrace
let request = LL.SubmitAndWaitRequest (Just (lowerCommands commands))
rpc (ClientNormalRequest request timeout mdm)
>>= unwrapWithInvalidArgument
>>= \case
Expand All @@ -66,7 +66,7 @@ submitAndWaitForTransactionTree commands =
withGRPCClient config $ \client -> do
service <- LL.commandServiceClient client
let LL.CommandService{commandServiceSubmitAndWaitForTransactionTree=rpc} = service
let request = LL.SubmitAndWaitRequest (Just (lowerCommands commands)) noTrace
let request = LL.SubmitAndWaitRequest (Just (lowerCommands commands))
rpc (ClientNormalRequest request timeout mdm)
>>= unwrapWithInvalidArgument
>>= \case
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ submit commands =
withGRPCClient config $ \client -> do
service <- commandSubmissionServiceClient client
let CommandSubmissionService rpc = service
let request = SubmitRequest (Just (lowerCommands commands)) noTrace
let request = SubmitRequest (Just (lowerCommands commands))
rpc (ClientNormalRequest request timeout mdm)
>>= unwrapWithInvalidArgument
<&> fmap (\Empty{} -> ())
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import qualified Com.Daml.Ledger.Api.V1.LedgerConfigurationService as LL
getLedgerConfiguration :: LedgerId -> LedgerService (Stream LedgerConfiguration)
getLedgerConfiguration lid =
makeLedgerService $ \timeout config mdm -> do
let request = LL.GetLedgerConfigurationRequest (unLedgerId lid) noTrace
let request = LL.GetLedgerConfigurationRequest (unLedgerId lid)
asyncStreamGen $ \stream ->
withGRPCClient config $ \client -> do
service <- LL.ledgerConfigurationServiceClient client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Network.GRPC.HighLevel.Generated
getLedgerIdentity :: LedgerService LedgerId
getLedgerIdentity =
makeLedgerService $ \timeout config mdm -> do
let request = GetLedgerIdentityRequest noTrace
let request = GetLedgerIdentityRequest
withGRPCClient config $ \client -> do
service <- ledgerIdentityServiceClient client
let LedgerIdentityService{ledgerIdentityServiceGetLedgerIdentity=rpc} = service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ listPackages lid =
withGRPCClient config $ \client -> do
service <- packageServiceClient client
let PackageService {packageServiceListPackages=rpc} = service
let request = ListPackagesRequest (unLedgerId lid) noTrace
let request = ListPackagesRequest (unLedgerId lid)
response <- rpc (ClientNormalRequest request timeout mdm)
ListPackagesResponse xs <- unwrap response
return $ map PackageId $ Vector.toList xs
Expand All @@ -37,7 +37,7 @@ getPackage lid pid =
withGRPCClient config $ \client -> do
service <- packageServiceClient client
let PackageService {packageServiceGetPackage=rpc} = service
let request = GetPackageRequest (unLedgerId lid) (unPackageId pid) noTrace
let request = GetPackageRequest (unLedgerId lid) (unPackageId pid)
rpc (ClientNormalRequest request timeout mdm)
>>= unwrapWithNotFound
>>= \case
Expand All @@ -52,7 +52,7 @@ getPackageStatus lid pid =
withGRPCClient config $ \client -> do
service <- packageServiceClient client
let PackageService {packageServiceGetPackageStatus=rpc} = service
let request = GetPackageStatusRequest (unLedgerId lid) (unPackageId pid) noTrace
let request = GetPackageStatusRequest (unLedgerId lid) (unPackageId pid)
rpc (ClientNormalRequest request timeout mdm)
>>= unwrap
>>= \case
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ ledgerEnd lid =
withGRPCClient config $ \client -> do
service <- LL.transactionServiceClient client
let LL.TransactionService{transactionServiceGetLedgerEnd=rpc} = service
let request = LL.GetLedgerEndRequest (unLedgerId lid) noTrace
let request = LL.GetLedgerEndRequest (unLedgerId lid)
rpc (ClientNormalRequest request timeout mdm)
>>= unwrap
>>= \case
Expand Down Expand Up @@ -157,8 +157,7 @@ lowerRequest = \case
getTransactionsRequestBegin = Just (lowerLedgerOffset begin),
getTransactionsRequestEnd = fmap lowerLedgerOffset end,
getTransactionsRequestFilter = Just filter,
getTransactionsRequestVerbose = unVerbosity verbose,
getTransactionsRequestTraceContext = noTrace
getTransactionsRequestVerbose = unVerbosity verbose
}

mkByEventIdRequest :: LedgerId -> EventId -> [Party] -> LL.GetTransactionByEventIdRequest
Expand All @@ -167,12 +166,10 @@ mkByEventIdRequest lid eid parties =
(unLedgerId lid)
(unEventId eid)
(Vector.fromList $ map unParty parties)
noTrace

mkByIdRequest :: LedgerId -> TransactionId -> [Party] -> LL.GetTransactionByIdRequest
mkByIdRequest lid trid parties =
LL.GetTransactionByIdRequest
(unLedgerId lid)
(unTransactionId trid)
(Vector.fromList $ map unParty parties)
noTrace
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,6 @@ final class BotTest extends AnyFlatSpec with Matchers with Eventually {
com.google.protobuf.timestamp.Timestamp.defaultInstance,
Seq(),
offset,
None,
)
val getTransactionsResponses = Observable.defer[TransactionsServiceImpl.LedgerItem](() =>
Observable.fromArray(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ class CommandCompletionClientImplTest

it should "return a stream with all the completions" in {
val applicationId = "applicationId"
val completion1 = Completion("cid1", Option(new Status(0)), "1", None)
val completion2 = Completion("cid2", Option(new Status(1)), traceContext = None)
val completion1 = Completion("cid1", Option(new Status(0)), "1")
val completion2 = Completion("cid2", Option(new Status(1)))
val completionResponse = CompletionStreamResponse(None, List(completion1, completion2))
ledgerServices.withCommandCompletionClient(
List(completionResponse),
Expand Down Expand Up @@ -90,7 +90,7 @@ class CommandCompletionClientImplTest

it should "send the request with the correct ledgerId" in {
val applicationId = "applicationId"
val completion1 = Completion("cid1", Option(new Status(0)), traceContext = None)
val completion1 = Completion("cid1", Option(new Status(0)))
val completionResponse = CompletionStreamResponse(None, List(completion1))
val parties = Set("Alice")
ledgerServices.withCommandCompletionClient(
Expand All @@ -113,7 +113,7 @@ class CommandCompletionClientImplTest
behavior of "Authorization"

def toAuthenticatedServer(fn: CommandCompletionClient => Any): Any = {
val completion1 = Completion("cid1", Option(new Status(0)), traceContext = None)
val completion1 = Completion("cid1", Option(new Status(0)))
val completionResponse = CompletionStreamResponse(None, List(completion1))
ledgerServices.withCommandCompletionClient(
List(completionResponse),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ trait DataLayerHelpers {
"",
"workflowId",
Seq[CreatedEvent](),
None,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ object TransactionGenerator {
(scalaEvents, javaEvents) <- eventsGen
offset <- Gen.numStr
} yield (
LedgerItem(transactionId, commandId, workflowId, scalaTimestamp, scalaEvents, offset, None),
LedgerItem(transactionId, commandId, workflowId, scalaTimestamp, scalaEvents, offset),
new data.Transaction(transactionId, commandId, workflowId, javaTimestamp, javaEvents, offset),
)

Expand All @@ -293,7 +293,7 @@ object TransactionGenerator {
(scalaEvents, javaEvents) <- eventsGen
offset <- Gen.numStr
} yield (
LedgerItem(transactionId, commandId, workflowId, scalaTimestamp, scalaEvents, offset, None),
LedgerItem(transactionId, commandId, workflowId, scalaTimestamp, scalaEvents, offset),
new data.TransactionTree(
transactionId,
commandId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import com.daml.ledger.api.v1.ledger_offset.LedgerOffset.LedgerBoundary.{
Unrecognized,
}
import com.daml.ledger.api.v1.ledger_offset.LedgerOffset.Value.{Absolute, Boundary}
import com.daml.ledger.api.v1.trace_context.TraceContext
import com.daml.ledger.api.v1.transaction.Transaction
import com.daml.ledger.api.v1.transaction_service.TransactionServiceGrpc.TransactionService
import com.daml.ledger.api.v1.transaction_service._
Expand Down Expand Up @@ -132,7 +131,6 @@ object TransactionsServiceImpl {
effectiveAt: Timestamp,
events: Seq[Event],
offset: String,
traceContext: Option[TraceContext],
) {

def toTransaction =
Expand All @@ -143,7 +141,6 @@ object TransactionsServiceImpl {
Some(effectiveAt),
events,
offset,
traceContext,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package com.daml.ledger.client.binding

import com.daml.ledger.api.refinements.ApiTypes.{CommandId, TransactionId, WorkflowId}
import com.daml.ledger.api.v1.ledger_offset.LedgerOffset
import com.daml.ledger.api.v1.trace_context.TraceContext
import com.google.protobuf.timestamp.Timestamp

case class DomainTransaction(
Expand All @@ -15,5 +14,4 @@ case class DomainTransaction(
commandId: CommandId,
effectiveAt: Timestamp,
events: Seq[DomainEvent],
traceContext: Option[TraceContext],
)
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ class DomainTransactionMapper(decoder: DecoderType) extends LazyLogging {
commandId,
effectiveAt,
events,
t.traceContext,
)

private def checkExists[T](
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ object CommandRetryFlow {
{
case Ctx(
RetryInfo(request, nrOfRetries, firstSubmissionTime, _),
Completion(_, Some(status: Status), _, _),
Completion(_, Some(status: Status), _),
_,
) =>
if (status.code == Code.OK_VALUE) {
Expand All @@ -87,7 +87,7 @@ object CommandRetryFlow {
RetryLogger.logFatal(request, status, nrOfRetries)
PROPAGATE_PORT
}
case Ctx(_, Completion(commandId, _, _, _), _) =>
case Ctx(_, Completion(commandId, _, _), _) =>
statusNotFoundError(commandId)
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ class DomainTransactionMapperUT extends AnyWordSpec with Matchers with AkkaTest
CommandId("cid"),
time,
events,
None,
)

"DomainTransactionMapper" should {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,15 @@ class CommandRetryFlowUT extends AsyncWordSpec with Matchers with AkkaTest {
val mockCommandSubmission: SubmissionFlowType[RetryInfo[Status]] =
Flow[In[RetryInfo[Status]]]
.map {
case Ctx(context @ RetryInfo(_, _, _, status), SubmitRequest(Some(commands), tc), _) =>
case Ctx(context @ RetryInfo(_, _, _, status), SubmitRequest(Some(commands)), _) =>
if (commands.deduplicationTime.get.nanos == 0) {
Ctx(context, Completion(commands.commandId, Some(status), traceContext = tc))
Ctx(context, Completion(commands.commandId, Some(status)))
} else {
Ctx(
context,
Completion(
commands.commandId,
Some(status.copy(code = Code.OK_VALUE)),
traceContext = tc,
),
)
}
Expand Down Expand Up @@ -74,8 +73,7 @@ class CommandRetryFlowUT extends AsyncWordSpec with Matchers with AkkaTest {
Seq.empty,
Some(protoDuration.of(120, 0)),
)
),
None,
)
)

val input =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ package com.daml.ledger.api.refinements

import com.daml.ledger.api.refinements.ApiTypes.{CommandId, Party, WorkflowId}
import com.daml.ledger.api.v1.commands.Command
import com.daml.ledger.api.v1.trace_context.TraceContext

final case class CompositeCommand(
commands: Seq[Command],
party: Party,
commandId: CommandId,
workflowId: WorkflowId,
traceContext: Option[TraceContext],
)
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class CompositeCommandAdapter(
c.commands,
)

SubmitRequest(Some(commands), c.traceContext)
SubmitRequest(Some(commands))
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package com.daml.ledger.api.refinements
import com.daml.ledger.api.refinements.ApiTypes._
import com.daml.ledger.api.v1.commands.Command.Command.Create
import com.daml.ledger.api.v1.commands.{Command, Commands, CreateCommand}
import com.daml.ledger.api.v1.trace_context.TraceContext
import com.daml.ledger.api.v1.value.Identifier
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec
Expand All @@ -23,13 +22,11 @@ class CompositeCommandAdapterUT extends AnyWordSpec with Matchers {
)
)

val submittedTraceContext = Some(TraceContext(1, 2, 3, Some(4L), true))
val compositeCommand = CompositeCommand(
commands,
Party("party"),
CommandId("commandId"),
WorkflowId("workflowId"),
submittedTraceContext,
)

val submitRequest = CompositeCommandAdapter(
Expand All @@ -40,8 +37,6 @@ class CompositeCommandAdapterUT extends AnyWordSpec with Matchers {
submitRequest.commands shouldBe Some(
Commands("ledgerId", "workflowId", "applicationId", "commandId", "party", commands)
)

submitRequest.traceContext shouldBe submittedTraceContext
}

}
Expand Down
Loading

0 comments on commit 0eba812

Please sign in to comment.