Commit Graph

451 Commits

Author SHA1 Message Date
Stephen Compall
dc204a37a7
remove known command ID from trigger state once Transaction and Completion message are seen (#7598)
- no assumption about order

- multiple transactions/completions are treated as one

CHANGELOG_BEGIN
CHANGELOG_END
2020-10-07 18:32:49 +00:00
Stephen Compall
ff706d5762
Trigger monad's Submit emits a command ID instead of accepting one (#7587)
* make TriggerF's Submit emit a command ID instead of accepting one

- LowLevel updated

- interpreter in Scala updated, preserving Message semantics as closely as possible

* remove nextCommandId and all management from high-level Trigger API implementation

* a note about TriggerF and simulateRule

* port submitCommands calls from tests

CHANGELOG_BEGIN
- [Triggers] The CommandIds as accessed from trigger DAML code are now exactly the command
  IDs used in command submission to the ledger; as such, they will vary randomly from run
  to run of the trigger rule.  To enable this, the low-level ``submitCommands`` function
  no longer accepts a command ID, instead returning one; there is no change to the
  corresponding high-level ``emitCommands`` function, so high-level triggers should only
  see improved and easier-to-understand logging.
  See `issue #7587 <https://github.com/digital-asset/daml/pull/7587>`__.
CHANGELOG_END

* port Scala-side assertion of trigger test

* rename commandIdMap to commandIdsUsed

* test that command IDs are like the ones we expect from the runner
2020-10-07 08:34:41 -04:00
Andreas Herrmann
8dee7ac9fc
Make trigger service auth middleware /login endpoint compatible with Auth0 (#7565)
* Make /login endpoint compatible to auth0

- Make the authorization and token endpoints configurable
- Use `application/x-www-form-urlencoded` as specified in
  https://tools.ietf.org/html/rfc6749#section-4.1.3
- Check the status code of the token endpoint response
- Fix the type of the token's `expires_in` field
  (`Int` instead of `String)

changelog_begin
changelog_end

* Add Auth0 testing instructions

* Use native application type on Auth0

* scope to claims mapping todo note

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2020-10-05 13:44:46 +00:00
Stephen Compall
0e71a2d3d2
interpret allowed updates and other actions in a free Trigger monad, like Script (#7456)
* conservatively move daml-script, trigger SValue interpreters to common library

* introduce expect and JavaList pattern for converters

* clean up trigger Converter Command interpretation

* add Church Free monad

* add an action language for trigger updates

* add expectE to remove some of the joins

* convert more of the converters to expect

* tool for unrolling Free/Roll

* split handleStepResult up and clean up its pattern

* handleStepFreeResult to interpret TriggerF

* replace Free Church with Pure/Roll free from Script

* newtype for ActionTrigger

* replace update in low-level Trigger with Free TriggerF

* submit one Commands at a time

* boolean blindness strikes again

* log missed TriggerF steps

* comment actual Submit contents

* match #7501 fromPureSExpr sig change in 00b80b8ea3

* avoid using forwardPort in runTrigger

* push State back into DAML, so it can be excluded from the action list

* push Message back into DAML, unifying the action language for initialState and update

* bringing TriggerF into initial state

* really add TriggerF into initial state, with all ports, tested

* add ActionTrigger class, express initialState in its terms

* add all TriggerF actions to existing TriggerA

* Trigger.rule will no longer have Time argument

* rename getS, setS to get, put, matching C.M.T.State from transformers

* make high-level Rule evaluate to the underlying TriggerF sequence

* Assert's testRule doesn't have a transform yet

* move DamlTuple2 to common converter library

- suggested by @cocreature; thanks

* combine the two Frees, provide from Script

* remove time argument from integration tests

CHANGELOG_BEGIN
- [Triggers] The ``Time`` argument was removed from the trigger rule function; instead, it
  can be fetched within the ``TriggerA`` ``do`` block by ``getTime``, as with ``Update``
  and ``Scenario``.  The ``LowLevel`` trigger interface has been redesigned; such triggers
  need to be rewritten or ported to high-level triggers.
  See `issue #7456 <https://github.com/digital-asset/daml/pull/7456>`_.
CHANGELOG_END

* add trigger rule simulator to support Assert module

* missed new Free module

- left in script per @cocreature

* remove retract as we ended up using foldFree for that purpose instead

- suggested by @cocreature; thanks

* throw ConverterException instead of RuntimeException

- suggested by @cocreature; thanks

* remove Time argument from coin-upgrade-trigger

* port trigger service tests

* port trigger scenario test

* put TriggerSetup and TriggerRule into LowLevel.Trigger instead of unboxed Free

- suggested by @cocreature; thanks

* remove Time argument from trigger compatibility test

* submit commands as soon as each `emitCommands` is sequenced

- we still collect a list, but only for tracking commandsInFlight

* filter out compatibility tests for triggers before now

* remove commented imports, libraries from new shared converter

* make the TriggerF interpreter tail-recursive

* remove unused compatibility trait

* add back new state logging

* remove refactoring comment

* rewrite some LowLevel initialStates in do

* hide Daml.Script.Free from docs

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

* remove forwardPortInitialState

- suggested by @cocreature; thanks

* manually port low-level updates

- suggested by @cocreature; thanks

* remove forwardPort

- suggested by @cocreature; thanks

* fail faster on unrecognized TriggerF

- suggested by @cocreature; thanks

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2020-10-02 14:18:13 -04:00
Moritz Kiefer
e6c43c798f
Document cookie passing in trigger service auth (#7554)
This has come up 2 times now so seems sensible to point this out
explicitly.

changelog_begin
changelog_end
2020-10-02 14:46:53 +02:00
Andreas Herrmann
c5abcece56
trigger service auth /auth endpoint (#7545)
* Factor out request bodies

Addressing review comment
https://github.com/digital-asset/daml/pull/7519#discussion_r497321689

* Implement /auth endpoint

changelog_begin
changelog_end

* /auth check the required claims

* Factor out middlewareUri

* fmt

* less implicit variables

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2020-10-01 15:10:38 +00:00
Andreas Herrmann
5a4f1d5d18
trigger service auth /login endpoint (#7519)
* trigger service auth /login endpoint

changelog_begin
changelog_end

* Configure client id and secret through environment

Addressing review comment
https://github.com/digital-asset/daml/pull/7519#discussion_r497303019

* Single flag for OAuth2 server URI

Addressing review comment
https://github.com/digital-asset/daml/pull/7519#discussion_r497301985

* Explain redirectUri in comments

Addressing review comment
https://github.com/digital-asset/daml/pull/7519#discussion_r497305958

* TODO configurable redirect URI

Addressing review comment
https://github.com/digital-asset/daml/pull/7519#discussion_r497318955

* Verify that cookie holds a token

Addressing review comment https://github.com/digital-asset/daml/pull/7519#discussion_r497328320

* fmt

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2020-09-30 11:38:54 +00:00
Moritz Kiefer
00b80b8ea3
Separate off-ledger ond on-ledger speedy (#7501)
* Separate off-ledger ond on-ledger speedy

changelog_begin
changelog_end

* Add OnLedgerBuiltin abstract class

changelog_begin
changelog_end

* fix typo

changelog_begin
changelog_end

* Fix borked rebase

changelog_begin
changelog_end

* Remove unscoped withOnLedger

changelog_begin
changelog_end
2020-09-29 10:05:45 +00:00
Remy
a899e5e4e6
Speedy: Check language version as part of Speedy compilation. (#7440)
Additionnally
+ move allowedLanguageVersion inside compiler config
+ add missing catch error insde
  ConcurrentCompiledPackages#addPackageInternal
+ implement EngineConfig method to easily produce a Compiler.Config

CHANGELOG_BEGIN
CHANGELOG_END
2020-09-22 12:43:48 +02:00
Stephen Compall
a670e68c72
add 'alter' function to DA.Map (#7427)
* add 'alter' function to DA.Map

CHANGELOG_BEGIN
CHANGELOG_END

* swap arguments for alter

- suggested by @cocreature; thanks

* alter moved to stdlib, remove from trigger lib

* use markdown formatting for alter doc

- suggested by @sofiafaro-da; thanks

* fix code block formatting

- suggested by @sofiafaro-da; thanks
2020-09-17 16:46:37 +00:00
Stephen Compall
1926ddbe9d
avoid ACS linear contract ID lookups in Trigger library (#7425)
* add Ord (ContractId a) instance

* change inner list in activeContracts to map

* adapt Internal module to new map

* support rest of Trigger daml lib

* rename adjust to alter, its Data.Map name

* no changelog

CHANGELOG_BEGIN
CHANGELOG_END

* distribute type arguments for ACS activeContracts

- suggested by @cocreature; thanks

* swap arguments for alter

- suggested by @cocreature; thanks

* reformat groupActiveContracts signature

- suggested by @cocreature; thanks
2020-09-17 15:31:03 +00:00
Moritz Kiefer
b6673b6b4d
Add design doc for authentication in the trigger service (#7394)
* Add design doc for authentication in the trigger service

This is a draft of how I currently imagine authentication in the
trigger service to work. Since the authentication middleware has to be
pluggable in the end anyway we need public documentation in the end
anyway and I find this much easier to manage than a google doc outside
of the repo which just never sees updates.

changelog_begin
changelog_end

* Update triggers/service/authentication.md

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

Co-authored-by: Stephen Compall <stephen.compall@daml.com>
2020-09-16 15:57:26 +02:00
Stephen Compall
09014dc637
use GenMaps for trigger ACS (#7365)
* use GenMaps for trigger ACS

* Next removed for 1.dev

* temp port trigger test code to 1.dev only

* run trigger tests on 1.dev only

* move pending back to TextMap

* include trigger service in the 1.dev test lineup

- it takes >2min, so shouldn't be permanent

* add Ord TypeRep and Ord TemplateTypeRep when possible

* swap names in Internal to reduce the diff

* try to enable cpp for triggers compilation

$ bazel build //triggers/daml:daml-trigger-1.dev
<snip>
File:     daml/Daml/Trigger/Internal.daml
Hidden:   no
Range:    103:-1-103:-1
Source:   CPP
Severity: DsError
Message:  22 in hpp-0.6.1:Hpp.CmdLine
File:     daml/Daml/Trigger.daml
Hidden:   no
Range:    103:-1-103:-1
Source:   CPP
Severity: DsError
Message:  22 in hpp-0.6.1:Hpp.CmdLine
ERROR: Creation of DAR file failed.
<snip>

* remove problematic options for invoking cpp

hpp: Couldn't open input file: -Werror
CallStack (from HasCallStack):
  error, called at src/Hpp/CmdLine.hs:103:22 in hpp-0.6.1:Hpp.CmdLine

* enough cpp so default and 1.dev triggers compile

* cpp needed for docs as well

* no changelog

CHANGELOG_BEGIN
CHANGELOG_END

* return trigger service to testing against sdk default lf version

* run trigger integration test against sdk default and LF 1.dev

* return trigger scenario test to SDK default LF version

* avoid import warnings in trigger lib

* Windows manifests a missing file differently. Hilarious
2020-09-15 12:30:23 -04:00
Moritz Kiefer
c0b6851abe
Generate hoogle docs for daml script/triggers (#7371)
* Generate hoogle docs for daml script/triggers

This PR switches over the documentation generation for daml script and
daml triggers to the multi-page format we already use for the standard
library and extends it to also generate hoogle documentation.

All 3 hoogle files are combined in a single hoogle_db.tar.gz archive.

Since the location in the multi-page format is different, I’ve added
redirects.

I verified locally, that I can generate the hoogle database and that
the links point to the right places.

changelog_begin
changelog_end

* Fix baseurl for daml-stdlib

changelog_begin
changelog_end
2020-09-10 15:58:15 +02:00
Moritz Kiefer
3171bb588a
Migrate trigger assertion library to DAML Script (#7318)
This is clearly a breaking change but triggers are still alpha so we
can get away this (confirmed with Bernhard).

changelog_begin

- [DAML Trigger] Daml.Trigger.Assert now uses DAML Script instead of scenarios.

changelog_end
2020-09-04 13:48:50 +02:00
Stephen Compall
0b72b6f716
more trigger service logs; tagged LoggingContext (#7205)
* get a LoggingContext into the TriggerRunnerImpl

* make some implicits more implicitly scoped and explicitly ascribed

* make some private/final markings

* most of JsonFormat[Identifier] is in companion

* experimental LoggingContext with phantom type

* ActorContext#log isn't really doing that much

* more details of LoggingContextOf

* make LoggingContextOf compile

* add trigger message logging, yet without context

* fix parent compile errors

* use Config as the phantom for its own logging extensions

* LocalDateTimeFormat cleanup

* switch TriggerRunner to contextual logging

* add trigger definition ID to logs

* log trigger-submitted commands, fix trigger test compile

* log trigger stopping and DAR uploads

* add context to PostStop/PreRestart logs

* add changelog

CHANGELOG_BEGIN
- [Triggers] More detailed logging of trigger actions and trigger service actions.
  See `issue #7205 <https://github.com/digital-asset/daml/pull/7205>`_.
CHANGELOG_END

* missed copyright header

* switch to Unit, scala/bug#9240 fixed
2020-09-03 17:47:09 +00:00
Samir Talwar
2b3cf1b3c0
ledger-api-client: Rename maxInboundMessageSize to maxInboundMetadataSize. (#7290)
* ledger-api-client: `maxInboundMessageSize` -> `maxInboundMetadataSize`.

CHANGELOG_BEGIN
- [Scala Bindings] Rename a field in the ``LedgerClientConfiguration``
  to ``maxInboundMetadataSize``, to match the builder Netty channel
  builder. It was incorrectly named ``maxInboundMessageSize``, which is
  a different channel property that configures the maximum message size,
  not the header size.
CHANGELOG_END

* ledger-api-client: Introduce a `maxInboundMessageSize` config property.

We use this a lot; easier if it's in the configuration.

CHANGELOG_BEGIN
- [Scala Bindings] Replace the
  ``LedgerClientConfiguration.maxInboundMessageSize`` property with a
  new one that represents the maximum size of the response body.
CHANGELOG_END
2020-09-02 08:41:34 +00:00
Moritz Kiefer
1df6ff49e3
Add a dummy OAuth2 authorization server (#7250)
* Add a dummy OAuth2 authorization server

This is intended for use in the trigger service integration tests not
as an artifact that we ship to users.

changelog_begin
changelog_end

* Address review feedback

changelog_begin
changelog_end
2020-08-28 17:28:06 +02:00
Moritz Kiefer
6e4f101aad
Remove ref-ledger-authenticator from trigger service (#7226)
* Remove authentication service from trigger service

This rips out the integration with ref-ledger-authenticator and
together with that the weird http basic auth which doesn’t actually
work for ref-ledger-authenticator outside of its testing mode and also
includes some very sketchy stuff like storing user
passwords (encrypted but still).

While the exact details of the new approach towards auth are still not
completely clear, it is clear that it is going to be sufficiently
different from what we did before that starting from a clean slate is
easier.

changelog_begin

- [Trigger Service] Parties are now specified in request bodies as
  opposed to via HTTP Basic auth. This is done in preparation for
  running the trigger service against authenticated ledgers.

changelog_end

* Fix integration tests

changelog_begin
changelog_end
2020-08-27 15:36:59 +02:00
Remy
89770cf1c1
Speedy: make the field names from SRecord immutable. (#7225)
CHANGELOG_BEGIN
CHANGELOG_END
2020-08-25 17:02:27 +02:00
Stephen Compall
2369a3bbae
use sandbox-style flyway migrations for trigger service (#7092)
* depend on flyway in trigger service; duplicate FlywayMigrations from sandbox

* bring in postgres/h2 detection, other data-source elements needed; use scalalogging

* use DataSource instead of DriverManager for DbTriggerDao, pass to flyway too

- initialization order isn't quite right yet

* hardcode postgres in triggers flyway path

* found an init order that doesn't fail in tests

* better pools for production, and don't forget to close them

* move most init SQL to first migration file

* make logHandler implicit again

- seems to have been an accidental implication of #6334

* move remaining create to V1__Init.sql

* use Prod poolSize

* prove that PostStop signals are never seen (in tests)

* move all the shutdown to Stop message

* remove dead code in DbFlywayMigrations

* always "initialize" database

CHANGELOG_BEGIN
- [Trigger Service] The database format has changed to allow migrations in
  future releases.  Databases are always initialized or migrated to the current
  version on start, so use of ``--init-db`` is no longer required.
  See `issue #7092 <https://github.com/digital-asset/daml/pull/7092>`__.
CHANGELOG_END

* it should always be obvious when there is no escape

* remove logs from experiments

* remove receiveSignal PostStop

* remove unused imports
2020-08-20 18:52:37 +00:00
Samir Talwar
30564a7c90
ledger-api-client: Add test cases for LedgerClient. (#7195)
* ledger-api-client: Add integration tests for the simple stuff.

* sandbox-common: Make `SandboxFixtureWithAuth` a mixin.

This makes it useful with `SandboxNextFixture` as well as
`SandboxFixture`.

Also, add types to non-private fields and methods, and make more fields
protected rather than public.

* ledger-api-client: Add tests to make sure the token is passed through.

CHANGELOG_BEGIN
CHANGELOG_END

* sandbox-common: Tokens are for auth, not auth.
2020-08-20 15:00:32 +00:00
Remy
e54c182032
Engine: move check of valide packages inside MutableCompiledPackages (#7186)
CHANGELOG_BEGIN
CHANGELOG_END
2020-08-19 19:37:53 +02:00
Moritz Kiefer
d4d0419c64
Use TO_TEXT_CONTRACT_ID in Show instance of ContractId (#7153)
fixes #7114

This PR changes the Show instance of ContractId and flips the switch
on triggers and DAML Script to run in off-ledger mode.

It also adds a test that for DAML Script we actually get back the
correct contract id.

There is a bit of a design decision here in how we want to print
contract ids, so let me list the options I considered. $cid will stand
for the actual cid and all options are wrapped in markdown inline
code.

1. `"$cid"`. Indistinguishable from string. Suggests that there might
be an IsString instance for ContractId.
2. `<$cid>`. Matches the dummy `<contract-id>` but it’s not a dummy so
I don’t think matching that is benefitial.
3. `$cid`. Easy to spot (contract ids start with # and have no
spaces), clearly not a string but might look slightly weird.

changelog_begin

- [DAML Script/DAML Triggers] When using DAML-LF 1.dev, the `Show` instance of `ContractId` will now display the actual contract id instead of a dummy `<contract-id>` value. Note that this only applies to DAML Script and DAML Triggers not to ledger code.

changelog_end
2020-08-17 17:06:24 +02:00
Stephen Compall
1737907415
add --address option to trigger service (#7090)
* factor --address, --http-port, --port-file options from http-json to cli-opts

- enabling reuse in trigger service

* use cli-opts for address and http-port options in Trigger service

* mark ServiceConfig and some defaults private

* use --address option to set up server

* document Setter

* test --address option is parsed

* missing (c) headers

* add changelog

CHANGELOG_BEGIN
- [Trigger Service] Accepts a new ``--address`` option to listen for HTTP connections on
  interfaces other than localhost, such as ``0.0.0.0`` for all addresses.
  See `issue #7090 <https://github.com/digital-asset/daml/pull/7090>`__.
CHANGELOG_END
2020-08-12 13:50:00 -04:00
Stephen Compall
7d5d6e125f
ensure /v1/status returns all results for restarted triggers (#7052)
* test only 'restart triggers with update errors' in CI, 100 times

CHANGELOG_BEGIN
CHANGELOG_END

* build fewer things and try 1000 runs

* test restart after shutdown, 200 times

* distrust the log

* report which withTriggerService is being used to provide log dividers

* log when TriggerStarting, TriggerStarted received in 'starting' state

- In mainline, we only add logs when we add triggers in the 'running'
  stat in Server.apply.  Let's see if we aren't sending these messages
  to the `Server.start` actor when it is still in the 'starting' loop

* log same thing in starting and running states

* revert build experiment and extra logs

- keep the fixture location log, as it's a very useful divider when
  parsing test results
2020-08-11 14:55:44 +00:00
Stephen Compall
0857c28874
turn on NonUnitStatements in trigger runner, service main code (#7079)
* turn on NonUnitStatements in trigger runner, service main code

* add some friendly discards

* add a not-so-friendly discard

* no changelog

CHANGELOG_BEGIN
CHANGELOG_END

* one more discard to clarify an Await.ready's type

* explain unbind issue
2020-08-11 14:30:11 +00:00
Moritz Kiefer
39085493c8
Make ApplicationId in DAML Triggers configurable (#7075)
fixes #7030

This deliberately ignores the trigger service. The main reason for
setting the ApplicationId at the moment is authentication and this is
still very WIP in the trigger service, so I don’t think it makes sense
to add this in some form to the API until that has settled.

changelog_begin

- [DAML Trigger] You can now configure the application id via
  `--application-id` in `daml trigger`. This is primarily useful if
  you run with authentication.

changelog_end
2020-08-10 18:15:16 +02:00
Stephen Compall
d2ee532949
remove more unused definitions, params, args from triggers Scala code (#7032)
CHANGELOG_BEGIN
CHANGELOG_END
2020-08-05 19:06:22 +00:00
Rohan Jacob-Rao
765cd181b5
Trigger service test: Increase timeout for trigger to start running after service shutdown (#6986)
changelog_begin
changelog_end
2020-08-04 18:11:06 +00:00
Stephen Compall
c3e79878ff
remove unused definitions, params, args from ledger API Scala code (#6985)
* remove unused definitions, params, args from ledger API Scala code

CHANGELOG_BEGIN
- [Ledger API] withTimeProvider removed from CommandClient; this method
  has done nothing since the new ledger time model was introduced in
  1.0.0.  See `issue #6985 <https://github.com/digital-asset/daml/pull/6985>`__.
CHANGELOG_END

* percolate withTimeProvider and label removal elsewhere
2020-08-04 18:02:19 +00:00
Stephen Compall
4ba9ae4e2b
remove unused definitions, params, args from triggers Scala code (#6983)
CHANGELOG_BEGIN
CHANGELOG_END
2020-08-04 16:50:32 +00:00
Stephen Compall
3196ef7575
fix flaky 'restart triggers after shutdown' test (#6926)
* reenable 'restart triggers after shutdown'

CHANGELOG_BEGIN
CHANGELOG_END

* wait for everything to shut down before completing a withTriggerService fixture

- similar to a change to HttpServiceFixture.withHttpService in #4593,
  but without the suppression of shutdown errors

* label the WithDb tests

* in CI, test only 'recover packages after shutdown', 50 times

* experiment: Process#destroy appears to be async

* is it in the in-between period?

* partial -> total

* replace some booleans with assertions for better error reporting

* make triggerLog concurrent

* close channel and file in other error cases for port locking

- suggested by @leo-da; thanks

* use port locking instead of port 0 for trigger service fixtures

* destroy one service at a time

* missed continuation in build script

* use assertion language for "restart triggers with update errors"

* Revert "is it in the in-between period?"

This reverts commit 211ebfe9d2.

* use better assertion language for "restart triggers with update errors"

* restore full CI build
2020-08-04 08:15:08 -04:00
Moritz Kiefer
5ceeb476c8
Remove duplicated tls config parsing from DAML Script/Triggers (#6947)
This was not only unnecessarily duplicated, it also had a bug where
`--crt` behaved like `--pem` instead of setting the cert chain.

I didn’t add new tests since it seems like the wrong place to test
config parsing of a library. We do have tests for TLS in general for
both DAML Script and DAML Triggers.

changelog_begin
changelog_end
2020-07-31 18:25:18 +02:00
Rohan Jacob-Rao
e6cf6d0d51
Trigger service tests: sequence toxiproxy setup before starting sandbox (#6939)
This should avoid potential contention for ports.

changelog_begin
changelog_end
2020-07-30 15:32:46 -04:00
Rohan Jacob-Rao
91b174da91
Trigger service tests: Remove auth service process in trigger service fixture (#6928)
This code has a few problems: the auth service test mode is not enabled, the
admin ledger should be separate from main ledger if auth is enabled, and the
retry strategy not executed.

The auth service is not used in these tests yet and we have an example
of how to do it correctly in the auth service fixture (and auth service
client tests). We can try to reuse that fixture instead or copy the
code over when necessary.

changelog_begin
changelog_end
2020-07-29 23:29:04 +00:00
Rohan Jacob-Rao
4c76cf98ee
Trigger service tests: Make sure toxiproxy server is running before connecting the client (#6927)
* Trigger service tests: Make sure toxiproxy server is running before connecting client

changelog_begin
changelog_end

* Undo infuriatingly wrong camel case
2020-07-29 23:00:43 +00:00
Samir Talwar
99463577af
triggers + ports: Lock free ports before binding. (#6911)
* triggers: Use `FreePort.find()`.

* ports: Move `LockedFreePort` from postgresql-testing for reuse.

* triggers: Use `LockedFreePort` to avoid race conditions.

* ports + triggers: Move common port testing into the ports library.

CHANGELOG_BEGIN
CHANGELOG_END
2020-07-29 14:29:55 +00:00
Samir Talwar
98de16606d
daml-on-sql: An elegant Main class, for a more civilized age. (#6829)
* daml-on-sql: Pull out a new `Main` object that wraps sandbox-classic.

CHANGELOG_BEGIN
CHANGELOG_END

* daml-on-sql: Fail if a JDBC URL is not provided or not for PostgreSQL.

* sandbox-classic: Rename the conformance test H2 database.

* daml-on-sql + sandbox-classic: Report configuration errors cleanly.

This means letting `ProgramResource` catch the errors, log, and exit.

* daml-on-sql: Change the name logged on startup.

* daml-on-sql: Change the default participant ID.

* sandbox-common: Give the ledger name its own tagged string type.

* sandbox-classic: Generate random ledger IDs using the ledger name.

* daml-on-sql: Remove the banner, replacing it with a blank line.

* daml-on-sql: Enable strong seeding by default.

And weak seeding in the conformance tests.

* sandbox-classic: Move the ledger name to a separate parameter.

It's not really configurable.

* sandbox-classic: Move LedgerName from sandbox-common.

* daml-on-sql: Remove "-participant" from the participant ID.

* daml-on-sql: Use `Name` where possible.

* daml-on-sql: Make the ledger ID mandatory.

* Revert "sandbox-classic: Move LedgerName from sandbox-common."

This reverts commit 0dad1584a7.

* daml-on-sql: Print "DAML-on-SQL" in the CLI help, not "Sandbox".

* daml-on-sql + sandbox + sandbox-classic: Split out custom CLI parsing. (#6846)

* participant-state: Simplify naming the seeding modes.
2020-07-24 18:54:19 +00:00
Rohan Jacob-Rao
4973bd3573
Trigger service: rest of auth service client (#6804)
* Method for service account request

* Extend domain and factor out sa/secure

* Methods to list service accounts and poll for service account

changelog_begin
changelog_end

* Run auth client tests 20 times

* Revert "Run auth client tests 20 times"

This reverts commit 5264ce6f30.

* Assert creds list for new service account is empty

* Request credential method

* Method to get a new credential id

* Method for fetching credential

* Login method (for ledger access token)

* Make authorize style consistent with rest

* Remove redundant test (subset of second test)

* Run auth client tests 20 times

* Fail future for http error responses and refine retry strategy

* Scalafmt

* Revert "Run auth client tests 20 times"

This reverts commit 2568dc6b47.

* Test getting service account before request
2020-07-21 21:26:49 +00:00
Samir Talwar
adcbfb45a1
sandbox-classic: Move the configuration from sandbox-common. (#6810)
* sandbox-common: Move the ledgerIdMode up in the configuration.

* sandbox-classic: Move the configuration from sandbox-common.

CHANGELOG_BEGIN
CHANGELOG_END

* Fix miscellaneous warnings caught by IntelliJ IDEA.
2020-07-21 14:43:53 +00:00
Stephen Compall
4355406259
add more scalac 2.12 warnings (#6798)
* set many extra scalac -Xlint options for all Scala projects

CHANGELOG_BEGIN
CHANGELOG_END

* move NoCopy to its own file

package.scala:18: warning: it is not recommended to define classes/objects inside of package objects.
If possible, define trait NoCopy in package data instead.
  trait NoCopy {
        ^

* move more traits, classes, and objects to proper packages

- note that `package` is itself a scoping construct, so if your reason
  is the apparent aesthetic of placing a bunch of things in one `package
  object`, that is easily remedied by deleting the `object` keyword

* fix some type-parameter-shadow warnings

- I'm generally in favor of sensible name-shadowing, following the
  "deliberately hide variables that should not be accessed here" school
  of thought.  But I think type name shadowing isn't quite as valuable
  and more likely to confuse than general variable shadowing, so have
  experimentally linted it out.

  Example warning:

EventsTableFlatEventsRangeQueries.scala:11: warning: type parameter
 Offset defined in trait EventsTableFlatEventsRangeQueries shadows class
 Offset defined in package v1. You may want to rename your type
 parameter, or possibly remove it.
private[events] sealed trait EventsTableFlatEventsRangeQueries[Offset] {
                                                               ^

* fix more package-object-classes warnings

* fix an inaccessible warning

ContractsService.scala:197: warning: method searchDb in class ContractsService references private class ContractsFetch.
Classes which cannot access ContractsFetch may be unable to override searchDb.
  def searchDb(dao: dbbackend.ContractDao, fetch: ContractsFetch)(
      ^

* enable -Xlint:infer-any

- continuing the saga of #6116, #6132

* enable -explaintypes for more detailed type errors

* missed header for NoCopy; probably should have left it in the package file

* misspelling in comment

* revert -Xlint:doc-detached

- there are a lot of these fixes, and they are noisy, so shifting to a
  separate PR
- thanks to @leo-da for pointing out
2020-07-21 08:18:01 -04:00
Moritz Kiefer
c524aee995
Bump timeouts in trigger auth service tests (#6797)
tested via --runs_per_test=8 and seems to be sufficient now.

changelog_begin
changelog_end
2020-07-20 17:06:45 +00:00
Rohan Jacob-Rao
9e979ced9a
Trigger service: Introduce auth service client and test fixture (#6768)
* WIP Call authorize before start trigger

* Intro auth service client

* Auth service client test setup

CHANGELOG_BEGIN
CHANGELOG_END

* scalafmt

* Use Spray JSON format and slightly better uri handling

* Get auth client test to work and fiddle with uris

* Remove changes to Server

* Add package for URI

* Format

* Copyrights

* Update sandbox packages

* Use default wallclock time for auth service sandbox
2020-07-20 13:35:14 +00:00
Robert Autenrieth
7ce9748066
Split sandbox code into separate packages (#6695)
* Move public code into daml-integration-api

CHANGELOG_BEGIN
[DAML Integration Kit]: Removed sandbox specific code from the API intended to be used by ledger integrations. Use the maven coordinates ``com.daml:participant-integration-api:VERSION`` instead of ``com.daml:ledger-api-server`` or ``com.daml:sandbox``.
CHANGELOG_END
2020-07-17 17:06:06 +02:00
Rohan Jacob-Rao
619209d0b1
Trigger service: Document steps to replicate auth flow from the command line (#6725)
CHANGELOG_BEGIN
CHANGELOG_END
2020-07-14 15:05:41 -04:00
Gary Verhaegen
8176fb0c8d
fix the the typo (#6723)
```
s/the the /the /
```

CHANGELOG_BEGIN
CHANGELOG_END
2020-07-14 16:55:33 +00:00
Rohan Jacob-Rao
98613d9671
Trigger service: doc explaining planned use of auth service (#6659)
* Add details about validity windows
* Reword description of auth service concepts
* Elaborate on auth flow dealing with token/credential expiry

CHANGELOG_BEGIN
CHANGELOG_END
2020-07-09 14:27:50 -04:00
Rohan Jacob-Rao
30f1bf8d5a
Disable recovery test until I can fix the flakiness (#6654)
CHANGELOG_BEGIN
CHANGELOG_END
2020-07-08 11:17:12 -04:00
Moritz Kiefer
02c59d4f2a
Revert ANF changes and add a testcase for evaluation order (#6645)
* Revert ANF changes and add a testcase for evaluation order

After careful consideration, we decided that the change in evaluation
order that was accidentally introduced by the ANF changes should be
considered a breaking change or arguably even a bug and should not
land in 1.3.0.

Therefore, this PR reverts the following commits:

1. 353d0da6f7
2. a45b51042f
3. 04c7b2af7f
4. a624dd7242
5. b3aab72cee

Other PRs mostly had trivial merge conflicts that I resolved. The two
most interesting ones here are probably

1. https://github.com/digital-asset/daml/pull/6576 which was easy to
   resolve and the change to return SEValue instead of SExpr is still
   nice and useful even if we do not need the guarantees.
2. it https://github.com/digital-asset/daml/pull/6542 which required
   some changes since the constructors changed. If you want to review
   those changes in detail (they are pretty straightforward so not too
   important), it’s probably easiest to check out this PR and run
   ```
   git diff 2cd2a8f2a8
   daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/speedy/Compiler.scala
   ```
   to see the diff to the parent commit of the first commit that
   introduced ANF.

changelog_begin
changelog_end
2020-07-08 12:40:12 +02:00
Stephen Compall
4cd419623a
replace traverseU and sequenceU with traverse and sequence (#6594)
* replace traverseU and sequenceU with traverse and sequence

- with -Ypartial-unification on, the extra Unapply typeclass lookup is
  unnecessary

* no changelog

CHANGELOG_BEGIN
CHANGELOG_END

* limit imports; we only need *> and void
2020-07-07 15:01:58 +00:00
Rohan Jacob-Rao
8261509312
Trigger service: Remove retries when checking trigger ids (#6628)
The running trigger store is now written to synchronously by the server, so there's no need for retry logic.

Also assert equality of trigger ids rather than an arbitrary predicate, as it gives better error messages and we don't use other types of predicates for this function.

CHANGELOG_BEGIN
CHANGELOG_END
2020-07-06 13:48:38 -04:00
Rohan Jacob-Rao
7501805eae
Trigger service: increase timeout for db restart test (#6624)
changelog_begin
changelog_end
2020-07-06 16:29:47 +00:00
Moritz Kiefer
907e4fe678
Fix project versions of DAML Script and DAML Triggers (#6622)
GHC has weird restriction on version numbers which damlc inserits so
we need to use `ghc_version` instead of `sdk_version`. That only makes
a difference for snapshot versions where the `-snapshot.` part is
replaced by `.`.

changelog_begin
changelog_end
2020-07-06 15:07:39 +00:00
nickchapman-da
b3b30ae71d
Speedy issue 6573 (#6576)
* address issue 6573

changelog_begin
changelog_end

* fmt

* push switch from SExpr to SValue to callers of the trigger service
2020-07-02 13:15:00 +01:00
Moritz Kiefer
cf4fcb560b
Fix the package version of daml-trigger and daml-script (#6566)
It makes no sense to keep this at 0.0.1.

changelog_begin

- [DAML Script] The DAML Script library now has the version of the
  corresponding SDK.

- [DAML Trigger] The DAML Trigger library now has the version of the
  corresponding SDK.

changelog_end
2020-07-01 19:06:00 +02:00
Rohan Jacob-Rao
bdaf9aa216
Trigger service: restart triggers in database on server startup (#6556)
* Add optional trigger id to startTrigger

CHANGELOG_BEGIN
CHANGELOG_END

* Read running trigger table in DbTriggerDao

And get rid of traverse type application!
(since we have partial unification on)

* Restart triggers in database

* Test for trigger restart on recovery

* Add order by clause and remove accidental overloading
2020-07-01 13:22:23 +00:00
Rohan Jacob-Rao
546c75b74f
Trigger service: Remove data in messages from TriggerRunnerImpl to Server (#6554)
* Remove data from message sent from TriggerRunnerImpl to Server

* Remove unused trigger name from config

changelog_begin
changelog_end
2020-06-30 21:02:10 -04:00
Rohan Jacob-Rao
ea16ff350d
Trigger service: Change to restart strategy with backoff (#6552)
* Add min/maxRestartInterval to configs and use in trigger restart strategy

* Adapt tests with triggers failing due to lack of network

changelog_begin
changelog_end

* Adapt tests for triggers with errors

* Remove comment about number of restarts

* Use a small initial restart interval for testing

* Remove old restart params

* Move maxInboundMessageSize to LedgerConfig

* Rename TriggerRunnerConfig to TriggerRestartConfig
2020-06-30 20:46:23 -04:00
nickchapman-da
353d0da6f7
Speedy ANF (#6440)
* ANF transformation in Speedy.

The idea behind this PR is to transform speedy expressions into a simpler form where all non-atomic sub-expressions are made explicit by the introduction of let-forms. In particular, for the function-application form. These simpler forms allow the execution engine to take advantage of the atomic assumption, and often removes many additional execution steps. In particular the pushing of continuations to allow execution to continue after a compound expression has been reduced to a value.

changelog_begin
changelog_end

* improve comment

* inline functions relocateA/L

* remove comment about scalafmt

* remove commented out alterative def for transformLet1

* improve code by adding incr methods to DepthA/E

* remove (n == 0) special case in trackBindings

* clarify comment further

* improve validate/go to not consume stack for deeply right-nested let-expressions

* address comments from Remy: be private; use final case case; etc

* rename to unsafeCompilationPipeline

* add back some trailing commas

* remove commented-out debug line

* improve comment

* remove dev/debug code in compilationPipeline

* remove commented out code in SEAppGeneral.execute

* undo unrelated code improvement in SValue.scala

* fix compile. object Anf cannot be private
2020-06-30 20:52:44 +00:00
Rohan Jacob-Rao
99a9662781
Trigger service: change convention for updating running trigger store (#6532)
* Don't modify running trigger store via the trigger runner actor

changelog_begin
changelog_end

* Remove runner actor from RunningTrigger type

And parent actor from TriggerRunnerImpl

* Add to running trigger store on start request

* Update tests for new trigger store convention

* Fix test with network outage
2020-06-30 12:00:45 -04:00
Rohan Jacob-Rao
9c4daad473
Trigger service nits (#6528)
- Move Stop Message back to original place with other Server state messages
- Other style nits

changelog_begin
changelog_end
2020-06-29 13:25:35 -04:00
Shayne Fletcher
44bb7f5233
Spawn a ref ledger auth instance from text fixture (#6502)
changelog_begin
changelog_end
2020-06-25 15:53:34 -04:00
Rohan Jacob-Rao
674fecf73f
Trigger service: split up ServiceMain into multiple files (#6498)
* Move top level case classes to package object

changelog_begin
changelog_end

* Move Server Message classes to separate file

* Server in Server.scala and ServiceMain in ServiceMain.scala

* Copyright headers
2020-06-25 16:01:35 +00:00
Rohan Jacob-Rao
eb861ffd4a
Trigger service: split up Server companion object (#6491)
The Server object and especially the apply method is extremely big and
hard to follow. There are a great many functions nested within the apply
method. This PR attempt to organize things, mostly by moving local
functions into methods of the Server class. I think this makes things
easier to follow, and I think it's more conventional.

Note that with this change I added some implicit parameters to the
Server constructor, which I think makes sense for these kinds of values
(contexts, sequencer factory, etc.) I also moved the Message trait to
the top level, but we will probably it its own file, following this PR.
There are a few other shallow tweaks that I made along the way.

Open to feedback on the high level structuring, as I'm not super
familiar with idiomatic design in Scala.

changelog_begin
changelog_end
2020-06-25 10:22:53 -04:00
Shayne Fletcher
2f539c477a
exe lookup in runfiles (#6489)
changelog_begin
changelog_end
2020-06-25 09:48:55 -04:00
Stephen Compall
a51d0db8ff
set scalac -Xsource:2.13 -Ypartial-unification globally (#6469)
* add -Xsource:2.13, -Ypartial-unification to common_scalacopts

* add now-referenced scalaz-core where needed

* work around bad type signatures in scalatest Aggregating, Containing

* unused Any suppression

* work around bad partial-unification wrought by type alias

* remove unused Conversions import

- not required in 4f68cfc480 either, so unsure how it's survived this long

* work around Future.traverse; remove unused show import

* no changelog

CHANGELOG_BEGIN
CHANGELOG_END

* remove unused bounds

* remove -Ypartial-unification and -Xsource:2.13 where they were explicitly passed

* longer comment on what the options do

- suggested by @stefanobaghino-da; thanks

* forget Future.traverse, just use scalaz, it knows how to do this
2020-06-24 16:51:24 -04:00
Shayne Fletcher
afc573d422
step 0 integration of ref-ledger-authentication (#6484)
changelog_begin
changelog_end
2020-06-24 13:40:03 -04:00
Rohan Jacob-Rao
10208fd194
Trigger service: read packages from database on startup (#6470)
* Move database initialization to Server apply method
* Reorder dao/server creation
* Read packages from database on startup
* Test starting a trigger after a shutdown
changelog_begin
changelog_end
2020-06-24 11:18:16 -04:00
Rohan Jacob-Rao
b10bfa1ba7
Trigger service: Write packages to database if we have one (#6424)
This is needed to recover state after the service shuts down or crashes.
We add a method to the RunningTriggerDao to persistPackages. This only
does something in the case of a DbTriggerDao. In any case the Server
keeps a package map in memory as it's required to construct a trigger runner.
Uploads of existing packages is considered harmless.

changelog_begin
changelog_end
2020-06-19 13:49:49 -04:00
Rohan Jacob-Rao
78d598ecf3
Trigger service: Improve formation of SQL queries (#6422)
Avoid the use of Fragment.const which interprets raw strings as SQL
queries without any checks. Use the `sql` string interpolation which I
found out does the right thing with Strings and other simple types.

CHANGELOG_BEGIN
CHANGELOG_END
2020-06-19 09:32:27 -04:00
Remy
1b1b4eab2c
Speedy: clean machine builder name (#6427)
* Address comment martin made in #6368

* changelog

CHANGELOG_BEGIN
CHANGELOG_END
2020-06-19 14:58:13 +02:00
Rohan Jacob-Rao
0ca1288d9d
Trigger service: Increase server binding timeout (#6421)
To avoid timeouts in CI. Also factor out the implicit val one level
so it is used by both tests and main method.

changelog_begin
changelog_end
2020-06-18 19:54:24 +00:00
Rohan Jacob-Rao
5934b22dda
Trigger service: Refactor Server.addDar to take encoded dar (#6395)
Trigger service: Refactor Server.addDar to take encoded dar

This is so we can write the encoded packages to the database if we have
one (without re-encoding them).

changelog_begin
changelog_end
2020-06-18 12:37:43 -04:00
Remy
5a9e7ebc7c
Speedy: refactor Machine builders (#6368)
In this PR we cleanup the constructor for the speedy Machine.

* We remove the `case`  keyword since `Machine` is a stateful class,
* We replace the pre-existing builders with
  + one generic builder `Machine.apply`,
  + scenario specific builder,

CHANGELOG_BEGIN
CHANGELOG_END
2020-06-18 15:39:55 +02:00
Rohan Jacob-Rao
5ca65ad69a
Trigger service: Refactor testing with and without database (#6373)
* Trigger service: Refactor testing with and without database

Following the approach taken in the HTTP JSON API.
Define an AbstractTriggerServiceTest class with abstract jdbcConfig
member. This is instantiated with None and Some in the in-memory and
database test classes respectively. Tests for the individual modes can
be added in these concrete classes.

changelog_begin
changelog_end

* Move db init and destroy into beforeEach/afterEach to avoid concurrent tests clashing
2020-06-16 18:00:20 -04:00
Rohan Jacob-Rao
3cfed4d7a3
Trigger Service: Refactor running trigger access using DAO interface (#6334)
Trigger Service: Refactor running trigger access using DAO interface

This introduces a RunningTriggerDao trait and two classes that implement
it, one for in-memory and one for database storage. This moves a lot of
code out of the Server class and into the DAO classes. The class chosen
at runtime depends on whether a JDBC config has been provided.

The database DAO also has methods for initialization and clean up used by
the server main function and the test fixture.

This is a pure refactoring (modulo some minor error message changes) so
functionality should stay the same.

CHANGELOG_BEGIN
CHANGELOG_END
2020-06-13 14:33:46 -04:00
Shayne Fletcher
23e7dc826e
Trigger service docs and SDK integration basics (#6329)
* Integrate trigger-service into the assistant

changelog_begin
changelog_end

* Assistant integration and bare bones docs

changelog_begin
changelog_end
2020-06-12 18:54:38 +00:00
Simon Maxen
5329a4f97f
Ledger id requirement (#6323)
* Add option based constructor for LedgerIdRequirement

changelog_begin
changelog_end

* Make option based consructor the default, deprecate old constructor

* Update with review comments
2020-06-12 15:00:32 +00:00
Shayne Fletcher
0f47b8d1bf
Simplify findCredentials logic (#6301)
changelog_begin
changelog_end
2020-06-11 23:04:14 +00:00
Shayne Fletcher
b8126ee75c
Add --no-secret-key (#6309)
changelog_begin
changelog_end
2020-06-11 18:41:26 -04:00
Shayne Fletcher
07f24c0d93
Encrypt credentials (#6296)
* Encrypt credentials

changelog_begin
changelog_end

* Move key aquisition and write a big fat warning

* Only write encrypted token to DB.
2020-06-10 17:14:29 -04:00
Shayne Fletcher
033c58bc60
Switch to basic auth in readiness for auth service integration (#6279)
* Switch to basic auth in readiness for auth service integration

changelog_begin
changelog_end

* Newtype for user credentials
2020-06-10 09:48:33 -04:00
Rohan Jacob-Rao
e7017e6943
Trigger service: delete from database in stop trigger (#6249)
Includes a fair amount of refactoring to smooth the logic with/without a database. All tests now run with and without a database.

CHANGELOG_BEGIN
CHANGELOG_END
2020-06-08 16:19:35 -04:00
Shayne Fletcher
ecad4ff7c3
Fix test descriptions (#6269)
changelog_begin
changelog_end
2020-06-08 19:11:59 +00:00
Shayne Fletcher
0b7989a715
Adjust status code response for unauthorized (#6268)
changelog_begin
changelog_end
2020-06-08 18:56:43 +00:00
Shayne Fletcher
0625e68988
Disambiguate initialization halted vs. failed (#6248)
changelog_begin
changelog_end
2020-06-05 17:18:38 -04:00
Rohan Jacob-Rao
3159c617f6
Tweak error handling in listTriggers helper (#6247)
changelog_begin
changelog_end
2020-06-05 20:32:49 +00:00
Rohan Jacob-Rao
de2b5d195e
Trigger service style touch ups (#6246)
* Touch up logTriggerStatus

* Touch up removeRunningTrigger

* Touch up addRunningTrigger

* Remove IntelliJ (scalastyle I think) warnings about public members without type annotations

CHANGELOG_BEGIN
CHANGELOG_END

* Redundant brackets
2020-06-05 16:07:10 -04:00
Shayne Fletcher
71ff65d5be
Trigger stop on db write failure (#6233)
* Stop running trigger under DB write failure

changelog_begin
changelog_end

* Another fix relating to initialization retries

changelog_begin
changelog_end

* Handle the error case directly
2020-06-04 17:00:12 -04:00
Shayne Fletcher
e23a488596
Put initialization failures through retries too (#6230)
changelog_begin
changelog_end
2020-06-04 15:24:51 -04:00
Shayne Fletcher
322b93c7e7
Temporarily disable flaky test (#6228)
changelog_begin
changelog_end
2020-06-04 12:04:35 -04:00
Shayne Fletcher
2c3efc6c4f
Refactor startTrigger (#6219)
changelog_begin
changelog_end
2020-06-04 09:30:47 -04:00
Rohan Jacob-Rao
09254a0fa8
Trigger service: streamline running tests with and without the database (#6205)
This adds a function withTriggerServiceAndDb which runs a test twice, once with and once without a database, and succeeds if both succeed. This will be useful for reusing test logic with both backends and making sure behaviour is consistent. I have used this function where possible, but it won't work for everything until stop is implemented on the DB side.

At the moment this new function squashes two tests into one making it hard to tell whether it failed with or without the database. In a future PR I will investigate using an abstract class to run the tests separately (hopefully with altered descriptions).

This feature required a few changes in the process, mainly:
- Use PostgresAroundAll to connect/disconnect to the database before and after all tests run
- Add a destroy method to the TriggerDao to reset the database between tests
- Use the TriggerDao in the withTriggerService functions to initialize / clean up the database at the start / end of each test
- Sort trigger instances from list using Scala's sort, not relying on Postgres' ordering of UUIDs. This also means we need to use UUIDs for trigger instances in the tests and sort nonempty vectors in expected results.
2020-06-04 09:30:26 -04:00
Shayne Fletcher
c2961b1957
Make the stop endpoint more robust and test (#6217)
* Make the stop endpoint more robust and test

changelog_begin
changelog_end

* Stopping an unknown trigger gives 404
2020-06-03 18:56:51 +00:00
Shayne Fletcher
6be68dc059
Renfinements to error test DAMLs (#6212)
changelog_begin
changelog_end
2020-06-03 15:02:53 +00:00
Shayne Fletcher
5ff8ec69df
Trigger error cases (#6202)
changelog_begin
changelog_end
2020-06-02 19:29:43 -04:00
Rohan Jacob-Rao
0b5762e437
Trigger service: use DB for start and list commands (#6153)
* Insert running trigger to DB when using one

If the DB write fails, the server sends itself a
TriggerInitializationFailure message so that the corresponding trigger
runner is stopped and the table is in sync with the actors.
We still need to retry writes here.

Includes basic test that runs the server with a JDBC config set and adds
a trigger, expecting a new entry to be added to the DB. However does not
check the running trigger table which we can do once reads are
implemented.

changelog_begin
changelog_end

* Await on future in test

* Update to new assertTriggerIds

* Apply scalafmt suggestions

* Create index on party token

* Read db in list command

* Update comment in test script

* Remove outdated comment

* Fix strings in insert and select

* Clean up test

* Add a second trigger in the db test

* Fix comment in test script

* Comment db tables

* Order trigger instances in list command

* Comment about TriggerDao execution context
2020-06-02 16:57:35 +00:00
Shayne Fletcher
256d48a431
Switch to timestamps not strings (#6191)
changelog_begin
changelog_end
2020-06-02 15:24:57 +00:00
Shayne Fletcher
2de23d93c2
Trigger record status (#6180)
* Store trigger history

changelog_begin
changelog_end

* Harvest trigger histories

changelog_begin
changelog_end

* Switch to Vector over List (and other bits and bobs)

* Use a better verb for updating trigger status method

* Add a comment

* Fix mangled comments
2020-06-01 20:19:51 +00:00
Shayne Fletcher
41c967f1f1
Failure path testing (#6178)
changelog_begin
changelog_end
2020-06-01 12:50:51 -04:00
Shayne Fletcher
f619dea380
Test trigger won't start when ledger connection not viable (#6150)
changelog_begin
changelog_end
2020-05-28 19:05:14 -04:00
Rohan Jacob-Rao
cc5d5d3fd8
Trigger service: refactor in prep for DB writes (#6134)
* Pass JdbcConfig object to TriggerDao apply

* No need to return TriggerDao from init db

* Refactor introducing RunningTrigger type

* Rename triggerId -> triggerInstance and triggerOrigId -> triggerName
Note this also changes the start request parameter name to triggerName.
However I have not yet renamed triggerId in the response messages. We
should probably make it triggerInstance there too but in a later PR.

changelog_begin
changelog_end
2020-05-28 13:47:24 -04:00
Stephen Compall
15350a7bc2
disable warts.Any and remove most suppressions (#6132)
* disable Any wart

* first pass removal of Any suppressions for false positives

* second pass removal of Any suppressions for false positives

* no changelog

CHANGELOG_BEGIN
CHANGELOG_END

* third pass removal of Any suppressions for false positives

* fourth pass removal of Any suppressions for false positives

* reformat newly single-suppressions into single lines

- suggested by @SamirTalwar-DA; thanks
2020-05-28 16:53:41 +00:00
Shayne Fletcher
4fb13734ad
Extend proxy into test functions and gentle refactor (#6147)
changelog_begin
changelog_end
2020-05-28 12:39:34 -04:00
Shayne Fletcher
576e47f587
Toxify Windows (#6122)
changelog_begin
changelog_end
2020-05-27 12:07:54 -04:00
Shayne Fletcher
79563ee74b
ToxiProxy config (#6114)
changelog_begin
changelog_end
2020-05-27 07:08:45 -04:00
Shayne Fletcher
b95dd39a6e
Don't update running triggers until we know the trigger is running (#6079)
* Don't update running triggers until we know the trigger is running

changelog_begin
changelog_end

* Don't update running triggers until we know the trigger is running
2020-05-26 16:15:29 -04:00
Stefano Baghino
9af85e56e9
Introduce DAML-LF value caching for transaction service (#6052)
* Introduce DAML-LF value caching for transaction service

Allows to keep the DAML-LF values in the most recently indexed events in memory,
so that they don't have to be deserialized on the client from their Protobuf encoding.

Closes #6044

CHANGELOG_BEGIN
[Sandbox] The --max-lf-value-translation-cache-entries option allows to set a
number of events for which DAML-LF values are cached. Could reduce latency in
serving transactions for consumers that are reasonably fast.
CHANGELOG_END

* Add missing dependency

* Address https://github.com/digital-asset/daml/pull/6052#discussion_r428076003

* Update ledger/sandbox/src/main/scala/com/digitalasset/platform/sandboxnext/Runner.scala

Co-authored-by: Samir Talwar <samir.talwar@digitalasset.com>

* Address https://github.com/digital-asset/daml/pull/6052#discussion_r428071324

* Address https://github.com/digital-asset/daml/pull/6052#discussion_r428076905

* Address https://github.com/digital-asset/daml/pull/6052#discussion_r428081294

* Fix fatal warnings

* //ledger/caching has to be used whenever sandbox is run

Co-authored-by: Samir Talwar <samir.talwar@digitalasset.com>
2020-05-26 08:33:53 +00:00
Remy
9e456a1016
DAML-LF: Kill RelativeContractId (#5991)
CHANGELOG_BEGIN
CHANGELOG_END
2020-05-25 22:30:45 +02:00
Rohan Jacob-Rao
f845bca12f
Trigger service: initialize database command (#6062)
Minimal database initialization with schemas for running_triggers and dalfs tables. The user passes in the database URL, username and password in a config string argument (approach and code adapted from the JSON API).

In future the idea is to also create a "service" role with permissions to read and write to the new tables. Then the user can pass in the service role to connect to the database when running the service for real.
2020-05-22 10:54:08 -04:00
Shayne Fletcher
90c0194dd9
Change trigger maps to store tokens not parties (#6061)
changelog_begin
changelog_end
2020-05-20 16:54:13 -04:00
Shayne Fletcher
639bec5a83
New module TokenManagement.scala (#6060)
changelog_begin
changelog_end
2020-05-20 16:51:40 -04:00
Shayne Fletcher
03d8425e16
Rework start/stop & list to require bearer header with JWT token (#6055)
changelog_begin
changelog_end
2020-05-20 15:40:22 -04:00
Martin Huschenbett
caedc72551
Implement a simple profiler for DAML scenarios (#5957)
* Implement a simple profiler for DAML scenarios

The profiler runs a single scenario and records timing information when
each function (and some other closures) are entered and left. The
resulting information can be visualized as a flamegraph using
[speedscope](https://www.speedscope.app/).

The profiler works by instrumenting the CEK machine at the heart of
DAML Engine. Unfortunetaly, this causes a very small overhead on
non-profiling runs too. However, in my benchmarks I could not measure
any significant impact on the overall runtime at all. More precisely,
the overhead is as follows:

Every closure now has an additional field called `label`. In
non-profiling runs this field is always set to `null`. This field needs
to be allocated, copied whenever we copy a closure and scanned during
garbage collection. Additionally, whenever we enter a closure, we check
this field and whenever it is _not_ `null`, i.e. never during
non-profiling runs, we record an "open event" and set up a hook for the
corresponding "close event". Thus, the additional cost during
non-profiling runs are a single pointer comparison and a jump beyond
the "then branch".

Since this is still very much in active development, there are no
documentation, other than an entry in a README, and no tests yet. They
will come before we promote this. However, the UX will look very
different then since we already have plans to significantly change it.

CHANGELOG_BEGIN
CHANGELOG_END

* Run scalafmt

* Make profiling argument to PureCompiledPackges optional

* Fix a bunch of tests

CHANGELOG_BEGIN
CHANGELOG_END

* scalafmt is so annoying

CHANGELOG_BEGIN
CHANGELOG_END

* Apply simple suggestions

CHANGELOG_BEGIN
CHANGELOG_END
2020-05-18 17:20:44 +00:00
Shayne Fletcher
0e1ac4670c
Add maxInboundMessageSize param to trigger service (#6000)
changelog_begin
- trigger runner supports the `max-inbound-message-size` option
changelog_end
2020-05-15 13:52:59 +00:00
Shayne Fletcher
97fd974381
Add createAndExerciseCmd to triggers (#5990)
changelog_begin
- New function `createAndExerciseCmd` added to DAML triggers
changelog_end
2020-05-14 13:24:01 -04:00
Shayne Fletcher
2b33a4d273
Version the existing paths (#5970)
changelog_begin
changelog_end
2020-05-13 16:09:41 -04:00
Shayne Fletcher
007ebeb56a
Add http-port option (#5951)
changelog_begin
changelog_end
2020-05-13 09:30:03 -04:00
Shayne Fletcher
221c6db0ae
Rename targets (#5950)
changelog_begin
changelog_end
2020-05-12 16:00:15 -04:00
Shayne Fletcher
6cbe36bf4d
Shutdown protocol (#5936)
changelog_begin
changelog_end
2020-05-12 08:33:05 -04:00
Shayne Fletcher
1007df46d2
script to start ledger and trigger service (#5939)
changelog_begin
changelog_end
2020-05-12 08:32:34 -04:00
Shayne Fletcher
75ed957c63
Restart triggers that fail (#5916)
changelog_begin
changelog_end
2020-05-08 15:23:54 -04:00
Shayne Fletcher
3e11122f77
More annotations (#5875)
changelog_begin
changelog_end
2020-05-07 11:30:01 +00:00
nickchapman-da
53b24793f4
Simplify and clarify the public interface to Speedy. (#5881)
* Simplify and clarify the public interface to Speedy.

- Remove `isFinal`. A client just uses `run()`.
- Remove `toSValue`. The value in available in `SResultFinalValue(v: SValue)`.
- A client never directly access the `.ctrl` (or `.returnValue`) components.
- A client may use `setExpressionToEvaluate(expr)` to evaluate a new expression on an existing machine.

changelog_begin
changelog_end

* remove while loop which executes just once

* avoid unnecessary mutation when running speedy
2020-05-07 08:55:16 +00:00
nickchapman-da
b318cb0299
Optimize Speedy machine.ctrl (#5811)
Remove the `Ctrl` trait and separate `Machine.ctrl: Ctrl` into `Machine.ctrl: SExpr` and `Machine.returnValue: SValue` instead. This allows for avoiding dynamic dispatch on `ctrl` and instead allows for checking a pointer for `null` to decide if we have an expression that needs further break-down or a return value ready to be passed to the next continuation.

To make this check really only a pointer comparison we also needed to remove the abomination of "fully applied partially applied primitives". In order to achieve this, we check whether a PAP will be fully applied afterward when applying the last argument.

On the `collect-authority` benchmark, this increases throughput by around 13%, on another more computation heave benchmark by about 21%.

`collect-authority` benchmark on `master`:
```
Result "com.daml.lf.speedy.perf.CollectAuthority.bench":
  112.361 ±(99.9%) 1.965 ms/op [Average]
  (min, avg, max) = (107.047, 112.361, 120.745), stdev = 3.493
  CI (99.9%): [110.396, 114.326] (assumes normal distribution)
```

`collect-authority` benchmark on this branch:
```
Result "com.daml.lf.speedy.perf.CollectAuthority.bench":
  98.196 ±(99.9%) 1.933 ms/op [Average]
  (min, avg, max) = (91.580, 98.196, 105.478), stdev = 3.436
  CI (99.9%): [96.263, 100.129] (assumes normal distribution)
```

computation heavy benchmark on master
```
Result "com.daml.lf.speedy.perf.CollectAuthority.bench":
  44.030 ±(99.9%) 0.742 ms/op [Average]
  (min, avg, max) = (42.124, 44.030, 46.781), stdev = 1.319
  CI (99.9%): [43.289, 44.772] (assumes normal distribution)
```

computation heavy benchmark on this branch:
```
Result "com.daml.lf.speedy.perf.CollectAuthority.bench":
  36.222 ±(99.9%) 0.580 ms/op [Average]
  (min, avg, max) = (34.897, 36.222, 39.787), stdev = 1.031
  CI (99.9%): [35.643, 36.802] (assumes normal distribution)
```

changelog_begin
changelog_end
2020-05-06 20:44:50 +02:00
Rohan Jacob-Rao
4797834e1d
Trigger service: use "triggerId" and "triggerIds" fields for response messages (#5854)
* Use triggerId field in trigger start response

* Use triggerId field for stop trigger result

* Fix indentation and make yields consistent

* Use pair constructor for JsObject instead of Map

* Use triggerIds field in list triggers response

changelog_begin
changelog_end
2020-05-06 11:44:07 -04:00
Shayne Fletcher
72fa959307
Mostly annotations. (#5852)
changelog_begin
changelog_end
2020-05-06 10:01:01 -04:00
Rohan Jacob-Rao
ac5f462f24
Trigger service: Use JSON object in result of upload dar response (#5849)
changelog_begin
changelog_end
2020-05-05 16:33:45 +00:00
Rohan Jacob-Rao
30fab0cbb9
Trigger service: Use response format from JSON API (#5829)
* Adapt ResponseFormat from JSON API

* Add some type annotations

* Use response format with status and errors/result fields

* Update and refactor tests

changelog_begin
changelog_end
2020-05-05 09:02:57 -04:00
nickchapman-da
572b21e882
Speedy: run() dont step() (#5814)
Speedy: run() dont step()

- Running the Speedy machine with  `run()` instead of `step()`
- Remove: `SResultContinue`
- Add: `SResultFinalValue(_)`

We change the top level control of Speedy: from machine.step() to machine.run, with the control of stepping while the machine returns SResultContinue moved into speedy itself. (And so SResultContinue is removed in favour of SResultFinalValue.) The main advantage of this approach is that the tight while loop can be moved inside the exception handler, rather than having to wrap the handler every step.

changelog_begin
changelog_end
2020-05-04 16:57:47 +01:00
Rohan Jacob-Rao
5a09a75859
Trigger service: Use tagged Party type instead of String (#5816)
changelog_begin
changelog_end
2020-05-01 18:08:06 +00:00
Rohan Jacob-Rao
947e6e5ebc
trigger service: Move request params to separate file (#5808)
* Move request types to new file
* Rename TriggerParams to StartParams and a bit more formatting
changelog_begin
changelog_end
2020-05-01 13:00:54 -04:00
Shayne Fletcher
e7741dd850
handle stop message received before acs query complete (#5801)
changelog_begin
changelog_end
2020-05-01 11:24:58 -04:00
Shayne Fletcher
1510d8ccd9
Rewrite acsQuery as a for-comprehension (#5803)
changelog_begin
changelog_end
2020-04-30 13:08:47 -04:00
Remy
9fc1ceae10
Engine: revisit freshness of cid discrimator (#5361)
CHANGELOG_BEGIN
CHANGELOG_END
2020-04-30 16:44:34 +02:00
Rohan Jacob-Rao
af8895b487
Trigger service: endpoint to list running triggers for a party (#5770)
* Endpoint to list all triggers (not yet by party)

* Clean up test code a little

changelog_begin
changelog_end

* Test for listing running triggers

* Respond with JSON list instead of random text

* List triggers by party

Pass party name in request body.
Store another map of party name to set of trigger ids.
Also store party names in the values of the original trigger id map, so
we can update the party map when stopping a trigger.
2020-04-29 14:43:56 -04:00
Remy
15354c3256
DAML-LF: remove submitter is in maintainer check (#5611)
CHANGELOG_BEGIN
CHANGELOG_END
2020-04-23 16:10:39 +02:00
Remy
7bdde70840
Speedy Compiler: clean up. (#5649)
CHANGELOG_BEGIN
CHANGELOG_END
2020-04-22 16:09:54 +02:00
Moritz Kiefer
d8db88e7e1
Make DAML Triggers and DAML Script default to wall-clock-time (#5632)
* Make DAML Triggers and DAML Script default to wall-clock-time

Now that sandbox defaults to wall-clock-time there is no reason why we
should not default in DAML triggers and DAML Script.

changelog_begin

- [DAML Triggers] ``daml trigger`` now defaults to wall clock time if
  neither ``--wall-clock-time`` or ``--static-time`` is passed.

- [DAML Script] ``daml script`` now defaults to wall clock time if
  neither ``--wall-clock-time`` or ``--static-time`` is passed.

changelog_end

* Make --static-time and --wall-clock-time exclusive
2020-04-20 14:42:19 +00:00
Remy
9704a39bae
Engine: refactor PartialTransaction context (#5578)
* Engine: refactor PartialTransaction context

CHANGELOG_BEGIN
CHANGELOG_END
2020-04-16 14:39:12 +02:00
Remy
d91da3be51
Engine: refactoring preprocessing. (#5434)
* Engine: refactor preprocessing

CHANGELOG_BEGIN
CHANGELOG_END
2020-04-09 20:29:03 +02:00
Moritz Kiefer
3bbd7719bb
Move remaining trigger tests over to scalatest (#5494)
This PR ports the remaining trigger tests to scalatest and kills the
whole client_server_test based infrastructure 🎉

changelog_begin
changelog_end
2020-04-08 17:28:34 +02:00
Gerolf Seitz
a2d785e3ee
Use com.daml as root package (#5343)
Packages com.digitalasset.daml and com.daml have been unified under com.daml

Ledger API and DAML-LF DEV protos have also been moved from `com/digitalasset`
to `com/daml` on the file system.
Protos for already released DAML LF versions (1.6, 1.7, 1.8) stay in the
package `com.digitalasset`.

CHANGELOG_BEGIN
[SDK] All Java and Scala packages starting with
``com.digitalasset.daml`` and ``com.digitalasset`` are now consolidated
under ``com.daml``. Simply changing imports should be enough to
migrate your code.
CHANGELOG_END
2020-04-05 19:49:57 +02:00
Moritz Kiefer
b17095e5cc
Move more trigger tests to scala-test (#5384)
* Move more trigger tests to scala tests

This PR moves more tests of triggers over to the Scala test suite, in
particular:

- The existing tests there abstract over the time mode and are
  instantiated once for wallclock mode and once for static time mode.
- I’ve added tests for TLS and Auth.
- I’ve removed the TLS and Auth tests outside of scala-test since they
  are now redundant.
- I’ve added the time tests to the scala-tests stuff since with the
  new ledger time model, that’s necessary to actually trigger a
  failure if you get static time vs wallclock time wrong (MRT and LET
  no longer exist).

I haven’t yet moved all the func tests over, I’ll do that separately
and then we can kill the old tests completely.

changelog_begin
changelog_end

* Factor out test utils into a library
2020-04-03 09:58:58 +00:00
Moritz Kiefer
29ed16b4cc
Improve handling of exposed-modules with data-dependencies (#5330)
* Improve handling of exposed-modules with data-dependencies

Previously, we tried to rename all modules of a dependency via
--package. This fails if some of those modules are not exported. This
was trivial to hit as a user since the ``daml-trigger`` library made
use of this.

This PR adds a few things to improve the situation:

1. We only rename modules that are exposed. This fixes the issue if
   you don’t actually reference a non-exposed module from your
   data-dependency.
2. I’ve removed the exposed-modules from daml-trigger. I don’t think
   they are essential here given that the module name has `Internal`
   in the name and it’s too easy to have something that actually
   references the non-exposed module since the types are reexported.
3. I’ve added documentation that mentions this issue.
4. I’ve added a warning if your exposed-modules are excluding some
   modules. Maybe worth turning this into an error in the future.

changelog_begin
changelog_end

* Update compiler/damlc/lib/DA/Cli/Damlc/Packaging.hs

Co-Authored-By: associahedron <231829+associahedron@users.noreply.github.com>

Co-authored-by: associahedron <231829+associahedron@users.noreply.github.com>
2020-04-01 13:57:52 +02:00
Gerolf Seitz
329320bad9
Organize maven coordinates (#5272)
* Use com.daml as groupId for all artifacts

CHANGELOG_BEGIN
[SDK] Changed the groupId for Maven artifacts to ``com.daml``.
CHANGELOG_END

* Add 2 additional maven related checks to the release binary

1. Check that all maven upload artifacts use com.daml as the groupId
2. Check that all maven upload artifacts have a unique artifactId

* Address @cocreature's comments in https://github.com/digital-asset/daml/pull/5272#pullrequestreview-385026181
2020-04-01 11:41:18 +02:00
Moritz Kiefer
da5daf3239
Turn script over JSON API tests into a proper test suite (#5278)
This replaces the rather horrible previous setup of having a custom
test runner that spawns 3 separate JVM processes by a single scalatest
test suite that starts sandbox and the JSON API in process.

changelog_begin
changelog_end
2020-03-31 11:55:29 +02:00
Moritz Kiefer
d70fa63a21
Add a proper scalatest test suite for triggers (#5250)
This PR adds a new test suite for DAML triggers based on scala test
rather than the client_server_test macro + a custom main. This seems
much nicer than the client_server_test (we get a lot of useful stuff
from scalatest, e.g., useful output of assertion failures, things
don’t blow up after the first test failure, …).

This PR only ports over a small fraction of the tests to make review
easier. The plan is then to port over everything and kill off the
existing test stuff once everything is ported over.

changelog_begin
changelog_end
2020-03-30 11:42:09 +02:00
Remy
1b37f6c482
DAML-LF: redesign absolute contract ids (#5207)
CHANGELOG_BEGIN
CHANGELOG_END
2020-03-27 19:07:42 +01:00
Gary Verhaegen
1872c668a5
replace DAML Authors with DA in copyright headers (#5228)
Change requested by Manoj.

CHANGELOG_BEGIN
CHANGELOG_END
2020-03-27 01:26:10 +01:00
Andreas Herrmann
9e5dff4109
Ship daml-script and daml-trigger libraries in multiple LF versions (#5192)
* Depend on LF version specific daml-libs

* daml-script.dar build multiple LF versions

CHANGELOG_BEGIN
[DAML Script] The `daml-script` library is now available in multiple LF
  versions, namely 1.7, 1.8, and 1.dev.
CHANGELOG_END

* daml-trigger.dar build multiple LF versions

[DAML Triggers] The `daml-trigger` library is now available in multiple
  LF versions, namely 1.7, 1.8, and 1.dev.

* Keep daml-script.dar available for tests

* Keep daml-trigger.dar available for tests

* daml-libs LF versions integration test

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2020-03-26 10:17:19 +01:00
Robert Autenrieth
a3ddde3a9d
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 <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
2020-03-25 16:50:27 +01:00
Robert Autenrieth
3f597aae16
New ledger time (#5100)
* Tighten result type

Command execution can't result in a sequencer error

* New helper method for extracting used contracts

* New error clause

* Add a DAO query for the maximum time of contracts

* Implement algorithm for finding ledger time

CHANGELOG_BEGIN
CHANGELOG_END

* fixup ledgerTimeHelper

* Use new ledger time algorithm

* Mark LET/MRT as deprecated

CHANGELOG_BEGIN
- [Ledger API] DAML ledgers have switched to a new ledger time model.
  The ledger_effective_time and maximum_record_time fields of command submission are deprecated,
  the ledger time of transactions is instead set automatically by the ledger API server.
  Ledger time is no longer strictly monotonically increasing, but only follows causal monotonicity:
  ledger time of transactions is greater than or equal to the ledger time of any used contract.
  See `#4345 <https://github.com/digital-asset/daml/issues/4345>`__.
CHANGELOG_END

* Add ledger time skew check

* Remove command updater

LET/MRT are now deprecated, this class is now useless

* Remove old time model validator

* Switch to new time model check: kvutils

* Switch to new time model check: in-memory ledger

* Switch to new time model check: SqlLedger

* Use initial ledger config

* Ignore user provided LET

* Use TimeProvider in submission services

* Use deduplication_time in daml-script runner

- Also remove unnecessary command completion output of CommandTracker.
- Remove usage of maximum record time in CommandTracker.

* Use arbitrary default value for deduplication time

* Use built-in Instant ordering

* Remove obsolete test

* Remove obsolete test: CommandStaticTimeIT

* Refactor test: TransactionMRTCompliance

* Disable test: CommandTrackerFlow timeout

* thread maxDeduplicationTime through to CommandTracker

* Improve test

* Refactor command client configuration

* Deduplication time should always use UTC

* Add missing method in TimedIndexService after rebase

* Put more details into the deduplication error response.

* Use system time for command dedup submittedAt.

* Use explicit UTC time source in command validator

* Revert CommandTracker[Flow] to previous completion-recovering-behavior

* Adapt scala client command config to new config params

Co-authored-by: Gerolf Seitz <gerolf.seitz@digitalasset.com>
2020-03-25 09:28:56 +01:00
Moritz Kiefer
a50b7b7dbd
Hide "Slf4jlogger started" log statement (#5163)
This just looks ugly and doesn’t help users at all.

changelog_begin
changelog_end
2020-03-24 17:06:14 +01:00
Moritz Kiefer
13816c75b3
Support uploading DARs to the trigger service (#5084)
* Support uploading DARs to the trigger service

This PR adds a new `upload_dar` endpoint that accepts a DAR as a
multi-part form request and adds it to the list of compiled packages.

I’ve also made the DAR passed in on startup optional now given the new
endpoint.

There is no endpoint for deleting a DAR so far but there is none on
the ledger API either so I think this not particularly urgent.

changelog_begin
changelog_end

* Address review comments
2020-03-19 13:02:04 +01:00
Remy
c2070170b3
Engine: add rank to Enum and Variant SValue (#5048)
CHANGELOG_BEGIN
CHANGELOG_END
2020-03-18 14:37:44 +01:00
Moritz Kiefer
bd6db5be68
Handle failures during trigger initialization synchronously (#5046)
Previously the http endpoint for starting a trigger would always
return immediately. Based on the recent refactorings, we now do the
non-IO trigger initialization synchronously and return a failed http
status code with an error message.

This also refactors the code to only have one (mutable) set of
compiled packages which is a prerequisite for dynamic package uploads.

changelog_begin
changelog_end
2020-03-18 10:23:41 +01:00
Samir Talwar
cbeeb5aafc
sandbox: Fail to start if a time mode is not explicitly specified. (#5033)
* sandbox: Fail to start if a time mode is not explicitly specified.

CHANGELOG_BEGIN
- [Sandbox] Sandbox is switching from Static Time mode to Wall Clock
  Time mode as the default. To ensure that our users know about this,
  for one version, there will be no default time mode. Instead, users
  will have to explicitly select their preferred time mode by means of
  the `--static-time` or `--wall-clock-time` switches. In the next
  release, Wall Clock Time will become the default, and users who are
  happy with the defaults will no longer need to specify the time mode.
CHANGELOG_END

* daml-script|triggers: Specify time mode when testing against Sandbox.

* daml-assistant: Default the Sandbox to wall clock time.

CHANGELOG_BEGIN
- [DAML Assistant] Initializing a new DAML project adds a switch to
  ``daml.yaml`` to ensure Sandbox can continue to start with ``daml
  start``::

      sandbox-options:
        - --wall-clock-time
CHANGELOG_END

* docs: Update the DAML Script and Triggers docs to use Wall Clock time.

It's now what Sandbox will use by default when using `daml init`.

* docs: Change the Quickstart to run Sandbox in wall clock time.

This explains why the contract IDs may vary.

It also updates the manual release testing script to match.
2020-03-18 08:25:03 +00:00
Moritz Kiefer
fb86152f8c
Move non-IO initialization out of trigger runner (#5042)
Previously parts of the initialization, in particular, the code for
finding the filter and the heartbeat were part of the Runner. This led
to an akward API and didn’t really make any sense.

Now all of this code is part of a pure `Trigger.fromIdentifier`
method and the runner only takes care of actually running the
ledger. This could also be useful for the trigger service where we
might want to synchronously call `getIdentifier` so users get some
indication if there request even points to a valid trigger
directly. However, this is not tackled by this PR.

changelog_begin
changelog_end
2020-03-17 15:26:58 +01:00
Moritz Kiefer
cc2ca20336
Make trigger runner specific to a given trigger (#5038)
Previously the runner class was in a weird state where it was specific
to a DAR but not to an individual trigger. This meant that you had to
pass around a fair bit of state which got a bit awkward. This PR
addresses this by making the trigger class specific to the trigger.

It also now accepts `CompiledPackages` instead of a DAR which should
make it easier in the trigger service to support dynamic package
uploads.

changelog_begin
changelog_end
2020-03-17 11:51:06 +01:00
Moritz Kiefer
9aa68cac4f
Fix detection of package ids for triggers (#5016)
Previously we assumed that the module name was globally unique in the
DAR which is definitely not guaranteed. Now we instead detect the
package id of the trigger library based on the type of the trigger we
are running which doesn’t fall apart if there are multiple versions of
the trigger library.

I’ve also removed the check for the package id of the trigger library
since I’d like the trigger runner to be backwarts compatible from now on (we
didn’t break that in a while).

This is slightly ugly since the Runner class is currently not specific
to a single trigger but only the individual methods are aware of the
specific trigger identifier. I’ll refactor this in a separate PR.

changelog_begin
changelog_end
2020-03-16 16:13:42 +01:00
Moritz Kiefer
b3a5c3b28d
Share test certificates (#4982)
* Share test certificates

This is primarily an attempt at making sure my contribution stats
remain negative but I think it’s a nice cleanup. The only difference
in the certs used by daml-helper which are now used everywhere is that
they use a different CN for the CA and the server. This is required to
make openssl happy (which is used by the daml-helper).

changelog_begin
changelog_end

* Fix script and trigger tests
2020-03-13 12:12:34 +01:00
Moritz Kiefer
96f62418c5
Support TLS in DAML script and DAML triggers (#4971)
This adds CLI parametrs for connecting via TLS following the scheme
used by navigator, extractor and `daml ledger`.

changelog_begin

- [DAML Script] Support TLS. Enable it by passing ``--tls``. You can
  set certificates for client authentication via ``--pem`` and
  ``-crt`` and a custom root CA for validating the server certificate
  via ``--cacrt``.

- [DAML Triggers - Experimental] Support TLS. Enable it by passing ``--tls``. You can
  set certificates for client authentication via ``--pem`` and
  ``-crt`` and a custom root CA for validating the server certificate
  via ``--cacrt``.

changelog_end
2020-03-13 09:54:44 +01:00
Samir Talwar
a99156252d
libs-scala/ports: Wrap socket ports in a type, Port. (#4784)
* libs-scala/ports: Wrap socket ports in a type, `Port`.

* sandbox: Use `Port` for the API server port, and propagate.

CHANGELOG_BEGIN
CHANGELOG_END

* extractor: Use `Port` for the server port.

* ports: Make Port a compile-time class only.

* ports: Allow port 0; it can be specified by a user.

* ports: Publish to Maven Central.
2020-03-03 08:59:15 +00:00
Shayne Fletcher
66dd112960
Remove pragma 'daml 1.2' (#4702)
changelog_begin
- The pragma 'daml 1.2' is now optional.
changelog_end
2020-02-26 13:17:45 -05:00
Gary Verhaegen
5a117dc358
introduce new release process (#4513)
Context
=======

After multiple discussions about our current release schedule and
process, we've come to the conclusion that we need to be able to make a
distinction between technical snapshots and marketing releases. In other
words, we need to be able to create a bundle for early adopters to test
without making it an officially-supported version, and without
necessarily implying everyone should go through the trouble of
upgrading. The underlying goal is to have less frequent but more stable
"official" releases.

This PR is a proposal for a new release process designed under the
following constraints:

- Reuse as much as possible of the existing infrastructure, to minimize
  effort but also chances of disruptions.
- Have the ability to create "snapshot"/"nightly"/... releases that are
  not meant for general public consumption, but can still be used by savvy
  users without jumping through too many extra hoops (ideally just
  swapping in a slightly-weirder version string).
- Have the ability to promote an existing snapshot release to "official"
  release status, with as few changes as possible in-between, so we can be
  confident that the official release is what we tested as a prerelease.
- Have as much of the release pipeline shared between the two types of
  releases, to avoid discovering non-transient problems while trying to
  promote a snapshot to an official release.
- Triggerring a release should still be done through a PR, so we can
  keep the same approval process for SOC2 auditability.

The gist of this proposal is to replace the current `VERSION` file with
a `LATEST` file, which would have the following format:

```
ef5d32b7438e481de0235c5538aedab419682388 0.13.53-alpha.20200214.3025.ef5d32b7
```

This file would be maintained with a script to reduce manual labor in
producing the version string. Other than that, the process will be
largely the same, with releases triggered by changes to this `LATEST`
and the release notes files.

Version numbers
===============

Because one of the goals is to reduce the velocity of our published
version numbers, we need a different version scheme for our snapshot
releases. Fortunately, most version schemes have some support for that;
unfortunately, the SDK sits at the intersection of three different
version schemes that have made incompatible choices. Without going into
too much detail:

- Semantic versioning (which we chose as the version format for the SDK
  version number) allows for "prerelease" version numbers as well as
  "metadata"; an example of a complete version string would be
  `1.2.3-nightly.201+server12.43`. The "main" part of the version string
  always has to have 3 numbers separated by dots; the "prerelease"
  (after the `-` but before the `+`) and the "metadata" (after the `+`)
  parts are optional and, if present, must consist of one or more segments
  separated by dots, where a segment can be either a number or an
  alphanumeric string. In terms of ordering, metadata is irrelevant and
  any version with a prerelease string is before the corresponding "main"
  version string alone. Amongst prereleases, segments are compared in
  order with purely numeric ones compared as numbers and mixed ones
  compared lexicographically. So 1.2.3 is more recent than 1.2.3-1,
  which is itself less recent than 1.2.3-2.
- Maven version strings are any number of segments separated by a `.`, a
  `-`, or a transition between a number and a letter. Version strings
  are compared element-wise, with numeric segments being compared as
  numbers. Alphabetic segments are treated specially if they happen to be
  one of a handful of magic words (such as "alpha", "beta" or "snapshot"
  for example) which count as "qualifiers"; a version string with a
  qualifier is "before" its prefix (`1.2.3` is before `1.2.3-alpha.3`,
  which is the same as `1.2.3-alpha3` or `1.2.3-alpha-3`), and there is a
  special ordering amongst qualifiers. Other alphabetic segments are
  compared alphabetically and count as being "after" their prefix
  (`1.2.3-really-final-this-time` counts as being released after `1.2.3`).
- GHC package numbers are comprised of any number of numeric segments
  separated by `.`, plus an optional (though deprecated) alphanumeric
  "version tag" separated by a `-`. I could not find any official
  documentation on ordering for the version tag; numeric segments are
  compared as numbers.
- npm uses semantic versioning so that is covered already.

After much more investigation than I'd care to admit, I have come up
with the following compromise as the least-bad solution. First,
obviously, the version string for stable/marketing versions is going to
be "standard" semver, i.e. major.minor.patch, all numbers, which works,
and sorts as expected, for all three schemes. For snapshot releases, we
shall use the following (semver) format:

```
0.13.53-alpha.20200214.3025.ef5d32b7
```

where the components are, respectively:

- `0.13.53`: the expected version string of the next "stable" release.
- `alpha`: a marker that hopefully scares people enough.
- `20200214`: the date of the release commit, which _MUST_ be on
  master.
- `3025`: the number of commits in master up to the release commit
  (included). Because we have a linear, append-only master branch, this
  uniquely identifies the commit.
- `ef5d32b7ù : the first 8 characters of the release commit sha. This is
  not strictly speaking necessary, but makes it a lot more convenient to
  identify the commit.

The main downsides of this format are:

1. It is not a valid format for GHC packages. We do not publish GHC
  packages from the SDK (so far we have instead opted to release our
  Haskell code as separate packages entirely), so this should not be an
  issue. However, our SDK version currently leaks to `ghc-pkg` as the
  version string for the stdlib (and prim) packages. This PR addresses
  that by tweaking the compiler to remove the offending bits, so `ghc-pkg`
  would see the above version number as `0.13.53.20200214.3025`, which
  should be enough to uniquely identify it. Note that, as far as I could
  find out, this number would never be exposed to users.
2. It is rather long, which I think is good from a human perspective as
  it makes it more scary. However, I have been told that this may be
  long enough to cause issues on Windows by pushing us past the max path
  size limitation of that "OS". I suggest we try it and see what
  happens.

The upsides are:

- It clearly indicates it is an unstable release (`alpha`).
- It clearly indicates how old it is, by including the date.
- To humans, it is immediately obvious which version is "later" even if
  they have the same date, allowing us to release same-day patches if
  needed. (Note: that is, commits that were made on the same day; the
  release date itself is irrelevant here.)
- It contains the git sha so the commit built for that release is
  immediately obvious.
- It sorts correctly under all schemes (modulo the modification for
  GHC).

Alternatives I considered:

- Pander to GHC: 0.13.53-alpha-20200214-3025-ef5d32b7. This format would
  be accepted by all schemes, but will not sort as expected under semantic
  versioning (though Maven will be fine). I have no idea how it will sort
  under GHC.
- Not having any non-numeric component, e.g. `0.13.53.20200214.3025`.
  This is not valid semantic versioning and is therefore rejected by
  npm.
- Not having detailed info: just go with `0.13.53-snapshot`. This is
  what is generally done in the Java world, but we then lose track of what
  version is actually in use and I'm concerned about bug reports. This
  would also not let us publish to the main Maven repo (at least not more
  than once), as artifacts there are supposed to be immutable.
- No having a qualifier: `0.13.53-3025` would be acceptable to all three
  version formats. However, it would not clearly indicate to humans that
  it is not meant as a stable version, and would sort differently under
  semantic versioning (which counts it as a prerelease, i.e. before
  `0.13.53`) than under maven (which counts it as a patch, so after
  `0.13.53`).
- Just counting releases: `0.13.53-alpha.1`, where we just count the
  number of prereleases in-between `0.13.52` and the next. This is
  currently the fallback plan if Windows path length causes issues. It
  would be less convenient to map releases to commits, but it could still
  be done via querying the history of the `LATEST` file.

Release notes
=============

> Note: We have decided not to have release notes for snapshot releases.

Release notes are a bit tricky. Because we want the ability to make
snapshot releases, then later on promote them to stable releases, it
follows that we want to build commits from the past. However, if we
decide post-hoc that a commit is actually a good candidate for a
release, there is no way that commit can have the appropriate release
notes: it cannot know what version number it's getting, and, moreover,
we now track changes in commit messages. And I do not think anyone wants
to go back to the release notes file being a merge bottleneck.

But release notes need to be published to the releases blog upon
releasing a stable version, and the docs website needs to be updated and
include them.

The only sensible solution here is to pick up the release notes as of
the commit that triggers the release. As the docs cron runs
asynchronously, this means walking down the git history to find the
relevant commit.

> Note: We could probably do away with the asynchronicity at this point.
> It was originally included to cover for the possibility of a release
> failing. If we are releasing commits from the past after they have been
> tested, this should not be an issue anymore. If the docs generation were
> part of the synchronous release step, it would have direct access to the
> correct release notes without having to walk down the git history.
>
> However, I think it is more prudent to keep this change as a future step,
> after we're confident the new release scheme does indeed produce much more
> reliable "stable" releases.

New release process
===================

Just like releases are currently controlled mostly by detecting
changes to the `VERSION` file, the new process will be controlled by
detecting changes to the `LATEST` file. The format of that file will
include both the version string and the corresponding SHA.

Upon detecting a change to the `LATEST` file, CI will run the entire
release process, just like it does now with the VERSION file. The main
differences are:

1. Before running the release step, CI will checkout the commit
  specified in the LATEST file. This requires separating the release
  step from the build step, which in my opinion is cleaner anyway.
2. The `//:VERSION` Bazel target is replaced by a repository rule
  that gets the version to build from an environment variable, with a
  default of `0.0.0` to remain consistent with the current `daml-head`
  behaviour.

Some of the manual steps will need to be skipped for a snapshot release.
See amended `release/RELEASE.md` in this commit for details.

The main caveat of this approach is that the official release will be a
different binary from the corresponding snapshot. It will have been
built from the same source, but with a different version string. This is
somewhat mitigated by Bazel caching, meaning any build step that does
not depend on the version string should use the cache and produce
identical results. I do not think this can be avoided when our artifact
includes its own version number.

I must note, though, that while going through the changes required after
removing the `VERSION` file, I have been quite surprised at the sheer number of
things that actually depend on the SDK version number. I believe we should
look into reducing that over time.

CHANGELOG_BEGIN
CHANGELOG_END
2020-02-25 17:01:23 +01:00
Samir Talwar
f231ebc1b3
Sandbox-Next: Re-establish static time support. (#4581)
* kvutils: Extract a committer from the uses of `SubmissionValidator`.

This makes the clock injectable too.

* kvutils: Provide logging contexts in the `Runner`.

* sandbox: Remove the `StaticAllowBackwards` time provider type.

It's not used anywhere.

* sandbox: Fix warnings in CliSpec.

* sandbox: Ensure that we cannot specify both static and wall-clock time.

* sandbox-next: Crash if wall clock time is not specified.

* sandbox-next: Document more known issues in the new Sandbox.

* sandbox: Add a Clock (and some tests) to TimeServiceBackend.

* sandbox-next: Support static time.

CHANGELOG_BEGIN
- [Sandbox Next] Re-establish static time mode.
CHANGELOG_END

* ledger-on-(memory|sql): Expect a `() => Instant`, not a `Clock`.
2020-02-18 17:03:15 +00:00
Moritz Kiefer
c64919cd58
Support --help in daml trigger/daml script/daml script-test (#4534)
fixes #4529
fixes #4530
fixes #4531

changelog_begin
changelog_end
2020-02-17 09:09:01 +01:00
Samir Talwar
a589f4af0b
sandbox: Move more resource acquisition into the owner. (#4501)
* sandbox: Move more resource acquisition into the `owner`.

CHANGELOG_BEGIN
CHANGELOG_END

* sandbox: Reimplement SandboxClientResource as a resources.Resource.

* codegen: Use resources in TestUtil.

* sandbox: Manage PostgreSQL in tests with ResourceOwners.
2020-02-14 13:52:45 +00:00
Moritz Kiefer
e7b8cdba89
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
2020-02-12 11:16:25 +01:00
Moritz Kiefer
8590ff8274
Document all arguments of the trigger rule (#4448)
Previously we were missing the time.

changelog_begin
changelog_end
2020-02-07 18:20:04 +01:00
Gary Verhaegen
47bd131f15
add copyright headers to yml files (#4407)
We seem to have forgotten about them in the copyright scripts.

CHANGELOG_BEGIN
CHANGELOG_END
2020-02-06 12:54:07 +01:00
Remy
5fa173ea19
Engine: make Transaction/Node/VersionnedValue mapContractId LF private (#4364)
CHANGELOG_BEGIN
CHANGELOG_END
2020-02-05 16:25:39 +00:00
Miklos
dc0bca5a2f
Fix missing interpolators (#4372)
CHANGELOG_BEGIN
CHANGELOG_END
2020-02-04 17:09:49 +01:00
Moritz Kiefer
6453a73968
Add first prototype of triggers as a service (TaaS) (#4287)
* Add first prototype of triggers as a service (TaaS)

This is an extremely basic version of the trigger as a service thingy.

Right now, it supports spawning triggers and stopping them but nothing
else.

There is a very simple test to check that it’s not completely broken.

changelog_begin
changelog_end

* Apply suggestions from code review

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

* remove debugging output

* remove leftover import

Co-authored-by: Andreas Herrmann <42969706+aherrmann-da@users.noreply.github.com>
2020-01-31 12:53:45 +01:00
Andreas Herrmann
2e08e23703
Daml.Trigger.Assert for trigger testing API (#4264)
* Daml.Trigger.Assert for trigger testing API

Requires extracting part of Daml.Trigger into Daml.Trigger.Internal to
get access to internal data constructors and functionality

CHANGELOG_BEGIN
- [DAML Trigger - Experimental] Trigger testing functionality is now
available in the module Daml.Trigger.Assert.
CHANGELOG_END

* Set exposed-modules to hide Daml.Trigger.Internal

* API docs for Daml.Trigger.Assert

Co-authored-by: Andreas Herrmann <andreash87@gmx.ch>
2020-01-29 16:57:00 +00:00
Andreas Herrmann
74984559e8 Test triggers in scenarios (#4233)
* Bazel test for trigger scenario

* daml-triggers: Allow testing trigger rules in scenarios

CHANGELOG_BEGIN
- [DAML Triggers - Experimental] DAML triggers can now be tested in
scenarios. Specifically, a trigger's ``rule`` can be executed in a
scenario and assertions performed on the emitted commands.
CHANGELOG_END

* Allow assertions on create commands

CHANGELOG_BEGIN
* [DAML stdlib] Add `CanAbort` instance for `Either Text`.
CHANGELOG_END

* Add convenience to construct ACS for testRule

* Add assertions for exercise and exerciseByKey

* fix assert message

* Test assertExercise(ByKey)Cmd

* unpackCommands --> flattenCommands

* Add API documentation

* Document that command ids start from "0"

* generalise command assertions to CanAbortm

* export ACSBuilder type

* Better haddocs for trigger command assertions

* explicit let

* ./fmt.sh

* Fix runfiles on Windows

* Add reference to Bazel issue

Co-authored-by: Andreas Herrmann <andreash87@gmx.ch>
2020-01-28 11:50:46 +00:00
Remy
b6e848b576
Engine: Add node and contract Discriminator
CHANGELOG_BEGIN
CHANGELOG_END
2020-01-22 18:49:30 +01:00
Moritz Kiefer
955978b894
Version the daml-trigger and daml-script DARs using the SDk version (#4148)
This makes much more sense than setting it to a fixed 0.0.1 version.

changelog_begin
changelog_end
2020-01-21 21:30:34 +01:00
Andreas Herrmann
3ec35be3de
Handle MHeartbeat in runTrigger (#4022)
* daml triggers: Set -Werror

* Handle MHeartbeat message in runTrigger

This was missing when heartbeat support was added.

CHANGELOG_BEGIN
CHANGELOG_END

Co-authored-by: Andreas Herrmann <andreash87@gmx.ch>
2020-01-13 14:56:21 +01:00
Andreas Herrmann
2b64ea3ca4 Implement DAML trigger heartbeat (#4011)
* Implement heartbeat messages in trigger runner.

* Add heartbeat to Daml.Trigger

CHANGELOG_BEGIN
- [DAML Triggers - Experimental] DAML triggers can now configure a heartbeat message to be sent at regular time interval.
CHANGELOG_END

* Add DAML trigger heartbeat test-case

* ./fmts.h

Co-authored-by: Andreas Herrmann <andreash87@gmx.ch>
2020-01-10 16:04:47 +00:00
Moritz Kiefer
27fd561af6 Fix trigger time tests (#4002)
These have failed quite a few times on Windows and occasionally also
on MacOS.

This test, first fixes a small issue where the tests were actually
using the times from completions instead of only the timings from
creations. (that technically shouldn’t be an issue but it’s at least
confusing since the error claims to test creations).

In addition to that, this PR changes the condition to allow for the
times to be equal since especially on Windows we don’t seem to have a
very high resolution and the tests are remarkably quick so sometimes
the times can be identical.

I’ve slightly rephrased the condition since I got confused by the fact
that we test for the negated condition.

changelog_begin
changelog_end
2020-01-09 16:53:43 +00:00
Gerolf Seitz
0438bd5ec2
Log DAML trace messages (#3983)
Fixes #28.

CHANGELOG_BEGIN
[Sandbox] DAML trace logs (trace, traceRaw, traceId) are now logged via the regular logging system (slf4j+logback) at interpretation time via the logger ``daml.tracelog`` at DEBUG level.
CHANGELOG_END
2020-01-08 17:14:50 +01:00
Gary Verhaegen
878429e3bf
update copyright notices to 2020 (#3939)
copyright update 2020

* update template
* run script: `dade-copyright-headers update .`
* update script
* manual adjustments
* exclude frozen proto files from further header checks (by adding NO_AUTO_COPYRIGHT files)
2020-01-02 21:21:13 +01:00
Brian Healey
9f13a2fb10 Upgrade to Akka 2.6.1, akka-http 10.1.11 and Scala 2.12.10 (#3903)
* Upgrade to Akka 2.6.1, akka-http 10.1.11 and Scala 2.12.10

Akka 2.6.1 Upgrade Changes
- Materializer in place of ActorMaterializer
- Source.future instead of Source.fromFuture
- The Scheduler.schedule method has been deprecated in favor of selecting scheduleWithFixedDelay or scheduleAtFixedRate
- onDownstreamFinish(cause: Throwable)
- ActorAttributes.supervisionStrategy(...) in place of ActorMaterializerSettings.withSupervisionStrategy

See https://doc.akka.io/docs/akka/current/project/migration-guide-2.5.x-2.6.x.html

* Akka 2.6.1 Upgrade Changes
- onDownstreamFinish(cause: Throwable)

See https://doc.akka.io/docs/akka/current/project/migration-guide-2.5.x-2.6.x.html

* code review: remove unnecessary supervision strategy
2019-12-19 18:00:59 +00:00
Andreas Herrmann
06cd1f14a2
Expose timestamp in DAML triggers (#3858)
* Add time to Trigger update function

CHANGELOG_BEGIN

- [DAML Triggers - Experimental] Expose timestamp in triggers.
  See `#3612 <https://github.com/digital-asset/daml/issues/3612>`__.

CHANGELOG_END

* Add triggers time test

* Update trigger docs
2019-12-17 11:12:05 +01:00
Moritz Kiefer
022c60ccb3 Publish the thin trigger library instead of the fat jar (#3739)
This still contains the main class so you can use it like you would
use the fat jar but publishing fat jars to maven central is apparently
bad practise and some peple have asked for the library.

This includes some slight tweaks to the scala_docs rule to make it
capable of coping with the generated source file and a hack in the
release script to avoid it complaining about the scenario proto
library not being published to Maven even though it is included in the
transitive deps.
2019-12-05 13:04:20 +00:00
Stefano Baghino
5254520b80 Spin off TokenHolder into a new library (#3741)
* Spin off TokenHolder into a new library

Avoids having weird dependencies between different packages, makes TokenHolder available on Maven

* Fix auth-utils path
2019-12-05 12:31:14 +00:00
Robin Krom
3f666792b1 language: suffix all dalfs dependencies in a dar with the pkgid. (#3668)
* language: suffix all dalfs dependencies in a dar with the pkgid.

This makes sure that dalf dependencies are not accidentally overwritten
when two packages with equally named dalfs are imported.

* factor out parseUnitId
2019-12-05 11:47:45 +00:00
Moritz Kiefer
24b6dfd319
Support authentication in DAML triggers (#3730)
* Support authentication in DAML triggers

fixes #3259

CHANGELOG_BEGIN

- [DAML Triggers - Experimental] DAML triggers can now be run against
an authenticated ledger.

CHANGELOG_END

* Remove debug printf

* Windows is bad
2019-12-04 13:57:44 +01:00
Moritz Kiefer
5a3b5f498a Fix SDK versions in trigger and daml-script dars (#3706)
* Fix SDK versions in trigger and daml-script dars

* Fix SDK versions in tests
2019-12-03 07:28:49 +00:00
Martin Huschenbett
9f18a83570
Fix error message for missing --ledger-party in daml trigger (#3677)
Who is "Ledger Pary"?
2019-11-29 12:31:19 +01:00
Martin Huschenbett
167232bd81
Ban usage of generic templates (#3631)
We don't drop full support from the compiler yet but rather ban their use by
adding a check to the preprocessor. We'll remove the actual support as we go
along with fixing the upgrading story.

CHANGELOG_BEGIN

- [DAML Compiler] Make the experimental feature "generic templates"
  unavailable. The current implementation is at odds with other, more important
  language features still under development.

CHANGELOG_END
2019-11-26 17:15:17 +01:00
Moritz Kiefer
c34f56ab2e
Add template id filtering to triggers (#3577)
* Add template id filtering to triggers

CHANGELOG_BEGIN
- [Daml Triggers - Experimental] DAML triggers now allow you to specify which templates you want to listen for which can improve performance.
CHANGELOG_END

* Address review comments

* Fix list-triggers test
2019-11-21 16:50:40 +01:00
Moritz Kiefer
c3438a58af
Refactor trigger runner in preparation for template id filtering (#3570)
This is a prepatory PR before introducing template id filtering in
DAML triggers. It does not change or introduce any new functionality.
2019-11-21 14:08:11 +01:00
Moritz Kiefer
6d2ed90f29 Remove target flags in DAML triggers and DAML script (#3545)
1.7 is now the default so we no longer need those.
2019-11-20 10:54:16 +00:00
Moritz Kiefer
1bc4bb76a4 Make AnyChoice and AnyContractKey take template type into account (#3541)
* Make AnyChoice and AnyContractKey take template type into account

fixes #3540

* Update template desugaring

* Switch to proper ghc-lib release
2019-11-20 10:40:14 +00:00
Moritz Kiefer
5458053ea9 Add pending set to DAML triggers (#3502)
fixes #3360
2019-11-18 14:25:40 +00:00
Andreas Herrmann
712bc456ba Map CommandIds in MTransaction (#3501)
* Regression test for #3485

* Respect CommandId mapping for transactions

* triggers: Fix ExerciseByKey

Make choice nonconsuming, so that no second `T` is created later.
Only execute `dedupExerciseByKey` if `T_` doesn't exist, yet.

* Update list-triggers test

* triggers: Empty commandId on foreign TransactionM

95ccc59b45 (r347287514)
2019-11-18 14:34:48 +01:00
Moritz Kiefer
4eb72d496e
Fix conversion from Ledger API to Speedy in DAML triggers (#3458)
Previously, we use SValue.fromValue for the conversion. However, this
breaks in cases like Numeric where the scale information is lost. By
using the ValueTranslator instead, we avoid this issue.

There is a similar problem in DAML script but I’ll fix that in a
separate PR.

Since the ValueTranslator is package private, this PR moves the
triggers in the engine package.
2019-11-14 09:26:36 +01:00
Moritz Kiefer
3fdc9f280c Clean trigger tracelog after each step (#3445)
Previously, we ended up accumulating trace messages which obviously is
not what you want. This PR changes this to replace the tracelog by a
new, empty TraceLog (if there actually was something to trace) and
thereby fixes this issue.

I don’t really want to start adding tests for logging output so for
now this doesn’t have a manual test but if this starts becoming a
problem again, we probably want to add a separate output source to the
trigger runner instead of going via the logger so we can test this easily.
2019-11-13 10:13:41 +00:00
Moritz Kiefer
45d2b7048c
[daml-triggers] Rename getTemplates to getContracts (#3430)
Given that this returns the contracts of a given template rather than
returning templates, this name makes a lot more sense.
2019-11-12 14:48:24 +01:00
Moritz Kiefer
11044f3683 Add exerciseByKey to DAML triggers (#3413)
fixes #3317
2019-11-11 18:12:25 +00:00
Moritz Kiefer
7db11ca427 Add toAnyContractKey and fromAnyContractKey (#3408)
* Add toAnyContractKey and fromAnyContractKey

This is necessary to add exerciseByKey to DAML triggers.

* Switch to proper ghc-lib release

* Remove unnecessary filter

* Bump timeout because macos is terrible

* bazel fmt
2019-11-11 17:35:53 +00:00
Moritz Kiefer
c57a31d630
Compile DAML trigger library with --target 1.7 (#3372) 2019-11-07 12:08:44 +01:00
Jussi Mäki
ca7bbacd6c Build rules for producing and verifying ledger dumps (#3290)
* Add client_server_build and integrity_test rules

And use them to implement ledger dump of the reference
server and to check it.

* Only build and test ledger dump on Linux. Only run tests relevant to dump.

* Make client_server_build quiet in happy path

* Reformat

* Remove unnecessary runfiles for client_server_build
2019-11-07 09:41:54 +00:00
Andreas Herrmann
6bbc6157d5 trigger.Converter avoid exceptions (#3341)
* trigger.Converter avoid exceptions

Refactor `com.daml.trigger.Converter` to consistently use
`Either[String, _]` instead of throwing exceptions to handle conversion
errors.

* Throw ConverterError on conversion error
2019-11-06 10:52:27 +00:00
Moritz Kiefer
90679c93f8
Use regular ContractIds in DAML triggers (#3337)
The only reason for having AbsoluteContractId was that we could get
some more instances in particular `Ord` and `MapKey` but given that
`ContractId` will be a valid key type for the new DAML-LF maps, we can
just use slower implementations for now and switch to Map-based
implementations once that has landed.

fixes #3336
2019-11-05 15:15:07 +01:00
Remy
7c427119e1 DAML-LF add Type Representation value (#3326)
* daml-lf: update spec with type-rep

* daml-lf: update proto with type-rep

* daml-lf: update scala side with TypeRep

* daml-lf: update compiler side with TypeRep

* Get triggers to compile

* Add featureTypeRep to allFeatures

* Apply suggestions from code review

Co-Authored-By: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>

* daml-lf: add builtin for TypeRep equality

* Address Andrea's comments

* formatting

* Fix triggers

* Fix template typerep tests
2019-11-04 17:00:55 +00:00
Moritz Kiefer
e7280f96b3 Add dedupCreate/dedupExercise helpers to the DAML trigger API (#3280)
Given how common this is, it seems worthwile to add helpers for this.
2019-10-29 18:06:43 +00:00
Moritz Kiefer
e70bb007be Add a command to list the triggers in a DAR (#3268)
For now, this uses a somewhat adhoc format with one trigger identifier
per line but given that I expect that it won’t be particularly common
to want to do this mechanically this should be sufficient and it’s
trivial to parse.
2019-10-28 22:34:19 +00:00
Moritz Kiefer
3cd5cfc1d7 Include daml-docs for daml-trigger in the documentation (#3263)
* Include daml-docs for daml-trigger in the documentation

* Fix link to trigger docs
2019-10-28 19:30:23 +00:00
Moritz Kiefer
d2e209aeb9 Cleanup internals of high-level trigger API (#3265)
This is in preparation for adding helpers for command
deduplication. There are no public API changes in this PR.
2019-10-28 19:20:35 +00:00
Moritz Kiefer
380c2cc494 Warn on trigger package id mismatch (#3258)
This is fairly easy to run into so it makes sense to warn about
this. Given that I expect the trigger library will be reasonably
stable in the near future, this is only a warning rather than an
error.

fixes #3244
2019-10-28 15:14:54 +00:00
Andreas Herrmann
2bd1db490a
Replace bazel-deps by rules_jvm_external (#3253)
* Update bazel-common to fix javadoc issues

Specifically, to fix the following error

```
ERROR: /home/aj/tweag.io/da/da-bazel-1.1/ledger-api/rs-grpc-bridge/BUILD.bazel:7:1: in javadoc_library rule //ledger-api/rs-grpc-bridge:rs-grpc-bridge_javadoc:
Traceback (most recent call last):
        File "/home/aj/tweag.io/da/da-bazel-1.1/ledger-api/rs-grpc-bridge/BUILD.bazel", line 7
                javadoc_library(name = 'rs-grpc-bridge_javadoc')
        File "/home/aj/.cache/bazel/_bazel_aj/5f825ad28f8e070f999ba37395e46ee5/external/com_github_google_bazel_common/tools/javadoc/javadoc.bzl", line 27, in _javadoc_library
                dep.java.transitive_deps
object of type 'JavaSkylarkApiProvider' has no field 'transitive_deps'
```

* Define Maven deps using rules_jvm_external

* Pin artifacts

* Remove bazel-deps generated targets

* Remove bazel-deps

* Switch to rules_jvm_external targets

* update bazel documentation

* pom_file: There are no more bazel-deps targets

* BAZEL-JVM.md `maven_install` typo
2019-10-28 13:53:14 +01:00
Andreas Herrmann
dc2f10ebe6 Use TemplateTypeRep in DAML Trigger API (#3245)
* Add TemplateTypeRep to AnyContractId

* Define Trigger.ContractId t

* Use Trigger.ContractId t

* Implement fromCreated and fromArchived

* instance MapKey TemplateTypeRep

* More efficient ACS access using Map TemplateTypeRep

* ./fmt.sh

* toString and fromString for Identifier

* Replace Identifier by TemplateTypeRep

* TheContractId --> AbsoluteContractId

https://github.com/digital-asset/daml/pull/3245#discussion_r338033546
2019-10-23 13:56:59 +00:00
Moritz Kiefer
6c36777a8e
Release DAML trigger runner to Bintray (#3243)
This should make it a bit easier to use in a managed environment and
has been requested by some users.
2019-10-21 18:14:46 -04:00
Andreas Herrmann
b0bd8328ea
Detect high level trigger (#3239)
* capture high-level module in converter

* Factor out trigger discovery

* Support running high-level triggers directly

* Don't convert to low-level trigger in Retry

* ./fmt.sh

* Update CopyTrigger, docs, and changelog
2019-10-21 14:22:08 +02:00
Moritz Kiefer
f2618ec85b Run DAML trigger rule on failed completions (#3226)
fixes #3214
2019-10-18 13:04:31 +00:00
Moritz Kiefer
e31526c35c Use the same CopyTrigger in the docs and the tests (#3213)
* Use the same CopyTrigger in the docs and the tests

That way, we actually test what we use in our docs which seem like a
much better idea than duplicating the code.

* Add debugging output on failures
2019-10-17 12:52:15 +00:00
Moritz Kiefer
6d3ae219d1 Improve logging and debugging of DAML triggers (#3210)
- We now display `trace` messages so they can be used for debugging.
- I’ve removed the log message from the low-level API since it is
  confusing as it is not exposed via the high-level API and somewhat
  redundant since you can use `trace` for debugging. If there is a
  demand for proper logging support we might want to add it back at
  some point.
- We now display errors from speedy properly. This is mainly important
  for calls to `error` since we previously lost the error message.
- Logging messages go through a proper logging library now and the
  internal debugging stuff is only displayed at debug level so not by default.
- We log failed completions at warning level to ease debugging.
2019-10-17 10:21:56 +00:00
Moritz Kiefer
155b2ea5d1
Disable debug logging messages from netty in the trigger runner (#3202)
This makes the output significantly less noisy.
2019-10-16 17:31:10 +02:00
Moritz Kiefer
87427ba334
Fix a race condition in the DAML trigger tests (#3199)
Previously, it could happen that the command flow used in the test was
started before the trigger queried the ACS on startup.

Now we wait for the ACS to be queried before starting the commands
flow which fixes this issue.
2019-10-16 16:51:06 +02:00
Moritz Kiefer
155302a247 [daml-triggers] Support wallclock time and make TTL configurable (#3186)
* [daml-triggers] Support wallclock time and make TTL configurable

fixes #3184

* Remove duplicate wall clock option
2019-10-15 15:43:55 +00:00
Moritz Kiefer
dbddead461
Add a first draft of documentation for DAML triggers (#3181)
* Add a first draft of documentation for DAML triggers

The API will still change in a bunch of ways but I’d rather get some
docs in place now and update them as we change things than not have
any docs at all.

* Fix path to daml.yaml

* s/bot/trigger/

* fix source code markers

* Fix tests

* Update docs/source/triggers/index.rst

Co-Authored-By: Andreas Herrmann <42969706+aherrmann-da@users.noreply.github.com>
2019-10-15 16:50:43 +02:00
Remy
e45b585307 daml-lf: repackage daml-lf archive proto (daml_lf -> daml_lf_dev) (#3169) 2019-10-15 09:36:11 +00:00
Remy
d64df4b5f7 daml-lf: clean achive bazel build (#3175)
* clean the mess in daml-lf achive bazel build

* add release note

* Address Moritz's comments

* more release notes
2019-10-15 08:36:46 +00:00
Remy
fc1a000090 daml-lf: rename daml_lf_archive_scala target to daml_lf_archive_reader (#3168)
* daml-lf: rename daml_lf_archive_scala target to daml_lf_archive_reader

* fix release
2019-10-14 14:53:50 +00:00
Moritz Kiefer
1da742ec60 Use UUIDs for command ids emitted from DAML triggers (#3170)
fixes #3130
2019-10-14 14:49:01 +00:00
Moritz Kiefer
b6e9e5ccea
Replace LedgerValue by AnyChoice in DAML triggers (#3162)
This means that we no longer rely on the fact that Speedy
accepts type errors which makes me very sad :(
2019-10-11 18:30:51 +02:00
Moritz Kiefer
48eb360a4f Add AnyChoice type to DAML (#3152)
* Add AnyChoice type to DAML

fixes #3131

* Fix ProposalDesugared

* Fix trigger tests

* Use the proper ghc-lib urls
2019-10-10 16:46:55 +00:00
Moritz Kiefer
dcdcf7f0c0
Generalize AnyTemplate type to Any in DAML-LF (#3141)
* Generalize AnyTemplate type to Any in DAML-LF

See #3131 for the motivation for this. The tl;dr is that we need
something like AnyTemplate for choice types as well.

Since the protobuf was already more general in anticipation of such a
change, this change only changes the internal AST on the Haskell and
Scala side.

Since AnyTemplate change has never made it out of 1.dev, I updated the
changelog in the LF spec instead of adding a new entry.

* Update daml-lf/spec/daml-lf-1.rst

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

* windows debugging

* more windows debugging

* clean expunge

* don’t cat the config file

* remove comment on type equality

* windows …

* gnah

* foobar

* foobar

* does anything ever work?

* reenable caching

* Do not build daml-lf-ast separately
2019-10-10 08:51:52 +02:00
Moritz Kiefer
3b1d8dfe33 Remove custom State monad from daml-trigger (#3136) 2019-10-09 07:42:48 +00:00
Moritz Kiefer
d500d9967a
Allow emitting commands on trigger initialization (#3132)
fixes #3128

Also includes a small bug fix to reenable some tests that I
accidentally disabled in #3127 and fixes deserialization of command
ids in completions which I accidentaly broke when making fromCommandId
return an Optional since that’s what we need for transactions.
2019-10-09 09:24:34 +02:00
Moritz Kiefer
bf04fe1be9
First draft of a high-level API for DAML triggers (#3127)
This PR adds a first draft of a high-level API for DAML
triggers. There is definitely more work to be done and the design is
absolutely not final. However it already allows expressing the copy
bot fairly cleanly so I would like to merge this in its current
state (or at least without bikeshedding the design too much) and then
iterate upon it.
2019-10-08 15:34:14 +02:00
Moritz Kiefer
e51e27fe27
Make the DAML trigger tests more generic (#3096)
This is a first step towards making our tests more generic so we can
add more easily tests different triggers.
2019-10-04 10:59:02 +02:00
Moritz Kiefer
a7eec73f38
Split trigger runner into multiple files (#3088)
Having everything in a single file has gotten a bit unwieldly so this
PR splits it up. There is no change in the actual code, this is just a reshuffling.
2019-10-02 18:26:13 +02:00
Moritz Kiefer
8743dbbda7
Use newtypes for id types in DAML triggers (#3082)
This makes the API a bit safer and nicer to use. Since this is a
low-level API the constructors are exposed, for the high-level API we
probably want to hide them.
2019-10-02 16:57:20 +02:00
Moritz Kiefer
a96f219f47 Share akka logic between DAML trigger main and tests (#3084) 2019-10-02 13:29:33 +00:00
Moritz Kiefer
7e7f35216f
Remove flaky=True from trigger tests (#3079)
I’ve run them a 100 times locally and haven’t been able to get them to
fail so it looks like the issue has been fixed since.

fixes #2881
2019-10-01 17:21:16 +02:00
Moritz Kiefer
a7fbad153c
Expose completions in daml triggers (#3077) 2019-10-01 15:28:59 +02:00
Andreas Herrmann
98bb580aa2 Bundle packages with SDK releases (#3056)
* Enable SDK daml-lib package dependencies

* integration-test: SDK daml-libs dependency

* trigger --> daml-trigger

Rename the trigger library package to match other builtin packages.

* Bundle daml-trigger.dar in SDK release tarball

* Describe SDK bundled packages in changelog

* Push case match inside expand

Addressing review comment
8208277747 (r329428240)
2019-09-30 09:15:11 +00:00
Moritz Kiefer
11c686b255
Support emitting multiple transations from DAML triggers (#3049)
fixes #3047
2019-09-30 08:46:08 +02:00
Moritz Kiefer
7a2e12d6d2
[daml-triggers] Expose template data in CreateEvents (#2973)
Now that we have AnyTemplate, we can actually make the template data accessible.
2019-09-23 12:49:01 +02:00
Andreas Herrmann
df7262e853 Infer templateId and choiceName in daml trigger commands (#2945)
* Infer templateId from createCmd argument

* Infer templateId and choiceName in exerciseCmd

* Use exerciseCmd in ACS test

Add a layer of indirection to test `exerciseCmd` in the ACS test.

The trigger first creates a `AssetMirrorProposal`, only when the
proposal has been created, will it exercise the `Accept` choice to
create the actual `AssetMirror` contract.

* Remove toTemplateId

* getTemplateId --> toTemplateId

* Tuple2 --> AnyContractId

* Run Scala formatter

* Export AnyContractId

* extractTemplateId|ChoiceName
2019-09-18 10:06:53 +00:00
Moritz Kiefer
01eccf2c64 Mark DAML trigger tests as flaky while we investigate (#2882) 2019-09-11 13:32:54 +00:00
Moritz Kiefer
77225af6da
Support Exercise and Create commands in DAML triggers (#2864)
* Support Exercise and Create commands in DAML triggers

This is a bit rough but I want something to experiment with before we
settle on a design and start making the LF changes required to make it
nicer.

It does already allow you to use the original template and choice types.

* Update triggers/runner/src/main/scala/com/daml/trigger/Runner.scala

Co-Authored-By: Martin Huschenbett <martin.huschenbett@posteo.me>
2019-09-10 17:31:36 +02:00
Moritz Kiefer
9de5e3cfa4
Initialize DAML triggers with ACS (#2798) 2019-09-09 15:47:11 +02:00
Moritz Kiefer
f1a9afdf17 Clean before running daml build (#2816)
This should hopefully fix some of the flakiness we’ve been seeing on
Windows. Not entirely sure what’s going wrong without the clean but
since this only happens the lack of sandboxing seems like the most
likely difference.
2019-09-08 17:49:00 +00:00