Commit Graph

170 Commits

Author SHA1 Message Date
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