Require explicit time mode for DAML script and DAML trigger (#4484)

This should provide a better migration path for people that still rely
on static time by forcing them to make this explicit. Given that both
DAML script and DAML triggers are still experimental, I’m not marking
this as a breaking change

changelog_begin

- [DAML Script - Experimental] The time mode must now always be
  specified explicitly. Use ``--static-time`` to recover the previous
  default time mode.

- [DAML Triggers - Experimental] The time mode must now always be
  specified explicitly. Use ``--static-time`` to recover the previous
  default time mode.

changelog_end
This commit is contained in:
Moritz Kiefer 2020-02-12 11:16:25 +01:00 committed by GitHub
parent 724367017d
commit e7b8cdba89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 11 deletions

View File

@ -52,7 +52,13 @@ object RunnerConfig {
.action { (t, c) =>
c.copy(timeProviderType = TimeProviderType.WallClock)
}
.text("Use wall clock time (UTC). When not provided, static time is used.")
.text("Use wall clock time (UTC).")
opt[Unit]('s', "static-time")
.action { (t, c) =>
c.copy(timeProviderType = TimeProviderType.Static)
}
.text("Use static time.")
opt[Long]("ttl")
.action { (t, c) =>
@ -73,6 +79,8 @@ object RunnerConfig {
failure("Cannot specify both --ledger-host and --participant-config")
} else if (c.ledgerHost.isEmpty && c.participantConfig.isEmpty) {
failure("Must specify either --ledger-host or --participant-config")
} else if (c.timeProviderType == null) {
failure("Must specify either --wall-clock-time or --static-time")
} else {
success
}
@ -87,7 +95,7 @@ object RunnerConfig {
ledgerHost = None,
ledgerPort = None,
participantConfig = None,
timeProviderType = TimeProviderType.Static,
timeProviderType = null,
commandTtl = Duration.ofSeconds(30L),
inputFile = None,
)

View File

@ -179,10 +179,10 @@ them away using ``map snd``.
:end-before: -- TEST_QUERIES_END
To run our script, we first build it with ``daml build`` and then run
it by pointing to the DAR, the name of our script and the host and
port our ledger is running on.
it by pointing to the DAR, the name of our script, the host and
port our ledger is running on and the time mode of the ledger.
``daml script --dar .daml/dist/script-example-0.0.1.dar --script-name ScriptExample:test --ledger-host localhost --ledger-port 6865``
``daml script --dar .daml/dist/script-example-0.0.1.dar --script-name ScriptExample:test --ledger-host localhost --ledger-port 6865 --static-time``
Up to now, we have worked with parties that we have allocated in the
test. We can also pass in the path to a file containing
@ -193,7 +193,7 @@ the input in the :doc:`/json-api/lf-value-specification`.
We can then initialize our ledger passing in the json file via ``--input-file``.
``daml script daml script --dar .daml/dist/script-example-0.0.1.dar --script-name ScriptExample:initialize --ledger-host localhost --ledger-port 6865 --input-file ledger-parties.json``
``daml script daml script --dar .daml/dist/script-example-0.0.1.dar --script-name ScriptExample:initialize --ledger-host localhost --ledger-port 6865 --input-file ledger-parties.json --static-time``
If you open Navigator, you can now see the contracts that have been created.

View File

@ -240,13 +240,14 @@ Now we are ready to run the trigger using ``daml trigger``:
.. code-block:: sh
daml trigger --dar .daml/dist/copy-trigger-0.0.1.dar --trigger-name CopyTrigger:copyTrigger --ledger-host localhost --ledger-port 6865 --ledger-party Alice
daml trigger --dar .daml/dist/copy-trigger-0.0.1.dar --trigger-name CopyTrigger:copyTrigger --ledger-host localhost --ledger-port 6865 --ledger-party Alice --static-time
The first argument specifies the ``.dar`` file that we have just
built. The second argument specifies the identifier of the trigger
using the syntax ``ModuleName:identifier``. Finally, we need to
specify the ledger host, port and the party that our trigger is executed
as.
specify the ledger host, port, the party that our trigger is executed
as, and the time mode of the ledger which is the sandbox default, i.e,
static time.
Now open Navigator at http://localhost:7500/.

View File

@ -50,7 +50,13 @@ object RunnerConfig {
.action { (t, c) =>
c.copy(timeProviderType = TimeProviderType.WallClock)
}
.text("Use wall clock time (UTC). When not provided, static time is used.")
.text("Use wall clock time (UTC).")
opt[Unit]('s', "static-time")
.action { (t, c) =>
c.copy(timeProviderType = TimeProviderType.Static)
}
.text("Use static time.")
opt[Long]("ttl")
.action { (t, c) =>
@ -83,6 +89,8 @@ object RunnerConfig {
failure("Missing option --ledger-port")
} else if (c.ledgerParty == null) {
failure("Missing option --ledger-party")
} else if (c.timeProviderType == null) {
failure("Must specify either --wall-clock-time or --static-time")
} else {
success
}
@ -98,7 +106,7 @@ object RunnerConfig {
ledgerHost = null,
ledgerPort = 0,
ledgerParty = null,
timeProviderType = TimeProviderType.Static,
timeProviderType = null,
commandTtl = Duration.ofSeconds(30L),
accessTokenFile = None,
)