Skip to content

Commit

Permalink
Remove MRT and LET (#5172)
Browse files Browse the repository at this point in the history
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 <https://github.com/digital-asset/daml/issues/4194>`__.
[Java Bindings] removed the usage of ledgerEffectiveTime and
maximumRecordTime, and instead added minLedgerTimeAbsolute and
minLedgerTimeRelative in CommandSubmissionClient and CommandClient
CHANGELOG_END
  • Loading branch information
rautenrieth-da authored Mar 25, 2020
1 parent 69220c3 commit a3ddde3
Show file tree
Hide file tree
Showing 95 changed files with 658 additions and 688 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 0 additions & 4 deletions docs/source/app-dev/services.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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) <com.digitalasset.ledger.api.v1.Commands.ledger_effective_time>`, and the :ref:`Maximum Record Time (MRT) <com.digitalasset.ledger.api.v1.Commands.maximum_record_time>`. 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 <com.digitalasset.ledger.api.v1.testing.TimeService>`.

.. _reset-service:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/getting-started/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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, \/}
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions language-support/hs/bindings/src/DA/Ledger/Convert.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions language-support/hs/bindings/src/DA/Ledger/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions language-support/hs/bindings/test/DA/Ledger/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,44 +10,72 @@
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}
*/
public interface CommandClient {

Single<Empty> 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<Instant> minLedgerTimeAbs,
@NonNull Optional<Duration> minLedgerTimeRel, @NonNull Optional<Duration> deduplicationTime, @NonNull List<@NonNull Command> commands);

Single<Empty> 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<Instant> minLedgerTimeAbs,
@NonNull Optional<Duration> minLedgerTimeRel, @NonNull Optional<Duration> deduplicationTime, @NonNull List<@NonNull Command> commands, @NonNull String accessToken);

Single<Empty> submitAndWait(@NonNull String workflowId, @NonNull String applicationId,
@NonNull String commandId, @NonNull String party, @NonNull List<@NonNull Command> commands);

Single<Empty> submitAndWait(@NonNull String workflowId, @NonNull String applicationId,
@NonNull String commandId, @NonNull String party, @NonNull List<@NonNull Command> commands, @NonNull String accessToken);


Single<String> submitAndWaitForTransactionId(@NonNull String workflowId, @NonNull String applicationId,
@NonNull String commandId, @NonNull String party, @NonNull Optional<Instant> minLedgerTimeAbs,
@NonNull Optional<Duration> minLedgerTimeRel, @NonNull Optional<Duration> deduplicationTime, @NonNull List<@NonNull Command> commands);

Single<String> submitAndWaitForTransactionId(@NonNull String workflowId, @NonNull String applicationId,
@NonNull String commandId, @NonNull String party, @NonNull Optional<Instant> minLedgerTimeAbs,
@NonNull Optional<Duration> minLedgerTimeRel, @NonNull Optional<Duration> deduplicationTime, @NonNull List<@NonNull Command> commands, @NonNull String accessToken);

Single<String> 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<String> 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<Transaction> submitAndWaitForTransaction(@NonNull String workflowId, @NonNull String applicationId,
@NonNull String commandId, @NonNull String party, @NonNull Optional<Instant> minLedgerTimeAbs,
@NonNull Optional<Duration> minLedgerTimeRel, @NonNull Optional<Duration> deduplicationTime, @NonNull List<@NonNull Command> commands);

Single<Transaction> submitAndWaitForTransaction(@NonNull String workflowId, @NonNull String applicationId,
@NonNull String commandId, @NonNull String party, @NonNull Optional<Instant> minLedgerTimeAbs,
@NonNull Optional<Duration> minLedgerTimeRel, @NonNull Optional<Duration> deduplicationTime, @NonNull List<@NonNull Command> commands, @NonNull String accessToken);

Single<Transaction> 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<Transaction> 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<TransactionTree> submitAndWaitForTransactionTree(@NonNull String workflowId, @NonNull String applicationId,
@NonNull String commandId, @NonNull String party, @NonNull Optional<Instant> minLedgerTimeAbs,
@NonNull Optional<Duration> minLedgerTimeRel, @NonNull Optional<Duration> deduplicationTime, @NonNull List<@NonNull Command> commands);

Single<TransactionTree> submitAndWaitForTransactionTree(@NonNull String workflowId, @NonNull String applicationId,
@NonNull String commandId, @NonNull String party, @NonNull Optional<Instant> minLedgerTimeAbs,
@NonNull Optional<Duration> minLedgerTimeRel, @NonNull Optional<Duration> deduplicationTime, @NonNull List<@NonNull Command> commands, @NonNull String accessToken);

Single<TransactionTree> 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<TransactionTree> 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);

}
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -20,16 +22,31 @@ Single<Empty> submit(@NonNull String workflowId,
@NonNull String applicationId,
@NonNull String commandId,
@NonNull String party,
@NonNull Instant ledgerEffectiveTime,
@NonNull Instant maximumRecordTime,
@NonNull Optional<Instant> minLedgerTimeAbs,
@NonNull Optional<Duration> minLedgerTimeRel,
@NonNull Optional<Duration> deduplicationTime,
@NonNull List<@NonNull Command> commands);

Single<Empty> submit(@NonNull String workflowId,
@NonNull String applicationId,
@NonNull String commandId,
@NonNull String party,
@NonNull Optional<Instant> minLedgerTimeAbs,
@NonNull Optional<Duration> minLedgerTimeRel,
@NonNull Optional<Duration> deduplicationTime,
@NonNull List<@NonNull Command> commands,
@NonNull String accessToken);

Single<Empty> submit(@NonNull String workflowId,
@NonNull String applicationId,
@NonNull String commandId,
@NonNull String party,
@NonNull List<@NonNull Command> commands);

Single<Empty> 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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ static Flowable<WorkflowEvent> 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.<LedgerViewFlowable.SubmissionFailure> empty())
.doOnError(t -> logger.error("Error submitting commands {} for party {}: {}", cs.getCommandId(), cs.getParty(), t.getMessage()))
.onErrorReturn(t -> new LedgerViewFlowable.SubmissionFailure(cs.getCommandId(), t))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.pcollections.PMap;
import org.pcollections.PSet;

import java.time.Instant;
import java.util.Collections;
import java.util.Objects;

Expand All @@ -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<Identifier, PSet<String>> contractIdsPendingIfSucceed) {
Expand Down
Loading

0 comments on commit a3ddde3

Please sign in to comment.