Commit Graph

451 Commits

Author SHA1 Message Date
Moisés Ackerman
8df9a42f29
Interface desugaring cont. (#11964)
* Move toInterfaceContractId and fromInterfaceContractId out of Implements class

* Split Implements class into single-method classes

* Define toInterface outside its class to swap type arguments

This allows users to call 'toInterface @Interface', since the type of the template can usually be inferred

* Move interface classes and functions to DA.Internal.Interface

changelog_begin
changelog_end
2021-12-07 13:56:57 +01:00
Moisés Ackerman
0b79d8ae7c
Deprecate 'controller ... can' syntax (#11363)
Closes #11317

* Add warning for uses of 'controller ... can' syntax

* Remove uses of 'controller ... can' syntax

* Add test cases for -W{,no-}controller-can

* Update docs to reflect 'controller ... can' syntax deprecation

changelog_begin
* Deprecate 'controller ... can' syntax.
  * It will be removed in a future version of Daml.
  * Instead, use 'choice ... with ... controller' syntax. Note that this does not implictly add the controller as an observer, so it must be added explictly as one (or as a signatory).
changelog_end
2021-12-01 13:36:04 +01:00
Moritz Kiefer
8179c73763
Drop support for Daml-LF party literals from the Scala side (#11922)
* Drop support for Daml-LF party literals from the Scala side

This PR enforces that forbidPartyLiterals is always `true` and drops
the corresponding literals from the AST. Haskell side is in #11930

fixes #11581

changelog_begin
changelog_end

* Update daml-lf/interpreter/src/test/scala/com/digitalasset/daml/lf/speedy/ComparisonSBuiltinTest.scala

Co-authored-by: Remy <remy.haemmerle@daml.com>

* Revert "Update daml-lf/interpreter/src/test/scala/com/digitalasset/daml/lf/speedy/ComparisonSBuiltinTest.scala"

This reverts commit 55e542ce4e3a7fd15544ee703de3277ffc309b17.

Co-authored-by: Remy <remy.haemmerle@daml.com>
2021-12-01 10:37:42 +00:00
Remy
58e69ade1a
LF: replace "dev" LF version by "1.dev" in bazel files (#11894)
the more consistent, as asked by Moritz in review of #11820

CHANGELOG_BEGIN
CHANGELOG_END
2021-11-26 12:23:17 +00:00
Sofia Faro
2f8f69e7cb
Drop DA.Next.Set and DA.Next.Map (#11864)
* Drop DA.Next.Set and DA.Next.Map

Fixes #11527. Also removed a bunch of unnecessary CPP, though there's
still a lot more CPP to remove.

changelog_begin

- [Daml Standard Library] DA.Next.Map and DA.Next.Set have been removed
  after being deprecated since Daml-LF 1.11

changelog_end

* Drop a deriving MapKey

* update unstable-types test
2021-11-25 13:02:08 +00:00
Moritz Kiefer
5785bbfcfd
Drop LF < 1.14 from supported damlc output versions (#11701)
* Drop LF < 1.14 from supported damlc output versions

fixes #11319

We keep test coverage by depending on the most recent snapshot which
still has 1.14 support.

changelog_begin

- [Daml Compiler] Damlc can only produce Daml-LF 1.14 or
  newer. Passing aynthing older to `--target` is an error. If you
  need to produce older versions, use an older SDK.

changelog_end

* Switch around legacy_compiler_lf_versions

changelog_begin
changelog_end

* drop since-lf

changelog_begin
changelog_end
2021-11-22 16:20:17 +00:00
Moisés Ackerman
d23d113667
Restructure interface desugaring (#11555)
* Update ghc patch

* Replace Implements proxy datatype with a class

* Expose 'Implements' class in Prelude

* Add DA.Internal.Desugar.HasMethod class

This allows us to get the type of a method of an interface through the functional dependency

* Convert interfaces from new desugaring

* Update Interface daml-test-file to use Interface class functions

* Update InterfaceDesugared daml-test-file

* Replace remaining uses of Is<Interface> methods with Implements

* Document HasMethod, Method and mkMethod

* Ignore _method_ bindings in convertBind

* Ignore interface desugaring types/classes/instances/functions in LF conversion

* update snapshot after pin on windows

changelog_begin
changelog_end
2021-11-19 10:06:49 +01:00
nicu-da
8f458d8d2a
[ledger-api] Include the completion offset in the command_service.proto responses [KVL-1171] (#11658)
CHANGELOG_BEGIN
[ledger-api] - Include the completion offset in the responses from the command_service.proto
CHANGELOG_END
2021-11-18 04:37:26 -08:00
Moritz Kiefer
869b8054c6
Bump sandbox acquisition timeout of trigger service tests to 1m (#11764)
This matches the timeouts we set in SandboxNextFixture and I’ve seen
the 30s timeouts be insufficient on CI.

changelog_begin
changelog_end
2021-11-18 11:43:26 +00:00
Moritz Kiefer
d3bb036591
Fix sandbox database config in script & trigger tests (#11655)
* Fix sandbox database config in script & trigger tests

Setting jdbcUrl does absolutely nothing because it later gets
overwritten again.

changelog_begin
changelog_end

* .

changelog_begin
changelog_end
2021-11-12 06:18:12 +00:00
nickchapman-da
2dd5289a35
different types for different speedy phases (#11605)
* Refactor speedy to distinuish SExpr types before/after ANF compilation phase

CHANGELOG_BEGIN
CHANGELOG_END

* remove commment/marker left in error

* make SExpr0 private to speedy

* reinstate (non-pp) print of original expression in AnfTest faiure

* avoid use of s./t. prefixes for expressions in SBuiltin; add 3 TODO markers

* inline "runtime" apply methods of SDefinitionRef into sole caller: SBCallInterface

* avoid use of t. prefix in SExpr0

* change s./t. prefix to source./target.

* add comment to summarize differences between SExpr0 and SExpr
2021-11-11 08:21:12 +00:00
akshayshirahatti-da
e69a871e2f
[JSON-API] Configurable Hikari connection pool props (#11621)
* Changes to make certain hikari cp connection pool properties configurable via jdbc conf string

CHANGELOG_BEGIN
[JSON-API] Make certain Hikari cp connection pool properties configurable via jdbc conf string, the properties are listed below
poolSize -- specifies the max pool size for the database connection pool
minIdle -- specifies the min idle connections for database connection pool
connectionTimeout -- long value, specifies the connection timeout for database connection pool
idleTimeout -- long value, specifies the idle timeout for the database connection pool
CHANGELOG_END

* some missed changes for DbTriggerDao

* remove defaults for poolSize on JdbcConfig

* add constants for test defaults
2021-11-11 05:43:56 +00:00
Moisés Ackerman
7d68e05f7f
Remove virtual choices (#11482)
* Remove virtual choices

* Remove choices without a body in 'interface' definition
* Remove choices in 'template ... implements' section

part of #11372

changelog_begin
changelog_end

* Remove virtual choices cont.

Switch uses of virtual choices to fixed choice with method implementation

* update snapshot after pin on windows

* Disable failing interface tests with TODO #10810
2021-11-08 17:05:23 +01:00
Moritz Kiefer
c098d75621
Add a --log-level flag to damlc (#11514)
This also allows us to quite down our builds a bit which is nice.

changelog_begin
changelog_end
2021-11-03 14:22:57 +01:00
Moritz Kiefer
bb37eef156
Switch script & trigger tests to postgres-backed Sadbonx (#11525)
DPP-695 is gift that keeps on giving and seems to also result in
timeouts here. Just marking all of our tests that depend on Sadbonx as
flaky doesn’t seem all that helpful so switch to a postgres-backed
sandbox instead.

changelog_begin
changelog_end
2021-11-03 08:39:46 +00:00
akshayshirahatti-da
9f8b039be3
[Trigger-Service] Migrate tests to sandbox (#11501)
* Migrate trigger service tests to sandbox from sandbox-classic

CHANGELOG_BEGIN
CHANGELOG_END

* remove config override for EngineMode.Dev based on code review
2021-11-02 14:35:30 +00:00
Moritz Kiefer
c415d9d1ee
Migrate trigger tests from sandbox-classic to sandbox (#11478)
Deliberately does not include the tests for the trigger service.

changelog_begin
changelog_end
2021-11-01 14:22:51 +00:00
Moritz Kiefer
07ad3e0d9a
Suport multi-party readAs in triggers (#11299)
* Suport multi-party readAs in triggers

fixes #7640

This does not yet include the trigger service. We’ll tackle that separately.

changelog_begin

- [Daml Triggers] Triggers now support readAs parties. They can be
  specified via `--ledger-readas a,b,c`. As part of this change
  ``testRule`` gained an extra argument to specify the `readAs`
  parties. If you previously used

  ```
  testRule trigger party acsBuilder commandsInFlight s
  ```

  you now need to use

  ```
  testRule trigger party [] acsBuilder commandsInFlight s
  ```

changelog_end

* Update triggers/tests/src/test/scala/com/digitalasset/daml/lf/engine/trigger/test/AbstractFuncTests.scala

Co-authored-by: Andreas Herrmann <42969706+aherrmann-da@users.noreply.github.com>

Co-authored-by: Andreas Herrmann <42969706+aherrmann-da@users.noreply.github.com>
2021-10-20 18:17:15 +00:00
Moritz Kiefer
50ea92f7b3
Use ApiTypes.Party instead of String in the trigger runner (#11298)
changelog_begin
changelog_end
2021-10-20 10:06:20 +02:00
tudor-da
2fc7490df2
[Self-service error codes] Adapt error factories [DPP-656] (#11270)
* Moved ErrorCodesVersionSwitcher to //ledger/error

CHANGELOG_BEGIN
CHANGELOG_END

* Rename ErrorCodeLoggingContext to ContextualizedErrorLogger

* Refactored ErrorFactories
* All error factories use ContextualizedErrorLogger for being able to dispatch self-service error codes.
* The ContextualizedErrorLogger is passed down from the dispatching Ledger API services.
* ErrorFactoriesSpec asserts both legacy (V1) and self-service error codes (V2).

* Adapted ApiSubmissionService

* Addressed Marcin's review comments
2021-10-18 16:46:20 +02:00
Robin Krom
7a88c7d97c
trigger-service: dev-mode-unsafe flag (#11233)
* trigger-service: dev-mode-unsafe flag

This adds a `--dev-mode-unsafe` flag analogous to the trigger service
analogous to its counterpart in the trigger runner.

CHANGELOG_BEGIN
CHANGELOG_END

* fix tests
2021-10-13 12:22:10 +00:00
Robin Krom
f4ca876756
interfaces: test for triggers (#11221)
This adds a test checking whether we can exercise choices on interface
contract IDs in triggers. We can only test this for daml-lf 1.dev.

CHANGELOG_BEGIN
CHANGELOG_END
2021-10-13 10:17:17 +02:00
Robin Krom
9835ccb1ef
trigger runner: added hidden dev-mode-unsafe flag (#11205)
This adds a hidden `dev-mode-unsafe` flag to the trigger runner to allow
running against a daml-lf 1.dev version dar.

CHANGELOG_BEGIN
CHANGELOG_END
2021-10-12 10:54:23 +00:00
Robin Krom
3115d104aa
daml script interfaces (#11124)
* interfaces: introduce TemplateOrInterface class in stdlib

The template typeclass is to strong for many applications. The new
constraint `TemplateOrInterface` only contains the methods to convert
contract IDs and choices.

CHANGELOG_BEGIN
CHANGELOG_END

* ghc-lib update, interface script tests

* pinned stackage on unix

* added missing implementation in preprocessor

* added test

* fixing tests

* remove Iface type

* pinned stackage windows

* make sure createAndExercise is not called on interfaces
2021-10-11 18:22:40 +02:00
nicu-da
9b2a8c7eb5
Enable top level statement blank lines scalafmt rule, which adds a blank line after imports (#11180)
CHANGELOG_BEGIN
CHANGELOG_END
2021-10-10 23:16:48 -07:00
Andreas Herrmann
d7ee278518
Optional table prefix for trigger service (#11047)
* Fix typo postgres --> oracle

* Move tablePrefix into base jdbcConfig

* Add table.prefix in trigger service migrations

* Add tablePrefix to trigger service db table names

changelog_begin
* [Trigger Service] Enable the new `tablePrefix` setting in the `--jdbc`
  flag to add a prefix to all tables used by the trigger service to
  avoid collisions with other components using the same db-schema.
changelog_end

* Add tablePrefix config test for trigger service

* Fix Oracle test

* Allow existing schema in trigger service

CHANGELOG_BEGIN
* [Trigger Service] Enable the new ``--allow-existing-schema`` flag to
  initialize the trigger service on a database with a pre-existing
  schema.
CHANGELOG_END

* Don't ignore CLI flag value

* Update triggers/service/src/main/scala/com/digitalasset/daml/lf/engine/trigger/dao/DbTriggerDao.scala

Co-authored-by: Stephen Compall <stephen.compall@daml.com>

* Use fragment interpolation

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
Co-authored-by: Gary Verhaegen <gary.verhaegen@digitalasset.com>
Co-authored-by: Stephen Compall <stephen.compall@daml.com>
2021-10-04 17:02:36 +00:00
Gary Verhaegen
9641fd5f83
auth middleware: no print secret (#11050)
At the moment, the OAuth2 Middleware prints its config at startup.
Unfortunately that config includes a secret, which presumably we'd
prefer not to show.

CHANGELOG_BEGIN
- The OAuth2 Middleware now obfuscates its Client Secret when logging
  its config.
CHANGELOG_END
2021-09-28 17:00:01 +02:00
Stefano Baghino
1b473c2b9a
Switch trigger service time provider default to wall-clock time (#10967)
Fixes #10957

changelog_begin
[Triggers Service] The service now starts by default using wall-clock time instead
of static time. If you want to run using static time, you need to do so explicitly
using the new '-s' or '--static-time' CLI option. If you were already using '-w'
or '--wall-clock-time' the flag has no effect. It's anyway safe to leave it there.
changelog_end
2021-09-21 19:24:09 +00:00
Gary Verhaegen
b4750a495c
trigger reach auth on internal network (#10844)
In many network setups, there will be a more direct route for the
trigger service to contact the auth middleware than going back through
the frontend's public IP address (and possibly thus also through
intermediaries like an nginx reverse proxy etc.). In _some_ network
setups, it may not even be possible for the trigger service to reach the
auth middleware through its externally-visible address.

This PR caters to these cases by allowing the trigger service to use two
separate addresses for the auth middleware, an internal one the trigger
service uses when it needs to talk to the auth middleware, and an
external one used in generating URLs for external clients.

This is backwards-compatible: if the old option is used, we simply use
the same value for both.

CHANGELOG_BEGIN
- The Trigger Service can now accept separate `--auth-internal` and
  `--auth-external` CLI arguments, where `--auth-internal` is the
  address used by the Trigger Service to reach the Auth Middleware
  directly, and `--auth-external` is the address the Trigger Service uses
  in generated URLs sent back to the client. The `--auth` option remains
  and keeps working as before, setting both internal and external
  addresses to the same given value.
CHANGELOG_END
2021-09-14 14:16:42 +00:00
pbatko-da
6dcdaa411c
[DPP-589] Add CLI flag to select minimum enabled TLS version (#10854)
- Add support for specifying either 1.2 or 1.3 as minimum TLS versions for ledger api server.
- Log enabled protocols (~TLS versions) and cipher suites at server and client startup.
- Add integration tests against Sandbox-classic and Sandbox

CHANGELOG_BEGIN
Sandbox: Add CLI flag to select minimum enabled TLS version for ledger API server.
CHANGELOG_END
2021-09-14 12:37:38 +02:00
Hubert Slojewski
b50bb8e437
Populate definite_answer in ApiException [KVL-1004] (#10832)
CHANGELOG_BEGIN
CHANGELOG_END
2021-09-13 16:28:39 +00:00
Remy
1e1c452b36
LF: drop ad-hoc FrontStack builders (#10839)
Following #10763, we drop the ad-hoc builders for `FrontStack`.

* Building a `Fronstack` from individuals elements should be done with
  standard scala buidler.

* Building a `Fronstack` from a `TraversableOne` should be done with
  the scala 2.13 `.to(FrontStack)` methd

* Building a `Fronstack` from a `ImmArray` should be done with the
  `toImmArray` method.

CHANGELOG_BEGIN
CHANGELOG_END
2021-09-13 17:49:09 +02:00
Gary Verhaegen
8cdeb7539a
make auth middleware aware that actAs => readAs (#10825)
It seems a bit silly that the auth middleware would refuse a token that
has an `actAs` when it needs a `readAs`.

Reference: https://docs.daml.com/app-dev/authorization.html#access-tokens-and-claims

CHANGELOG_BEGIN
- The auth middleware will now consider that actAs credentials are valid
  for readAs requests.
CHANGELOG_END
2021-09-09 11:03:55 +00:00
Andreas Herrmann
1ff34ffbe8
Remove workaround for akka supervisor issue (#10818)
The workaround for https://github.com/akka/akka/issues/29841 is no
longer required as that issue has been fixed upstream and we have
updated to a version that includes the fix.

changelog_begin
changelog_end

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-09-08 17:55:57 +02:00
Andreas Herrmann
a1da025b78
FreePort draw from outside ephemeral port range (#10774)
* Test case for LockedFreePort not colliding with port 0

changelog_begin
changelog_end

* Discover dynamic port range on Linux

* Random port generator outside ephemeral range

* remove dev comments

* Draw FreePort from outside the ephemeral port range

Note, there is a race condition between the socket being closed and the
lock-file being created in LockedFreePort. This is not a new issue, it
was already present with the previous port 0 based implementation.

LockedFreePort handles this by attempting to find a free port and taking
a file lock multiple times.

But, it could happen that A `find`s port N, and obtains the lock, but
doesn't bind port N again, yet; then B binds port N during `find`; then
A attempts to bind port N before B could release it again and fails
because B still holds it.

* Select dynamic port range based on OS

* Detect dynamic port range on MacOS and Windows

* Import sysctl from Nix on MacOS

changelog_begin
changelog_end

* Windows line separator

* FreePort helpers visibility

* Use more informative exception types

* Use a more light weight unit test

* Add comments

* Fix Windows

* Update libs-scala/ports/src/main/scala/com/digitalasset/ports/FreePort.scala

Co-authored-by: Stefano Baghino <43749967+stefanobaghino-da@users.noreply.github.com>

* Update libs-scala/ports/src/main/scala/com/digitalasset/ports/FreePort.scala

Co-authored-by: Stefano Baghino <43749967+stefanobaghino-da@users.noreply.github.com>

* Add a comment to clarify the generated port range

* fmt

* unused import

* Split libs-scala/ports

Splits the FreePort and LockedFreePort components into a separate
library as this is only used for testing purposes.

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
Co-authored-by: Stefano Baghino <43749967+stefanobaghino-da@users.noreply.github.com>
2021-09-07 15:41:43 +02:00
Gary Verhaegen
b1c6e87803
fix claims check in auth middleware (#10768)
The claims check in the auth middleware was switched around: in effect,
it checked that we did not receive _more_ than we asked for, rather than
checking we receive _at least_ what we asked for.

Of course this would still not let anyone run any trigger without the
proper access token, but it would let people list running triggers and
request (or stop) trigger executions.

CHANGELOG_BEGIN
- Fix a bug in the auth middleware where insufficient credentials could
  still give access to list of running triggers.
CHANGELOG_END
2021-09-03 13:31:26 +00:00
Andreas Herrmann
7270ee3c71
Handle dynamic port in auth middleware client (trigger service) (#10755)
* Do not require redirect URI upfront

changelog_begin
changelog_end

This allows users to configure the redirect URI after the middleware
client binding occurred such that dynamic port selection can be taken
into account.

* Use port 0 in trigger service fixture

changelog_begin
changelog_end

* Update triggers/service/auth/src/test/scala/com/daml/auth/middleware/oauth2/TestMiddleware.scala

Co-authored-by: Stefano Baghino <43749967+stefanobaghino-da@users.noreply.github.com>

* Update triggers/service/auth/src/test/scala/com/daml/auth/middleware/oauth2/TestMiddleware.scala

Co-authored-by: Stefano Baghino <43749967+stefanobaghino-da@users.noreply.github.com>

* Update triggers/service/auth/src/test/scala/com/daml/auth/middleware/oauth2/TestMiddleware.scala

Co-authored-by: Stefano Baghino <43749967+stefanobaghino-da@users.noreply.github.com>

* Update triggers/service/auth/src/test/scala/com/daml/auth/middleware/oauth2/TestMiddleware.scala

Co-authored-by: Stefano Baghino <43749967+stefanobaghino-da@users.noreply.github.com>

* Update triggers/service/auth/src/test/scala/com/daml/auth/middleware/oauth2/TestMiddleware.scala

Co-authored-by: Stefano Baghino <43749967+stefanobaghino-da@users.noreply.github.com>

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
Co-authored-by: Stefano Baghino <43749967+stefanobaghino-da@users.noreply.github.com>
2021-09-02 18:06:48 +02:00
Stephen Compall
e5c4734780
enable JSON search index on Oracle by default (#10539)
* unconditionally enable JSON search index on Oracle

In '1kb of data' and larger Oracle integration tests:

ORA-29902: error in executing ODCIIndexStart() routine
ORA-20000: Oracle Text error:
DRG-50943: query token too long on line 1 on column 3

From https://docs.oracle.com/en/database/oracle/oracle-database/19/errmg/DRG-10000.html#GUID-46BC3B3F-4DB7-4EB4-85DA-55E9461966CB

    Cause: A query token is longer than 256 bytes

    Action: Rewrite query

* add changelog

CHANGELOG_BEGIN
- [JSON API] The Oracle database schema has changed; if using
  ``--query-store-jdbc-config``, you must rebuild the database by adding
  ``,start-mode=create-only``.  See #10539.
CHANGELOG_END

* test only 1kb

* extra flag in db config string

* let Queries backends configure themselves from maps

* new Queries constructor dataflow to better support config values

* remove fields as we go, isolating backend-specific from -agnostic conf

- we use StateT to avoid the problems that will definitely arise if we
  don't DRY.

* fix up DbConfig including DbStartupMode

* start to uncouple json-api's config from db-utils

* two JdbcConfigs with different purposes/scopes

- also moves db-utils contents to com.daml.dbutils

* adapt trigger service to refactoring

* fix JdbcConfig leftovers

* adapt http-json-cli to new JdbcConfig

* remove extra ConfigCompanion

* explain more about the QueryBackend/Queries distinction

* split SupportedJdbcDriver into two phases with a tparam

* use SupportedJdbcDriver.TC instead of SupportedJdbcDriver as the nullary typeclass

* patch around all the moved objects with imports

* missed import from moving ConnectionPool to dbutils

* use new 2-phase SupportedJdbcDriver for ContractDao setup

* left off part of a comment

* more q.queries imports

* other imports from the dbutils move

* nested JdbcConfig

* configure the driver in each backend-specific test

* very confusing error, but make the imports nicer and it goes away

* nested JdbcConfig in perf

* missing newline

* port contractdao-bench

* test new option parsing all the way through QueryBackend

* disable search index for some tests, enable for others

* add changelog

CHANGELOG_BEGIN
- [Trigger Service] ``--help`` no longer advertises unsupported JDBC
  options from JSON API.

- [JSON API] [EE only] By default, on Oracle, sets up a JSON search
  index to speed up the queries endpoints.  However, Oracle versions
  prior to 19.12 have an unrecoverably buggy implementation of this
  index; in addition, the current implementation fails on queries with
  strings >256 bytes, with no way to disable the index for that query.

  Pass the ``disableContractPayloadIndexing=true`` option as part of
  ``--query-store-jdbc-config`` to disable this index when creating the
  schema.
  See `issue #10539 <https://github.com/digital-asset/daml/pull/10539>`__.
CHANGELOG_END

* port failure tests

* init version table last, drop first

- suggested by @realvictorprm; thanks

* rename split DBConfig.scala

- suggested by @realvictorprm; thanks

* move imports to not be in alphabetical order

- suggested by @realvictorprm; thanks

* remove createSchema

- suggested by @realvictorprm; thanks

* Revert "test only 1kb"

This reverts commit 616e173e63.

* port to scala 2.12

- bug in unused imports

- old name `-` for `removed`
2021-08-31 09:29:36 +00:00
Remy
97bda3ca36
LF: V1 Contract ID check in Preprocessor (#10687)
This PR makes possible to reject V0 contract IDs during preprocessing.

CHANGELOG_BEGIN
CHANGELOG_END
2021-08-30 20:14:55 +02:00
Moritz Kiefer
f42e6b6877
Expose pending contracts in triggers (#10672)
fixes #10671

changelog_begin
changelog_end
2021-08-25 13:23:15 +00:00
nickchapman-da
387c68b9eb
Normalize transaction values within the engine (#10648)
Create normalized TXs when a partial TX is finalised.

Except in limited cases! (i.e for scenario-runner, sandbox)

CHANGELOG_BEGIN
CHANGELOG_END

normalize values in the engine as they are converted from speedy-values

fix 2.12 build

backout redundant change

ensure byKey field is correctly normalized when constructed by engine

rename flag: valueNormalization -> transactionNormalization

improve comment

delete commented-out code

rename: toValueNorm --> toNormalizedValue

rename: (SValue.) toValue --> toUnNormalizedValue

revert changes to ptx so that the interface to insertCreate() etc is Value-based (not SValue-based)

improve comments

respell: toUnNormalizedValue --> toUnnormalizedValue

fix build
2021-08-25 09:53:26 +01:00
Remy
b22de6893b
LF: Contract ID suffix check in Preprocessor (#10642)
This PR makes possible to check for contract IDs suffix during
preprocessing.

This is the first part of the task 3 described in #10504.

CHANGELOG_BEGIN
CHANGELOG_END
2021-08-24 18:45:33 +02:00
Samir Talwar
8dd136fc7d
bazel-tools: Replace runner with either runner_with_port_check or runner_with_port_file. (#10615)
* Use `extra` in the port file runner, rather than `temporary`.

* ledger-api-test-tool-on-canton: Use the port check runner.

Much simpler than the port file runner for our purposes.

* Replace `runner` with `runner_with_port_file`.

Rather than expecting a particular set of command-line-arguments, we use
templating.

CHANGELOG_BEGIN
CHANGELOG_END

* Rename the `runner_with_port_check` target to the default.
2021-08-18 15:23:45 +00:00
Gary Verhaegen
f8c0a35940
rewrite trigger docs to follow gsg (#10509)
* rewrite trigger docs to follow gsg

Per #10419 point 4, I've rewritten the Triggers section to build upon
the Getting Started Guide instead of inventing its own example.

Compared to #10395, this has a lot more explanations as this page must
now serve the dual purpose of being a possible "next step" from the GSG
and being the main reference page for triggers. It's also lost the "next
steps" section, which I think is a bit of a shame, but it doesn't really
make sense here.

There's also no easy way for people not interested in the GSG to follow
along; should we expose the "completed GSG" as a tempate?

CHANGELOG_BEGIN
CHANGELOG_END

* keep copy-trigger as a template

* fix copy-trigger project name

* make up gsg-trigger template

* remove awkward sentence, fix existing typo

* update code to use when{,Some}

* add  to

* swap emitCommands and getCommandsInFlight

* typo

* insist on state-correction perspective

* fix copy-trigger tests

* add back copy-trigger to whitelist

* add gsg-trigger to whitelist
2021-08-17 13:28:07 +00:00
Samir Talwar
4b8b67a1b5
Upgrade Scalatest to v3.2.9. (#10576)
* Upgrade Scalatest to v3.2.9.

Because of some coupling we also have to upgrade Scalaz to the latest
v7.2 point release, v7.2.33.

The Scalatest changes are quite involved because the JAR has been broken
up into several smaller JARs. Because Bazel expects us to specify all
dependencies and doesn't allow transitive dependencies to be used
directly, this means that we need to specify the explicit Scalatest
components that we use.

As you can imagine, this results in quite a big set of changes. They
are, however, constrained to dependency management; all the code remains
the same.

CHANGELOG_BEGIN
CHANGELOG_END

* http-json-oracle: Fix a Scalatest dependency.

* ledger-api-client: Fix a Scalatest dependency.
2021-08-12 23:19:35 +00:00
akshayshirahatti-da
b00e146aa0
[JSON-API/trigger-service] Refactor db conn (#10497)
* Move ExceptionOps from ledger-service/utils to //libs-scala/scala-utils

* extract connection and JdbcConfig from //ledger-service to independent db-utils module
Changelog_begin
Changelog_end

* update trigger service to use new libs-scala/db-utils

* missed changes for http-json-oracle

* minor cleanup based on comments

* fix breaking scala 2_12 build

* cleanup db-utils/BAZEL.md file
2021-08-09 09:56:58 +00:00
Samir Talwar
df78f9cb1e
Replace LedgerConfiguration with InitialLedgerConfiguration or the load timeout. [KVL-1058] (#10487)
* participant-integration-api: Encapsulate the initial configuration.

* participant-integration-api: Reduce usage of `LedgerConfiguration`.

* Inline `LedgerConfiguration` wherever it's used.

Most things don't need all its constituent parts; this reduces the
amount of unused properties.

CHANGELOG_BEGIN
- [Integration Kit] The ``LedgerConfiguration`` class has been
  removed in favor of ``InitialLedgerConfiguration``. Its usage
  has been changed accordingly, with the ``configurationLoadTimeout``
  property becoming part of ``ApiServerConfig`` instead.

  The default options provided by ``LedgerConfiguration`` have been
  removed; you are now encouraged to come up with sensible values for
  your own ledger. The ``Configuration.reasonableInitialConfiguration``
  value may help.
CHANGELOG_END

* Correct the initial configuration submission delay for KV ledgers.

* kvutils: Mark supertype unused parameters as unused.

* kvutils: Extract out common configuration submission delays.

These values are specific to kvutils; other drivers should come up with
their own.

* configuration: Delete `NoGeneration`, as it's unused.
2021-08-05 16:31:45 +00:00
Moritz Kiefer
b7cf42d173
Upgrade doobie to version 0.13.4 (#10326)
Was curious if there were any relevant performance improvements in
newer versions. Looks like the answer is no but we might as well
upgrade anyway.

changelog_begin
changelog_end
2021-07-20 19:19:11 +02:00
Remy
159728d716
LF: use Either by default in all archive reader API (#10295)
This is a follow up of #10277.
This is part of #9974.

CHANGELOG_BEGIN
CHANGELOG_END
2021-07-19 19:48:37 +02:00
Samir Talwar
bd12170af2
participant-state: Remove the ParticipantId, PackageId, and Party aliases. [KVL-1002] (#10308)
* participant-state: Remove the `ParticipantId` alias.

This alias adds nothing. By using `Ref.ParticipantId` directly, many
packages can remove their dependency on the _participant-state_ package.

CHANGELOG_BEGIN
CHANGELOG_END

* participant-state: Remove the `PackageId` and `Party` aliases.

They don't add anything. Let's just use `Ref`.

* kvutils: Restore missing compat imports.
2021-07-19 12:31:25 +00:00
Remy
a8f190214c
LF: change type from Try to Either in archive module (#10277)
* LF: change type from Try to Either in archive module

This is the first part of restructuring errors in archive module.
This is part of #9974.

CHANGELOG_BEGIN
CHANGELOG_END

* Apply suggestions from code review

Co-authored-by: Stephen Compall <stephen.compall@daml.com>

* remove type alias

* apply stephen suggestion

* fix after rebase

* fix test

Co-authored-by: Stephen Compall <stephen.compall@daml.com>
2021-07-14 19:24:31 +00:00
Remy
caf85a2270
LF: rationalize archive Parser/Reader/Decoder (#10239)
CHANGELOG_BEGIN
CHANGELOG_END
2021-07-14 11:05:17 +02:00
Samir Talwar
6c63f96ba9
participant-integration-api: Move SeedService here. (#10261)
I don't see a reason why it's part of the participant state API, and
it definitely doesn't need to change between v1 and v2.

CHANGELOG_BEGIN
- [Integration Kit] The class ``SeedService`` has been moved from the
  *participant-state* Maven package to the *participant-integration-api*
  Maven package, under the Java package name
  ``com.daml.platform.apiserver`` to reflect its usage by the API
  server, not the participant state API. If you use this class directly,
  you will need to change your imports.
CHANGELOG_END
2021-07-14 08:35:29 +00:00
Sofia Faro
b8e2198873
Separate traces from warnings in engine. (#10253)
* Separate traces from warnings in engine.

I decided to separate the engine warnings from the tracelog after all,
because I think it will make testing and maintenance easier in the
long run.

Part of #9947, follow up from #10179

changelog_begin
changelog_end

* scalafmt

* Apply suggestions from code review

Co-authored-by: Remy <remy.haemmerle@daml.com>

* dont use case class for WarningLog

* revert TraceLog changes from last PR

* Scala 2.12 doesnt have ArrayBuffer.addOne :(

* remove isWarnEnabled check

Co-authored-by: Remy <remy.haemmerle@daml.com>
2021-07-13 14:24:27 +00:00
Remy
f19f5b0821
LF: Simplify DarReader (#10217)
This PR simplifies a bit DarReader and UniversalDarReader

This is a follow up of #10208.

CHANGELOG_BEGIN
CHANGELOG_END
2021-07-08 17:03:45 +02:00
Remy
ebb76dca4c
LF: reorganize errors in com.daml.lf.archive (#10213)
* LF: reorganize errors in com.daml.lf.archive

part of #9974

CHANGELOG_BEGIN
CHANGELOG_END

* fix
2021-07-08 13:03:42 +00:00
Remy
41b8448b17
LF: Simplify archive reader. (#10208)
* LF: Simplify archive reader.

- decouple Reader and Decoder
- introduce case class to handle hash, proto payload, and version

CHANGELOG_BEGIN
CHANGELOG_END

* Address Moritz' review

* cosmetic
2021-07-07 19:56:40 +00:00
Samir Talwar
c929a14486
logging-entries: Split from contextualized-logging. [KVL-996] (#10149)
* logging-entries: Split from contextualized-logging.

This allows us to introduce it to Daml-LF without bringing in the
Logback, Logstash, and gRPC dependencies.

CHANGELOG_BEGIN
CHANGELOG_END

* logging-entries: Fix dependencies for 2.12.

* logging-entries: Missed one more Scala 2.12 dependency.

* release: Publish logging-entries.
2021-06-30 12:08:33 +00:00
Samir Talwar
c764fbe573
contextualized-logging: Introduce different logging types for more structure. [KVL-996] (#10134)
* contextualized-logging: Automatically convert logging values to strings.

For now, this has almost the same behavior, but it allows us to
customize the output in the future.

The main change is that the log format has gone from:

    context: {a=b, x=1, foo=bar}

to:

    context: {a: "b", x: "1", foo: "bar"}

* contextualized-logging: Move `writeTo` inside `LoggingValue`.

* contextualized-logging: Allow for more than just strings.

`null`, numbers, and sequences are now correctly logged.

The log format has gone from:

    context: {a: "b", x: "1", foo: "bar", parties: "[alice, bob]"}

to:

    context: {a: "b", x: 1, foo: "bar", parties: ["alice", "bob"]}

CHANGELOG_BEGIN
- The log output of Daml components has changed so that the structured
  part is closer to JSON. This allows us to distinguish and parse
  numbers and lists. If you are parsing this log output, you may need to
  change your parser.

  The log output has changed from:

  .. code-block::

     context: {a=b, x=1, foo=bar, parties=[alice, bob]}

  to:

  .. code-block::

     context: {a: "b", x: 1, foo: "bar", parties: ["alice", "bob"]}

CHANGELOG_END

* contextualized-logging: Extract the string serializer.

* Use non-string logging where possible.

* contextualized-logging: Split logging values from serialization.

So that callers don't have to know about Jackson.

* contextualized-logging: `SeqView` is `Iterable`. Don't need both.

* contextualized-logging: Make `ToStringToLoggingValue` a `val`.

Co-Authored-By: Stephen Compall <stephen.compall@daml.com>

* contextualized-logging: Add a transient dependency for 2.12 only.

This required more infrastructure than I thought it would.

* kvutils: Make it explicit that we're logging the hashes of archives.

The implicit was found to be a little confusing.

Co-authored-by: Stephen Compall <stephen.compall@daml.com>
2021-06-29 09:16:26 +00:00
Samir Talwar
af9382ce92
contextualized-logging: Reduce the API surface and avoid name collisions. (#10102)
* contextualized-logging: Remove `Map` from the `LoggingContextOf` API.

* contextualized-logging: Encapsulate entries.

CHANGELOG_BEGIN
CHANGELOG_END

* contextualized-logging: Disambiguate `withEnrichedLoggingContext`.

So forthcoming implicit conversions won't confuse the compiler.

* contextualized-logging: Remove a now-unused compat import.

* contextualized-logging: Avoid overloading `LoggingEntries#apply`.

* contextualized-logging: Remove the silencer plugin.
2021-06-24 16:21:26 +00:00
Stephen Compall
401069ef00
prepare for upgrade to Scalaz 7.3.3 (#9997)
* upgrade scalacheck to 1.14.3

* regenerate maven_install files

* some different names and implicits

* remove some fromTryCatchNonFatal

* more porting

* port fromTryCatchNonFatal to attempt

* factor the assertions in SignatureSpec to avoid \/

* deal with invariant \/

* make partial unification do what we want

* \/, parse*, and toNel

* many uses of the .right method

* a legitimate use of fromTryCatchThrowable

* rebuild maven pins

* further invariant \/

* OneAnd and Nel interface changes

* further Either games

* \/ and reformatting

* \/ in http-json

* \/ in http-json

* deprecations

* more invariance

* cleanup unused

* more invariance; http-json compiles

* final either follies

* small 2.12 extra incompatibility

* rebuild deps

* revisit a couple earlier fixes using nicer expressions I learned later

* no changelog

CHANGELOG_BEGIN
CHANGELOG_END

* repin 2.12
2021-06-15 14:41:48 -04:00
Rafael Guglielmetti
1dc8472017
Fix variable name (#9927)
Fix typos

CHANGELOG_BEGIN
Small fixes to the doc
CHANGELOG_END
2021-06-08 19:15:07 +02:00
Remy
7bc925e4d2
LF: Factorize the logic for AST lookup (#9871)
Factorize the logic for AST lookup in
 - compiler 
 - type checker 
 - preprocessor
 - script triggers 
 - some tests

CHANGELOG_BEGIN
CHANGELOG_END
2021-06-03 13:32:56 +02:00
Victor Peter Rouven Müller
beb2d138f2
Add cli option & system property to enable json only logging for http json service (#9725)
changelog_begin
- [Ledger HTTP Json Service] Logging output can now be in JSON either via providing the cli option `--log-encoder json` or via setting the env var `LOG_FORMAT_JSON=true`
changelog_end
2021-05-20 13:28:34 +00:00
Sofia Faro
2ba5ca7ca2
Make DA.Assert throw AssertionFailed instead of GeneralError (#9747)
* Make DA.Assert throw AssertionFailed instead of GeneralError

changelog_begin

- [Daml Standard Library] `assert`, `(===)`, and other assertion functions (see DA.Assert) now use a new `CanAssert` typeclass constraint instead of `CanAbort`, in preparation for exceptions support.

changelog_end

* Add CanAssert instances for Script and Trigger.

* buildifier-fix

* update script test runner output

* Fix flag and add tests.

* update script test runner again
2021-05-20 12:01:50 +00:00
Miklos
cd9933328a
runtime: Damlification of Scala files (#9668)
CHANGELOG_BEGIN
CHANGELOG_END
2021-05-17 10:28:50 +02:00
Stephen Compall
ca9e89b3da
check whether collection.compat is unused when compiling for Scala 2.12 (#9604)
* check whether collection.compat is unused when compiling for Scala 2.12

- Instead of always suppressing warnings for collection.compat._,
  we should only do it for Scala 2.13

- We can also reduce boilerplate by automatically adding this
  option when both silencer_plugin and collection-compat are
  present

CHANGELOG_BEGIN
CHANGELOG_END

* remove unused import

* remove another unused import

* remove even more unused imports

* missed compat dependency

* more missed compat dependencies

* missed compat dependency

* use scala_deps in scaladoc_jar

- #8423 inlined the major version expansion, but this seems to
  have been prior to proper support by scaladoc_jar

* restore custom handling of participant-integration-api

- fixing scaladoc_jar isn't worth it for a single case, as with
  deps vs scala_deps
2021-05-11 21:54:14 +00:00
Moritz Kiefer
4aca199bbd
Upgrade to Scala 2.13.5 (#9528)
changelog_begin
changelog_end
2021-04-29 13:05:57 +00:00
Moritz Kiefer
0075ff1899
Pass along tags in da_scala_test_suite (#9521)
changelog_begin
changelog_end
2021-04-28 09:14:27 +02:00
Samir Talwar
8cd3658b14
Switch to an environment variable for enabling Oracle tests. (#9511)
* participant-integration-api: Build Oracle tests, but don't run them.

CHANGELOG_BEGIN
CHANGELOG_END

* triggers: Switch to an environment variable for enabling Oracle tests.

* http-json: Switch to an environment variable for enabling Oracle tests.

* Disable running Oracle tests by default, not building them.

* triggers/service: Remove unused test dependencies.
2021-04-27 11:50:39 +00:00
Samir Talwar
e1af564bcc
Switch from @silent to @nowarn. (#9498)
* Switch from `@silent` to `@nowarn`.

This annotation is native to Scala 2.12.13+ and 2.13.2+. It replaces
most usages of `@silent`.

I had to get creative about a couple of use cases that didn't work.
Specifically:

  1.  Suppressing deprecation warnings works, but Scala 2.12 erroneously
      complains that the `@nowarn` is unnecessary.  I had to suppress
      this warning too with `-Ywarn-unused:-nowarn`.
  2.  I can't seem to suppress the warning, "The outer reference in this
      type test cannot be checked at run time." Instead, I have
      refactored the code to remove the warning.

We still need to use the silencer plugin to suppress some warnings about
unused imports (because of compatibility between Scala 2.12 and 2.13),
but this means we no longer need the library, and therefore it is not a
transitive dependency that downstream consumers need to worry about.

CHANGELOG_BEGIN
CHANGELOG_END

* Add some comments around `@nowarn` support.

* language-support/scala: Fix a warning suppression.

* Revert to the default warnings.

Compatibility was complaining.
2021-04-26 19:46:14 +00:00
Moritz Kiefer
f0f8027a47
Set supported jdbc driver names at compile time (#9489)
* Set supported jdbc driver names at compile time

This is mainly to unblock the work on Oracle support in the Ledger API
but I think it’s a sensible thing in general. For the Ledger API,
moving the dependency to the top-level is apparently rather
tricky. Because the SDK bundles everything into a single megajar,
Sandbox depending on the oracle library does also result in the JSON
API and the trigger service will also have the oracle library in scope
and will support Oracle in CE which they should not.

This PR simply hardcodes the list of supported drivers to address
that. Not pretty but does the job.

changelog_begin
changelog_end

* format

* Address review comments

changelog_begin
changelog_end
2021-04-26 09:19:31 +02:00
Moritz Kiefer
e84c954973
Expose Oracle support in the EE trigger service (#9342)
* Expose tho Oracle support in the EE trigger service

This PR builds on the previous PR that did all the actual work on
Oracle support and exposes it in the enterprise edition. This PR only
releases the enterprise edition via the SDK tarball. I’ll add
artifactory publishing separately.

changelog_begin
changelog_end

* Update daml-assistant/daml-sdk/validate.sh

Co-authored-by: Gary Verhaegen <gary.verhaegen@digitalasset.com>

Co-authored-by: Gary Verhaegen <gary.verhaegen@digitalasset.com>
2021-04-08 14:50:47 +02:00
Moritz Kiefer
f7b2f14294
Add Oracle support in the trigger service (#9286)
* Add Oracle support in the trigger service

This PR migrates the ddl & queries and adds tests for this. It does
not yet expose this to users. I’ll handle that in a separate PR.

changelog_begin
changelog_end

* use getOrElse

changelog_begin
changelog_end
2021-03-31 18:39:08 +02:00
Moritz Kiefer
5d88c08832
Bump ghcide (#9041)
* Bump ghcide

Includes https://github.com/digital-asset/daml-ghcide/pull/13 meaning
we can now remove the hacks for missing signatures

changelog_begin

- [Daml Compiler] Fix a bug where passing `--ghc-option=-Werror` also
  produced errors for warnings produced by `-Wmissing-signatures` even
  if the user did not explicitly enable this.

changelog_end

* Bump to merged commit

changelog_begin
changelog_end
2021-03-05 18:17:28 +01:00
Moritz Kiefer
0281b442b8
-Werror all the things (#9027)
We used to do this for some packages but it broke cpp. I don’t
actually know why it doesn’t do that anymore but I’ll gladly accept
that fact and turn it on everywhere.

changelog_begin
changelog_end
2021-03-04 19:08:59 +01:00
Andreas Herrmann
c7ee410fa3
Use DA.Map in triggers if available (#9023)
* Use DA.Map in triggers if available

Replaces DA.Next.Map by DA.Map in the trigger library if the DAML-LF
version supports it, i.e. above 1.11.
Selects on `DAML_GENMAP` and `DAML_GENERIC_COMPARISON` using `CPP`.

changelog_begin
- [Triggers] The trigger library now uses `DA.Map` instead of the
  deprecated `DA.Next.Map` if the targeted Daml-LF version supports it.
  This is a breaking change: Code that interfaced with the triggers
  library using `DA.Next.Map`, e.g. with
  `Daml.Trigger.getCommandsInFlight` or `Daml.Trigger.Assert.testRule`,
  will need to be changed to use `DA.Map` instead.
changelog_end

* Deduplicate GMap imports in triggers

* DA.Next.Map --> DA.Map in carbon-upgrade-trigger

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-03-04 14:15:01 +01:00
Remy
a9b035e92e
LF: release LF 1.12 (#8856)
CHANGELOG_BEGIN

    - [LF] Release LF 1.12. This version reduce the size of transaction

    - [Compiler]: Change the default LF output from 1.8 to 1.11.

CHANGELOG_END
2021-02-24 21:17:33 +01:00
Moritz Kiefer
40e1a39f2c
Port //triggers/... to Scala 2.13 (#8781)
changelog_begin
changelog_end
2021-02-09 13:35:05 +01:00
Stefano Baghino
42e071f2c2
Add //libs-scala/doobie-slf4j and replace usages of jdkLogHandler (#8731)
The jdkLogHandler provided by Doobie exists purely as an example and the library
itself does not recommend using it in production.

Note that this slightly changes the runtime behavior, logging successful queries
at debug level rather then info. The message itself is preserved from the original
MIT-licensed example.

This uses Slf4j as most of our components, instead of java.util.logging.

changelog_begin
[HTTP JSON API] The server now logs successful queries at debug level
instead of info
[Trigger Service] The server now logs successful queries at debug level
instead of info
changelog_end
2021-02-03 10:45:05 +00:00
Andreas Herrmann
a226324afa
Use cliopts.Http for OAuth 2.0 middleware (#8671)
* Use cliopts.Http for OAuth 2.0 middleware

changelog_begin
- [OAuth 2.0 Middleware] You can now configure the address that the
  middleware listens to using the ``--address`` flag.
  The port that the middleware listens to is now configured using the
  ``--http-port`` flag, use 0 to dynamically choose a free port.
  You can now configure a port file where the chosen port will be
  written to using the ``--port-file`` flag.
changelog_end

* Add test-case for OAuth 2.0 middleware port file

* Don't forget to close source

* Fix integration test

* Update triggers/service/auth/src/main/scala/com/daml/auth/middleware/oauth2/Config.scala

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2021-01-29 09:32:07 +00:00
Remy
de14275528
triggers: do not use the type information from SRecord (#8623)
This type information is there for debugging purpose, one should not
use it.  We use type from SAny instead.

CHANGELOG_BEGIN
CHANGELOG_END
2021-01-26 12:08:53 +01:00
Andreas Herrmann
5706f5e15d
Drop early access tag on trigger service and auth middleware (#8611)
* add livez endpoint to auth middleware

* Add OAuth 2.0 middleware to Daml SDK

* unhide trigger service auth flags

changelog_begin
- [Triggers] The trigger service now supports authorization through an
  auth middleware. The feature is enabled using the `--auth` and
  `--auth-callback` command-line flags. Please refer to the
  Authorization chapter of the trigger service documentation for further
  instructions.
- [OAuth 2.0 middleware] Daml Connect now includes an implementation of
  the auth middleware API that supports OAuth 2.0 Authorization Code
  Grant. Please refer to the Auth Middleware and OAuth 2.0 Auth
  Middleware chapters of the documentation.
changelog_end

* drop early access flag on triggers

Daml triggers, the trigger service, and the auth middleware are no
longer marked as early access features.

changelog_begin
- [Triggers] Daml Triggers and the Trigger Service are no longer in
  early access status.
changelog_end

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-01-22 17:02:24 +01:00
Gary Verhaegen
ce8c38bac1
copyright updates (#8610)
CHANGELOG_BEGIN
CHANGELOG_END
2021-01-22 15:03:36 +00:00
Andreas Herrmann
7543c6fdc0
Document authorization with trigger service (#8581)
* Docs for trigger-service auth and auth middleware

changelog_begin
changelog_end

* Document OAuth 2.0 authorization middleware

* Explain 401 Unauthorized resonse

* Add JS frontend example

* Update docs/source/tools/auth-middleware/index.rst

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>

* Update docs/source/tools/auth-middleware/index.rst

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>

* Update docs/source/tools/auth-middleware/index.rst

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>

* Update docs/source/tools/auth-middleware/index.rst

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>

* Update docs/source/tools/auth-middleware/oauth2.rst

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>

* trigger service don't redirect by default

3a5dba7a70 (r562497928)

* Call it Auth Middleware

https://github.com/digital-asset/daml/pull/8581#discussion_r562442571

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2021-01-22 11:53:26 +01:00
Andreas Herrmann
33e13aeb3d
Improve browser compatbility of auth middleware (#8590)
* Include auth challenge in response body

changelog_begin
changelog_end

Some browsers make it difficult to access the `WWW-Authenticate`
response header from Javascript. For example, Firefox 84.0.2 (64-bit) on
Linux does not expose the `WWW-Authenticate` header in the result of the
`fetch` function, independent of the server's access control headers.
In that case the header is only accessible through the `XMLHttpRequest`
API, which is more cumbersome to use.

This adds the challenge to the response body in JSON format as well to
avoid exposing users to any such browser related issues.

* Make Secure Set-Cookie attribute configurable

changelog_begin
changelog_end

Since Chrome 80 Set-Cookie with the Secure attribute enabled is rejected
for connections that don't use https [1]. This includes localhost.
Firefox, at least as of version 84.0.2, allows such cookies on
localhost.

This adds a command-line flag to the authorization middleware to make
the value of the Secure attribute configurable. This way it can be
disabled for development purposes.

[1]: https://blog.chromium.org/2019/10/developers-get-ready-for-new.html

* Expand description on --cookie-secure flag

* Fix TriggerServiceFixture

* Fix middleware TestFixture

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-01-21 16:10:09 +00:00
Andreas Herrmann
199c52fd79
Don't always redirect to /login automatically (#8532)
* Don't always redirect to /login automatically

The redirect mode can be configured to never redirect, always redirect,
or redirect based on the request type (redirect for text/html).

In case of no redirect the auth middleware client will reply with 401
Unauthorized with a custom WWW-Authenticate challenge to login on the
auth middleware.

* Make login to redirect configurable on trigger service

By default the trigger service will redirect for HTML requests and not
redirect for JSON requests. The test suite uses automatic redirect as
the OAuth2 test server works without user interaction.

changelog_begin
changelog_end

* Preserve path and query in authMiddlewareUri

This is necessary if the auth middleware lies behind a reverse proxy
with a path prefix or a similar setup.

* Bump default auth middleware login timeout

One minute was to short for a login cycle that requires manual user
input.

* Set token cookie properties

`path = "/"` is required so that the `/login` endpoint can reliably
override the cookie value for other endoints such as `/cb` or
`/v1/triggers`.

* Test redirectToLogin modes

* Redirect on HTML

https://github.com/digital-asset/daml/pull/8532#discussion_r559368335

* Use pass/reject in onRedirectToLogin

8db2bff9af (r559370308)

* default login timeout 5min

https://github.com/digital-asset/daml/pull/8532#discussion_r559535511

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-01-18 14:03:39 +00:00
Moritz Kiefer
427ea0fb7d
Remove redundant list of LF versions (#8490)
* Remove redundant list of LF versions

After #8472, I realized that there must be a list used for daml-stdlib
and daml-prim already and it turns out there is. I’ve removed that one
in favor of the one added in #8472 since I like having all in one
place and the one from #8472 is created by filtering an existing list
instead of creating a completely separate list like we do here.

changelog_begin
changelog_end

* Introduce SCRIPT_LF_VERSIONS

changelog_begin
changelog_end
2021-01-13 13:21:39 +00:00
Andreas Herrmann
7855b023ac
Oauth template (#8453)
* Use ActorSystem and ExecutionContext from RequestContext

* Factor out middleware server class

To avoid passing around config and state manually.

changelog_begin
changelog_end

* Depend on databricks/sjsonnet

changelog_begin
changelog_end

* Generate request params from jsonnet template

changelog_begin
changelog_end

* Split middleware test suite sources

* Add test suite for request templates

* fmt

* TriggerServiceFixture template arguments

* Use null to indicate missing applicationId claim

Addressing
https://github.com/digital-asset/daml/pull/8453/files#r555025173

* Fix invalid path on Windows

* Close request template source

* Avoid repeated re-reading of Jsonnet files

https://github.com/digital-asset/daml/pull/8453/files#r555044262

* Factor out template argument mappings

* factor out template error handling

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-01-11 17:27:46 +00:00
Moritz Kiefer
22ce940954
Upgrade scalafmt and enable trailing commas (#8437)
This PR updates scalafmt and enables trailingCommas =
multiple. Unfortunately, scalafmt broke the version field which means
we cannot fully preserve the rest of the config. I’ve made some
attempts to stay reasonably close to the original config but couldn’t
find an exact equivalent in a lot of cases. I don’t feel strongly
about any of the settings so happy to change them to something else.

As announced, this will be merged on Saturday to avoid too many conflicts.

changelog_begin
changelog_end
2021-01-09 11:37:37 +01:00
Bernhard Elsner
cda93db944
Daml case and logo (#8433)
* Replace many occurrences of DAML with Daml

* Update docs logo

* A few more CLI occurrences

CHANGELOG_BEGIN
- Change DAML capitalization and docs logo
CHANGELOG_END

* Fix some over-eager replacements

* A few mor occurrences in md files

* Address comments in *.proto files

* Change case in comments and strings in .ts files

* Revert changes to frozen proto files

* Also revert LF 1.11

* Update get-daml.sh

* Update windows installer

* Include .py files

* Include comments in .daml files

* More instances in the assistant CLI

* some more help texts
2021-01-08 12:50:15 +00:00
Andreas Herrmann
ef26c08ef8
Make auth callback state bounded (#8351)
* Bounded auth middleware client callback store

changelog_begin
changelog_end

* Json format for login response

* Add middleware client binding to test fixture

* Test middleware client callback store size

* Make max auth callbacks and timeout configurable on trigger service

changelog_begin
changelog_end

* Bounded pending login requests at auth middleware

* Make max logins and timeout configurable on middleware

* Test middleware login store size

* fmt

* Fix Windows

failed with `"localhost" != "127.0.0.1"`. Hardcode "localhost" to avoid
platform specific resolution.

* Use FiniteDuration for login timeout

* Respond with 503 on full login request store

Addresses https://github.com/digital-asset/daml/pull/8351#pullrequestreview-560859604

* Add tests for RequestStore

* Lower DefaultMaxLoginRequests

b48050eb91 (r552649275)

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-01-06 16:02:05 +00:00
Gary Verhaegen
a925f0174c
update copyright notices for 2021 (#8257)
* update copyright notices for 2021

To be merged on 2021-01-01.

CHANGELOG_BEGIN
CHANGELOG_END

* patch-bazel-windows & da-ghc-lib
2021-01-01 19:49:51 +01:00
Remy
9ba146a3e4
LF: Preview of LF 1.11 (#8280)
First step of LF 1.11 release #7139

Preview version is not stable and cannot be used in the ledger only in dev mode.

CHANGELOG_BEGIN
CHANGELOG_END
2020-12-18 17:08:22 +01:00
Andreas Herrmann
20cf6fcbd0
Make auth callback URIs configurable (#8342)
* Make middleware callback URI configurable

changelog_begin
changelog_end

* Make trigger service callback URI configurable

changelog_begin
changelog_end

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2020-12-18 14:39:27 +00:00
Andreas Herrmann
652c9428ed
Use execution context, actor system, and materialzer from request context in route (#8300)
* Extract actor system and execution context from request context

* Extract actor system and execution context from request context

* Extract actor system, materializer, and execution context from request context

changelog_begin
changelog_end

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2020-12-16 09:41:42 +01:00
Sofia Faro
e52c2a0252
Bundle ghcversion.h and hpp with damlc. (#8278)
* Bundle hpp with damlc.

This PR eliminates the red squiggly lines you get when opening up the
standard library in daml studio (e.g. after a Go To Definitien).

(When CPP is used, Go To Definition is still pointing to the wrong place,
because the line numbers are messed up. But it's better than having a
million error messages.)

We could also remove --cpp flag in a separate PR, though that may be
considered a breaking change.

changelog_begin
changelog_end

* cleanup locateRunfiles jank

* Revert "cleanup locateRunfiles jank"

This reverts commit 82552003ae.
2020-12-14 17:23:41 +00:00
Gary Verhaegen
73724bccb8
protect trigger migrations (#8265)
This prevents the `dade-copyright-headers` script from changing those
files (and from checking them for copyright headers, unfortunately).

CHANGELOG_BEGIN
CHANGELOG_END
2020-12-11 17:05:37 +01:00
Andreas Herrmann
d3b4042ade
Factor out the middleware client from the trigger server (#8244)
* Factor out authorization middleware client

changelog_begin
changelog_end

* Factor out token refresh

* Factor out auth request

* Factor out auth middleware URIs

* factor out auth directive

* Factor out login directive

* Add login response type to api library

* Allow error handling in login callback

* Factor error handling out of authorize directive

* Move tagged token types into middleware api

* Factor out the auth middleware client

* Dedicated exception types in middleware client

* Handle auth middleware client exception

Restores the behavior of authorize before factoring out the client

* expose middleware URIs

* Use the middleware client in the middleware tests

* Use localhost/CALLBACK in testing

https://github.com/digital-asset/daml/pull/8244#discussion_r540328001

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2020-12-10 17:26:06 +00:00
Andreas Herrmann
bd09e8265d
Require authorization on DAR upload endpoint (#8193)
* Test authentication on upload_dar endpoint

changelog_begin
changelog_end

* require authentication on upload_dar endpoint

* push Directive into auth

* Fully upload request before auth redirection

* Make HTTP entity upload parameters configurable

changelog_begin
changelog_end

* Shorten help message

https://github.com/digital-asset/daml/pull/8193#discussion_r538428368

* maxHttpEntityUploadSize as Long

https://github.com/digital-asset/daml/pull/8193#discussion_r538431773

* use DefaultMaxInboundMessageSize for DefaultMaxHttpEntityUploadSize

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2020-12-08 18:09:06 +01:00