From a3ddde3a9dfb53b2a5a68b2bb1f3ed218acc2746 Mon Sep 17 00:00:00 2001 From: Robert Autenrieth <31539813+rautenrieth-da@users.noreply.github.com> Date: Wed, 25 Mar 2020 16:50:27 +0100 Subject: [PATCH] Remove MRT and LET (#5172) Contributes to #4194. Closes #4231. Closes #5022. CHANGELOG_BEGIN - [Ledger API] The protobuf fields ledger_effective_time and maximum_record_time have been removed from command submission. These fields were previously deprecated following the introduction of a new ledger time model. See issue `#4194 `__. [Java Bindings] removed the usage of ledgerEffectiveTime and maximumRecordTime, and instead added minLedgerTimeAbsolute and minLedgerTimeRelative in CommandSubmissionClient and CommandClient CHANGELOG_END --- .../daml/lf/engine/script/Runner.scala | 2 - docs/source/app-dev/services.rst | 4 - docs/source/getting-started/quickstart.rst | 2 +- .../digitalasset/quickstart/iou/IouMain.java | 5 +- .../com/digitalasset/extractor/AuthSpec.scala | 16 +-- .../chat/src/DA/Ledger/App/Chat/ChatLedger.hs | 4 +- .../nim/src/DA/Ledger/App/Nim/NimLedger.hs | 4 +- .../hs/bindings/src/DA/Ledger/Convert.hs | 2 - .../hs/bindings/src/DA/Ledger/Types.hs | 2 - .../hs/bindings/test/DA/Ledger/Tests.hs | 4 +- .../com/daml/ledger/rxjava/CommandClient.java | 60 ++++++++--- .../rxjava/CommandSubmissionClient.java | 25 ++++- .../daml/ledger/rxjava/components/Bot.java | 4 +- .../helpers/CommandsAndPendingSet.java | 3 +- .../ledger/rxjava/grpc/CommandClientImpl.java | 96 ++++++++++++----- .../grpc/CommandSubmissionClientImpl.java | 41 +++++-- .../ledger/rxjava/DamlLedgerClientTest.scala | 10 +- .../ledger/rxjava/components/BotTest.scala | 42 ++++++-- .../tests/helpers/DummyLedgerClient.scala | 38 +++++-- .../rxjava/grpc/CommandClientImplTest.scala | 61 ++++++++--- .../CommandSubmissionClientImplTest.scala | 32 ++++-- .../grpc/helpers/DataLayerHelpers.scala | 7 +- .../javaapi/data/SubmitAndWaitRequest.java | 19 ++-- .../javaapi/data/SubmitCommandsRequest.java | 75 +++++++------ .../ledger/javaapi/data/SubmitRequest.java | 19 ++-- .../scala/com/digitalasset/TestUtil.scala | 9 +- .../client/binding/LedgerClientBinding.scala | 20 +--- .../binding/retrying/CommandRetryFlowUT.scala | 17 +-- .../refinements/CompositeCommandAdapter.scala | 14 +-- .../CompositeCommandAdapterUT.scala | 18 +--- .../digitalasset/codegen/ScalaCodeGenIT.scala | 6 -- .../quickstart/iou/ClientUtil.scala | 4 - .../quickstart/iou/ClientUtil.scala | 9 +- .../digitalasset/quickstart/iou/IouMain.scala | 7 +- .../digitalasset/ledger/api/v1/commands.proto | 7 +- .../api/testing/utils/MockMessages.scala | 11 +- .../com/digitalasset/http/util/Commands.scala | 3 - .../commands/CommandTrackerFlowTest.scala | 2 +- .../api/validation/CommandsValidator.scala | 9 +- .../SubmitAndWaitRequestValidator.scala | 4 +- .../validation/SubmitRequestValidator.scala | 4 +- .../services/grpc/GrpcCommandService.scala | 10 +- .../grpc/GrpcCommandSubmissionService.scala | 4 +- .../SubmitRequestValidatorTest.scala | 26 ----- .../com/digitalasset/ledger/api/domain.scala | 8 -- .../BUILD.bazel | 6 +- .../com/daml/ledger/api/testtool/Cli.scala | 10 -- .../com/daml/ledger/api/testtool/Config.scala | 2 - .../api/testtool/LedgerApiTestTool.scala | 1 - .../infrastructure/LedgerSession.scala | 1 - .../LedgerSessionConfiguration.scala | 1 - .../participant/ParticipantSession.scala | 35 ------ .../ParticipantSessionConfiguration.scala | 1 - .../participant/ParticipantTestContext.scala | 101 ++++++++---------- .../testtool/tests/CommandDeduplication.scala | 46 ++++---- .../api/testtool/tests/CommandService.scala | 64 ++++++----- .../tests/CommandSubmissionCompletion.scala | 21 ++-- .../api/testtool/tests/ContractKeys.scala | 5 +- .../tests/LedgerConfigurationService.scala | 2 +- .../api/testtool/tests/SemanticTests.scala | 2 +- .../api/testtool/tests/TransactionScale.scala | 8 +- .../testtool/tests/TransactionService.scala | 22 ++-- .../src/main/protobuf/daml_kvutils.proto | 5 +- .../state/kvutils/Conversions.scala | 2 - .../state/kvutils/KeyValueConsumption.scala | 2 - .../ProcessTransactionSubmission.scala | 2 - .../ParticipantStateIntegrationSpecBase.scala | 3 +- .../participant/state/kvutils/KVTest.scala | 2 - .../kvutils/KVUtilsTransactionSpec.scala | 13 --- .../KeyValueParticipantStateWriterSpec.scala | 1 - .../state/v1/RejectionReason.scala | 10 -- .../participant/state/v1/SubmitterInfo.scala | 8 -- .../platform/sandbox/perf/TestHelper.scala | 5 - .../V15__Remove_maximum_record_time.sha256 | 1 + .../V15__Remove_maximum_record_time.sql | 13 +++ .../V22__Remove_maximum_record_time.sha256 | 1 + .../V22__Remove_maximum_record_time.sql | 13 +++ .../apiserver/CommandExecutorImpl.scala | 1 - .../services/ApiCommandService.scala | 2 +- .../services/ApiSubmissionService.scala | 2 +- .../platform/indexer/JdbcIndexer.scala | 2 - .../ledger/inmemory/InMemoryLedger.scala | 2 - .../sandbox/stores/ledger/sql/SqlLedger.scala | 2 +- .../store/CompletionFromTransaction.scala | 4 +- .../platform/store/dao/JdbcLedgerDao.scala | 4 +- .../postgres/V2_1__Rebuild_Acs.scala | 2 +- .../sandbox/ScenarioLoadingITBase.scala | 16 +-- .../sandbox/services/TestCommands.scala | 15 +-- .../dao/JdbcLedgerDaoCompletionsSpec.scala | 1 - .../ledger/ImplicitPartyAdditionIT.scala | 2 - .../TransactionTimeModelComplianceIT.scala | 1 - .../model/converter/LedgerApiV1.scala | 8 -- .../store/platform/PlatformSubscriber.scala | 5 +- .../daml/lf/engine/trigger/ServiceTest.scala | 2 - .../lf/engine/trigger/test/TestMain.scala | 97 +++++++++-------- 95 files changed, 658 insertions(+), 688 deletions(-) create mode 100644 ledger/sandbox/src/main/resources/db/migration/h2database/V15__Remove_maximum_record_time.sha256 create mode 100644 ledger/sandbox/src/main/resources/db/migration/h2database/V15__Remove_maximum_record_time.sql create mode 100644 ledger/sandbox/src/main/resources/db/migration/postgres/V22__Remove_maximum_record_time.sha256 create mode 100644 ledger/sandbox/src/main/resources/db/migration/postgres/V22__Remove_maximum_record_time.sql diff --git a/daml-script/runner/src/main/scala/com/digitalasset/daml/lf/engine/script/Runner.scala b/daml-script/runner/src/main/scala/com/digitalasset/daml/lf/engine/script/Runner.scala index 8f908edc91de..51510ac0a317 100644 --- a/daml-script/runner/src/main/scala/com/digitalasset/daml/lf/engine/script/Runner.scala +++ b/daml-script/runner/src/main/scala/com/digitalasset/daml/lf/engine/script/Runner.scala @@ -265,8 +265,6 @@ class Runner( ledgerId = ledgerId.unwrap, applicationId = applicationId.unwrap, commandId = UUID.randomUUID.toString, - ledgerEffectiveTime = None, - maximumRecordTime = None, deduplicationTime = Some(Duration(30)) ) SubmitAndWaitRequest(Some(commands)) diff --git a/docs/source/app-dev/services.rst b/docs/source/app-dev/services.rst index 5df8c9ef2661..03c8e7bb9cf3 100644 --- a/docs/source/app-dev/services.rst +++ b/docs/source/app-dev/services.rst @@ -203,10 +203,6 @@ Time service Use the **time service** to obtain the time as known by the ledger server. -This is important because you have to include two timestamps when you submit a command - the :ref:`Ledger Effective Time (LET) `, and the :ref:`Maximum Record Time (MRT) `. For the command to be accepted, LET must be greater than the current ledger time. - -MRT is used in the detection of lost commands. - For full details, see :ref:`the proto documentation for the service `. .. _reset-service: diff --git a/docs/source/getting-started/quickstart.rst b/docs/source/getting-started/quickstart.rst index 6bf418b0b71c..cee8ddf3262f 100644 --- a/docs/source/getting-started/quickstart.rst +++ b/docs/source/getting-started/quickstart.rst @@ -555,7 +555,7 @@ It consists of the application in file ``IouMain.java``. It uses the class ``Iou .. literalinclude:: quickstart/template-root/src/main/java/com/digitalasset/quickstart/iou/IouMain.java :language: java - :lines: 126-136 + :lines: 126-137 :dedent: 4 You can find examples of ``ExerciseCommand`` and ``CreateCommand`` instantiation in the bodies of the ``transfer`` and ``iou`` endpoints, respectively. diff --git a/docs/source/getting-started/quickstart/template-root/src/main/java/com/digitalasset/quickstart/iou/IouMain.java b/docs/source/getting-started/quickstart/template-root/src/main/java/com/digitalasset/quickstart/iou/IouMain.java index 33ae2e4e0703..b02cfac18f1d 100644 --- a/docs/source/getting-started/quickstart/template-root/src/main/java/com/digitalasset/quickstart/iou/IouMain.java +++ b/docs/source/getting-started/quickstart/template-root/src/main/java/com/digitalasset/quickstart/iou/IouMain.java @@ -129,8 +129,9 @@ private static Empty submit(LedgerClient client, String party, Command c) { "IouApp", UUID.randomUUID().toString(), party, - Instant.EPOCH, - Instant.EPOCH.plusSeconds(10), + Optional.empty(), + Optional.empty(), + Optional.empty(), Collections.singletonList(c)) .blockingGet(); } diff --git a/extractor/src/test/suite/scala/com/digitalasset/extractor/AuthSpec.scala b/extractor/src/test/suite/scala/com/digitalasset/extractor/AuthSpec.scala index 24088a5a5387..a55cd3c9c48f 100644 --- a/extractor/src/test/suite/scala/com/digitalasset/extractor/AuthSpec.scala +++ b/extractor/src/test/suite/scala/com/digitalasset/extractor/AuthSpec.scala @@ -4,8 +4,7 @@ package com.digitalasset.extractor import java.nio.file.Files -import java.time.temporal.ChronoUnit -import java.time.{Duration, Instant} +import java.time.Duration import java.util.concurrent.atomic.AtomicReference import com.digitalasset.daml.lf.data.Ref.Party @@ -23,7 +22,6 @@ import com.digitalasset.ledger.client.services.commands.SynchronousCommandClient import com.digitalasset.ledger.service.LedgerReader.PackageStore import com.digitalasset.platform.sandbox.services.{SandboxFixtureWithAuth, TestCommands} import com.digitalasset.timer.Delayed -import com.google.protobuf.timestamp.Timestamp import org.scalatest.{AsyncFlatSpec, Matchers} import org.slf4j.LoggerFactory import scalaz.{OneAnd, \/} @@ -43,17 +41,7 @@ final class AuthSpec private def newSyncClient = new SynchronousCommandClient(CommandServiceGrpc.stub(channel)) - private lazy val dummyRequest = { - // we need to adjust the time of the request because we pass 10 - // days in the test scenario. - val letInstant = Instant.EPOCH.plus(10, ChronoUnit.DAYS) - val let = Timestamp(letInstant.getEpochSecond, letInstant.getNano) - val mrt = Timestamp(let.seconds + 30L, let.nanos) - dummyCommands(wrappedLedgerId, "commandId1").update( - _.commands.ledgerEffectiveTime := let, - _.commands.maximumRecordTime := mrt - ) - } + private lazy val dummyRequest = dummyCommands(wrappedLedgerId, "commandId1") private val operator = "OPERATOR" private val operatorPayload = AuthServiceJWTPayload( diff --git a/language-support/hs/bindings/examples/chat/src/DA/Ledger/App/Chat/ChatLedger.hs b/language-support/hs/bindings/examples/chat/src/DA/Ledger/App/Chat/ChatLedger.hs index 2abce82d666b..f88ecd2ae345 100644 --- a/language-support/hs/bindings/examples/chat/src/DA/Ledger/App/Chat/ChatLedger.hs +++ b/language-support/hs/bindings/examples/chat/src/DA/Ledger/App/Chat/ChatLedger.hs @@ -65,11 +65,9 @@ getTrans party Handle{log,lid} = do submitCommand :: Handle -> Party -> Command -> IO (Either String ()) submitCommand Handle{lid} party com = do cid <- randomCid - run 5 $ Ledger.submit (Commands {lid,wid,aid=myAid,cid,party,leTime,mrTime,dedupTime=Nothing,coms=[com],minLeTimeAbs=Nothing,minLeTimeRel=Nothing}) + run 5 $ Ledger.submit (Commands {lid,wid,aid=myAid,cid,party,dedupTime=Nothing,coms=[com],minLeTimeAbs=Nothing,minLeTimeRel=Nothing}) where wid = Nothing - leTime = Timestamp 0 0 - mrTime = Timestamp 5 0 myAid = ApplicationId "chat-console" randomCid :: IO CommandId diff --git a/language-support/hs/bindings/examples/nim/src/DA/Ledger/App/Nim/NimLedger.hs b/language-support/hs/bindings/examples/nim/src/DA/Ledger/App/Nim/NimLedger.hs index 317c42e6e7bd..854b7e42ed34 100644 --- a/language-support/hs/bindings/examples/nim/src/DA/Ledger/App/Nim/NimLedger.hs +++ b/language-support/hs/bindings/examples/nim/src/DA/Ledger/App/Nim/NimLedger.hs @@ -65,11 +65,9 @@ getTrans player Handle{log,lid} = do submitCommand :: Handle -> Party -> Command -> IO (Either String ()) submitCommand Handle{lid} party com = do cid <- randomCid - run 5 (Ledger.submit (Commands {lid,wid,aid=myAid,cid,party,leTime,mrTime,dedupTime=Nothing,coms=[com],minLeTimeAbs=Nothing,minLeTimeRel=Nothing})) + run 5 (Ledger.submit (Commands {lid,wid,aid=myAid,cid,party,dedupTime=Nothing,coms=[com],minLeTimeAbs=Nothing,minLeTimeRel=Nothing})) where wid = Nothing - leTime = Timestamp 0 0 - mrTime = Timestamp 5 0 myAid = ApplicationId "nim" randomCid :: IO CommandId diff --git a/language-support/hs/bindings/src/DA/Ledger/Convert.hs b/language-support/hs/bindings/src/DA/Ledger/Convert.hs index 6a24f5b406f8..4411be7bc65e 100644 --- a/language-support/hs/bindings/src/DA/Ledger/Convert.hs +++ b/language-support/hs/bindings/src/DA/Ledger/Convert.hs @@ -71,8 +71,6 @@ lowerCommands = \case commandsApplicationId = unApplicationId aid, commandsCommandId = unCommandId cid, commandsParty = unParty party, - commandsLedgerEffectiveTime = Just (lowerTimestamp leTime), - commandsMaximumRecordTime = Just (lowerTimestamp mrTime), commandsDeduplicationTime = dedupTime, commandsCommands = Vector.fromList $ map lowerCommand coms, commandsMinLedgerTimeAbs = fmap lowerTimestamp minLeTimeAbs, diff --git a/language-support/hs/bindings/src/DA/Ledger/Types.hs b/language-support/hs/bindings/src/DA/Ledger/Types.hs index a0bdad6b14e1..5df7c4c722ad 100644 --- a/language-support/hs/bindings/src/DA/Ledger/Types.hs +++ b/language-support/hs/bindings/src/DA/Ledger/Types.hs @@ -75,8 +75,6 @@ data Commands = Commands , aid :: ApplicationId , cid :: CommandId , party :: Party - , leTime :: Timestamp - , mrTime :: Timestamp , dedupTime :: Maybe LL.Duration , coms :: [Command] , minLeTimeAbs :: Maybe Timestamp diff --git a/language-support/hs/bindings/test/DA/Ledger/Tests.hs b/language-support/hs/bindings/test/DA/Ledger/Tests.hs index eed47ca2b4a0..35cb3eab9010 100644 --- a/language-support/hs/bindings/test/DA/Ledger/Tests.hs +++ b/language-support/hs/bindings/test/DA/Ledger/Tests.hs @@ -642,9 +642,7 @@ makeCommands :: LedgerId -> Party -> Command -> IO (CommandId,Commands) makeCommands lid party com = do cid <- liftIO randomCid let wid = Nothing - let leTime = Timestamp 0 0 - let mrTime = Timestamp 5 0 - return $ (cid,) $ Commands {lid,wid,aid=myAid,cid,party,leTime,mrTime,dedupTime=Nothing,coms=[com],minLeTimeAbs=Nothing,minLeTimeRel=Nothing} + return $ (cid,) $ Commands {lid,wid,aid=myAid,cid,party,dedupTime=Nothing,coms=[com],minLeTimeAbs=Nothing,minLeTimeRel=Nothing} myAid :: ApplicationId diff --git a/language-support/java/bindings-rxjava/src/main/java/com/daml/ledger/rxjava/CommandClient.java b/language-support/java/bindings-rxjava/src/main/java/com/daml/ledger/rxjava/CommandClient.java index 1a12ed1430ef..0c595e292882 100644 --- a/language-support/java/bindings-rxjava/src/main/java/com/daml/ledger/rxjava/CommandClient.java +++ b/language-support/java/bindings-rxjava/src/main/java/com/daml/ledger/rxjava/CommandClient.java @@ -10,8 +10,10 @@ import io.reactivex.Single; import org.checkerframework.checker.nullness.qual.NonNull; +import java.time.Duration; import java.time.Instant; import java.util.List; +import java.util.Optional; /** * An RxJava version of {@link com.digitalasset.ledger.api.v1.CommandServiceGrpc} @@ -19,35 +21,61 @@ public interface CommandClient { Single submitAndWait(@NonNull String workflowId, @NonNull String applicationId, - @NonNull String commandId, @NonNull String party, @NonNull Instant ledgerEffectiveTime, - @NonNull Instant maximumRecordTime, @NonNull List<@NonNull Command> commands); + @NonNull String commandId, @NonNull String party, @NonNull Optional minLedgerTimeAbs, + @NonNull Optional minLedgerTimeRel, @NonNull Optional deduplicationTime, @NonNull List<@NonNull Command> commands); Single submitAndWait(@NonNull String workflowId, @NonNull String applicationId, - @NonNull String commandId, @NonNull String party, @NonNull Instant ledgerEffectiveTime, - @NonNull Instant maximumRecordTime, @NonNull List<@NonNull Command> commands, @NonNull String accessToken); + @NonNull String commandId, @NonNull String party, @NonNull Optional minLedgerTimeAbs, + @NonNull Optional minLedgerTimeRel, @NonNull Optional deduplicationTime, @NonNull List<@NonNull Command> commands, @NonNull String accessToken); + + Single submitAndWait(@NonNull String workflowId, @NonNull String applicationId, + @NonNull String commandId, @NonNull String party, @NonNull List<@NonNull Command> commands); + + Single submitAndWait(@NonNull String workflowId, @NonNull String applicationId, + @NonNull String commandId, @NonNull String party, @NonNull List<@NonNull Command> commands, @NonNull String accessToken); + + + Single submitAndWaitForTransactionId(@NonNull String workflowId, @NonNull String applicationId, + @NonNull String commandId, @NonNull String party, @NonNull Optional minLedgerTimeAbs, + @NonNull Optional minLedgerTimeRel, @NonNull Optional deduplicationTime, @NonNull List<@NonNull Command> commands); + + Single submitAndWaitForTransactionId(@NonNull String workflowId, @NonNull String applicationId, + @NonNull String commandId, @NonNull String party, @NonNull Optional minLedgerTimeAbs, + @NonNull Optional minLedgerTimeRel, @NonNull Optional deduplicationTime, @NonNull List<@NonNull Command> commands, @NonNull String accessToken); Single submitAndWaitForTransactionId(@NonNull String workflowId, @NonNull String applicationId, - @NonNull String commandId, @NonNull String party, @NonNull Instant ledgerEffectiveTime, - @NonNull Instant maximumRecordTime, @NonNull List<@NonNull Command> commands); + @NonNull String commandId, @NonNull String party, @NonNull List<@NonNull Command> commands); Single submitAndWaitForTransactionId(@NonNull String workflowId, @NonNull String applicationId, - @NonNull String commandId, @NonNull String party, @NonNull Instant ledgerEffectiveTime, - @NonNull Instant maximumRecordTime, @NonNull List<@NonNull Command> commands, @NonNull String accessToken); + @NonNull String commandId, @NonNull String party, @NonNull List<@NonNull Command> commands, @NonNull String accessToken); + + + Single submitAndWaitForTransaction(@NonNull String workflowId, @NonNull String applicationId, + @NonNull String commandId, @NonNull String party, @NonNull Optional minLedgerTimeAbs, + @NonNull Optional minLedgerTimeRel, @NonNull Optional deduplicationTime, @NonNull List<@NonNull Command> commands); + + Single submitAndWaitForTransaction(@NonNull String workflowId, @NonNull String applicationId, + @NonNull String commandId, @NonNull String party, @NonNull Optional minLedgerTimeAbs, + @NonNull Optional minLedgerTimeRel, @NonNull Optional deduplicationTime, @NonNull List<@NonNull Command> commands, @NonNull String accessToken); Single submitAndWaitForTransaction(@NonNull String workflowId, @NonNull String applicationId, - @NonNull String commandId, @NonNull String party, @NonNull Instant ledgerEffectiveTime, - @NonNull Instant maximumRecordTime, @NonNull List<@NonNull Command> commands); + @NonNull String commandId, @NonNull String party, @NonNull List<@NonNull Command> commands); Single submitAndWaitForTransaction(@NonNull String workflowId, @NonNull String applicationId, - @NonNull String commandId, @NonNull String party, @NonNull Instant ledgerEffectiveTime, - @NonNull Instant maximumRecordTime, @NonNull List<@NonNull Command> commands, @NonNull String accessToken); + @NonNull String commandId, @NonNull String party, @NonNull List<@NonNull Command> commands, @NonNull String accessToken); + + Single submitAndWaitForTransactionTree(@NonNull String workflowId, @NonNull String applicationId, + @NonNull String commandId, @NonNull String party, @NonNull Optional minLedgerTimeAbs, + @NonNull Optional minLedgerTimeRel, @NonNull Optional deduplicationTime, @NonNull List<@NonNull Command> commands); + + Single submitAndWaitForTransactionTree(@NonNull String workflowId, @NonNull String applicationId, + @NonNull String commandId, @NonNull String party, @NonNull Optional minLedgerTimeAbs, + @NonNull Optional minLedgerTimeRel, @NonNull Optional deduplicationTime, @NonNull List<@NonNull Command> commands, @NonNull String accessToken); Single submitAndWaitForTransactionTree(@NonNull String workflowId, @NonNull String applicationId, - @NonNull String commandId, @NonNull String party, @NonNull Instant ledgerEffectiveTime, - @NonNull Instant maximumRecordTime, @NonNull List<@NonNull Command> commands); + @NonNull String commandId, @NonNull String party, @NonNull List<@NonNull Command> commands); Single submitAndWaitForTransactionTree(@NonNull String workflowId, @NonNull String applicationId, - @NonNull String commandId, @NonNull String party, @NonNull Instant ledgerEffectiveTime, - @NonNull Instant maximumRecordTime, @NonNull List<@NonNull Command> commands, @NonNull String accessToken); + @NonNull String commandId, @NonNull String party, @NonNull List<@NonNull Command> commands, @NonNull String accessToken); } diff --git a/language-support/java/bindings-rxjava/src/main/java/com/daml/ledger/rxjava/CommandSubmissionClient.java b/language-support/java/bindings-rxjava/src/main/java/com/daml/ledger/rxjava/CommandSubmissionClient.java index c3162c94ab5b..35ce7274ebb3 100644 --- a/language-support/java/bindings-rxjava/src/main/java/com/daml/ledger/rxjava/CommandSubmissionClient.java +++ b/language-support/java/bindings-rxjava/src/main/java/com/daml/ledger/rxjava/CommandSubmissionClient.java @@ -8,8 +8,10 @@ import io.reactivex.Single; import org.checkerframework.checker.nullness.qual.NonNull; +import java.time.Duration; import java.time.Instant; import java.util.List; +import java.util.Optional; /** * An RxJava version of {@link com.digitalasset.ledger.api.v1.CommandSubmissionServiceGrpc} @@ -20,16 +22,31 @@ Single submit(@NonNull String workflowId, @NonNull String applicationId, @NonNull String commandId, @NonNull String party, - @NonNull Instant ledgerEffectiveTime, - @NonNull Instant maximumRecordTime, + @NonNull Optional minLedgerTimeAbs, + @NonNull Optional minLedgerTimeRel, + @NonNull Optional deduplicationTime, + @NonNull List<@NonNull Command> commands); + + Single submit(@NonNull String workflowId, + @NonNull String applicationId, + @NonNull String commandId, + @NonNull String party, + @NonNull Optional minLedgerTimeAbs, + @NonNull Optional minLedgerTimeRel, + @NonNull Optional deduplicationTime, + @NonNull List<@NonNull Command> commands, + @NonNull String accessToken); + + Single submit(@NonNull String workflowId, + @NonNull String applicationId, + @NonNull String commandId, + @NonNull String party, @NonNull List<@NonNull Command> commands); Single submit(@NonNull String workflowId, @NonNull String applicationId, @NonNull String commandId, @NonNull String party, - @NonNull Instant ledgerEffectiveTime, - @NonNull Instant maximumRecordTime, @NonNull List<@NonNull Command> commands, @NonNull String accessToken); diff --git a/language-support/java/bindings-rxjava/src/main/java/com/daml/ledger/rxjava/components/Bot.java b/language-support/java/bindings-rxjava/src/main/java/com/daml/ledger/rxjava/components/Bot.java index 8bfc7d0437ad..7c3d472c355e 100644 --- a/language-support/java/bindings-rxjava/src/main/java/com/daml/ledger/rxjava/components/Bot.java +++ b/language-support/java/bindings-rxjava/src/main/java/com/daml/ledger/rxjava/components/Bot.java @@ -204,8 +204,8 @@ static Flowable activeContractSetAndNewTransactions(LedgerClient return cs -> { logger.debug("Submitting: {}", cs); return FlowableLogger.log(commandSubmissionClient.submit(cs.getWorkflowId(), cs.getApplicationId(), - cs.getCommandId(), cs.getParty(), cs.getLedgerEffectiveTime(), cs.getMaximumRecordTime(), - cs.getCommands()) + cs.getCommandId(), cs.getParty(), cs.getMinLedgerTimeAbsolute(), cs.getMinLedgerTimeRelative(), + cs.getDeduplicationTime(), cs.getCommands()) .flatMapMaybe(s -> Maybe. empty()) .doOnError(t -> logger.error("Error submitting commands {} for party {}: {}", cs.getCommandId(), cs.getParty(), t.getMessage())) .onErrorReturn(t -> new LedgerViewFlowable.SubmissionFailure(cs.getCommandId(), t)) diff --git a/language-support/java/bindings-rxjava/src/main/java/com/daml/ledger/rxjava/components/helpers/CommandsAndPendingSet.java b/language-support/java/bindings-rxjava/src/main/java/com/daml/ledger/rxjava/components/helpers/CommandsAndPendingSet.java index a17affe5fd0c..e6d12adfac64 100644 --- a/language-support/java/bindings-rxjava/src/main/java/com/daml/ledger/rxjava/components/helpers/CommandsAndPendingSet.java +++ b/language-support/java/bindings-rxjava/src/main/java/com/daml/ledger/rxjava/components/helpers/CommandsAndPendingSet.java @@ -10,7 +10,6 @@ import org.pcollections.PMap; import org.pcollections.PSet; -import java.time.Instant; import java.util.Collections; import java.util.Objects; @@ -25,7 +24,7 @@ public class CommandsAndPendingSet { // we use this as "invalid" value to signal that no submitCommandsRequest have been emitted by the bot public final static CommandsAndPendingSet empty = new CommandsAndPendingSet(new SubmitCommandsRequest("", "", - "", "", Instant.EPOCH, Instant.EPOCH, Collections.emptyList()), + "", "", java.util.Optional.empty(), java.util.Optional.empty(), java.util.Optional.empty(), Collections.emptyList()), HashTreePMap.empty()); public CommandsAndPendingSet(@NonNull SubmitCommandsRequest submitCommandsRequest, @NonNull PMap> contractIdsPendingIfSucceed) { diff --git a/language-support/java/bindings-rxjava/src/main/java/com/daml/ledger/rxjava/grpc/CommandClientImpl.java b/language-support/java/bindings-rxjava/src/main/java/com/daml/ledger/rxjava/grpc/CommandClientImpl.java index 26592914192d..df0bf0a2510c 100644 --- a/language-support/java/bindings-rxjava/src/main/java/com/daml/ledger/rxjava/grpc/CommandClientImpl.java +++ b/language-support/java/bindings-rxjava/src/main/java/com/daml/ledger/rxjava/grpc/CommandClientImpl.java @@ -16,6 +16,7 @@ import io.reactivex.Single; import org.checkerframework.checker.nullness.qual.NonNull; +import java.time.Duration; import java.time.Instant; import java.util.List; import java.util.Optional; @@ -31,80 +32,119 @@ public CommandClientImpl(@NonNull String ledgerId, @NonNull Channel channel, @No } private Single submitAndWait(@NonNull String workflowId, @NonNull String applicationId, - @NonNull String commandId, @NonNull String party, @NonNull Instant ledgerEffectiveTime, - @NonNull Instant maximumRecordTime, @NonNull List<@NonNull Command> commands, @NonNull Optional accessToken) { + @NonNull String commandId, @NonNull String party, @NonNull Optional minLedgerTimeAbs, + @NonNull Optional minLedgerTimeRel, @NonNull Optional deduplicationTime,@NonNull List<@NonNull Command> commands, @NonNull Optional accessToken) { CommandServiceOuterClass.SubmitAndWaitRequest request = SubmitAndWaitRequest.toProto(this.ledgerId, - workflowId, applicationId, commandId, party, ledgerEffectiveTime, maximumRecordTime, commands); + workflowId, applicationId, commandId, party, minLedgerTimeAbs, minLedgerTimeRel, deduplicationTime, commands); return Single.fromFuture(StubHelper.authenticating(this.serviceStub, accessToken).submitAndWait(request)); } @Override - public Single submitAndWait(@NonNull String workflowId, @NonNull String applicationId, @NonNull String commandId, @NonNull String party, @NonNull Instant ledgerEffectiveTime, @NonNull Instant maximumRecordTime, @NonNull List<@NonNull Command> commands) { - return submitAndWait(workflowId, applicationId, commandId, party, ledgerEffectiveTime, maximumRecordTime, commands, Optional.empty()); + public Single submitAndWait(@NonNull String workflowId, @NonNull String applicationId, @NonNull String commandId, @NonNull String party, @NonNull Optional minLedgerTimeAbs, @NonNull Optional minLedgerTimeRel, @NonNull Optional deduplicationTime,@NonNull List<@NonNull Command> commands) { + return submitAndWait(workflowId, applicationId, commandId, party, minLedgerTimeAbs, minLedgerTimeRel, deduplicationTime, commands, Optional.empty()); } @Override - public Single submitAndWait(@NonNull String workflowId, @NonNull String applicationId, @NonNull String commandId, @NonNull String party, @NonNull Instant ledgerEffectiveTime, @NonNull Instant maximumRecordTime, @NonNull List<@NonNull Command> commands, @NonNull String accessToken) { - return submitAndWait(workflowId, applicationId, commandId, party, ledgerEffectiveTime, maximumRecordTime, commands, Optional.of(accessToken)); + public Single submitAndWait(@NonNull String workflowId, @NonNull String applicationId, @NonNull String commandId, @NonNull String party, @NonNull Optional minLedgerTimeAbs, @NonNull Optional minLedgerTimeRel, @NonNull Optional deduplicationTime,@NonNull List<@NonNull Command> commands, @NonNull String accessToken) { + return submitAndWait(workflowId, applicationId, commandId, party, minLedgerTimeAbs, minLedgerTimeRel, deduplicationTime, commands, Optional.of(accessToken)); + } + + @Override + public Single submitAndWait(@NonNull String workflowId, @NonNull String applicationId, @NonNull String commandId, @NonNull String party, @NonNull List<@NonNull Command> commands) { + return submitAndWait(workflowId, applicationId, commandId, party, Optional.empty(), Optional.empty(), Optional.empty(), commands, Optional.empty()); + } + + @Override + public Single submitAndWait(@NonNull String workflowId, @NonNull String applicationId, @NonNull String commandId, @NonNull String party, @NonNull List<@NonNull Command> commands, @NonNull String accessToken) { + return submitAndWait(workflowId, applicationId, commandId, party, Optional.empty(), Optional.empty(), Optional.empty(), commands, Optional.of(accessToken)); } private Single submitAndWaitForTransactionId(@NonNull String workflowId, @NonNull String applicationId, - @NonNull String commandId, @NonNull String party, @NonNull Instant ledgerEffectiveTime, - @NonNull Instant maximumRecordTime, @NonNull List<@NonNull Command> commands, @NonNull Optional accessToken) { + @NonNull String commandId, @NonNull String party, @NonNull Optional minLedgerTimeAbs, @NonNull Optional minLedgerTimeRel, + @NonNull Optional deduplicationTime, @NonNull List<@NonNull Command> commands, @NonNull Optional accessToken) { CommandServiceOuterClass.SubmitAndWaitRequest request = SubmitAndWaitRequest.toProto(this.ledgerId, - workflowId, applicationId, commandId, party, ledgerEffectiveTime, maximumRecordTime, commands); + workflowId, applicationId, commandId, party, minLedgerTimeAbs, minLedgerTimeRel, deduplicationTime, commands); return Single.fromFuture(StubHelper.authenticating(this.serviceStub, accessToken).submitAndWaitForTransactionId(request)) .map(CommandServiceOuterClass.SubmitAndWaitForTransactionIdResponse::getTransactionId); } @Override - public Single submitAndWaitForTransactionId(@NonNull String workflowId, @NonNull String applicationId, @NonNull String commandId, @NonNull String party, @NonNull Instant ledgerEffectiveTime, @NonNull Instant maximumRecordTime, @NonNull List<@NonNull Command> commands) { - return submitAndWaitForTransactionId(workflowId, applicationId, commandId, party, ledgerEffectiveTime, maximumRecordTime, commands, Optional.empty()); + public Single submitAndWaitForTransactionId(@NonNull String workflowId, @NonNull String applicationId, @NonNull String commandId, @NonNull String party, @NonNull Optional minLedgerTimeAbs, @NonNull Optional minLedgerTimeRel, @NonNull Optional deduplicationTime,@NonNull List<@NonNull Command> commands) { + return submitAndWaitForTransactionId(workflowId, applicationId, commandId, party, minLedgerTimeAbs, minLedgerTimeRel, deduplicationTime, commands, Optional.empty()); + } + + @Override + public Single submitAndWaitForTransactionId(@NonNull String workflowId, @NonNull String applicationId, @NonNull String commandId, @NonNull String party, @NonNull Optional minLedgerTimeAbs, @NonNull Optional minLedgerTimeRel, @NonNull Optional deduplicationTime,@NonNull List<@NonNull Command> commands, @NonNull String accessToken) { + return submitAndWaitForTransactionId(workflowId, applicationId, commandId, party, minLedgerTimeAbs, minLedgerTimeRel, deduplicationTime, commands, Optional.of(accessToken)); + } + + @Override + public Single submitAndWaitForTransactionId(@NonNull String workflowId, @NonNull String applicationId, @NonNull String commandId, @NonNull String party, @NonNull List<@NonNull Command> commands) { + return submitAndWaitForTransactionId(workflowId, applicationId, commandId, party, Optional.empty(), Optional.empty(), Optional.empty(), commands, Optional.empty()); } @Override - public Single submitAndWaitForTransactionId(@NonNull String workflowId, @NonNull String applicationId, @NonNull String commandId, @NonNull String party, @NonNull Instant ledgerEffectiveTime, @NonNull Instant maximumRecordTime, @NonNull List<@NonNull Command> commands, @NonNull String accessToken) { - return submitAndWaitForTransactionId(workflowId, applicationId, commandId, party, ledgerEffectiveTime, maximumRecordTime, commands, Optional.of(accessToken)); + public Single submitAndWaitForTransactionId(@NonNull String workflowId, @NonNull String applicationId, @NonNull String commandId, @NonNull String party, @NonNull List<@NonNull Command> commands, @NonNull String accessToken) { + return submitAndWaitForTransactionId(workflowId, applicationId, commandId, party, Optional.empty(), Optional.empty(), Optional.empty(), commands, Optional.of(accessToken)); } private Single submitAndWaitForTransaction(@NonNull String workflowId, @NonNull String applicationId, - @NonNull String commandId, @NonNull String party, @NonNull Instant ledgerEffectiveTime, - @NonNull Instant maximumRecordTime, @NonNull List<@NonNull Command> commands, @NonNull Optional accessToken) { + @NonNull String commandId, @NonNull String party, @NonNull Optional minLedgerTimeAbs, @NonNull Optional minLedgerTimeRel, + @NonNull Optional deduplicationTime, @NonNull List<@NonNull Command> commands, @NonNull Optional accessToken) { CommandServiceOuterClass.SubmitAndWaitRequest request = SubmitAndWaitRequest.toProto(this.ledgerId, - workflowId, applicationId, commandId, party, ledgerEffectiveTime, maximumRecordTime, commands); + workflowId, applicationId, commandId, party, minLedgerTimeAbs, minLedgerTimeRel, deduplicationTime, commands); return Single.fromFuture(StubHelper.authenticating(this.serviceStub, accessToken).submitAndWaitForTransaction(request)) .map(CommandServiceOuterClass.SubmitAndWaitForTransactionResponse::getTransaction) .map(Transaction::fromProto); } @Override - public Single submitAndWaitForTransaction(@NonNull String workflowId, @NonNull String applicationId, @NonNull String commandId, @NonNull String party, @NonNull Instant ledgerEffectiveTime, @NonNull Instant maximumRecordTime, @NonNull List<@NonNull Command> commands) { - return submitAndWaitForTransaction(workflowId, applicationId, commandId, party, ledgerEffectiveTime, maximumRecordTime, commands, Optional.empty()); + public Single submitAndWaitForTransaction(@NonNull String workflowId, @NonNull String applicationId, @NonNull String commandId, @NonNull String party, @NonNull Optional minLedgerTimeAbs, @NonNull Optional minLedgerTimeRel, @NonNull Optional deduplicationTime,@NonNull List<@NonNull Command> commands) { + return submitAndWaitForTransaction(workflowId, applicationId, commandId, party, minLedgerTimeAbs, minLedgerTimeRel, deduplicationTime, commands, Optional.empty()); } @Override - public Single submitAndWaitForTransaction(@NonNull String workflowId, @NonNull String applicationId, @NonNull String commandId, @NonNull String party, @NonNull Instant ledgerEffectiveTime, @NonNull Instant maximumRecordTime, @NonNull List<@NonNull Command> commands, @NonNull String accessToken) { - return submitAndWaitForTransaction(workflowId, applicationId, commandId, party, ledgerEffectiveTime, maximumRecordTime, commands, Optional.of(accessToken)); + public Single submitAndWaitForTransaction(@NonNull String workflowId, @NonNull String applicationId, @NonNull String commandId, @NonNull String party, @NonNull Optional minLedgerTimeAbs, @NonNull Optional minLedgerTimeRel, @NonNull Optional deduplicationTime,@NonNull List<@NonNull Command> commands, @NonNull String accessToken) { + return submitAndWaitForTransaction(workflowId, applicationId, commandId, party, minLedgerTimeAbs, minLedgerTimeRel, deduplicationTime, commands, Optional.of(accessToken)); + } + + @Override + public Single submitAndWaitForTransaction(@NonNull String workflowId, @NonNull String applicationId, @NonNull String commandId, @NonNull String party, @NonNull List<@NonNull Command> commands) { + return submitAndWaitForTransaction(workflowId, applicationId, commandId, party, Optional.empty(), Optional.empty(), Optional.empty(), commands, Optional.empty()); + } + + @Override + public Single submitAndWaitForTransaction(@NonNull String workflowId, @NonNull String applicationId, @NonNull String commandId, @NonNull String party, @NonNull List<@NonNull Command> commands, @NonNull String accessToken) { + return submitAndWaitForTransaction(workflowId, applicationId, commandId, party, Optional.empty(), Optional.empty(), Optional.empty(), commands, Optional.of(accessToken)); } private Single submitAndWaitForTransactionTree(@NonNull String workflowId, @NonNull String applicationId, - @NonNull String commandId, @NonNull String party, @NonNull Instant ledgerEffectiveTime, - @NonNull Instant maximumRecordTime, @NonNull List<@NonNull Command> commands, @NonNull Optional accessToken) { + @NonNull String commandId, @NonNull String party, @NonNull Optional minLedgerTimeAbs, + @NonNull Optional minLedgerTimeRel, @NonNull Optional deduplicationTime,@NonNull List<@NonNull Command> commands, @NonNull Optional accessToken) { CommandServiceOuterClass.SubmitAndWaitRequest request = SubmitAndWaitRequest.toProto(this.ledgerId, - workflowId, applicationId, commandId, party, ledgerEffectiveTime, maximumRecordTime, commands); + workflowId, applicationId, commandId, party, minLedgerTimeAbs, minLedgerTimeRel, deduplicationTime, commands); return Single.fromFuture(StubHelper.authenticating(this.serviceStub, accessToken).submitAndWaitForTransactionTree(request)) .map(CommandServiceOuterClass.SubmitAndWaitForTransactionTreeResponse::getTransaction) .map(TransactionTree::fromProto); } @Override - public Single submitAndWaitForTransactionTree(@NonNull String workflowId, @NonNull String applicationId, @NonNull String commandId, @NonNull String party, @NonNull Instant ledgerEffectiveTime, @NonNull Instant maximumRecordTime, @NonNull List<@NonNull Command> commands) { - return submitAndWaitForTransactionTree(workflowId, applicationId, commandId, party, ledgerEffectiveTime, maximumRecordTime, commands, Optional.empty()); + public Single submitAndWaitForTransactionTree(@NonNull String workflowId, @NonNull String applicationId, @NonNull String commandId, @NonNull String party, @NonNull Optional minLedgerTimeAbs, @NonNull Optional minLedgerTimeRel, @NonNull Optional deduplicationTime,@NonNull List<@NonNull Command> commands) { + return submitAndWaitForTransactionTree(workflowId, applicationId, commandId, party, minLedgerTimeAbs, minLedgerTimeRel, deduplicationTime, commands, Optional.empty()); } @Override - public Single submitAndWaitForTransactionTree(@NonNull String workflowId, @NonNull String applicationId, @NonNull String commandId, @NonNull String party, @NonNull Instant ledgerEffectiveTime, @NonNull Instant maximumRecordTime, @NonNull List<@NonNull Command> commands, @NonNull String accessToken) { - return submitAndWaitForTransactionTree(workflowId, applicationId, commandId, party, ledgerEffectiveTime, maximumRecordTime, commands, Optional.of(accessToken)); + public Single submitAndWaitForTransactionTree(@NonNull String workflowId, @NonNull String applicationId, @NonNull String commandId, @NonNull String party, @NonNull Optional minLedgerTimeAbs, @NonNull Optional minLedgerTimeRel, @NonNull Optional deduplicationTime,@NonNull List<@NonNull Command> commands, @NonNull String accessToken) { + return submitAndWaitForTransactionTree(workflowId, applicationId, commandId, party, minLedgerTimeAbs, minLedgerTimeRel, deduplicationTime, commands, Optional.of(accessToken)); } + @Override + public Single submitAndWaitForTransactionTree(@NonNull String workflowId, @NonNull String applicationId, @NonNull String commandId, @NonNull String party, @NonNull List<@NonNull Command> commands) { + return submitAndWaitForTransactionTree(workflowId, applicationId, commandId, party, Optional.empty(), Optional.empty(), Optional.empty(), commands, Optional.empty()); + } + + @Override + public Single submitAndWaitForTransactionTree(@NonNull String workflowId, @NonNull String applicationId, @NonNull String commandId, @NonNull String party, @NonNull List<@NonNull Command> commands, @NonNull String accessToken) { + return submitAndWaitForTransactionTree(workflowId, applicationId, commandId, party, Optional.empty(), Optional.empty(), Optional.empty(), commands, Optional.of(accessToken)); + } } diff --git a/language-support/java/bindings-rxjava/src/main/java/com/daml/ledger/rxjava/grpc/CommandSubmissionClientImpl.java b/language-support/java/bindings-rxjava/src/main/java/com/daml/ledger/rxjava/grpc/CommandSubmissionClientImpl.java index ec6d18370eb4..eec8affd1548 100644 --- a/language-support/java/bindings-rxjava/src/main/java/com/daml/ledger/rxjava/grpc/CommandSubmissionClientImpl.java +++ b/language-support/java/bindings-rxjava/src/main/java/com/daml/ledger/rxjava/grpc/CommandSubmissionClientImpl.java @@ -9,10 +9,12 @@ import com.daml.ledger.rxjava.grpc.helpers.StubHelper; import com.digitalasset.ledger.api.v1.CommandSubmissionServiceGrpc; import com.digitalasset.ledger.api.v1.CommandSubmissionServiceOuterClass; +import com.google.protobuf.Empty; import io.grpc.Channel; import io.reactivex.Single; import org.checkerframework.checker.nullness.qual.NonNull; +import java.time.Duration; import java.time.Instant; import java.util.List; import java.util.Optional; @@ -31,12 +33,13 @@ public Single submit(@NonNull String workflowId, @NonNull String applicationId, @NonNull String commandId, @NonNull String party, - @NonNull Instant ledgerEffectiveTime, - @NonNull Instant maximumRecordTime, + @NonNull Optional minLedgerTimeAbs, + @NonNull Optional minLedgerTimeRel, + @NonNull Optional deduplicationTime, @NonNull List<@NonNull Command> commands, Optional accessToken) { CommandSubmissionServiceOuterClass.SubmitRequest request = SubmitRequest.toProto(ledgerId, - workflowId, applicationId, commandId, party, ledgerEffectiveTime, maximumRecordTime, commands); + workflowId, applicationId, commandId, party, minLedgerTimeAbs, minLedgerTimeRel, deduplicationTime, commands); return Single .fromFuture(StubHelper.authenticating(this.serviceStub, accessToken).submit(request)); } @@ -46,10 +49,8 @@ public Single submit(@NonNull String workflowId, @NonNull String applicationId, @NonNull String commandId, @NonNull String party, - @NonNull Instant ledgerEffectiveTime, - @NonNull Instant maximumRecordTime, @NonNull List<@NonNull Command> commands) { - return submit(workflowId, applicationId, commandId, party, ledgerEffectiveTime, maximumRecordTime, commands, Optional.empty()); + return submit(workflowId, applicationId, commandId, party, Optional.empty(), Optional.empty(), Optional.empty(), commands, Optional.empty()); } @Override @@ -57,11 +58,33 @@ public Single submit(@NonNull String workflowId, @NonNull String applicationId, @NonNull String commandId, @NonNull String party, - @NonNull Instant ledgerEffectiveTime, - @NonNull Instant maximumRecordTime, + @NonNull Optional minLedgerTimeAbs, + @NonNull Optional minLedgerTimeRel, + @NonNull Optional deduplicationTime, @NonNull List<@NonNull Command> commands, @NonNull String accessToken) { - return submit(workflowId, applicationId, commandId, party, ledgerEffectiveTime, maximumRecordTime, commands, Optional.of(accessToken)); + return submit(workflowId, applicationId, commandId, party, minLedgerTimeAbs, minLedgerTimeRel, deduplicationTime, commands, Optional.of(accessToken)); } + @Override + public Single submit(@NonNull String workflowId, + @NonNull String applicationId, + @NonNull String commandId, + @NonNull String party, + @NonNull Optional minLedgerTimeAbs, + @NonNull Optional minLedgerTimeRel, + @NonNull Optional deduplicationTime, + @NonNull List<@NonNull Command> commands) { + return submit(workflowId, applicationId, commandId, party, minLedgerTimeAbs, minLedgerTimeRel, deduplicationTime, commands, Optional.empty()); + } + + @Override + public Single submit(@NonNull String workflowId, + @NonNull String applicationId, + @NonNull String commandId, + @NonNull String party, + @NonNull List<@NonNull Command> commands, + @NonNull String accessToken) { + return submit(workflowId, applicationId, commandId, party, Optional.empty(), Optional.empty(), Optional.empty(), commands, Optional.of(accessToken)); + } } diff --git a/language-support/java/bindings-rxjava/src/test/scala/com/daml/ledger/rxjava/DamlLedgerClientTest.scala b/language-support/java/bindings-rxjava/src/test/scala/com/daml/ledger/rxjava/DamlLedgerClientTest.scala index 2bb7524234e2..043d1e7235a3 100644 --- a/language-support/java/bindings-rxjava/src/test/scala/com/daml/ledger/rxjava/DamlLedgerClientTest.scala +++ b/language-support/java/bindings-rxjava/src/test/scala/com/daml/ledger/rxjava/DamlLedgerClientTest.scala @@ -141,8 +141,9 @@ class DamlLedgerClientTest commands.getApplicationId, commands.getCommandId, commands.getParty, - commands.getLedgerEffectiveTime, - commands.getMaximumRecordTime, + commands.getMinLedgerTimeAbsolute, + commands.getMinLedgerTimeRelative, + commands.getDeduplicationTime, commands.getCommands ) .timeout(1l, TimeUnit.SECONDS) @@ -183,8 +184,9 @@ class DamlLedgerClientTest commands.getApplicationId, commands.getCommandId, commands.getParty, - commands.getLedgerEffectiveTime, - commands.getMaximumRecordTime, + commands.getMinLedgerTimeAbsolute, + commands.getMinLedgerTimeRelative, + commands.getDeduplicationTime, commands.getCommands ) .timeout(1l, TimeUnit.SECONDS) diff --git a/language-support/java/bindings-rxjava/src/test/scala/com/daml/ledger/rxjava/components/BotTest.scala b/language-support/java/bindings-rxjava/src/test/scala/com/daml/ledger/rxjava/components/BotTest.scala index 94da3b1d34f6..b9877650770b 100644 --- a/language-support/java/bindings-rxjava/src/test/scala/com/daml/ledger/rxjava/components/BotTest.scala +++ b/language-support/java/bindings-rxjava/src/test/scala/com/daml/ledger/rxjava/components/BotTest.scala @@ -3,7 +3,7 @@ package com.daml.ledger.rxjava.components -import java.time.Instant +import java.time.{Duration, Instant} import java.util import java.util.concurrent.TimeUnit import java.util.concurrent.atomic.{AtomicBoolean, AtomicInteger} @@ -134,8 +134,9 @@ final class BotTest extends FlatSpec with Matchers with Eventually { applicationId: String, commandId: String, party: String, - ledgerEffectiveTime: Instant, - maximumRecordTime: Instant, + minLedgerTimeAbs: Optional[Instant], + minLedgerTimeRel: Optional[Duration], + deduplicationTime: Optional[Duration], commands: util.List[Command]): Single[JEmpty] = { submitted.append( new SubmitCommandsRequest( @@ -143,8 +144,9 @@ final class BotTest extends FlatSpec with Matchers with Eventually { applicationId, commandId, party, - ledgerEffectiveTime, - maximumRecordTime, + minLedgerTimeAbs, + minLedgerTimeRel, + deduplicationTime, commands)) Single.error(new RuntimeException("expected failure")) } @@ -153,11 +155,27 @@ final class BotTest extends FlatSpec with Matchers with Eventually { applicationId: String, commandId: String, party: String, - ledgerEffectiveTime: Instant, - maximumRecordTime: Instant, + minLedgerTimeAbs: Optional[Instant], + minLedgerTimeRel: Optional[Duration], + deduplicationTime: Optional[Duration], commands: util.List[Command], accessToken: String): Single[JEmpty] = untestedEndpoint + + override def submit( + workflowId: String, + applicationId: String, + commandId: String, + party: String, + commands: util.List[Command]): Single[JEmpty] = untestedEndpoint + + override def submit( + workflowId: String, + applicationId: String, + commandId: String, + party: String, + commands: util.List[Command], + accessToken: String): Single[JEmpty] = untestedEndpoint } } @@ -194,8 +212,9 @@ final class BotTest extends FlatSpec with Matchers with Eventually { appId, s"commandId_${counter.get()}", party, - ZeroTimestamp, - ZeroTimestamp, + Optional.empty(), + Optional.empty(), + Optional.empty(), commandList ) Flowable.fromArray( @@ -279,8 +298,9 @@ final class BotTest extends FlatSpec with Matchers with Eventually { appId, s"commandId_${atomicCount.incrementAndGet()}", party, - ZeroTimestamp, - ZeroTimestamp, + Optional.empty(), + Optional.empty(), + Optional.empty(), commandList ) logger.debug(s"commands: $commands") diff --git a/language-support/java/bindings-rxjava/src/test/scala/com/daml/ledger/rxjava/components/tests/helpers/DummyLedgerClient.scala b/language-support/java/bindings-rxjava/src/test/scala/com/daml/ledger/rxjava/components/tests/helpers/DummyLedgerClient.scala index 4672544a96a1..c08dd5d371e3 100644 --- a/language-support/java/bindings-rxjava/src/test/scala/com/daml/ledger/rxjava/components/tests/helpers/DummyLedgerClient.scala +++ b/language-support/java/bindings-rxjava/src/test/scala/com/daml/ledger/rxjava/components/tests/helpers/DummyLedgerClient.scala @@ -3,8 +3,9 @@ package com.daml.ledger.rxjava.components.tests.helpers -import java.time.Instant +import java.time.{Duration, Instant} import java.util +import java.util.Optional import com.daml.ledger.javaapi.data._ import com.daml.ledger.rxjava._ @@ -150,16 +151,19 @@ class DummyLedgerClient( offset: LedgerOffset, parties: util.Set[String]): Flowable[CompletionStreamResponse] = commandCompletions + override def completionStream( applicationId: String, offset: LedgerOffset, parties: util.Set[String], accessToken: String): Flowable[CompletionStreamResponse] = untestedEndpoint + override def completionStream( applicationId: String, parties: util.Set[String]): Flowable[CompletionStreamResponse] = commandCompletions + override def completionStream( applicationId: String, parties: util.Set[String], @@ -167,6 +171,7 @@ class DummyLedgerClient( untestedEndpoint override def completionEnd(): Single[CompletionEndResponse] = untestedEndpoint + override def completionEnd(accessToken: String): Single[CompletionEndResponse] = untestedEndpoint } @@ -177,8 +182,9 @@ class DummyLedgerClient( applicationId: String, commandId: String, party: String, - ledgerEffectiveTime: Instant, - maximumRecordTime: Instant, + minLedgerTimeAbs: Optional[Instant], + minLedgerTimeRel: Optional[Duration], + deduplicationTime: Optional[Duration], commands: util.List[Command]): Single[Empty] = { submitted.append( new SubmitCommandsRequest( @@ -186,8 +192,9 @@ class DummyLedgerClient( applicationId, commandId, party, - ledgerEffectiveTime, - maximumRecordTime, + minLedgerTimeAbs, + minLedgerTimeRel, + deduplicationTime, commands)) Single.just(Empty.getDefaultInstance) } @@ -197,14 +204,31 @@ class DummyLedgerClient( applicationId: String, commandId: String, party: String, - ledgerEffectiveTime: Instant, - maximumRecordTime: Instant, + minLedgerTimeAbs: Optional[Instant], + minLedgerTimeRel: Optional[Duration], + deduplicationTime: Optional[Duration], + commands: util.List[Command], + accessToken: String): Single[Empty] = untestedEndpoint + + override def submit( + workflowId: String, + applicationId: String, + commandId: String, + party: String, + commands: util.List[Command]): Single[Empty] = untestedEndpoint + + override def submit( + workflowId: String, + applicationId: String, + commandId: String, + party: String, commands: util.List[Command], accessToken: String): Single[Empty] = untestedEndpoint } override def getLedgerIdentityClient: LedgerIdentityClient = new LedgerIdentityClient { override def getLedgerIdentity: Single[String] = Single.just(ledgerId) + override def getLedgerIdentity(accessToken: String): Single[String] = untestedEndpoint } diff --git a/language-support/java/bindings-rxjava/src/test/scala/com/daml/ledger/rxjava/grpc/CommandClientImplTest.scala b/language-support/java/bindings-rxjava/src/test/scala/com/daml/ledger/rxjava/grpc/CommandClientImplTest.scala index 280f7a7f640d..00e13fcfa436 100644 --- a/language-support/java/bindings-rxjava/src/test/scala/com/daml/ledger/rxjava/grpc/CommandClientImplTest.scala +++ b/language-support/java/bindings-rxjava/src/test/scala/com/daml/ledger/rxjava/grpc/CommandClientImplTest.scala @@ -3,8 +3,8 @@ package com.daml.ledger.rxjava.grpc -import java.time.Instant -import java.util.UUID +import java.time.{Duration, Instant} +import java.util.{Optional, UUID} import java.util.concurrent.TimeUnit import com.daml.ledger.javaapi.data.{Command, CreateCommand, Identifier, Record} @@ -43,6 +43,10 @@ class CommandClientImplTest ) _ } + implicit class JavaOptionalAsScalaOption[A](opt: Optional[A]) { + def asScala: Option[A] = if (opt.isPresent) Some(opt.get()) else None + } + behavior of "[2.1] CommandClientImpl.submitAndWait" it should "send the given command to the Ledger" in { @@ -54,8 +58,9 @@ class CommandClientImplTest commands.getApplicationId, commands.getCommandId, commands.getParty, - commands.getLedgerEffectiveTime, - commands.getMaximumRecordTime, + commands.getMinLedgerTimeAbsolute, + commands.getMinLedgerTimeRelative, + commands.getDeduplicationTime, commands.getCommands ) .timeout(TestConfiguration.timeoutInSeconds, TimeUnit.SECONDS) @@ -78,8 +83,9 @@ class CommandClientImplTest commands.getApplicationId, commands.getCommandId, commands.getParty, - commands.getLedgerEffectiveTime, - commands.getMaximumRecordTime, + commands.getMinLedgerTimeAbsolute, + commands.getMinLedgerTimeRelative, + commands.getDeduplicationTime, commands.getCommands ) .timeout(TestConfiguration.timeoutInSeconds, TimeUnit.SECONDS) @@ -89,10 +95,14 @@ class CommandClientImplTest service.getLastRequest.value.getCommands.party shouldBe commands.getParty service.getLastRequest.value.getCommands.workflowId shouldBe commands.getWorkflowId service.getLastRequest.value.getCommands.ledgerId shouldBe ledgerServices.ledgerId - service.getLastRequest.value.getCommands.getMaximumRecordTime.seconds shouldBe commands.getMaximumRecordTime.getEpochSecond - service.getLastRequest.value.getCommands.getMaximumRecordTime.nanos shouldBe commands.getMaximumRecordTime.getNano - service.getLastRequest.value.getCommands.getLedgerEffectiveTime.seconds shouldBe commands.getLedgerEffectiveTime.getEpochSecond - service.getLastRequest.value.getCommands.getLedgerEffectiveTime.nanos shouldBe commands.getLedgerEffectiveTime.getNano + service.getLastRequest.value.getCommands.minLedgerTimeRel + .map(_.seconds) shouldBe commands.getMinLedgerTimeRelative.asScala.map(_.getSeconds) + service.getLastRequest.value.getCommands.minLedgerTimeRel + .map(_.nanos) shouldBe commands.getMinLedgerTimeRelative.asScala.map(_.getNano) + service.getLastRequest.value.getCommands.minLedgerTimeAbs + .map(_.seconds) shouldBe commands.getMinLedgerTimeAbsolute.asScala.map(_.getEpochSecond) + service.getLastRequest.value.getCommands.minLedgerTimeAbs + .map(_.nanos) shouldBe commands.getMinLedgerTimeAbsolute.asScala.map(_.getNano) service.getLastRequest.value.getCommands.commands should have size 1 val receivedCommand = service.getLastRequest.value.getCommands.commands.head.command receivedCommand.isCreate shouldBe true @@ -115,9 +125,26 @@ class CommandClientImplTest } private type SubmitAndWait[A] = - (String, String, String, String, Instant, Instant, java.util.List[Command]) => Single[A] + ( + String, + String, + String, + String, + Optional[Instant], + Optional[Duration], + Optional[Duration], + java.util.List[Command]) => Single[A] private type SubmitAndWaitWithToken[A] = - (String, String, String, String, Instant, Instant, java.util.List[Command], String) => Single[A] + ( + String, + String, + String, + String, + Optional[Instant], + Optional[Duration], + Optional[Duration], + java.util.List[Command], + String) => Single[A] private def submitAndWaitFor[A](noToken: SubmitAndWait[A], withToken: SubmitAndWaitWithToken[A])( commands: java.util.List[Command], @@ -130,16 +157,18 @@ class CommandClientImplTest UUID.randomUUID.toString, UUID.randomUUID.toString, party, - Instant.EPOCH, - Instant.EPOCH, + Optional.empty(), + Optional.empty(), + Optional.empty(), dummyCommands))( withToken( UUID.randomUUID.toString, UUID.randomUUID.toString, UUID.randomUUID.toString, party, - Instant.EPOCH, - Instant.EPOCH, + Optional.empty(), + Optional.empty(), + Optional.empty(), commands, _)) .timeout(TestConfiguration.timeoutInSeconds, TimeUnit.SECONDS) diff --git a/language-support/java/bindings-rxjava/src/test/scala/com/daml/ledger/rxjava/grpc/CommandSubmissionClientImplTest.scala b/language-support/java/bindings-rxjava/src/test/scala/com/daml/ledger/rxjava/grpc/CommandSubmissionClientImplTest.scala index 43983d1afe2a..5eb99e781f6d 100644 --- a/language-support/java/bindings-rxjava/src/test/scala/com/daml/ledger/rxjava/grpc/CommandSubmissionClientImplTest.scala +++ b/language-support/java/bindings-rxjava/src/test/scala/com/daml/ledger/rxjava/grpc/CommandSubmissionClientImplTest.scala @@ -3,6 +3,7 @@ package com.daml.ledger.rxjava.grpc +import java.util.Optional import java.util.concurrent.TimeUnit import com.daml.ledger.javaapi.data.{Command, CreateCommand, Identifier, Record} @@ -23,6 +24,10 @@ class CommandSubmissionClientImplTest val ledgerServices = new LedgerServices("command-submission-service-ledger") + implicit class JavaOptionalAsScalaOption[A](opt: Optional[A]) { + def asScala: Option[A] = if (opt.isPresent) Some(opt.get()) else None + } + behavior of "[3.1] CommandSubmissionClientImpl.submit" it should "send a commands to the ledger" in { @@ -35,8 +40,9 @@ class CommandSubmissionClientImplTest commands.getApplicationId, commands.getCommandId, commands.getParty, - commands.getLedgerEffectiveTime, - commands.getMaximumRecordTime, + commands.getMinLedgerTimeAbsolute, + commands.getMinLedgerTimeRelative, + commands.getDeduplicationTime, commands.getCommands ) .timeout(TestConfiguration.timeoutInSeconds, TimeUnit.SECONDS) @@ -46,10 +52,14 @@ class CommandSubmissionClientImplTest receivedCommands.applicationId shouldBe commands.getApplicationId receivedCommands.workflowId shouldBe commands.getWorkflowId receivedCommands.commandId shouldBe commands.getCommandId - receivedCommands.getLedgerEffectiveTime.seconds shouldBe commands.getLedgerEffectiveTime.getEpochSecond - receivedCommands.getLedgerEffectiveTime.nanos shouldBe commands.getLedgerEffectiveTime.getNano - receivedCommands.getMaximumRecordTime.seconds shouldBe commands.getMaximumRecordTime.getEpochSecond - receivedCommands.getMaximumRecordTime.nanos shouldBe commands.getMaximumRecordTime.getNano + receivedCommands.minLedgerTimeAbs.map(_.seconds) shouldBe commands.getMinLedgerTimeAbsolute.asScala + .map(_.getEpochSecond) + receivedCommands.minLedgerTimeAbs.map(_.nanos) shouldBe commands.getMinLedgerTimeAbsolute.asScala + .map(_.getNano) + receivedCommands.minLedgerTimeRel.map(_.seconds) shouldBe commands.getMinLedgerTimeRelative.asScala + .map(_.getSeconds) + receivedCommands.minLedgerTimeRel.map(_.nanos) shouldBe commands.getMinLedgerTimeRelative.asScala + .map(_.getNano) receivedCommands.party shouldBe commands.getParty receivedCommands.commands.size shouldBe commands.getCommands.size() } @@ -75,8 +85,9 @@ class CommandSubmissionClientImplTest commands.getApplicationId, commands.getCommandId, commands.getParty, - commands.getLedgerEffectiveTime, - commands.getMaximumRecordTime, + commands.getMinLedgerTimeAbsolute, + commands.getMinLedgerTimeRelative, + commands.getDeduplicationTime, commands.getCommands ))( client @@ -85,8 +96,9 @@ class CommandSubmissionClientImplTest commands.getApplicationId, commands.getCommandId, commands.getParty, - commands.getLedgerEffectiveTime, - commands.getMaximumRecordTime, + commands.getMinLedgerTimeAbsolute, + commands.getMinLedgerTimeRelative, + commands.getDeduplicationTime, commands.getCommands, _ )) diff --git a/language-support/java/bindings-rxjava/src/test/scala/com/daml/ledger/rxjava/grpc/helpers/DataLayerHelpers.scala b/language-support/java/bindings-rxjava/src/test/scala/com/daml/ledger/rxjava/grpc/helpers/DataLayerHelpers.scala index a8ffecb2c999..4840728cd406 100644 --- a/language-support/java/bindings-rxjava/src/test/scala/com/daml/ledger/rxjava/grpc/helpers/DataLayerHelpers.scala +++ b/language-support/java/bindings-rxjava/src/test/scala/com/daml/ledger/rxjava/grpc/helpers/DataLayerHelpers.scala @@ -3,7 +3,7 @@ package com.daml.ledger.rxjava.grpc.helpers -import java.time.Instant +import java.util.Optional import com.daml.ledger.javaapi.data._ import com.digitalasset.ledger.api.v1.active_contracts_service.GetActiveContractsResponse @@ -39,8 +39,9 @@ trait DataLayerHelpers { "applicationId", "commandId", party.getOrElse("party"), - Instant.EPOCH, - Instant.EPOCH, + Optional.empty(), + Optional.empty(), + Optional.empty(), commands.asJava) } def genLedgerOffset(absVal: String): LedgerOffset = diff --git a/language-support/java/bindings/src/main/java/com/daml/ledger/javaapi/data/SubmitAndWaitRequest.java b/language-support/java/bindings/src/main/java/com/daml/ledger/javaapi/data/SubmitAndWaitRequest.java index c83314e08cc5..d86d63ecafe6 100644 --- a/language-support/java/bindings/src/main/java/com/daml/ledger/javaapi/data/SubmitAndWaitRequest.java +++ b/language-support/java/bindings/src/main/java/com/daml/ledger/javaapi/data/SubmitAndWaitRequest.java @@ -6,22 +6,25 @@ import com.digitalasset.ledger.api.v1.CommandServiceOuterClass; import org.checkerframework.checker.nullness.qual.NonNull; +import java.time.Duration; import java.time.Instant; import java.util.List; +import java.util.Optional; public class SubmitAndWaitRequest { public static CommandServiceOuterClass.SubmitAndWaitRequest toProto(@NonNull String ledgerId, - @NonNull String workflowId, - @NonNull String applicationId, - @NonNull String commandId, - @NonNull String party, - @NonNull Instant ledgerEffectiveTime, - @NonNull Instant maximumRecordTime, - @NonNull List<@NonNull Command> commands) { + @NonNull String workflowId, + @NonNull String applicationId, + @NonNull String commandId, + @NonNull String party, + @NonNull Optional minLedgerTimeAbsolute, + @NonNull Optional minLedgerTimeRelative, + @NonNull Optional deduplicationTime, + @NonNull List<@NonNull Command> commands) { return CommandServiceOuterClass.SubmitAndWaitRequest.newBuilder() .setCommands(SubmitCommandsRequest.toProto(ledgerId, workflowId, applicationId, - commandId, party, ledgerEffectiveTime, maximumRecordTime, commands)) + commandId, party, minLedgerTimeAbsolute, minLedgerTimeRelative, deduplicationTime, commands)) .build(); } } diff --git a/language-support/java/bindings/src/main/java/com/daml/ledger/javaapi/data/SubmitCommandsRequest.java b/language-support/java/bindings/src/main/java/com/daml/ledger/javaapi/data/SubmitCommandsRequest.java index 9d72b01f8ffa..d38030c165f7 100644 --- a/language-support/java/bindings/src/main/java/com/daml/ledger/javaapi/data/SubmitCommandsRequest.java +++ b/language-support/java/bindings/src/main/java/com/daml/ledger/javaapi/data/SubmitCommandsRequest.java @@ -7,10 +7,12 @@ import com.google.protobuf.Timestamp; import org.checkerframework.checker.nullness.qual.NonNull; +import java.time.Duration; import java.time.Instant; import java.util.ArrayList; import java.util.List; import java.util.Objects; +import java.util.Optional; public class SubmitCommandsRequest { @@ -22,21 +24,22 @@ public class SubmitCommandsRequest { private final String party; - private final Instant ledgerEffectiveTime; - - private final Instant maximumRecordTime; - + private final Optional minLedgerTimeAbsolute; + private final Optional minLedgerTimeRelative; + private final Optional deduplicationTime; private final List commands; public SubmitCommandsRequest(@NonNull String workflowId, @NonNull String applicationId, - @NonNull String commandId, @NonNull String party, @NonNull Instant ledgerEffectiveTime, - @NonNull Instant maximumRecordTime, @NonNull List<@NonNull Command> commands) { + @NonNull String commandId, @NonNull String party, @NonNull Optional minLedgerTimeAbsolute, + @NonNull Optional minLedgerTimeRelative, @NonNull Optional deduplicationTime, + @NonNull List<@NonNull Command> commands) { this.workflowId = workflowId; this.applicationId = applicationId; this.commandId = commandId; this.party = party; - this.ledgerEffectiveTime = ledgerEffectiveTime; - this.maximumRecordTime = maximumRecordTime; + this.minLedgerTimeAbsolute = minLedgerTimeAbsolute; + this.minLedgerTimeRelative = minLedgerTimeRelative; + this.deduplicationTime = deduplicationTime; this.commands = commands; } @@ -46,36 +49,39 @@ public static SubmitCommandsRequest fromProto(CommandsOuterClass.Commands comman String applicationId = commands.getApplicationId(); String commandId = commands.getCommandId(); String party = commands.getParty(); - Timestamp ledgerEffectiveTime = commands.getLedgerEffectiveTime(); - Timestamp maximumRecordTime = commands.getMaximumRecordTime(); + Optional minLedgerTimeAbs = commands.hasMinLedgerTimeAbs() ? + Optional.of(Instant.ofEpochSecond(commands.getMinLedgerTimeAbs().getSeconds(), commands.getMinLedgerTimeAbs().getNanos())) : Optional.empty(); + Optional minLedgerTimeRel = commands.hasMinLedgerTimeRel() ? + Optional.of(Duration.ofSeconds(commands.getMinLedgerTimeRel().getSeconds(), commands.getMinLedgerTimeRel().getNanos())) : Optional.empty(); + Optional deduplicationTime = commands.hasDeduplicationTime() ? + Optional.of(Duration.ofSeconds(commands.getDeduplicationTime().getSeconds(), commands.getDeduplicationTime().getNanos())) : Optional.empty(); ArrayList listOfCommands = new ArrayList<>(commands.getCommandsCount()); for (CommandsOuterClass.Command command : commands.getCommandsList()) { listOfCommands.add(Command.fromProtoCommand(command)); } - return new SubmitCommandsRequest(workflowId, applicationId, commandId, party, - Instant.ofEpochSecond(ledgerEffectiveTime.getSeconds(), ledgerEffectiveTime.getNanos()), - Instant.ofEpochSecond(maximumRecordTime.getSeconds(), maximumRecordTime.getNanos()), - listOfCommands); + return new SubmitCommandsRequest(workflowId, applicationId, commandId, party, minLedgerTimeAbs, minLedgerTimeRel, deduplicationTime, listOfCommands); } public static CommandsOuterClass.Commands toProto(@NonNull String ledgerId, - @NonNull String workflowId, @NonNull String applicationId, - @NonNull String commandId, @NonNull String party, @NonNull Instant ledgerEffectiveTime, - @NonNull Instant maximumRecordTime, @NonNull List<@NonNull Command> commands) { + @NonNull String workflowId, @NonNull String applicationId, + @NonNull String commandId, @NonNull String party, @NonNull Optional minLedgerTimeAbsolute, + @NonNull Optional minLedgerTimeRelative, @NonNull Optional deduplicationTime, + @NonNull List<@NonNull Command> commands) { ArrayList commandsConverted = new ArrayList<>(commands.size()); for (Command command : commands) { commandsConverted.add(command.toProtoCommand()); } - return CommandsOuterClass.Commands.newBuilder() + CommandsOuterClass.Commands.Builder builder = CommandsOuterClass.Commands.newBuilder() .setLedgerId(ledgerId) .setWorkflowId(workflowId) .setApplicationId(applicationId) .setCommandId(commandId) .setParty(party) - .setLedgerEffectiveTime(Timestamp.newBuilder().setSeconds(ledgerEffectiveTime.getEpochSecond()).setNanos(ledgerEffectiveTime.getNano()).build()) - .setMaximumRecordTime(Timestamp.newBuilder().setSeconds(maximumRecordTime.getEpochSecond()).setNanos(maximumRecordTime.getNano()).build()) - .addAllCommands(commandsConverted) - .build(); + .addAllCommands(commandsConverted); + minLedgerTimeAbsolute.ifPresent(abs -> builder.setMinLedgerTimeAbs(Timestamp.newBuilder().setSeconds(abs.getEpochSecond()).setNanos(abs.getNano()))); + minLedgerTimeRelative.ifPresent(rel -> builder.setMinLedgerTimeRel(com.google.protobuf.Duration.newBuilder().setSeconds(rel.getSeconds()).setNanos(rel.getNano()))); + deduplicationTime.ifPresent(dedup -> builder.setDeduplicationTime(com.google.protobuf.Duration.newBuilder().setSeconds(dedup.getSeconds()).setNanos(dedup.getNano()))); + return builder.build(); } @NonNull @@ -99,13 +105,18 @@ public String getParty() { } @NonNull - public Instant getLedgerEffectiveTime() { - return ledgerEffectiveTime; + public Optional getMinLedgerTimeAbsolute() { + return minLedgerTimeAbsolute; + } + + @NonNull + public Optional getMinLedgerTimeRelative() { + return minLedgerTimeRelative; } @NonNull - public Instant getMaximumRecordTime() { - return maximumRecordTime; + public Optional getDeduplicationTime() { + return deduplicationTime; } @NonNull @@ -120,8 +131,9 @@ public String toString() { ", applicationId='" + applicationId + '\'' + ", commandId='" + commandId + '\'' + ", party='" + party + '\'' + - ", ledgerEffectiveTime=" + ledgerEffectiveTime + - ", maximumRecordTime=" + maximumRecordTime + + ", minLedgerTimeAbs=" + minLedgerTimeAbsolute + + ", minLedgerTimeRel=" + minLedgerTimeRelative + + ", deduplicationTime=" + deduplicationTime + ", commands=" + commands + '}'; } @@ -135,14 +147,15 @@ public boolean equals(Object o) { Objects.equals(applicationId, submitCommandsRequest1.applicationId) && Objects.equals(commandId, submitCommandsRequest1.commandId) && Objects.equals(party, submitCommandsRequest1.party) && - Objects.equals(ledgerEffectiveTime, submitCommandsRequest1.ledgerEffectiveTime) && - Objects.equals(maximumRecordTime, submitCommandsRequest1.maximumRecordTime) && + Objects.equals(minLedgerTimeAbsolute, submitCommandsRequest1.minLedgerTimeAbsolute) && + Objects.equals(minLedgerTimeRelative, submitCommandsRequest1.minLedgerTimeRelative) && + Objects.equals(deduplicationTime, submitCommandsRequest1.deduplicationTime) && Objects.equals(commands, submitCommandsRequest1.commands); } @Override public int hashCode() { - return Objects.hash(workflowId, applicationId, commandId, party, ledgerEffectiveTime, maximumRecordTime, commands); + return Objects.hash(workflowId, applicationId, commandId, party, minLedgerTimeAbsolute, minLedgerTimeRelative, deduplicationTime, commands); } } diff --git a/language-support/java/bindings/src/main/java/com/daml/ledger/javaapi/data/SubmitRequest.java b/language-support/java/bindings/src/main/java/com/daml/ledger/javaapi/data/SubmitRequest.java index a1cfe5072e2b..3fb8646621b3 100644 --- a/language-support/java/bindings/src/main/java/com/daml/ledger/javaapi/data/SubmitRequest.java +++ b/language-support/java/bindings/src/main/java/com/daml/ledger/javaapi/data/SubmitRequest.java @@ -6,22 +6,25 @@ import com.digitalasset.ledger.api.v1.CommandSubmissionServiceOuterClass; import org.checkerframework.checker.nullness.qual.NonNull; +import java.time.Duration; import java.time.Instant; import java.util.List; +import java.util.Optional; public class SubmitRequest { static public CommandSubmissionServiceOuterClass.SubmitRequest toProto(@NonNull String ledgerId, - @NonNull String workflowId, - @NonNull String applicationId, - @NonNull String commandId, - @NonNull String party, - @NonNull Instant ledgerEffectiveTime, - @NonNull Instant maximumRecordTime, - @NonNull List<@NonNull Command> commands) { + @NonNull String workflowId, + @NonNull String applicationId, + @NonNull String commandId, + @NonNull String party, + @NonNull Optional minLedgerTimeAbs, + @NonNull Optional minLedgerTimeRel, + @NonNull Optional deduplicationTime, + @NonNull List<@NonNull Command> commands) { return CommandSubmissionServiceOuterClass.SubmitRequest.newBuilder() .setCommands(SubmitCommandsRequest.toProto(ledgerId, workflowId, applicationId, commandId, - party, ledgerEffectiveTime, maximumRecordTime, commands)) + party, minLedgerTimeAbs, minLedgerTimeRel, deduplicationTime, commands)) .build(); } diff --git a/language-support/java/codegen/src/ledger-tests/scala/com/digitalasset/TestUtil.scala b/language-support/java/codegen/src/ledger-tests/scala/com/digitalasset/TestUtil.scala index 099e09e5b39a..cec7bb58d385 100644 --- a/language-support/java/codegen/src/ledger-tests/scala/com/digitalasset/TestUtil.scala +++ b/language-support/java/codegen/src/ledger-tests/scala/com/digitalasset/TestUtil.scala @@ -4,8 +4,8 @@ package com.digitalasset import java.io.File -import java.time.Instant -import java.util.UUID +import java.time.{Duration, Instant} +import java.util.{Optional, UUID} import java.util.concurrent.TimeUnit import java.util.stream.{Collectors, StreamSupport} @@ -82,8 +82,9 @@ object TestUtil { randomId, randomId, Alice, - Instant.now, - Instant.now.plusSeconds(10), + Optional.empty[Instant], + Optional.empty[Duration], + Optional.empty[Duration], cmds.asJava)) .build) } diff --git a/language-support/scala/bindings-akka/src/main/scala/com/digitalasset/ledger/client/binding/LedgerClientBinding.scala b/language-support/scala/bindings-akka/src/main/scala/com/digitalasset/ledger/client/binding/LedgerClientBinding.scala index 002679ab8463..6e983fec0a86 100644 --- a/language-support/scala/bindings-akka/src/main/scala/com/digitalasset/ledger/client/binding/LedgerClientBinding.scala +++ b/language-support/scala/bindings-akka/src/main/scala/com/digitalasset/ledger/client/binding/LedgerClientBinding.scala @@ -9,7 +9,6 @@ import java.util.concurrent.TimeUnit.MINUTES import akka.NotUsed import akka.stream.scaladsl.{Flow, Source} import com.digitalasset.api.util.TimeProvider -import com.digitalasset.api.util.TimestampConversion.fromInstant import com.digitalasset.ledger.api.refinements.ApiTypes.{ApplicationId, LedgerId, Party} import com.digitalasset.ledger.api.refinements.{CompositeCommand, CompositeCommandAdapter} import com.digitalasset.ledger.api.v1.command_submission_service.SubmitRequest @@ -84,8 +83,6 @@ class LedgerClientBinding( private val compositeCommandAdapter = new CompositeCommandAdapter( LedgerId(ledgerClient.ledgerId.unwrap), ApplicationId(ledgerClientConfig.applicationId), - ledgerClientConfig.commandClient.defaultDeduplicationTime, - timeProvider ) def retryingConfirmedCommands[C](party: Party)( @@ -96,27 +93,18 @@ class LedgerClientBinding( ledgerClient.commandClient, timeProvider, retryTimeout, - createRetry(ledgerClientConfig.commandClient.defaultDeduplicationTime)) + createRetry) } yield Flow[Ctx[C, CompositeCommand]] .map(_.map(compositeCommandAdapter.transform)) .via(tracking) - private def createRetry[C]( - ttl: Duration)(retryInfo: RetryInfo[C], completion: Completion): SubmitRequest = { - val newLet = timeProvider.getCurrentTime - - val newCommands = retryInfo.request.commands.map( - _.copy( - ledgerEffectiveTime = Some(fromInstant(newLet)), - maximumRecordTime = Some(fromInstant(newLet plus ttl))) - ) - - if (newCommands.isEmpty) { + private def createRetry[C](retryInfo: RetryInfo[C], completion: Completion): SubmitRequest = { + if (retryInfo.request.commands.isEmpty) { logger.warn(s"Retrying with empty commands for {}", retryInfo.request) } - retryInfo.request.copy(commands = newCommands) + retryInfo.request } type CommandsFlow[C] = Flow[Ctx[C, CompositeCommand], Ctx[C, Completion], NotUsed] diff --git a/language-support/scala/bindings-akka/src/test/scala/com/digitalasset/ledger/client/binding/retrying/CommandRetryFlowUT.scala b/language-support/scala/bindings-akka/src/test/scala/com/digitalasset/ledger/client/binding/retrying/CommandRetryFlowUT.scala index 21a9bf06486f..c97d3e312084 100644 --- a/language-support/scala/bindings-akka/src/test/scala/com/digitalasset/ledger/client/binding/retrying/CommandRetryFlowUT.scala +++ b/language-support/scala/bindings-akka/src/test/scala/com/digitalasset/ledger/client/binding/retrying/CommandRetryFlowUT.scala @@ -17,7 +17,7 @@ import com.digitalasset.ledger.client.binding.retrying.CommandRetryFlow.{ SubmissionFlowType } import com.digitalasset.util.Ctx -import com.google.protobuf.timestamp.Timestamp +import com.google.protobuf.duration.{Duration => protoDuration} import com.google.rpc.Code import com.google.rpc.status.Status import org.scalatest.{AsyncWordSpec, Matchers} @@ -34,7 +34,7 @@ class CommandRetryFlowUT extends AsyncWordSpec with Matchers with AkkaTest { Flow[In[RetryInfo[Status]]] .map { case Ctx(context @ RetryInfo(_, _, _, status), SubmitRequest(Some(commands), tc)) => - if (commands.ledgerEffectiveTime.get.seconds == 0) { + if (commands.deduplicationTime.get.nanos == 0) { Ctx(context, Completion(commands.commandId, Some(status), traceContext = tc)) } else { Ctx( @@ -53,9 +53,9 @@ class CommandRetryFlowUT extends AsyncWordSpec with Matchers with AkkaTest { private def createRetry(retryInfo: RetryInfo[Status], completion: Completion) = { val commands = retryInfo.request.commands.get - val let = commands.ledgerEffectiveTime.get - val newLet = let.copy(seconds = let.seconds + 1) - SubmitRequest(Some(commands.copy(ledgerEffectiveTime = Some(newLet)))) + val dedupTime = commands.deduplicationTime.get + val newDedupTime = dedupTime.copy(nanos = dedupTime.nanos + 1) + SubmitRequest(Some(commands.copy(deduplicationTime = Some(newDedupTime)))) } val retryFlow: SubmissionFlowType[RetryInfo[Status]] = @@ -71,9 +71,10 @@ class CommandRetryFlowUT extends AsyncWordSpec with Matchers with AkkaTest { "applicationId", "commandId", "party", - Some(Timestamp(0, 0)), - Some(Timestamp(0, 0)), - Seq.empty)), + Seq.empty, + Some(protoDuration.of(120, 0)), + ) + ), None ) diff --git a/language-support/scala/bindings/src/main/scala/com/digitalasset/ledger/api/refinements/CompositeCommandAdapter.scala b/language-support/scala/bindings/src/main/scala/com/digitalasset/ledger/api/refinements/CompositeCommandAdapter.scala index 536c5c27de8b..534e51301c63 100644 --- a/language-support/scala/bindings/src/main/scala/com/digitalasset/ledger/api/refinements/CompositeCommandAdapter.scala +++ b/language-support/scala/bindings/src/main/scala/com/digitalasset/ledger/api/refinements/CompositeCommandAdapter.scala @@ -3,10 +3,6 @@ package com.digitalasset.ledger.api.refinements -import java.time.Duration - -import com.digitalasset.api.util.TimeProvider -import com.digitalasset.api.util.TimestampConversion.fromInstant import com.digitalasset.ledger.api.refinements.ApiTypes.{ApplicationId, LedgerId} import com.digitalasset.ledger.api.v1.command_submission_service.SubmitRequest import com.digitalasset.ledger.api.v1.commands.Commands @@ -15,10 +11,8 @@ import scalaz.syntax.tag._ class CompositeCommandAdapter( ledgerId: LedgerId, applicationId: ApplicationId, - ttl: Duration, - timeProvider: TimeProvider) { +) { def transform(c: CompositeCommand): SubmitRequest = { - val now = timeProvider.getCurrentTime val commands = Commands( ledgerId.unwrap, @@ -26,8 +20,6 @@ class CompositeCommandAdapter( applicationId.unwrap, c.commandId.unwrap, c.party.unwrap, - Some(fromInstant(now)), - Some(fromInstant(now plus ttl)), c.commands ) @@ -40,7 +32,5 @@ object CompositeCommandAdapter { def apply( ledgerId: LedgerId, applicationId: ApplicationId, - ttl: Duration, - timeProvider: TimeProvider) = - new CompositeCommandAdapter(ledgerId, applicationId, ttl, timeProvider) + ) = new CompositeCommandAdapter(ledgerId, applicationId) } diff --git a/language-support/scala/bindings/src/test/scala/com/digitalasset/ledger/api/refinements/CompositeCommandAdapterUT.scala b/language-support/scala/bindings/src/test/scala/com/digitalasset/ledger/api/refinements/CompositeCommandAdapterUT.scala index 1e547a5a8f38..287ee16bf6eb 100644 --- a/language-support/scala/bindings/src/test/scala/com/digitalasset/ledger/api/refinements/CompositeCommandAdapterUT.scala +++ b/language-support/scala/bindings/src/test/scala/com/digitalasset/ledger/api/refinements/CompositeCommandAdapterUT.scala @@ -3,15 +3,11 @@ package com.digitalasset.ledger.api.refinements -import java.time.{Duration, Instant} - -import com.digitalasset.api.util.TimeProvider import com.digitalasset.ledger.api.refinements.ApiTypes._ import com.digitalasset.ledger.api.v1.commands.Command.Command.Create import com.digitalasset.ledger.api.v1.commands.{Command, Commands, CreateCommand} import com.digitalasset.ledger.api.v1.trace_context.TraceContext import com.digitalasset.ledger.api.v1.value.Identifier -import com.google.protobuf.timestamp.Timestamp import org.scalatest.{Matchers, WordSpec} class CompositeCommandAdapterUT extends WordSpec with Matchers { @@ -33,25 +29,13 @@ class CompositeCommandAdapterUT extends WordSpec with Matchers { submittedTraceContext ) - val timeProvider = TimeProvider.Constant(Instant.ofEpochSecond(60)) - val submitRequest = CompositeCommandAdapter( LedgerId("ledgerId"), ApplicationId("applicationId"), - Duration.ofMinutes(1), - timeProvider ).transform(compositeCommand) submitRequest.commands shouldBe Some( - Commands( - "ledgerId", - "workflowId", - "applicationId", - "commandId", - "party", - Some(Timestamp(60, 0)), - Some(Timestamp(120, 0)), - commands)) + Commands("ledgerId", "workflowId", "applicationId", "commandId", "party", commands)) submitRequest.traceContext shouldBe submittedTraceContext } diff --git a/language-support/scala/codegen-sample-app/src/test/scala/com/digitalasset/codegen/ScalaCodeGenIT.scala b/language-support/scala/codegen-sample-app/src/test/scala/com/digitalasset/codegen/ScalaCodeGenIT.scala index 82c0622d1ae0..5a1d3de18a0f 100644 --- a/language-support/scala/codegen-sample-app/src/test/scala/com/digitalasset/codegen/ScalaCodeGenIT.scala +++ b/language-support/scala/codegen-sample-app/src/test/scala/com/digitalasset/codegen/ScalaCodeGenIT.scala @@ -8,8 +8,6 @@ import java.time.Instant import java.util.UUID import akka.stream.scaladsl.{Sink, Source} -import com.digitalasset.api.util.TimeProvider -import com.digitalasset.api.util.TimestampConversion.fromInstant import com.digitalasset.codegen.util.TestUtil.{TestContext, requiredResource} import com.digitalasset.ledger.api.domain.LedgerId import com.digitalasset.ledger.api.refinements.ApiTypes.{CommandId, WorkflowId} @@ -72,7 +70,6 @@ class ScalaCodeGenIT private val ledgerId = this.getClass.getSimpleName private val applicationId = ledgerId + "-client" private val decoder: DecoderType = EventDecoder.createdEventToContractRef - private val timeProvider = TimeProvider.UTC private val traceContext = TraceContext(1L, 2L, 3L, Some(4L)) private val alice = P.Party("Alice") @@ -448,15 +445,12 @@ class ScalaCodeGenIT party: P.Party, seq: P.Update[_]*): SubmitRequest = { - val now = timeProvider.getCurrentTime val commands = Commands( ledgerId = ledger.ledgerId.unwrap, workflowId = WorkflowId.unwrap(workflowId), applicationId = applicationId, commandId = CommandId.unwrap(commandId), party = P.Party.unwrap(party), - ledgerEffectiveTime = Some(fromInstant(now)), - maximumRecordTime = Some(fromInstant(now.plus(java.time.Duration.ofSeconds(2)))), commands = seq.map(_.command) ) SubmitRequest(Some(commands), Some(traceContext)) diff --git a/language-support/scala/examples/iou-no-codegen/application/src/main/scala/com/digitalasset/quickstart/iou/ClientUtil.scala b/language-support/scala/examples/iou-no-codegen/application/src/main/scala/com/digitalasset/quickstart/iou/ClientUtil.scala index 6db2bb72c9a8..7663b09cc8b1 100644 --- a/language-support/scala/examples/iou-no-codegen/application/src/main/scala/com/digitalasset/quickstart/iou/ClientUtil.scala +++ b/language-support/scala/examples/iou-no-codegen/application/src/main/scala/com/digitalasset/quickstart/iou/ClientUtil.scala @@ -8,7 +8,6 @@ import akka.stream.Materializer import akka.stream.scaladsl.{Sink, Source} import akka.{Done, NotUsed} import com.digitalasset.api.util.TimeProvider -import com.digitalasset.api.util.TimestampConversion.fromInstant import com.digitalasset.ledger.api.domain.LedgerId import com.digitalasset.ledger.api.refinements.ApiTypes.{ApplicationId, WorkflowId} import com.digitalasset.ledger.api.v1.command_submission_service.SubmitRequest @@ -43,15 +42,12 @@ class ClientUtil( transactionClient.getLedgerEnd().flatMap(response => toFuture(response.offset)) def submitCommand(party: String, workflowId: WorkflowId, cmd: Command.Command): Future[Empty] = { - val now = timeProvider.getCurrentTime val commands = Commands( ledgerId = LedgerId.unwrap(ledgerId), workflowId = WorkflowId.unwrap(workflowId), applicationId = ApplicationId.unwrap(applicationId), commandId = uniqueId, party = party, - ledgerEffectiveTime = Some(fromInstant(now)), - maximumRecordTime = Some(fromInstant(now.plusNanos(ttl.toNanos))), commands = Seq(Command(cmd)) ) diff --git a/language-support/scala/examples/quickstart-scala/application/src/main/scala/com/digitalasset/quickstart/iou/ClientUtil.scala b/language-support/scala/examples/quickstart-scala/application/src/main/scala/com/digitalasset/quickstart/iou/ClientUtil.scala index 2aa98f24d2ed..ddf732a9d875 100644 --- a/language-support/scala/examples/quickstart-scala/application/src/main/scala/com/digitalasset/quickstart/iou/ClientUtil.scala +++ b/language-support/scala/examples/quickstart-scala/application/src/main/scala/com/digitalasset/quickstart/iou/ClientUtil.scala @@ -7,8 +7,6 @@ import java.util.UUID import akka.stream.Materializer import akka.stream.scaladsl.{Sink, Source} import akka.{Done, NotUsed} -import com.digitalasset.api.util.TimeProvider -import com.digitalasset.api.util.TimestampConversion.fromInstant import com.digitalasset.ledger.api.refinements.ApiTypes.{ApplicationId, WorkflowId} import com.digitalasset.ledger.api.v1.command_submission_service.SubmitRequest import com.digitalasset.ledger.api.v1.commands.Commands @@ -22,14 +20,12 @@ import com.google.protobuf.empty.Empty import scalaz.syntax.tag._ -import scala.concurrent.duration._ import scala.concurrent.{ExecutionContext, Future} class ClientUtil( client: LedgerClient, applicationId: ApplicationId, - ttl: Duration, - timeProvider: TimeProvider) { +) { import ClientUtil._ @@ -51,15 +47,12 @@ class ClientUtil( party: P.Party, workflowId: WorkflowId, seq: P.Update[P.ContractId[T]]*): SubmitRequest = { - val now = timeProvider.getCurrentTime val commands = Commands( ledgerId = ledgerId.unwrap, workflowId = WorkflowId.unwrap(workflowId), applicationId = ApplicationId.unwrap(applicationId), commandId = uniqueId, party = P.Party.unwrap(party), - ledgerEffectiveTime = Some(fromInstant(now)), - maximumRecordTime = Some(fromInstant(now.plusNanos(ttl.toNanos))), commands = seq.map(_.command) ) SubmitRequest(Some(commands), None) diff --git a/language-support/scala/examples/quickstart-scala/application/src/main/scala/com/digitalasset/quickstart/iou/IouMain.scala b/language-support/scala/examples/quickstart-scala/application/src/main/scala/com/digitalasset/quickstart/iou/IouMain.scala index 0bcd8b61bcb6..a289877f363d 100644 --- a/language-support/scala/examples/quickstart-scala/application/src/main/scala/com/digitalasset/quickstart/iou/IouMain.scala +++ b/language-support/scala/examples/quickstart-scala/application/src/main/scala/com/digitalasset/quickstart/iou/IouMain.scala @@ -3,11 +3,8 @@ package com.digitalasset.quickstart.iou -import java.time.Instant - import akka.actor.ActorSystem import akka.stream.Materializer -import com.digitalasset.api.util.TimeProvider import com.digitalasset.grpc.adapter.AkkaExecutionSequencerPool import com.digitalasset.ledger.api.refinements.ApiTypes.{ApplicationId, WorkflowId} import com.digitalasset.ledger.api.v1.ledger_offset.LedgerOffset @@ -63,8 +60,6 @@ object IouMain extends App with StrictLogging { private val applicationId = ApplicationId("IOU Example") - private val timeProvider = TimeProvider.Constant(Instant.EPOCH) - // private val clientConfig = LedgerClientConfiguration( applicationId = ApplicationId.unwrap(applicationId), @@ -79,7 +74,7 @@ object IouMain extends App with StrictLogging { LedgerClient.singleHost(ledgerHost, ledgerPort, clientConfig)(ec, aesf) private val clientUtilF: Future[ClientUtil] = - clientF.map(client => new ClientUtil(client, applicationId, 30.seconds, timeProvider)) + clientF.map(client => new ClientUtil(client, applicationId)) private val offset0F: Future[LedgerOffset] = clientUtilF.flatMap(_.ledgerEnd) diff --git a/ledger-api/grpc-definitions/com/digitalasset/ledger/api/v1/commands.proto b/ledger-api/grpc-definitions/com/digitalasset/ledger/api/v1/commands.proto index 34e07fa67353..1556f14c9cf7 100644 --- a/ledger-api/grpc-definitions/com/digitalasset/ledger/api/v1/commands.proto +++ b/ledger-api/grpc-definitions/com/digitalasset/ledger/api/v1/commands.proto @@ -47,11 +47,8 @@ message Commands { // Required string party = 5; - // Deprecated. This field currently has the same function as min_ledger_time_abs, and will be removed in the future. - google.protobuf.Timestamp ledger_effective_time = 6; - - // Deprecated. This field is ignored, and will be removed in the future. - google.protobuf.Timestamp maximum_record_time = 7; + reserved 6; // was ledger_effective_time + reserved 7; // was maximum_record_time // Individual elements of this atomic command. Must be non-empty. // Required diff --git a/ledger-api/testing-utils/src/main/scala/com/digitalasset/ledger/api/testing/utils/MockMessages.scala b/ledger-api/testing-utils/src/main/scala/com/digitalasset/ledger/api/testing/utils/MockMessages.scala index 55de766848f0..3677f9dd283d 100644 --- a/ledger-api/testing-utils/src/main/scala/com/digitalasset/ledger/api/testing/utils/MockMessages.scala +++ b/ledger-api/testing-utils/src/main/scala/com/digitalasset/ledger/api/testing/utils/MockMessages.scala @@ -34,17 +34,8 @@ object MockMessages { val party = "party" val party2 = "party2" val ledgerEffectiveTime = Timestamp(0L, 0) - val maximumRecordTime = ledgerEffectiveTime.copy(seconds = ledgerEffectiveTime.seconds + 30L) - val commands = Commands( - ledgerId, - workflowId, - applicationId, - commandId, - party, - Some(ledgerEffectiveTime), - Some(maximumRecordTime), - Nil) + val commands = Commands(ledgerId, workflowId, applicationId, commandId, party, Nil) val submitRequest = SubmitRequest(Some(commands), None) diff --git a/ledger-service/http-json/src/main/scala/com/digitalasset/http/util/Commands.scala b/ledger-service/http-json/src/main/scala/com/digitalasset/http/util/Commands.scala index 73d2d242bd50..a71ec20e4bfc 100644 --- a/ledger-service/http-json/src/main/scala/com/digitalasset/http/util/Commands.scala +++ b/ledger-service/http-json/src/main/scala/com/digitalasset/http/util/Commands.scala @@ -5,7 +5,6 @@ package com.digitalasset.http.util import java.time.Instant -import com.digitalasset.api.util.TimestampConversion.fromInstant import com.digitalasset.ledger.api.refinements.{ApiTypes => lar} import com.digitalasset.ledger.api.{v1 => lav1} import scalaz.syntax.tag._ @@ -78,8 +77,6 @@ object Commands { applicationId = applicationId.unwrap, commandId = commandId.unwrap, party = party.unwrap, - ledgerEffectiveTime = Some(fromInstant(ledgerEffectiveTime)), - maximumRecordTime = Some(fromInstant(maximumRecordTime)), commands = Seq(lav1.commands.Command(command)) ) lav1.command_service.SubmitAndWaitRequest(Some(commands)) diff --git a/ledger/ledger-api-client/src/test/suite/scala/com/digitalasset/ledger/client/services/commands/CommandTrackerFlowTest.scala b/ledger/ledger-api-client/src/test/suite/scala/com/digitalasset/ledger/client/services/commands/CommandTrackerFlowTest.scala index 4b40b6badfdc..027b86045f94 100644 --- a/ledger/ledger-api-client/src/test/suite/scala/com/digitalasset/ledger/client/services/commands/CommandTrackerFlowTest.scala +++ b/ledger/ledger-api-client/src/test/suite/scala/com/digitalasset/ledger/client/services/commands/CommandTrackerFlowTest.scala @@ -60,7 +60,7 @@ class CommandTrackerFlowTest private val context = 1 private val submitRequest = Ctx( context, - SubmitRequest(Some(Commands(commandId = commandId, maximumRecordTime = Some(fromInstant(mrt))))) + SubmitRequest(Some(Commands(commandId = commandId))) ) private case class Handle( diff --git a/ledger/ledger-api-common/src/main/scala/com/digitalasset/ledger/api/validation/CommandsValidator.scala b/ledger/ledger-api-common/src/main/scala/com/digitalasset/ledger/api/validation/CommandsValidator.scala index 86211b04d4ca..a08c2444633c 100644 --- a/ledger/ledger-api-common/src/main/scala/com/digitalasset/ledger/api/validation/CommandsValidator.scala +++ b/ledger/ledger-api-common/src/main/scala/com/digitalasset/ledger/api/validation/CommandsValidator.scala @@ -34,7 +34,7 @@ final class CommandsValidator(ledgerId: LedgerId) { def validateCommands( commands: ProtoCommands, currentLedgerTime: Instant, - currentUTCTime: Instant, + currentUtcTime: Instant, maxDeduplicationTime: Duration): Either[StatusRuntimeException, domain.Commands] = for { cmdLegerId <- requireLedgerString(commands.ledgerId, "ledger_id") @@ -66,9 +66,8 @@ final class CommandsValidator(ledgerId: LedgerId) { commandId = commandId, submitter = submitter, ledgerEffectiveTime = ledgerEffectiveTime, - maximumRecordTime = Instant.EPOCH, - submittedAt = currentUTCTime, - deduplicateUntil = currentUTCTime.plus(deduplicationTime), + submittedAt = currentUtcTime, + deduplicateUntil = currentUtcTime.plus(deduplicationTime), commands = Commands( submitter = submitter, commands = ImmArray(validatedCommands), @@ -92,7 +91,7 @@ final class CommandsValidator(ledgerId: LedgerId) { case (Some(_), Some(_)) => Left( invalidArgument( - "min_ledger_time_abs can not be specified at the same time as min_ledger_time_rel")) + "min_ledger_time_abs cannot be specified at the same time as min_ledger_time_rel")) } } diff --git a/ledger/ledger-api-common/src/main/scala/com/digitalasset/ledger/api/validation/SubmitAndWaitRequestValidator.scala b/ledger/ledger-api-common/src/main/scala/com/digitalasset/ledger/api/validation/SubmitAndWaitRequestValidator.scala index 7d50d8456a8d..c24f01dda315 100644 --- a/ledger/ledger-api-common/src/main/scala/com/digitalasset/ledger/api/validation/SubmitAndWaitRequestValidator.scala +++ b/ledger/ledger-api-common/src/main/scala/com/digitalasset/ledger/api/validation/SubmitAndWaitRequestValidator.scala @@ -16,14 +16,14 @@ class SubmitAndWaitRequestValidator(commandsValidator: CommandsValidator) { def validate( req: SubmitAndWaitRequest, currentLedgerTime: Instant, - currentUTCTime: Instant, + currentUtcTime: Instant, maxDeduplicationTime: Duration): Either[StatusRuntimeException, submission.SubmitRequest] = for { commands <- requirePresence(req.commands, "commands") validatedCommands <- commandsValidator.validateCommands( commands, currentLedgerTime, - currentUTCTime, + currentUtcTime, maxDeduplicationTime) } yield submission.SubmitRequest(validatedCommands, req.traceContext.map(toBrave)) diff --git a/ledger/ledger-api-common/src/main/scala/com/digitalasset/ledger/api/validation/SubmitRequestValidator.scala b/ledger/ledger-api-common/src/main/scala/com/digitalasset/ledger/api/validation/SubmitRequestValidator.scala index 5e92258de513..6a4146da543e 100644 --- a/ledger/ledger-api-common/src/main/scala/com/digitalasset/ledger/api/validation/SubmitRequestValidator.scala +++ b/ledger/ledger-api-common/src/main/scala/com/digitalasset/ledger/api/validation/SubmitRequestValidator.scala @@ -16,14 +16,14 @@ class SubmitRequestValidator(commandsValidator: CommandsValidator) { def validate( req: SubmitRequest, currentLedgerTime: Instant, - currentUTCTime: Instant, + currentUtcTime: Instant, maxDeduplicationTime: Duration): Either[StatusRuntimeException, submission.SubmitRequest] = for { commands <- requirePresence(req.commands, "commands") validatedCommands <- commandsValidator.validateCommands( commands, currentLedgerTime, - currentUTCTime, + currentUtcTime, maxDeduplicationTime) } yield submission.SubmitRequest(validatedCommands, req.traceContext.map(toBrave)) diff --git a/ledger/ledger-api-common/src/main/scala/com/digitalasset/platform/server/api/services/grpc/GrpcCommandService.scala b/ledger/ledger-api-common/src/main/scala/com/digitalasset/platform/server/api/services/grpc/GrpcCommandService.scala index 390f65872cc0..0818dde0a62b 100644 --- a/ledger/ledger-api-common/src/main/scala/com/digitalasset/platform/server/api/services/grpc/GrpcCommandService.scala +++ b/ledger/ledger-api-common/src/main/scala/com/digitalasset/platform/server/api/services/grpc/GrpcCommandService.scala @@ -22,7 +22,7 @@ class GrpcCommandService( protected val service: CommandService with AutoCloseable, val ledgerId: LedgerId, currentLedgerTime: () => Instant, - currentUTCTime: () => Instant, + currentUtcTime: () => Instant, maxDeduplicationTime: () => Duration ) extends CommandService with GrpcApiService @@ -35,25 +35,25 @@ class GrpcCommandService( override def submitAndWait(request: SubmitAndWaitRequest): Future[Empty] = validator - .validate(request, currentLedgerTime(), currentUTCTime(), maxDeduplicationTime()) + .validate(request, currentLedgerTime(), currentUtcTime(), maxDeduplicationTime()) .fold(Future.failed, _ => service.submitAndWait(request)) override def submitAndWaitForTransactionId( request: SubmitAndWaitRequest): Future[SubmitAndWaitForTransactionIdResponse] = validator - .validate(request, currentLedgerTime(), currentUTCTime(), maxDeduplicationTime()) + .validate(request, currentLedgerTime(), currentUtcTime(), maxDeduplicationTime()) .fold(Future.failed, _ => service.submitAndWaitForTransactionId(request)) override def submitAndWaitForTransaction( request: SubmitAndWaitRequest): Future[SubmitAndWaitForTransactionResponse] = validator - .validate(request, currentLedgerTime(), currentUTCTime(), maxDeduplicationTime()) + .validate(request, currentLedgerTime(), currentUtcTime(), maxDeduplicationTime()) .fold(Future.failed, _ => service.submitAndWaitForTransaction(request)) override def submitAndWaitForTransactionTree( request: SubmitAndWaitRequest): Future[SubmitAndWaitForTransactionTreeResponse] = validator - .validate(request, currentLedgerTime(), currentUTCTime(), maxDeduplicationTime()) + .validate(request, currentLedgerTime(), currentUtcTime(), maxDeduplicationTime()) .fold(Future.failed, _ => service.submitAndWaitForTransactionTree(request)) override def bindService(): ServerServiceDefinition = diff --git a/ledger/ledger-api-common/src/main/scala/com/digitalasset/platform/server/api/services/grpc/GrpcCommandSubmissionService.scala b/ledger/ledger-api-common/src/main/scala/com/digitalasset/platform/server/api/services/grpc/GrpcCommandSubmissionService.scala index 2a2d1d6aa933..997d6dbbbf0b 100644 --- a/ledger/ledger-api-common/src/main/scala/com/digitalasset/platform/server/api/services/grpc/GrpcCommandSubmissionService.scala +++ b/ledger/ledger-api-common/src/main/scala/com/digitalasset/platform/server/api/services/grpc/GrpcCommandSubmissionService.scala @@ -28,7 +28,7 @@ class GrpcCommandSubmissionService( protected val service: CommandSubmissionService with AutoCloseable, val ledgerId: LedgerId, currentLedgerTime: () => Instant, - currentUTCTime: () => Instant, + currentUtcTime: () => Instant, maxDeduplicationTime: () => Duration ) extends ApiCommandSubmissionService with ProxyCloseable @@ -41,7 +41,7 @@ class GrpcCommandSubmissionService( override def submit(request: ApiSubmitRequest): Future[Empty] = validator - .validate(request, currentLedgerTime(), currentUTCTime(), maxDeduplicationTime()) + .validate(request, currentLedgerTime(), currentUtcTime(), maxDeduplicationTime()) .fold( Future.failed, service.submit(_).map(_ => Empty.defaultInstance)(DirectExecutionContext)) diff --git a/ledger/ledger-api-common/src/test/suite/scala/com/digitalasset/ledger/api/validation/SubmitRequestValidatorTest.scala b/ledger/ledger-api-common/src/test/suite/scala/com/digitalasset/ledger/api/validation/SubmitRequestValidatorTest.scala index f9c3c27a77b8..687729e07318 100644 --- a/ledger/ledger-api-common/src/test/suite/scala/com/digitalasset/ledger/api/validation/SubmitRequestValidatorTest.scala +++ b/ledger/ledger-api-common/src/test/suite/scala/com/digitalasset/ledger/api/validation/SubmitRequestValidatorTest.scala @@ -61,8 +61,6 @@ class SubmitRequestValidatorTest applicationId = applicationId, commandId = commandId, party = submitter, - ledgerEffectiveTime = None, - maximumRecordTime = None, commands = Seq(command), deduplicationTime = Some(deduplicationTime), minLedgerTimeAbs = None, @@ -85,7 +83,6 @@ class SubmitRequestValidatorTest commandId = commandId, submitter = DomainMocks.party, ledgerEffectiveTime = ledgerTime, - maximumRecordTime = Instant.EPOCH, submittedAt = submittedAt, deduplicateUntil = deduplicateUntil, commands = LfCommands( @@ -223,29 +220,6 @@ class SubmitRequestValidatorTest ) shouldEqual Right(withLedgerTime(internal.emptyCommands, minLedgerTimeAbs)) } - "ignore ledgerEffectiveTime values" in { - // Note: until ledgerEffectiveTime is removed, it is simply ignored - commandsValidator.validateCommands( - api.commands.copy( - ledgerEffectiveTime = Some(TimestampConversion.fromInstant(Instant.now))), - internal.ledgerTime, - internal.submittedAt, - internal.maxDeduplicationTime - ) shouldEqual Right(internal.emptyCommands) - } - - "ignore mrt values" in { - // Note: until MRT is removed, it is simply ignored - commandsValidator - .validateCommands( - api.commands.copy( - maximumRecordTime = Some(TimestampConversion.fromInstant(Instant.now))), - internal.ledgerTime, - internal.submittedAt, - internal.maxDeduplicationTime - ) shouldEqual Right(internal.emptyCommands) - } - "not allow negative deduplication time" in { requestMustFailWith( commandsValidator.validateCommands( diff --git a/ledger/ledger-api-domain/src/main/scala/com/digitalasset/ledger/api/domain.scala b/ledger/ledger-api-domain/src/main/scala/com/digitalasset/ledger/api/domain.scala index 10548b2e5a9d..9fba1d3525e4 100644 --- a/ledger/ledger-api-domain/src/main/scala/com/digitalasset/ledger/api/domain.scala +++ b/ledger/ledger-api-domain/src/main/scala/com/digitalasset/ledger/api/domain.scala @@ -191,13 +191,6 @@ object domain { */ final case class OutOfQuota(description: String) extends RejectionReason - /** The transaction submission timed out. - * - * This means the 'maximumRecordTime' was smaller than the recordTime seen - * in an event in the Participant node. - */ - final case class TimedOut(description: String) extends RejectionReason - /** The transaction submission was disputed. * * This means that the underlying ledger and its validation logic @@ -279,7 +272,6 @@ object domain { commandId: CommandId, submitter: Ref.Party, ledgerEffectiveTime: Instant, - maximumRecordTime: Instant, submittedAt: Instant, deduplicateUntil: Instant, commands: LfCommands) diff --git a/ledger/ledger-api-test-tool-on-canton/BUILD.bazel b/ledger/ledger-api-test-tool-on-canton/BUILD.bazel index 586b27445771..72bf0756a9c5 100644 --- a/ledger/ledger-api-test-tool-on-canton/BUILD.bazel +++ b/ledger/ledger-api-test-tool-on-canton/BUILD.bazel @@ -69,4 +69,8 @@ conformance_test( "--verbose", "--include=SemanticTests", ], -) if not is_windows else None + # temporarily disabling canton tests, because the api server + # in the canton release still requires old time model fields. + # Enable the tests again, once canton is upgraded. +) if False else None +#) if not is_windows else None diff --git a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/Cli.scala b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/Cli.scala index 420889c3a414..595a15f8f613 100644 --- a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/Cli.scala +++ b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/Cli.scala @@ -82,16 +82,6 @@ object Cli { .text("TLS: The crt file to be used as the the trusted root CA. Applied to all endpoints.") .action(cacrtConfig) - opt[Double](name = "command-submission-ttl-scale-factor") - .optional() - .action((v, c) => c.copy(commandSubmissionTtlScaleFactor = v)) - .text("""Scale factor for time-to-live of commands sent for ledger processing - |(captured as Maximum Record Time in submitted transactions) for - |all test suites. Regardless the output of multiplying by this factor - |the TTL will always be clipped by the minimum and maximum value as defined - |by the LedgerConfigurationService, with the maximum being the default - |(which means that any value above 1.0 won't have any effect.""".stripMargin) - opt[Double](name = "timeout-scale-factor") .optional() .action((v, c) => c.copy(timeoutScaleFactor = v)) diff --git a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/Config.scala b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/Config.scala index ec60e01b5a9f..26d9ce71c0a0 100644 --- a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/Config.scala +++ b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/Config.scala @@ -13,7 +13,6 @@ final case class Config( darPackages: List[File], mustFail: Boolean, verbose: Boolean, - commandSubmissionTtlScaleFactor: Double, timeoutScaleFactor: Double, loadScaleFactor: Double, concurrentTestRuns: Int, @@ -33,7 +32,6 @@ object Config { darPackages = Nil, mustFail = false, verbose = false, - commandSubmissionTtlScaleFactor = 1.0, timeoutScaleFactor = 1.0, loadScaleFactor = 1.0, concurrentTestRuns = Runtime.getRuntime.availableProcessors(), diff --git a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/LedgerApiTestTool.scala b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/LedgerApiTestTool.scala index 4635c47ef319..c9fe8b06005d 100644 --- a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/LedgerApiTestTool.scala +++ b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/LedgerApiTestTool.scala @@ -111,7 +111,6 @@ object LedgerApiTestTool { config.participants, config.shuffleParticipants, config.tlsConfig, - config.commandSubmissionTtlScaleFactor, config.loadScaleFactor, config.partyAllocation, ), diff --git a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/LedgerSession.scala b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/LedgerSession.scala index c4a208d4a610..d6736cda292d 100644 --- a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/LedgerSession.scala +++ b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/LedgerSession.scala @@ -27,7 +27,6 @@ private[testtool] final class LedgerSession( host, port, config.ssl, - config.commandTtlFactor, config.partyAllocation, ), ) diff --git a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/LedgerSessionConfiguration.scala b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/LedgerSessionConfiguration.scala index 161cc6449532..9876628dc7c8 100644 --- a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/LedgerSessionConfiguration.scala +++ b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/LedgerSessionConfiguration.scala @@ -9,7 +9,6 @@ private[testtool] final case class LedgerSessionConfiguration( participants: Vector[(String, Int)], shuffleParticipants: Boolean, ssl: Option[TlsConfiguration], - commandTtlFactor: Double, loadScaleFactor: Double, partyAllocation: PartyAllocationConfiguration, ) diff --git a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/participant/ParticipantSession.scala b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/participant/ParticipantSession.scala index 6b398679cc88..174079f37e5d 100644 --- a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/participant/ParticipantSession.scala +++ b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/participant/ParticipantSession.scala @@ -3,17 +3,9 @@ package com.daml.ledger.api.testtool.infrastructure.participant -import java.time.Duration - import com.daml.ledger.api.testtool.infrastructure.LedgerServices -import com.daml.ledger.api.testtool.infrastructure.ProtobufConverters._ -import com.digitalasset.ledger.api.v1.ledger_configuration_service.{ - GetLedgerConfigurationRequest, - GetLedgerConfigurationResponse -} import com.digitalasset.ledger.api.v1.ledger_identity_service.GetLedgerIdentityRequest import com.digitalasset.ledger.api.v1.transaction_service.GetLedgerEndRequest -import com.digitalasset.platform.testing.StreamConsumer import com.digitalasset.timer.RetryStrategy import io.grpc.ManagedChannel import io.netty.channel.nio.NioEventLoopGroup @@ -42,31 +34,6 @@ private[participant] final class ParticipantSession( services.identity.getLedgerIdentity(new GetLedgerIdentityRequest).map(_.ledgerId) } - // The time-to-live for commands defaults to the maximum value as defined by the ledger - // configuration and can be adjusted down. Regardless the output of the adjustment, the - // value is always going to be clipped by the minimum and maximum configured values. - // Note that this value is going to never change after it's read the first time, so changing - // ledger configuration across tests may have wildly unexpected consequences. In general the - // test tool is designed to have tests work in isolation and tests addressing changes to the - // global state of the ledger should be isolated in their own test runs. - private[this] val ttlF: Future[Duration] = - ledgerIdF - .flatMap { id => - new StreamConsumer[GetLedgerConfigurationResponse]( - services.configuration - .getLedgerConfiguration(new GetLedgerConfigurationRequest(id), _), - ).first() - .map(_.get.getLedgerConfiguration) - } - .map { configuration => - val factor = config.commandTtlFactor - val min = configuration.getMinTtl.asScala - val max = configuration.getMaxTtl.asScala - val ttl = (max * factor).min(max).max(min) - logger.info(s"Command TTL is $ttl (min: $min, max: $max, factor: $factor)") - Duration.ofNanos(ttl.toNanos) - } - private[testtool] def createTestContext( endpointId: String, applicationId: String, @@ -74,7 +41,6 @@ private[participant] final class ParticipantSession( ): Future[ParticipantTestContext] = for { ledgerId <- ledgerIdF - ttl <- ttlF end <- services.transaction.getLedgerEnd(new GetLedgerEndRequest(ledgerId)).map(_.getOffset) } yield new ParticipantTestContext( @@ -84,7 +50,6 @@ private[participant] final class ParticipantSession( identifierSuffix, end, services, - ttl, config.partyAllocation, ) diff --git a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/participant/ParticipantSessionConfiguration.scala b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/participant/ParticipantSessionConfiguration.scala index 68a92b132529..85819901b9da 100644 --- a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/participant/ParticipantSessionConfiguration.scala +++ b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/participant/ParticipantSessionConfiguration.scala @@ -10,6 +10,5 @@ private[testtool] final case class ParticipantSessionConfiguration( host: String, port: Int, ssl: Option[TlsConfiguration], - commandTtlFactor: Double, partyAllocation: PartyAllocationConfiguration, ) diff --git a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/participant/ParticipantTestContext.scala b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/participant/ParticipantTestContext.scala index 7d6e9f9f6634..d435c1c3be8e 100644 --- a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/participant/ParticipantTestContext.scala +++ b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/participant/ParticipantTestContext.scala @@ -3,7 +3,7 @@ package com.daml.ledger.api.testtool.infrastructure.participant -import java.time.{Clock, Duration, Instant} +import java.time.{Clock, Instant} import com.daml.ledger.api.testtool.infrastructure.Eventually.eventually import com.daml.ledger.api.testtool.infrastructure.ProtobufConverters._ @@ -101,7 +101,6 @@ private[testtool] final class ParticipantTestContext private[participant] ( val identifierSuffix: String, referenceOffset: LedgerOffset, services: LedgerServices, - ttl: Duration, partyAllocation: PartyAllocationConfiguration, )(implicit ec: ExecutionContext) { @@ -438,8 +437,7 @@ private[testtool] final class ParticipantTestContext private[participant] ( party: Party, template: Template[T], ): Future[Primitive.ContractId[T]] = - submitAndWaitRequest(party, template.create.command) - .flatMap(submitAndWaitForTransaction) + submitAndWaitForTransaction(submitAndWaitRequest(party, template.create.command)) .map(extractContracts) .map(_.head) @@ -447,8 +445,7 @@ private[testtool] final class ParticipantTestContext private[participant] ( party: Party, template: Template[T], ): Future[(String, Primitive.ContractId[T])] = - submitAndWaitRequest(party, template.create.command) - .flatMap(submitAndWaitForTransaction) + submitAndWaitForTransaction(submitAndWaitRequest(party, template.create.command)) .map(tx => tx.transactionId -> tx.events.collect { case Event(Created(e)) => Primitive.ContractId(e.contractId) @@ -458,20 +455,19 @@ private[testtool] final class ParticipantTestContext private[participant] ( party: Party, exercise: Party => Primitive.Update[T], ): Future[TransactionTree] = - submitAndWaitRequest(party, exercise(party).command).flatMap(submitAndWaitForTransactionTree) + submitAndWaitForTransactionTree(submitAndWaitRequest(party, exercise(party).command)) def exerciseForFlatTransaction[T]( party: Party, exercise: Party => Primitive.Update[T], ): Future[Transaction] = - submitAndWaitRequest(party, exercise(party).command).flatMap(submitAndWaitForTransaction) + submitAndWaitForTransaction(submitAndWaitRequest(party, exercise(party).command)) def exerciseAndGetContract[T]( party: Party, exercise: Party => Primitive.Update[_], ): Future[Primitive.ContractId[T]] = - submitAndWaitRequest(party, exercise(party).command) - .flatMap(submitAndWaitForTransaction) + submitAndWaitForTransaction(submitAndWaitRequest(party, exercise(party).command)) .map(extractContracts) .map(_.head.asInstanceOf[Primitive.ContractId[T]]) @@ -479,8 +475,7 @@ private[testtool] final class ParticipantTestContext private[participant] ( party: Party, exercise: Party => Primitive.Update[T], ): Future[Seq[Primitive.ContractId[_]]] = - submitAndWaitRequest(party, exercise(party).command) - .flatMap(submitAndWaitForTransaction) + submitAndWaitForTransaction(submitAndWaitRequest(party, exercise(party).command)) .map(extractContracts) def exerciseByKey[T]( @@ -490,53 +485,47 @@ private[testtool] final class ParticipantTestContext private[participant] ( choice: String, argument: Value, ): Future[TransactionTree] = - submitAndWaitRequest( - party, - Command( - Command.Command.ExerciseByKey( - ExerciseByKeyCommand( - Some(template.unwrap), - Option(key), - choice, - Option(argument), + submitAndWaitForTransactionTree( + submitAndWaitRequest( + party, + Command( + Command.Command.ExerciseByKey( + ExerciseByKeyCommand( + Some(template.unwrap), + Option(key), + choice, + Option(argument), + ), ), ), ), - ).flatMap(submitAndWaitForTransactionTree) - - def submitRequest(party: Party, commands: Command*): Future[SubmitRequest] = - time().map( - let => - new SubmitRequest( - Some( - new Commands( - ledgerId = ledgerId, - applicationId = applicationId, - commandId = nextCommandId(), - party = party.unwrap, - ledgerEffectiveTime = Some(let.asProtobuf), - maximumRecordTime = Some(let.plus(ttl).asProtobuf), - commands = commands, - ), - ), - )) - - def submitAndWaitRequest(party: Party, commands: Command*): Future[SubmitAndWaitRequest] = - time().map( - let => - new SubmitAndWaitRequest( - Some( - new Commands( - ledgerId = ledgerId, - applicationId = applicationId, - commandId = nextCommandId(), - party = party.unwrap, - ledgerEffectiveTime = Some(let.asProtobuf), - maximumRecordTime = Some(let.plus(ttl).asProtobuf), - commands = commands, - ), - ), - )) + ) + + def submitRequest(party: Party, commands: Command*): SubmitRequest = + new SubmitRequest( + Some( + new Commands( + ledgerId = ledgerId, + applicationId = applicationId, + commandId = nextCommandId(), + party = party.unwrap, + commands = commands, + ), + ), + ) + + def submitAndWaitRequest(party: Party, commands: Command*): SubmitAndWaitRequest = + new SubmitAndWaitRequest( + Some( + new Commands( + ledgerId = ledgerId, + applicationId = applicationId, + commandId = nextCommandId(), + party = party.unwrap, + commands = commands, + ), + ), + ) def submit(request: SubmitRequest): Future[Unit] = services.commandSubmission.submit(request).map(_ => ()) diff --git a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/tests/CommandDeduplication.scala b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/tests/CommandDeduplication.scala index abb3af7b53ff..8e54aa6363a7 100644 --- a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/tests/CommandDeduplication.scala +++ b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/tests/CommandDeduplication.scala @@ -35,13 +35,17 @@ final class CommandDeduplication(session: LedgerSession) extends LedgerTestSuite val deduplicationTime = Duration.of(deduplicationSeconds.toLong, 0) val a = UUID.randomUUID.toString val b = UUID.randomUUID.toString - - for { - request <- ledger.submitRequest(party, Dummy(party).create.command) - requestA = request.update( + val requestA = ledger + .submitRequest(party, Dummy(party).create.command) + .update( _.commands.deduplicationTime := deduplicationTime, - _.commands.commandId := a) + _.commands.commandId := a, + ) + val requestB = ledger + .submitAndWaitRequest(party, Dummy(party).create.command) + .update(_.commands.commandId := b) + for { // Submit command A (first deduplication window) _ <- ledger.submit(requestA) failure1 <- ledger.submit(requestA).failed @@ -54,8 +58,7 @@ final class CommandDeduplication(session: LedgerSession) extends LedgerTestSuite failure2 <- ledger.submit(requestA).failed // Submit and wait for command B (to get a unique completion for the end of the test) - submitAndWaitRequest <- ledger.submitAndWaitRequest(party, Dummy(party).create.command) - _ <- ledger.submitAndWait(submitAndWaitRequest.update(_.commands.commandId := b)) + _ <- ledger.submitAndWait(requestB) // Inspect created contracts activeContracts <- ledger.activeContracts(party) @@ -79,13 +82,14 @@ final class CommandDeduplication(session: LedgerSession) extends LedgerTestSuite val deduplicationSeconds = 5 val deduplicationTime = Duration.of(deduplicationSeconds.toLong, 0) val a = UUID.randomUUID.toString - - for { - request <- ledger.submitAndWaitRequest(party, Dummy(party).create.command) - requestA = request.update( + val requestA = ledger + .submitAndWaitRequest(party, Dummy(party).create.command) + .update( _.commands.deduplicationTime := deduplicationTime, - _.commands.commandId := a) + _.commands.commandId := a, + ) + for { // Submit command A (first TTL window) _ <- ledger.submitAndWait(requestA) failure1 <- ledger.submitAndWait(requestA).failed @@ -116,16 +120,17 @@ final class CommandDeduplication(session: LedgerSession) extends LedgerTestSuite allocate(TwoParties), ) { case Participants(Participant(ledger, alice, bob)) => + val aliceRequest = ledger.submitRequest(alice, Dummy(alice).create.command) + val bobRequest = ledger + .submitRequest(bob, Dummy(bob).create.command) + .update(_.commands.commandId := aliceRequest.getCommands.commandId) + for { // Submit a command as alice - aliceRequest <- ledger.submitRequest(alice, Dummy(alice).create.command) _ <- ledger.submit(aliceRequest) failure1 <- ledger.submit(aliceRequest).failed // Submit another command that uses same commandId, but is submitted by Bob - bobRequestTemplate <- ledger.submitRequest(bob, Dummy(bob).create.command) - bobRequest = bobRequestTemplate - .update(_.commands.commandId := aliceRequest.getCommands.commandId) _ <- ledger.submit(bobRequest) failure2 <- ledger.submit(bobRequest).failed @@ -156,16 +161,17 @@ final class CommandDeduplication(session: LedgerSession) extends LedgerTestSuite allocate(TwoParties), ) { case Participants(Participant(ledger, alice, bob)) => + val aliceRequest = ledger.submitAndWaitRequest(alice, Dummy(alice).create.command) + val bobRequest = ledger + .submitAndWaitRequest(bob, Dummy(bob).create.command) + .update(_.commands.commandId := aliceRequest.getCommands.commandId) + for { // Submit a command as alice - aliceRequest <- ledger.submitAndWaitRequest(alice, Dummy(alice).create.command) _ <- ledger.submitAndWait(aliceRequest) failure1 <- ledger.submitAndWait(aliceRequest).failed // Submit another command that uses same commandId, but is submitted by Bob - bobRequestTemplate <- ledger.submitAndWaitRequest(bob, Dummy(bob).create.command) - bobRequest = bobRequestTemplate - .update(_.commands.commandId := aliceRequest.getCommands.commandId) _ <- ledger.submitAndWait(bobRequest) failure2 <- ledger.submitAndWait(bobRequest).failed diff --git a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/tests/CommandService.scala b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/tests/CommandService.scala index 8715577fb70d..aebfcc08a075 100644 --- a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/tests/CommandService.scala +++ b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/tests/CommandService.scala @@ -27,8 +27,8 @@ final class CommandService(session: LedgerSession) extends LedgerTestSuite(sessi allocate(SingleParty), ) { case Participants(Participant(ledger, party)) => + val request = ledger.submitAndWaitRequest(party, Dummy(party).create.command) for { - request <- ledger.submitAndWaitRequest(party, Dummy(party).create.command) _ <- ledger.submitAndWait(request) active <- ledger.activeContracts(party) } yield { @@ -44,8 +44,8 @@ final class CommandService(session: LedgerSession) extends LedgerTestSuite(sessi allocate(SingleParty), ) { case Participants(Participant(ledger, party)) => + val request = ledger.submitAndWaitRequest(party, Dummy(party).create.command) for { - request <- ledger.submitAndWaitRequest(party, Dummy(party).create.command) transactionId <- ledger.submitAndWaitForTransactionId(request) retrievedTransaction <- ledger.transactionTreeById(transactionId, party) transactions <- ledger.flatTransactions(party) @@ -93,8 +93,8 @@ final class CommandService(session: LedgerSession) extends LedgerTestSuite(sessi allocate(SingleParty), ) { case Participants(Participant(ledger, party)) => + val request = ledger.submitAndWaitRequest(party, Dummy(party).create.command) for { - request <- ledger.submitAndWaitRequest(party, Dummy(party).create.command) transaction <- ledger.submitAndWaitForTransaction(request) } yield { assert( @@ -123,8 +123,8 @@ final class CommandService(session: LedgerSession) extends LedgerTestSuite(sessi allocate(SingleParty), ) { case Participants(Participant(ledger, party)) => + val request = ledger.submitAndWaitRequest(party, Dummy(party).create.command) for { - request <- ledger.submitAndWaitRequest(party, Dummy(party).create.command) transactionTree <- ledger.submitAndWaitForTransactionTree(request) } yield { assert( @@ -153,8 +153,8 @@ final class CommandService(session: LedgerSession) extends LedgerTestSuite(sessi allocate(SingleParty), ) { case Participants(Participant(ledger, party)) => + val request = ledger.submitAndWaitRequest(party, Dummy(party).create.command) for { - request <- ledger.submitAndWaitRequest(party, Dummy(party).create.command) _ <- ledger.submitAndWait(request) failure <- ledger.submitAndWait(request).failed } yield { @@ -168,8 +168,8 @@ final class CommandService(session: LedgerSession) extends LedgerTestSuite(sessi allocate(SingleParty), ) { case Participants(Participant(ledger, party)) => + val request = ledger.submitAndWaitRequest(party, Dummy(party).create.command) for { - request <- ledger.submitAndWaitRequest(party, Dummy(party).create.command) _ <- ledger.submitAndWaitForTransactionId(request) failure <- ledger.submitAndWaitForTransactionId(request).failed } yield { @@ -183,8 +183,8 @@ final class CommandService(session: LedgerSession) extends LedgerTestSuite(sessi allocate(SingleParty), ) { case Participants(Participant(ledger, party)) => + val request = ledger.submitAndWaitRequest(party, Dummy(party).create.command) for { - request <- ledger.submitAndWaitRequest(party, Dummy(party).create.command) _ <- ledger.submitAndWaitForTransaction(request) failure <- ledger.submitAndWaitForTransaction(request).failed } yield { @@ -198,8 +198,8 @@ final class CommandService(session: LedgerSession) extends LedgerTestSuite(sessi allocate(SingleParty), ) { case Participants(Participant(ledger, party)) => + val request = ledger.submitAndWaitRequest(party, Dummy(party).create.command) for { - request <- ledger.submitAndWaitRequest(party, Dummy(party).create.command) _ <- ledger.submitAndWaitForTransactionTree(request) failure <- ledger.submitAndWaitForTransactionTree(request).failed } yield { @@ -214,10 +214,11 @@ final class CommandService(session: LedgerSession) extends LedgerTestSuite(sessi ) { case Participants(Participant(ledger, party)) => val invalidLedgerId = "CSsubmitAndWaitForTransactionIdInvalidLedgerId" + val request = ledger + .submitAndWaitRequest(party, Dummy(party).create.command) + .update(_.commands.ledgerId := invalidLedgerId) for { - request <- ledger.submitAndWaitRequest(party, Dummy(party).create.command) - badLedgerId = request.update(_.commands.ledgerId := invalidLedgerId) - failure <- ledger.submitAndWaitForTransactionId(badLedgerId).failed + failure <- ledger.submitAndWaitForTransactionId(request).failed } yield assertGrpcError( failure, @@ -233,10 +234,11 @@ final class CommandService(session: LedgerSession) extends LedgerTestSuite(sessi ) { case Participants(Participant(ledger, party)) => val invalidLedgerId = "CSsubmitAndWaitForTransactionInvalidLedgerId" + val request = ledger + .submitAndWaitRequest(party, Dummy(party).create.command) + .update(_.commands.ledgerId := invalidLedgerId) for { - request <- ledger.submitAndWaitRequest(party, Dummy(party).create.command) - badLedgerId = request.update(_.commands.ledgerId := invalidLedgerId) - failure <- ledger.submitAndWaitForTransaction(badLedgerId).failed + failure <- ledger.submitAndWaitForTransaction(request).failed } yield assertGrpcError( failure, @@ -252,10 +254,11 @@ final class CommandService(session: LedgerSession) extends LedgerTestSuite(sessi ) { case Participants(Participant(ledger, party)) => val invalidLedgerId = "CSsubmitAndWaitForTransactionTreeInvalidLedgerId" + val request = ledger + .submitAndWaitRequest(party, Dummy(party).create.command) + .update(_.commands.ledgerId := invalidLedgerId) for { - request <- ledger.submitAndWaitRequest(party, Dummy(party).create.command) - badLedgerId = request.update(_.commands.ledgerId := invalidLedgerId) - failure <- ledger.submitAndWaitForTransactionTree(badLedgerId).failed + failure <- ledger.submitAndWaitForTransactionTree(request).failed } yield assertGrpcError( failure, @@ -272,8 +275,8 @@ final class CommandService(session: LedgerSession) extends LedgerTestSuite(sessi case Participants(Participant(ledger, party)) => val createWithBadArgument = Dummy(party).create.command .update(_.create.createArguments.fields.foreach(_.label := "INVALID_PARAM")) + val badRequest = ledger.submitAndWaitRequest(party, createWithBadArgument) for { - badRequest <- ledger.submitAndWaitRequest(party, createWithBadArgument) failure <- ledger.submitAndWait(badRequest).failed } yield { assertGrpcError(failure, Status.Code.INVALID_ARGUMENT, s"Missing record label") @@ -373,8 +376,8 @@ final class CommandService(session: LedgerSession) extends LedgerTestSuite(sessi case Participants(Participant(ledger, party)) => val target = 15 val commands = Vector.fill(target)(Dummy(party).create.command) + val request = ledger.submitAndWaitRequest(party, commands: _*) for { - request <- ledger.submitAndWaitRequest(party, commands: _*) _ <- ledger.submitAndWait(request) acs <- ledger.activeContracts(party) } yield { @@ -433,12 +436,15 @@ final class CommandService(session: LedgerSession) extends LedgerTestSuite(sessi val positiveOutOfBounds = "10000000000000000000000000000.0000000000" val negativeOutOfBounds = "-10000000000000000000000000000.0000000000" for { - r1 <- ledger.submitAndWaitRequest(party, rounding(wouldLosePrecision)) - e1 <- ledger.submitAndWait(r1).failed - r2 <- ledger.submitAndWaitRequest(party, rounding(positiveOutOfBounds)) - e2 <- ledger.submitAndWait(r2).failed - r3 <- ledger.submitAndWaitRequest(party, rounding(negativeOutOfBounds)) - e3 <- ledger.submitAndWait(r3).failed + e1 <- ledger + .submitAndWait(ledger.submitAndWaitRequest(party, rounding(wouldLosePrecision))) + .failed + e2 <- ledger + .submitAndWait(ledger.submitAndWaitRequest(party, rounding(positiveOutOfBounds))) + .failed + e3 <- ledger + .submitAndWait(ledger.submitAndWaitRequest(party, rounding(negativeOutOfBounds))) + .failed } yield { assertGrpcError(e1, Status.Code.INVALID_ARGUMENT, "Cannot represent") assertGrpcError(e2, Status.Code.INVALID_ARGUMENT, "Out-of-bounds (Numeric 10)") @@ -449,8 +455,8 @@ final class CommandService(session: LedgerSession) extends LedgerTestSuite(sessi test("CSCreateAndExercise", "Implement create-and-exercise correctly", allocate(SingleParty)) { case Participants(Participant(ledger, party)) => val createAndExercise = Dummy(party).createAnd.exerciseDummyChoice1(party).command + val request = ledger.submitAndWaitRequest(party, createAndExercise) for { - request <- ledger.submitAndWaitRequest(party, createAndExercise) _ <- ledger.submitAndWait(request) transactions <- ledger.flatTransactions(party) trees <- ledger.transactionTrees(party) @@ -483,8 +489,8 @@ final class CommandService(session: LedgerSession) extends LedgerTestSuite(sessi .exerciseDummyChoice1(party) .command .update(_.createAndExercise.createArguments := Record()) + val request = ledger.submitAndWaitRequest(party, createAndExercise) for { - request <- ledger.submitAndWaitRequest(party, createAndExercise) failure <- ledger.submitAndWait(request).failed } yield { assertGrpcError(failure, Status.Code.INVALID_ARGUMENT, "Expecting 1 field for record") @@ -501,8 +507,8 @@ final class CommandService(session: LedgerSession) extends LedgerTestSuite(sessi .exerciseDummyChoice1(party) .command .update(_.createAndExercise.choiceArgument := Value(Value.Sum.Bool(false))) + val request = ledger.submitAndWaitRequest(party, createAndExercise) for { - request <- ledger.submitAndWaitRequest(party, createAndExercise) failure <- ledger.submitAndWait(request).failed } yield { assertGrpcError(failure, Status.Code.INVALID_ARGUMENT, "mismatching type") @@ -520,8 +526,8 @@ final class CommandService(session: LedgerSession) extends LedgerTestSuite(sessi .exerciseDummyChoice1(party) .command .update(_.createAndExercise.choice := missingChoice) + val request = ledger.submitAndWaitRequest(party, createAndExercise) for { - request <- ledger.submitAndWaitRequest(party, createAndExercise) failure <- ledger.submitAndWait(request).failed } yield { assertGrpcError( diff --git a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/tests/CommandSubmissionCompletion.scala b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/tests/CommandSubmissionCompletion.scala index 9bea85dd353d..ec81f7f5241d 100644 --- a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/tests/CommandSubmissionCompletion.scala +++ b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/tests/CommandSubmissionCompletion.scala @@ -23,8 +23,8 @@ final class CommandSubmissionCompletion(session: LedgerSession) extends LedgerTe allocate(SingleParty), ) { case Participants(Participant(ledger, party)) => + val request = ledger.submitRequest(party, Dummy(party).create.command) for { - request <- ledger.submitRequest(party, Dummy(party).create.command) _ <- ledger.submit(request) completions <- ledger.firstCompletions(party) } yield { @@ -43,8 +43,8 @@ final class CommandSubmissionCompletion(session: LedgerSession) extends LedgerTe allocate(SingleParty), ) { case Participants(Participant(ledger, party)) => + val request = ledger.submitRequest(party, Dummy(party).create.command) for { - request <- ledger.submitRequest(party, Dummy(party).create.command) _ <- ledger.submit(request) invalidRequest = ledger .completionStreamRequest()(party) @@ -61,8 +61,8 @@ final class CommandSubmissionCompletion(session: LedgerSession) extends LedgerTe allocate(TwoParties), ) { case Participants(Participant(ledger, party, notTheSubmittingParty)) => + val request = ledger.submitRequest(party, Dummy(party).create.command) for { - request <- ledger.submitRequest(party, Dummy(party).create.command) _ <- ledger.submit(request) failed <- WithTimeout(5.seconds)(ledger.firstCompletions(notTheSubmittingParty)).failed } yield { @@ -81,7 +81,7 @@ final class CommandSubmissionCompletion(session: LedgerSession) extends LedgerTe dummy <- ledger.create(party, Dummy(party)) exercise = dummy.exerciseDummyChoice1(party).command wrongExercise = exercise.update(_.exercise.choice := badChoice) - wrongRequest <- ledger.submitRequest(party, wrongExercise) + wrongRequest = ledger.submitRequest(party, wrongExercise) failure <- ledger.submit(wrongRequest).failed } yield { assertGrpcError( @@ -99,10 +99,11 @@ final class CommandSubmissionCompletion(session: LedgerSession) extends LedgerTe ) { case Participants(Participant(ledger, party)) => val invalidLedgerId = "CSsubmitAndWaitInvalidLedgerId" + val request = ledger + .submitRequest(party, Dummy(party).create.command) + .update(_.commands.ledgerId := invalidLedgerId) for { - request <- ledger.submitRequest(party, Dummy(party).create.command) - badLedgerId = request.update(_.commands.ledgerId := invalidLedgerId) - failure <- ledger.submit(badLedgerId).failed + failure <- ledger.submit(request).failed } yield assertGrpcError( failure, @@ -117,8 +118,8 @@ final class CommandSubmissionCompletion(session: LedgerSession) extends LedgerTe allocate(SingleParty), ) { case Participants(Participant(ledger, party)) => + val emptyRequest = ledger.submitRequest(party) for { - emptyRequest <- ledger.submitRequest(party) failure <- ledger.submit(emptyRequest).failed } yield { assertGrpcError(failure, Status.Code.INVALID_ARGUMENT, "Missing field: commands") @@ -133,9 +134,9 @@ final class CommandSubmissionCompletion(session: LedgerSession) extends LedgerTe case Participants(Participant(ledger, alice, bob)) => val a = UUID.randomUUID.toString val b = UUID.randomUUID.toString + val aliceRequest = ledger.submitRequest(alice, Dummy(alice).create.command) + val bobRequest = ledger.submitRequest(bob, Dummy(bob).create.command) for { - aliceRequest <- ledger.submitRequest(alice, Dummy(alice).create.command) - bobRequest <- ledger.submitRequest(bob, Dummy(bob).create.command) _ <- ledger.submit(aliceRequest.update(_.commands.commandId := a)) _ <- ledger.submit(bobRequest.update(_.commands.commandId := b)) _ <- WithTimeout(5.seconds)(ledger.findCompletion(alice, bob)(_.commandId == a)) diff --git a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/tests/ContractKeys.scala b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/tests/ContractKeys.scala index ae3f9164a73b..9fcf4452c952 100644 --- a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/tests/ContractKeys.scala +++ b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/tests/ContractKeys.scala @@ -193,8 +193,9 @@ final class ContractKeys(session: LedgerSession) extends LedgerTestSuite(session val key = s"${UUID.randomUUID.toString}-key" for { delegated1TxTree <- ledger - .submitAndWaitRequest(owner, Delegated(owner, key).create.command) - .flatMap(ledger.submitAndWaitForTransactionTree) + .submitAndWaitForTransactionTree( + ledger.submitAndWaitRequest(owner, Delegated(owner, key).create.command) + ) delegated1Id = com.digitalasset.ledger.client.binding.Primitive .ContractId[Delegated](delegated1TxTree.eventsById.head._2.getCreated.contractId) diff --git a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/tests/LedgerConfigurationService.scala b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/tests/LedgerConfigurationService.scala index c0a493cb7134..2ce4a71304d5 100644 --- a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/tests/LedgerConfigurationService.scala +++ b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/tests/LedgerConfigurationService.scala @@ -40,8 +40,8 @@ class LedgerConfigurationService(session: LedgerSession) extends LedgerTestSuite // and there might be an actual clock skew between the devices running the test and the ledger. // This test therefore does not attempt to simulate any clock skew // but simply checks whether basic command submission with an unmodified LET works. + val request = ledger.submitRequest(party, Dummy(party).create.command) for { - request <- ledger.submitRequest(party, Dummy(party).create.command) _ <- ledger.submit(request) } yield { // No assertions to make, since the command went through as expected diff --git a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/tests/SemanticTests.scala b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/tests/SemanticTests.scala index 61c9fb65726b..ac7291229ebd 100644 --- a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/tests/SemanticTests.scala +++ b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/tests/SemanticTests.scala @@ -67,7 +67,7 @@ final class SemanticTests(session: LedgerSession) extends LedgerTestSuite(sessio case Participants(Participant(alpha, payer, owner), Participant(_, newOwner1, newOwner2)) => for { iou <- alpha.create(payer, Iou(payer, owner, onePound)) - doubleSpend <- alpha.submitAndWaitRequest( + doubleSpend = alpha.submitAndWaitRequest( owner, iou.exerciseTransfer(owner, newOwner1).command, iou.exerciseTransfer(owner, newOwner2).command, diff --git a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/tests/TransactionScale.scala b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/tests/TransactionScale.scala index 34137319bbd6..6878f9c7b9d7 100644 --- a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/tests/TransactionScale.scala +++ b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/tests/TransactionScale.scala @@ -24,11 +24,11 @@ class TransactionScale(session: LedgerSession) extends LedgerTestSuite(session) ) { case Participants(Participant(ledger, party)) => val targetNumberOfSubCommands = numberOfCommands(units = 3) + val request = ledger.submitAndWaitRequest( + party, + List.fill(targetNumberOfSubCommands)(Dummy(party).create.command): _*, + ) for { - request <- ledger.submitAndWaitRequest( - party, - List.fill(targetNumberOfSubCommands)(Dummy(party).create.command): _*, - ) result <- ledger.submitAndWaitForTransaction(request) } yield { val _ = assertLength("LargeCommand", targetNumberOfSubCommands, result.events) diff --git a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/tests/TransactionService.scala b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/tests/TransactionService.scala index 70066c1609e7..fc6f0b350367 100644 --- a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/tests/TransactionService.scala +++ b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/tests/TransactionService.scala @@ -393,12 +393,12 @@ class TransactionService(session: LedgerSession) extends LedgerTestSuite(session ) { case Participants(Participant(ledger, party)) => val filterBy = Dummy.id + val create = ledger.submitAndWaitRequest( + party, + Dummy(party).create.command, + DummyFactory(party).create.command, + ) for { - create <- ledger.submitAndWaitRequest( - party, - Dummy(party).create.command, - DummyFactory(party).create.command, - ) _ <- ledger.submitAndWait(create) transactions <- ledger.flatTransactionsByTemplateId(filterBy, party) } yield { @@ -497,8 +497,8 @@ class TransactionService(session: LedgerSession) extends LedgerTestSuite(session Primitive.List(0L, 1L, 2L, 3L), Primitive.Optional("some optional text"), ) + val create = ledger.submitAndWaitRequest(party, template.create.command) for { - create <- ledger.submitAndWaitRequest(party, template.create.command) transaction <- ledger.submitAndWaitForTransaction(create) } yield { val contract = assertSingleton("CreateWithAnyType", createdEvents(transaction)) @@ -564,8 +564,8 @@ class TransactionService(session: LedgerSession) extends LedgerTestSuite(session veryLongList, Primitive.Optional("some optional text"), ) + val create = ledger.submitAndWaitRequest(party, template.create.command) for { - create <- ledger.submitAndWaitRequest(party, template.create.command) transaction <- ledger.submitAndWaitForTransaction(create) } yield { val contract = assertSingleton("VeryLongList", createdEvents(transaction)) @@ -614,8 +614,8 @@ class TransactionService(session: LedgerSession) extends LedgerTestSuite(session ) { case Participants(Participant(alpha, alice), Participant(beta, bob)) => val template = BranchingSignatories(false, alice, bob) + val create = beta.submitAndWaitRequest(bob, template.create.command) for { - create <- beta.submitAndWaitRequest(bob, template.create.command) transaction <- beta.submitAndWaitForTransaction(create) _ <- synchronize(alpha, beta) transactions <- alpha.flatTransactions(alice) @@ -671,8 +671,8 @@ class TransactionService(session: LedgerSession) extends LedgerTestSuite(session ) { case Participants(Participant(alpha, alice), Participant(beta, bob, eve)) => val template = BranchingControllers(alice, false, bob, eve) + val create = alpha.submitAndWaitRequest(alice, template.create.command) for { - create <- alpha.submitAndWaitRequest(alice, template.create.command) transaction <- alpha.submitAndWaitForTransaction(create) _ <- synchronize(alpha, beta) transactions <- beta.flatTransactions(bob) @@ -691,8 +691,8 @@ class TransactionService(session: LedgerSession) extends LedgerTestSuite(session ) { case Participants(Participant(alpha, alice), Participant(beta, observers @ _*)) => val template = WithObservers(alice, Primitive.List(observers: _*)) + val create = alpha.submitAndWaitRequest(alice, template.create.command) for { - create <- alpha.submitAndWaitRequest(alice, template.create.command) transactionId <- alpha.submitAndWaitForTransactionId(create) _ <- eventually { for { @@ -713,8 +713,8 @@ class TransactionService(session: LedgerSession) extends LedgerTestSuite(session ) { case Participants(Participant(ledger, party)) => val template = NothingArgument(party, Primitive.Optional.empty) + val create = ledger.submitAndWaitRequest(party, template.create.command) for { - create <- ledger.submitAndWaitRequest(party, template.create.command) transaction <- ledger.submitAndWaitForTransaction(create) } yield { val contract = assertSingleton("UnitAsArgumentToNothing", createdEvents(transaction)) diff --git a/ledger/participant-state/kvutils/src/main/protobuf/daml_kvutils.proto b/ledger/participant-state/kvutils/src/main/protobuf/daml_kvutils.proto index dc27e0a64e0e..d2d3d1289b71 100644 --- a/ledger/participant-state/kvutils/src/main/protobuf/daml_kvutils.proto +++ b/ledger/participant-state/kvutils/src/main/protobuf/daml_kvutils.proto @@ -121,7 +121,7 @@ message DamlSubmitterInfo { string submitter = 1; string command_id = 2; string application_id = 3; - google.protobuf.Timestamp maximum_record_time = 4; + reserved 4; // was maximum_record_time google.protobuf.Timestamp deduplicate_until = 5; } @@ -163,11 +163,12 @@ message DamlTransactionEntry { message DamlTransactionRejectionEntry { DamlSubmitterInfo submitter_info = 1; + reserved 5; // was reason.maximum_record_time_exceeded + oneof reason { Inconsistent inconsistent = 2; Disputed disputed = 3; ResourcesExhausted resources_exhausted = 4; - MaximumRecordTimeExceeded maximum_record_time_exceeded = 5; Duplicate duplicate_command = 6; PartyNotKnownOnLedger party_not_known_on_ledger = 7; SubmitterCannotActViaParticipant submitter_cannot_act_via_participant = 8; diff --git a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/Conversions.scala b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/Conversions.scala index 0b3b22726a3a..0e19e2ca5ffc 100644 --- a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/Conversions.scala +++ b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/Conversions.scala @@ -131,7 +131,6 @@ private[state] object Conversions { .setSubmitter(subInfo.submitter) .setApplicationId(subInfo.applicationId) .setCommandId(subInfo.commandId) - .setMaximumRecordTime(buildTimestamp(subInfo.maxRecordTime)) .build def parseSubmitterInfo(subInfo: DamlSubmitterInfo): SubmitterInfo = @@ -139,7 +138,6 @@ private[state] object Conversions { submitter = Party.assertFromString(subInfo.getSubmitter), applicationId = LedgerString.assertFromString(subInfo.getApplicationId), commandId = LedgerString.assertFromString(subInfo.getCommandId), - maxRecordTime = parseTimestamp(subInfo.getMaximumRecordTime), deduplicateUntil = parseTimestamp(subInfo.getDeduplicateUntil).toInstant, ) diff --git a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/KeyValueConsumption.scala b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/KeyValueConsumption.scala index 9d91e271c081..d4acba0e4ded 100644 --- a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/KeyValueConsumption.scala +++ b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/KeyValueConsumption.scala @@ -194,8 +194,6 @@ object KeyValueConsumption { wrap(RejectionReason.Inconsistent) case DamlTransactionRejectionEntry.ReasonCase.RESOURCES_EXHAUSTED => wrap(RejectionReason.ResourcesExhausted) - case DamlTransactionRejectionEntry.ReasonCase.MAXIMUM_RECORD_TIME_EXCEEDED => - wrap(RejectionReason.MaximumRecordTimeExceeded) case DamlTransactionRejectionEntry.ReasonCase.DUPLICATE_COMMAND => List() case DamlTransactionRejectionEntry.ReasonCase.PARTY_NOT_KNOWN_ON_LEDGER => diff --git a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/committing/ProcessTransactionSubmission.scala b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/committing/ProcessTransactionSubmission.scala index a844235871d8..a5304e3897e0 100644 --- a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/committing/ProcessTransactionSubmission.scala +++ b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/committing/ProcessTransactionSubmission.scala @@ -492,8 +492,6 @@ private[kvutils] class ProcessTransactionSubmission( builder.setDisputed(Disputed.newBuilder.setDetails(disputeReason)) case RejectionReason.ResourcesExhausted => builder.setResourcesExhausted(ResourcesExhausted.newBuilder.setDetails("")) - case RejectionReason.MaximumRecordTimeExceeded => - builder.setMaximumRecordTimeExceeded(MaximumRecordTimeExceeded.newBuilder.setDetails("")) case RejectionReason.PartyNotKnownOnLedger => builder.setPartyNotKnownOnLedger(PartyNotKnownOnLedger.newBuilder.setDetails("")) case RejectionReason.SubmitterCannotActViaParticipant(details) => diff --git a/ledger/participant-state/kvutils/src/test/lib/scala/com/daml/ledger/participant/state/kvutils/ParticipantStateIntegrationSpecBase.scala b/ledger/participant-state/kvutils/src/test/lib/scala/com/daml/ledger/participant/state/kvutils/ParticipantStateIntegrationSpecBase.scala index f66c7ef00b97..125c7bcd0c06 100644 --- a/ledger/participant-state/kvutils/src/test/lib/scala/com/daml/ledger/participant/state/kvutils/ParticipantStateIntegrationSpecBase.scala +++ b/ledger/participant-state/kvutils/src/test/lib/scala/com/daml/ledger/participant/state/kvutils/ParticipantStateIntegrationSpecBase.scala @@ -722,7 +722,6 @@ abstract class ParticipantStateIntegrationSpecBase(implementationName: String)( submitter = party, applicationId = Ref.LedgerString.assertFromString("tests"), commandId = Ref.LedgerString.assertFromString(commandId), - maxRecordTime = inTheFuture(10.seconds), deduplicateUntil = inTheFuture(10.seconds).toInstant, ) @@ -783,7 +782,7 @@ object ParticipantStateIntegrationSpecBase { private def matchTransaction(update: Update, expectedCommandId: String): Assertion = inside(update) { - case TransactionAccepted(Some(SubmitterInfo(_, _, actualCommandId, _, _)), _, _, _, _, _) => + case TransactionAccepted(Some(SubmitterInfo(_, _, actualCommandId, _)), _, _, _, _, _) => actualCommandId should be(expectedCommandId) } } diff --git a/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/KVTest.scala b/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/KVTest.scala index 984425f07ba4..0376c82a5add 100644 --- a/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/KVTest.scala +++ b/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/KVTest.scala @@ -209,7 +209,6 @@ object KVTest { submitter: Party, transaction: (Transaction.AbsTransaction, Transaction.Metadata), submissionSeed: Option[crypto.Hash], - mrtDelta: Duration = minMRTDelta, letDelta: Duration = Duration.ZERO, commandId: CommandId = randomLedgerString, deduplicationTime: Duration = Duration.ofDays(1)): KVTest[(DamlLogEntryId, DamlLogEntry)] = @@ -219,7 +218,6 @@ object KVTest { submitter = submitter, applicationId = Ref.LedgerString.assertFromString("test"), commandId = commandId, - maxRecordTime = testState.recordTime.addMicros(mrtDelta.toNanos / 1000), deduplicateUntil = testState.recordTime.addMicros(deduplicationTime.toNanos / 1000).toInstant, ) diff --git a/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/KVUtilsTransactionSpec.scala b/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/KVUtilsTransactionSpec.scala index acbfbc278c07..82caee5d5073 100644 --- a/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/KVUtilsTransactionSpec.scala +++ b/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/KVUtilsTransactionSpec.scala @@ -101,19 +101,6 @@ class KVUtilsTransactionSpec extends WordSpec with Matchers { } } - /* Disabled while we rework the time model. - "reject transaction with elapsed max record time" in KVTest.runTestWithSimplePackage( - for { - tx <- runSimpleCommand(alice, simpleCreateCmd) - logEntry <- submitTransaction(submitter = alice, tx = tx, mrtDelta = Duration.ZERO) - .map(_._2) - } yield { - logEntry.getPayloadCase shouldEqual DamlLogEntry.PayloadCase.TRANSACTION_REJECTION_ENTRY - logEntry.getTransactionRejectionEntry.getReasonCase shouldEqual DamlTransactionRejectionEntry.ReasonCase.MAXIMUM_RECORD_TIME_EXCEEDED - } - ) - */ - "reject transaction with out of bounds LET" in KVTest.runTestWithSimplePackage(alice, bob, eve) { val seed = hash(this.getClass.getName) for { diff --git a/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/api/KeyValueParticipantStateWriterSpec.scala b/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/api/KeyValueParticipantStateWriterSpec.scala index e20a00972626..8213047211aa 100644 --- a/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/api/KeyValueParticipantStateWriterSpec.scala +++ b/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/api/KeyValueParticipantStateWriterSpec.scala @@ -107,7 +107,6 @@ object KeyValueParticipantStateWriterSpec { submitter = party, applicationId = Ref.LedgerString.assertFromString("tests"), commandId = Ref.LedgerString.assertFromString("X"), - maxRecordTime = rt.addMicros(Duration.ofSeconds(10).toNanos / 1000), deduplicateUntil = rt.addMicros(Duration.ofDays(1).toNanos / 1000).toInstant, ) diff --git a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/RejectionReason.scala b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/RejectionReason.scala index c64340498133..4d007ea949b6 100644 --- a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/RejectionReason.scala +++ b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/RejectionReason.scala @@ -40,16 +40,6 @@ object RejectionReason { override def description: String = "Resources exhausted" } - /** The transaction submission exceeded its maximum record time. - * - * This means the 'maximumRecordTime' was smaller than the record time - * in the ledger state at which the transaction was sequenced. - */ - final case object MaximumRecordTimeExceeded extends RejectionReason { - override def description: String = - "The maximum record time of the command exceeded" - } - /** A party mentioned as a stakeholder or actor has not been on-boarded on * the ledger. * diff --git a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/SubmitterInfo.scala b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/SubmitterInfo.scala index 1cb6a25ad2d1..eb23fb1f2cb9 100644 --- a/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/SubmitterInfo.scala +++ b/ledger/participant-state/src/main/scala/com/daml/ledger/participant/state/v1/SubmitterInfo.scala @@ -5,8 +5,6 @@ package com.daml.ledger.participant.state.v1 import java.time.Instant -import com.digitalasset.daml.lf.data.Time.Timestamp - /** Information provided by the submitter of changes submitted to the ledger. * * Note that this is used for party-originating changes only. They are @@ -22,11 +20,6 @@ import com.digitalasset.daml.lf.data.Time.Timestamp * correlate the stream of changes to the participant state with the * changes he submitted. * - * @param maxRecordTime: the maximum record time (inclusive) until which - * the submitted change can be validly added to the ledger. This is used - * by DAML applications to deduce from the record time reported by the - * ledger whether a change that they submitted has been lost in transit. - * * @param deduplicateUntil: the time until which the command should be deduplicated. * Command deduplication is already performed by the participant. * The ledger may choose to perform additional (cross-participant) @@ -40,6 +33,5 @@ final case class SubmitterInfo( submitter: Party, applicationId: ApplicationId, commandId: CommandId, - maxRecordTime: Timestamp, //TODO: this should be a regular Instant deduplicateUntil: Instant, ) diff --git a/ledger/sandbox-perf/src/perf/lib/scala/com/digitalasset/platform/sandbox/perf/TestHelper.scala b/ledger/sandbox-perf/src/perf/lib/scala/com/digitalasset/platform/sandbox/perf/TestHelper.scala index 8293c1279dc0..a8a70937ce5d 100644 --- a/ledger/sandbox-perf/src/perf/lib/scala/com/digitalasset/platform/sandbox/perf/TestHelper.scala +++ b/ledger/sandbox-perf/src/perf/lib/scala/com/digitalasset/platform/sandbox/perf/TestHelper.scala @@ -18,7 +18,6 @@ import com.digitalasset.ledger.api.v1.value.{Identifier, Value} import com.digitalasset.ledger.client.services.acs.ActiveContractSetClient import com.digitalasset.dec.DirectExecutionContext import com.digitalasset.platform.sandbox.perf.util.DarUtil -import com.google.protobuf.timestamp.Timestamp import scala.concurrent.{ExecutionContext, Future} import scala.concurrent.duration._ @@ -31,8 +30,6 @@ trait TestHelper { val ledgerId: String = "ledger-server" val applicationId: String = "app1" - val ledgerEffectiveTime = Some(Timestamp(0L, 0)) - val maximumRecordTime = ledgerEffectiveTime.map(x => x.copy(seconds = x.seconds + 30L)) val traceContext = Some(TraceContext(1L, 2L, 3L, Some(4L))) val party = "party" @@ -68,8 +65,6 @@ trait TestHelper { workflowId = workflowId, applicationId = applicationId, commandId = commandId, - ledgerEffectiveTime = ledgerEffectiveTime, - maximumRecordTime = maximumRecordTime, party = party, commands = Seq(Command(command)) ) diff --git a/ledger/sandbox/src/main/resources/db/migration/h2database/V15__Remove_maximum_record_time.sha256 b/ledger/sandbox/src/main/resources/db/migration/h2database/V15__Remove_maximum_record_time.sha256 new file mode 100644 index 000000000000..7a34e0d28880 --- /dev/null +++ b/ledger/sandbox/src/main/resources/db/migration/h2database/V15__Remove_maximum_record_time.sha256 @@ -0,0 +1 @@ +139d2cb5d8926079415257d14b3b718490f452801416080e18fcbda97c4336bb diff --git a/ledger/sandbox/src/main/resources/db/migration/h2database/V15__Remove_maximum_record_time.sql b/ledger/sandbox/src/main/resources/db/migration/h2database/V15__Remove_maximum_record_time.sql new file mode 100644 index 000000000000..8bfa603ad18a --- /dev/null +++ b/ledger/sandbox/src/main/resources/db/migration/h2database/V15__Remove_maximum_record_time.sql @@ -0,0 +1,13 @@ +-- Copyright (c) 2019 The DAML Authors. All rights reserved. +-- SPDX-License-Identifier: Apache-2.0 + +--------------------------------------------------------------------------------------------------- +-- V22: Stable Offsets +-- +-- The removal of maximum record time (MRT) also removed the "TimedOut" rejection reason. +-- For historical data, it is replaced by the similar "InvalidLedgerTime" rejection reason. +--------------------------------------------------------------------------------------------------- + +UPDATE ledger_entries +SET rejection_type = 'InvalidLedgerTime' +WHERE rejection_type = 'TimedOut' diff --git a/ledger/sandbox/src/main/resources/db/migration/postgres/V22__Remove_maximum_record_time.sha256 b/ledger/sandbox/src/main/resources/db/migration/postgres/V22__Remove_maximum_record_time.sha256 new file mode 100644 index 000000000000..7a34e0d28880 --- /dev/null +++ b/ledger/sandbox/src/main/resources/db/migration/postgres/V22__Remove_maximum_record_time.sha256 @@ -0,0 +1 @@ +139d2cb5d8926079415257d14b3b718490f452801416080e18fcbda97c4336bb diff --git a/ledger/sandbox/src/main/resources/db/migration/postgres/V22__Remove_maximum_record_time.sql b/ledger/sandbox/src/main/resources/db/migration/postgres/V22__Remove_maximum_record_time.sql new file mode 100644 index 000000000000..8bfa603ad18a --- /dev/null +++ b/ledger/sandbox/src/main/resources/db/migration/postgres/V22__Remove_maximum_record_time.sql @@ -0,0 +1,13 @@ +-- Copyright (c) 2019 The DAML Authors. All rights reserved. +-- SPDX-License-Identifier: Apache-2.0 + +--------------------------------------------------------------------------------------------------- +-- V22: Stable Offsets +-- +-- The removal of maximum record time (MRT) also removed the "TimedOut" rejection reason. +-- For historical data, it is replaced by the similar "InvalidLedgerTime" rejection reason. +--------------------------------------------------------------------------------------------------- + +UPDATE ledger_entries +SET rejection_type = 'InvalidLedgerTime' +WHERE rejection_type = 'TimedOut' diff --git a/ledger/sandbox/src/main/scala/com/digitalasset/platform/apiserver/CommandExecutorImpl.scala b/ledger/sandbox/src/main/scala/com/digitalasset/platform/apiserver/CommandExecutorImpl.scala index 09712b9d1007..8779f406329c 100644 --- a/ledger/sandbox/src/main/scala/com/digitalasset/platform/apiserver/CommandExecutorImpl.scala +++ b/ledger/sandbox/src/main/scala/com/digitalasset/platform/apiserver/CommandExecutorImpl.scala @@ -66,7 +66,6 @@ class CommandExecutorImpl( submitted.submitter, submitted.applicationId.unwrap, submitted.commandId.unwrap, - Time.Timestamp.assertFromInstant(submitted.maximumRecordTime), submitted.deduplicateUntil, ), transactionMeta = TransactionMeta( diff --git a/ledger/sandbox/src/main/scala/com/digitalasset/platform/apiserver/services/ApiCommandService.scala b/ledger/sandbox/src/main/scala/com/digitalasset/platform/apiserver/services/ApiCommandService.scala index ef2360421f38..16e2996fbfa7 100644 --- a/ledger/sandbox/src/main/scala/com/digitalasset/platform/apiserver/services/ApiCommandService.scala +++ b/ledger/sandbox/src/main/scala/com/digitalasset/platform/apiserver/services/ApiCommandService.scala @@ -170,7 +170,7 @@ object ApiCommandService { new ApiCommandService(services, configuration), ledgerId = configuration.ledgerId, currentLedgerTime = () => timeProvider.getCurrentTime, - currentUTCTime = () => Instant.now, + currentUtcTime = () => Instant.now, maxDeduplicationTime = () => configuration.maxDeduplicationTime, ) diff --git a/ledger/sandbox/src/main/scala/com/digitalasset/platform/apiserver/services/ApiSubmissionService.scala b/ledger/sandbox/src/main/scala/com/digitalasset/platform/apiserver/services/ApiSubmissionService.scala index 1c06452231ac..b2d7dec3235d 100644 --- a/ledger/sandbox/src/main/scala/com/digitalasset/platform/apiserver/services/ApiSubmissionService.scala +++ b/ledger/sandbox/src/main/scala/com/digitalasset/platform/apiserver/services/ApiSubmissionService.scala @@ -90,7 +90,7 @@ object ApiSubmissionService { ), ledgerId = ledgerId, currentLedgerTime = () => timeProvider.getCurrentTime, - currentUTCTime = () => Instant.now, + currentUtcTime = () => Instant.now, maxDeduplicationTime = () => configuration.maxDeduplicationTime, ) diff --git a/ledger/sandbox/src/main/scala/com/digitalasset/platform/indexer/JdbcIndexer.scala b/ledger/sandbox/src/main/scala/com/digitalasset/platform/indexer/JdbcIndexer.scala index f022f6ff4b9e..3f273e9c5d6e 100644 --- a/ledger/sandbox/src/main/scala/com/digitalasset/platform/indexer/JdbcIndexer.scala +++ b/ledger/sandbox/src/main/scala/com/digitalasset/platform/indexer/JdbcIndexer.scala @@ -314,8 +314,6 @@ class JdbcIndexer private[indexer] ( case RejectionReason.Inconsistent => domain.RejectionReason.Inconsistent(RejectionReason.Inconsistent.description) case RejectionReason.Disputed(_) => domain.RejectionReason.Disputed(state.description) - case RejectionReason.MaximumRecordTimeExceeded => - domain.RejectionReason.TimedOut(state.description) case RejectionReason.ResourcesExhausted => domain.RejectionReason.OutOfQuota(state.description) case RejectionReason.PartyNotKnownOnLedger => domain.RejectionReason.PartyNotKnownOnLedger(state.description) diff --git a/ledger/sandbox/src/main/scala/com/digitalasset/platform/sandbox/stores/ledger/inmemory/InMemoryLedger.scala b/ledger/sandbox/src/main/scala/com/digitalasset/platform/sandbox/stores/ledger/inmemory/InMemoryLedger.scala index a1775b3b14c5..c3cf102ae9c6 100644 --- a/ledger/sandbox/src/main/scala/com/digitalasset/platform/sandbox/stores/ledger/inmemory/InMemoryLedger.scala +++ b/ledger/sandbox/src/main/scala/com/digitalasset/platform/sandbox/stores/ledger/inmemory/InMemoryLedger.scala @@ -212,8 +212,6 @@ class InMemoryLedger( _ => { val (transactionForIndex, disclosureForIndex, globalDivulgence) = Ledger.convertToCommittedTransaction(transactionId, transaction) - // 5b. modify the ActiveContracts, while checking that we do not have double - // spends or timing issues val acsRes = acs.addTransaction( transactionMeta.ledgerEffectiveTime.toInstant, transactionId, diff --git a/ledger/sandbox/src/main/scala/com/digitalasset/platform/sandbox/stores/ledger/sql/SqlLedger.scala b/ledger/sandbox/src/main/scala/com/digitalasset/platform/sandbox/stores/ledger/sql/SqlLedger.scala index be80890dda1a..c00ff3f83520 100644 --- a/ledger/sandbox/src/main/scala/com/digitalasset/platform/sandbox/stores/ledger/sql/SqlLedger.scala +++ b/ledger/sandbox/src/main/scala/com/digitalasset/platform/sandbox/stores/ledger/sql/SqlLedger.scala @@ -183,7 +183,7 @@ private final class SqlLedger( currentConfiguration .get() .fold[Either[String, Unit]]( - Left("No ledger configuration available, can not validate ledger time") + Left("No ledger configuration available, cannot validate ledger time") )( config => config.timeModel.checkTime(ledgerTime, recordTime) ) diff --git a/ledger/sandbox/src/main/scala/com/digitalasset/platform/store/CompletionFromTransaction.scala b/ledger/sandbox/src/main/scala/com/digitalasset/platform/store/CompletionFromTransaction.scala index 2a7186e5b9be..559e7b347bc5 100644 --- a/ledger/sandbox/src/main/scala/com/digitalasset/platform/store/CompletionFromTransaction.scala +++ b/ledger/sandbox/src/main/scala/com/digitalasset/platform/store/CompletionFromTransaction.scala @@ -38,9 +38,9 @@ private[platform] object CompletionFromTransaction { def toErrorCode(rejection: RejectionReason): Code = { rejection match { case _: RejectionReason.Inconsistent | _: RejectionReason.Disputed | - _: RejectionReason.PartyNotKnownOnLedger | _: RejectionReason.InvalidLedgerTime => + _: RejectionReason.PartyNotKnownOnLedger => Code.INVALID_ARGUMENT - case _: RejectionReason.OutOfQuota | _: RejectionReason.TimedOut => + case _: RejectionReason.OutOfQuota | _: RejectionReason.InvalidLedgerTime => Code.ABORTED case _: RejectionReason.SubmitterCannotActViaParticipant => Code.PERMISSION_DENIED diff --git a/ledger/sandbox/src/main/scala/com/digitalasset/platform/store/dao/JdbcLedgerDao.scala b/ledger/sandbox/src/main/scala/com/digitalasset/platform/store/dao/JdbcLedgerDao.scala index dc6a36af7638..27d1a138f864 100644 --- a/ledger/sandbox/src/main/scala/com/digitalasset/platform/store/dao/JdbcLedgerDao.scala +++ b/ledger/sandbox/src/main/scala/com/digitalasset/platform/store/dao/JdbcLedgerDao.scala @@ -1071,7 +1071,6 @@ private class JdbcLedgerDao( (rejectionReason.description, rejectionReason match { case _: Inconsistent => "Inconsistent" case _: OutOfQuota => "OutOfQuota" - case _: TimedOut => "TimedOut" case _: Disputed => "Disputed" case _: PartyNotKnownOnLedger => "PartyNotKnownOnLedger" case _: SubmitterCannotActViaParticipant => "SubmitterCannotActViaParticipant" @@ -1082,7 +1081,6 @@ private class JdbcLedgerDao( rejectionType match { case "Inconsistent" => Inconsistent(description) case "OutOfQuota" => OutOfQuota(description) - case "TimedOut" => TimedOut(description) case "Disputed" => Disputed(description) case "PartyNotKnownOnLedger" => PartyNotKnownOnLedger(description) case "SubmitterCannotActViaParticipant" => SubmitterCannotActViaParticipant(description) @@ -1369,7 +1367,7 @@ private class JdbcLedgerDao( case (_, _, _, _, _, _, _, _, _) => sys.error( - "mapContractDetails called with partial data, can not map to either active or divulged contract") + "mapContractDetails called with partial data, cannot map to either active or divulged contract") } private def lookupWitnesses(coid: String)(implicit conn: Connection): Set[Party] = diff --git a/ledger/sandbox/src/main/scala/db/migration/postgres/V2_1__Rebuild_Acs.scala b/ledger/sandbox/src/main/scala/db/migration/postgres/V2_1__Rebuild_Acs.scala index 027b393e42a9..5dedca9674cd 100644 --- a/ledger/sandbox/src/main/scala/db/migration/postgres/V2_1__Rebuild_Acs.scala +++ b/ledger/sandbox/src/main/scala/db/migration/postgres/V2_1__Rebuild_Acs.scala @@ -473,7 +473,7 @@ class V2_1__Rebuild_Acs extends BaseJavaMigration { rejectionType match { case "Inconsistent" => Inconsistent(description) case "OutOfQuota" => OutOfQuota(description) - case "TimedOut" => TimedOut(description) + case "TimedOut" => InvalidLedgerTime(description) case "Disputed" => Disputed(description) case typ => sys.error(s"unknown rejection reason: $typ") } diff --git a/ledger/sandbox/src/test/lib/scala/com/digitalasset/platform/sandbox/ScenarioLoadingITBase.scala b/ledger/sandbox/src/test/lib/scala/com/digitalasset/platform/sandbox/ScenarioLoadingITBase.scala index 67314e7c899e..21a2e086158c 100644 --- a/ledger/sandbox/src/test/lib/scala/com/digitalasset/platform/sandbox/ScenarioLoadingITBase.scala +++ b/ledger/sandbox/src/test/lib/scala/com/digitalasset/platform/sandbox/ScenarioLoadingITBase.scala @@ -3,9 +3,6 @@ package com.digitalasset.platform.sandbox -import java.time.Instant -import java.time.temporal.ChronoUnit - import akka.stream.scaladsl.Sink import com.digitalasset.dec.DirectExecutionContext import com.digitalasset.ledger.api.domain.LedgerId @@ -28,7 +25,6 @@ import com.digitalasset.ledger.client.services.acs.ActiveContractSetClient import com.digitalasset.ledger.client.services.commands.SynchronousCommandClient import com.digitalasset.ledger.client.services.transactions.TransactionClient import com.digitalasset.platform.sandbox.services.{SandboxFixture, TestCommands} -import com.google.protobuf.timestamp.Timestamp import org.scalatest.concurrent.ScalaFutures import org.scalatest.time.{Millis, Span} import org.scalatest.{Matchers, Suite, WordSpec} @@ -96,17 +92,7 @@ abstract class ScenarioLoadingITBase private def extractEvents(response: GetActiveContractsResponse) = response.activeContracts.toSet - lazy val dummyRequest = { - // we need to adjust the time of the request because we pass 10 - // days in the test scenario. - val letInstant = Instant.EPOCH.plus(10, ChronoUnit.DAYS) - val let = Timestamp(letInstant.getEpochSecond, letInstant.getNano) - val mrt = Timestamp(let.seconds + 30L, let.nanos) - dummyCommands(ledgerId(), "commandId1").update( - _.commands.ledgerEffectiveTime := let, - _.commands.maximumRecordTime := mrt - ) - } + lazy val dummyRequest = dummyCommands(ledgerId(), "commandId1") implicit val ec = DirectExecutionContext diff --git a/ledger/sandbox/src/test/lib/scala/com/digitalasset/platform/sandbox/services/TestCommands.scala b/ledger/sandbox/src/test/lib/scala/com/digitalasset/platform/sandbox/services/TestCommands.scala index 83bbeaeda10e..febd5972f5cb 100644 --- a/ledger/sandbox/src/test/lib/scala/com/digitalasset/platform/sandbox/services/TestCommands.scala +++ b/ledger/sandbox/src/test/lib/scala/com/digitalasset/platform/sandbox/services/TestCommands.scala @@ -4,18 +4,12 @@ package com.digitalasset.platform.sandbox.services import java.io.File -import java.time.Instant import java.util -import com.digitalasset.api.util.TimestampConversion import com.digitalasset.daml.lf.archive.DarReader import com.digitalasset.daml.lf.data.Ref.PackageId import com.digitalasset.ledger.api.domain -import com.digitalasset.ledger.api.testing.utils.MockMessages.{ - applicationId, - ledgerEffectiveTime, - maximumRecordTime -} +import com.digitalasset.ledger.api.testing.utils.MockMessages.applicationId import com.digitalasset.ledger.api.testing.utils.{MockMessages => M} import com.digitalasset.ledger.api.v1.command_service.SubmitAndWaitRequest import com.digitalasset.ledger.api.v1.command_submission_service.SubmitRequest @@ -26,7 +20,6 @@ import com.digitalasset.ledger.api.v1.value.Value.Sum.{Bool, Party, Text, Timest import com.digitalasset.ledger.api.v1.value.{Identifier, Record, RecordField, Value, Variant} import com.digitalasset.platform.participant.util.ValueConversions._ import com.digitalasset.platform.testing.TestTemplateIdentifiers -import com.google.protobuf.timestamp.{Timestamp => GTimestamp} import scalaz.syntax.tag._ trait TestCommands { @@ -41,8 +34,6 @@ trait TestCommands { ledgerId: domain.LedgerId, commandId: String, commands: Seq[Command], - let: GTimestamp = ledgerEffectiveTime, - maxRecordTime: GTimestamp = maximumRecordTime, appId: String = applicationId, ): SubmitRequest = M.submitRequest.update( @@ -50,8 +41,6 @@ trait TestCommands { _.commands.ledgerId := ledgerId.unwrap, _.commands.applicationId := appId, _.commands.commands := commands, - _.commands.ledgerEffectiveTime := let, - _.commands.maximumRecordTime := maxRecordTime ) protected def dummyCommands( @@ -122,8 +111,6 @@ trait TestCommands { "appId", "cmd", "Alice", - Some(TimestampConversion.fromInstant(Instant.now)), - Some(TimestampConversion.fromInstant(Instant.now)), Seq( Command(Command.Command.Create( CreateCommand(Some(templateIds.parameterShowcase), Option(paramShowcaseArgs))))) diff --git a/ledger/sandbox/src/test/lib/scala/com/digitalasset/platform/store/dao/JdbcLedgerDaoCompletionsSpec.scala b/ledger/sandbox/src/test/lib/scala/com/digitalasset/platform/store/dao/JdbcLedgerDaoCompletionsSpec.scala index 67480697f558..0db96e73c8f6 100644 --- a/ledger/sandbox/src/test/lib/scala/com/digitalasset/platform/store/dao/JdbcLedgerDaoCompletionsSpec.scala +++ b/ledger/sandbox/src/test/lib/scala/com/digitalasset/platform/store/dao/JdbcLedgerDaoCompletionsSpec.scala @@ -103,7 +103,6 @@ private[dao] trait JdbcLedgerDaoCompletionsSpec extends OptionValues with LoneEl RejectionReason.OutOfQuota(""), RejectionReason.PartyNotKnownOnLedger(""), RejectionReason.SubmitterCannotActViaParticipant(""), - RejectionReason.TimedOut(""), RejectionReason.InvalidLedgerTime(""), ) diff --git a/ledger/sandbox/src/test/suite/scala/com/digitalasset/platform/sandbox/stores/ledger/ImplicitPartyAdditionIT.scala b/ledger/sandbox/src/test/suite/scala/com/digitalasset/platform/sandbox/stores/ledger/ImplicitPartyAdditionIT.scala index 1ca766ef8cbe..84314b8f4f5b 100644 --- a/ledger/sandbox/src/test/suite/scala/com/digitalasset/platform/sandbox/stores/ledger/ImplicitPartyAdditionIT.scala +++ b/ledger/sandbox/src/test/suite/scala/com/digitalasset/platform/sandbox/stores/ledger/ImplicitPartyAdditionIT.scala @@ -171,7 +171,6 @@ object ImplicitPartyAdditionIT { private val ledgerConfig = Configuration(0, TimeModel.reasonableDefault, Duration.ofDays(1)) private val LET = Instant.EPOCH.plusSeconds(10) - private val MRT = Instant.EPOCH.plusSeconds(10) private val DeduplicateUntil = Instant.now.plusSeconds(3600) private val templateId1: Ref.Identifier = Ref.Identifier( @@ -204,7 +203,6 @@ object ImplicitPartyAdditionIT { Ref.Party.assertFromString(submitter), Ref.LedgerString.assertFromString("appId"), Ref.LedgerString.assertFromString(commandId), - Time.Timestamp.assertFromInstant(MRT), DeduplicateUntil, ) diff --git a/ledger/sandbox/src/test/suite/scala/com/digitalasset/platform/sandbox/stores/ledger/TransactionTimeModelComplianceIT.scala b/ledger/sandbox/src/test/suite/scala/com/digitalasset/platform/sandbox/stores/ledger/TransactionTimeModelComplianceIT.scala index 6c132f76341b..5a9c6d256c96 100644 --- a/ledger/sandbox/src/test/suite/scala/com/digitalasset/platform/sandbox/stores/ledger/TransactionTimeModelComplianceIT.scala +++ b/ledger/sandbox/src/test/suite/scala/com/digitalasset/platform/sandbox/stores/ledger/TransactionTimeModelComplianceIT.scala @@ -83,7 +83,6 @@ class TransactionTimeModelComplianceIT submitter = Ref.Party.assertFromString("submitter"), applicationId = Ref.LedgerString.assertFromString("appId"), commandId = Ref.LedgerString.assertFromString(commandId), - maxRecordTime = Time.Timestamp.assertFromInstant(Instant.EPOCH), deduplicateUntil = Instant.EPOCH ) val transactionMeta = TransactionMeta( diff --git a/navigator/backend/src/main/scala/com/digitalasset/navigator/model/converter/LedgerApiV1.scala b/navigator/backend/src/main/scala/com/digitalasset/navigator/model/converter/LedgerApiV1.scala index ff65cb434733..372dd72399ba 100644 --- a/navigator/backend/src/main/scala/com/digitalasset/navigator/model/converter/LedgerApiV1.scala +++ b/navigator/backend/src/main/scala/com/digitalasset/navigator/model/converter/LedgerApiV1.scala @@ -19,7 +19,6 @@ import com.digitalasset.platform.participant.util.LfEngineToApi.{ lfValueToApiValue } -import com.google.protobuf.timestamp.Timestamp import com.google.rpc.code.Code import scalaz.Tag import scalaz.syntax.bifunctor._ @@ -478,25 +477,18 @@ case object LedgerApiV1 { def writeCommands( party: Model.PartyState, command: Model.Command, - maxRecordDelay: Long, ledgerId: String, applicationId: Ref.LedgerString ): Result[V1.commands.Commands] = { for { ledgerCommand <- writeCommand(party, command) } yield { - val ledgerEffectiveTime = - new Timestamp(command.platformTime.getEpochSecond, command.platformTime.getNano) - val maximumRecordTime = - ledgerEffectiveTime.copy(seconds = ledgerEffectiveTime.seconds + maxRecordDelay) V1.commands.Commands( ledgerId, Tag.unwrap(command.workflowId), applicationId, Tag.unwrap(command.id), Tag.unwrap(party.name), - Some(ledgerEffectiveTime), - Some(maximumRecordTime), List(ledgerCommand) ) } diff --git a/navigator/backend/src/main/scala/com/digitalasset/navigator/store/platform/PlatformSubscriber.scala b/navigator/backend/src/main/scala/com/digitalasset/navigator/store/platform/PlatformSubscriber.scala index 500899da091b..05fe86104df1 100644 --- a/navigator/backend/src/main/scala/com/digitalasset/navigator/store/platform/PlatformSubscriber.scala +++ b/navigator/backend/src/main/scala/com/digitalasset/navigator/store/platform/PlatformSubscriber.scala @@ -312,12 +312,9 @@ class PlatformSubscriber( command: Command, sender: ActorRef ): Unit = { - // Delay for observing this command in the completion stream before considering it lost, in seconds. - val maxRecordDelay: Long = 30L - // Convert to ledger API command converter.LedgerApiV1 - .writeCommands(party, command, maxRecordDelay, ledgerClient.ledgerId.unwrap, applicationId) + .writeCommands(party, command, ledgerClient.ledgerId.unwrap, applicationId) .fold[Unit]( error => { // Failed to convert command. Most likely, the argument is incomplete. diff --git a/triggers/service/src/test/scala/com/digitalasset/daml/lf/engine/trigger/ServiceTest.scala b/triggers/service/src/test/scala/com/digitalasset/daml/lf/engine/trigger/ServiceTest.scala index 10e85c75984e..7436c197d800 100644 --- a/triggers/service/src/test/scala/com/digitalasset/daml/lf/engine/trigger/ServiceTest.scala +++ b/triggers/service/src/test/scala/com/digitalasset/daml/lf/engine/trigger/ServiceTest.scala @@ -54,8 +54,6 @@ class ServiceTest extends AsyncFlatSpec with Eventually with Matchers { applicationId = testId, ledgerId = client.ledgerId.unwrap, commandId = UUID.randomUUID.toString, - ledgerEffectiveTime = None, - maximumRecordTime = None, commands = Seq(cmd) ))) client.commandServiceClient.submitAndWait(req) diff --git a/triggers/tests/src/test/scala/com/digitalasset/daml/lf/engine/trigger/test/TestMain.scala b/triggers/tests/src/test/scala/com/digitalasset/daml/lf/engine/trigger/test/TestMain.scala index 6d65185ea051..91f62f1197e6 100644 --- a/triggers/tests/src/test/scala/com/digitalasset/daml/lf/engine/trigger/test/TestMain.scala +++ b/triggers/tests/src/test/scala/com/digitalasset/daml/lf/engine/trigger/test/TestMain.scala @@ -5,7 +5,6 @@ package com.digitalasset.daml.lf.engine.trigger.test import java.nio.file.{Path, Paths} import java.io.File -import java.time.Instant import akka.actor.ActorSystem import akka.stream._ @@ -25,7 +24,6 @@ import com.digitalasset.ledger.client.configuration.{ LedgerIdRequirement } import com.digitalasset.ledger.client.LedgerClient -import com.digitalasset.api.util.TimestampConversion.fromInstant import com.digitalasset.ledger.api.v1.command_submission_service._ import com.digitalasset.ledger.api.v1.commands._ import com.digitalasset.ledger.api.v1.value @@ -315,15 +313,16 @@ case class AcsTests(dar: Dar[(PackageId, Package)], runner: TestRunner) { for { r <- client.commandClient .withTimeProvider(Some(Runner.getTimeProvider(runner.config.timeProviderType))) - .trackSingleCommand(SubmitRequest(commands = Some(Commands( - ledgerId = client.ledgerId.unwrap, - applicationId = runner.applicationId.unwrap, - commandId = commandId, - party = party, - ledgerEffectiveTime = Some(fromInstant(Instant.EPOCH)), - maximumRecordTime = Some(fromInstant(Instant.EPOCH.plusSeconds(5))), - commands = commands - )))) + .trackSingleCommand( + SubmitRequest( + commands = Some( + Commands( + ledgerId = client.ledgerId.unwrap, + applicationId = runner.applicationId.unwrap, + commandId = commandId, + party = party, + commands = commands + )))) t <- client.transactionClient.getFlatTransactionById(r.transactionId, Seq(party)) } yield t.transaction.get.events.head.getCreated.contractId } @@ -359,15 +358,16 @@ case class AcsTests(dar: Dar[(PackageId, Package)], runner: TestRunner) { for { comp <- client.commandClient .withTimeProvider(Some(Runner.getTimeProvider(runner.config.timeProviderType))) - .trackSingleCommand(SubmitRequest(commands = Some(Commands( - ledgerId = client.ledgerId.unwrap, - applicationId = runner.applicationId.unwrap, - commandId = commandId, - party = party, - ledgerEffectiveTime = Some(fromInstant(Instant.EPOCH)), - maximumRecordTime = Some(fromInstant(Instant.EPOCH.plusSeconds(5))), - commands = commands - )))) + .trackSingleCommand( + SubmitRequest( + commands = Some( + Commands( + ledgerId = client.ledgerId.unwrap, + applicationId = runner.applicationId.unwrap, + commandId = commandId, + party = party, + commands = commands + )))) _ <- Future { if (comp.getStatus.code != 0) { throw new RuntimeException("archive failed") @@ -508,15 +508,16 @@ case class CopyTests(dar: Dar[(PackageId, Package)], runner: TestRunner) { for { _ <- client.commandClient .withTimeProvider(Some(Runner.getTimeProvider(runner.config.timeProviderType))) - .trackSingleCommand(SubmitRequest(commands = Some(Commands( - ledgerId = client.ledgerId.unwrap, - applicationId = runner.applicationId.unwrap, - commandId = commandId, - party = owner, - ledgerEffectiveTime = Some(fromInstant(Instant.EPOCH)), - maximumRecordTime = Some(fromInstant(Instant.EPOCH.plusSeconds(5))), - commands = commands - )))) + .trackSingleCommand( + SubmitRequest( + commands = Some( + Commands( + ledgerId = client.ledgerId.unwrap, + applicationId = runner.applicationId.unwrap, + commandId = commandId, + party = owner, + commands = commands + )))) } yield () } @@ -540,15 +541,16 @@ case class CopyTests(dar: Dar[(PackageId, Package)], runner: TestRunner) { for { _ <- client.commandClient .withTimeProvider(Some(Runner.getTimeProvider(runner.config.timeProviderType))) - .trackSingleCommand(SubmitRequest(commands = Some(Commands( - ledgerId = client.ledgerId.unwrap, - applicationId = runner.applicationId.unwrap, - commandId = commandId, - party = subscriber, - ledgerEffectiveTime = Some(fromInstant(Instant.EPOCH)), - maximumRecordTime = Some(fromInstant(Instant.EPOCH.plusSeconds(5))), - commands = commands - )))) + .trackSingleCommand( + SubmitRequest( + commands = Some( + Commands( + ledgerId = client.ledgerId.unwrap, + applicationId = runner.applicationId.unwrap, + commandId = commandId, + party = subscriber, + commands = commands + )))) } yield () } @@ -886,15 +888,16 @@ case class TemplateFilterTests(dar: Dar[(PackageId, Package)], runner: TestRunne for { r <- client.commandClient .withTimeProvider(Some(Runner.getTimeProvider(runner.config.timeProviderType))) - .trackSingleCommand(SubmitRequest(commands = Some(Commands( - ledgerId = client.ledgerId.unwrap, - applicationId = runner.applicationId.unwrap, - commandId = commandId, - party = party, - ledgerEffectiveTime = Some(fromInstant(Instant.EPOCH)), - maximumRecordTime = Some(fromInstant(Instant.EPOCH.plusSeconds(5))), - commands = commands - )))) + .trackSingleCommand( + SubmitRequest( + commands = Some( + Commands( + ledgerId = client.ledgerId.unwrap, + applicationId = runner.applicationId.unwrap, + commandId = commandId, + party = party, + commands = commands + )))) } yield () }