Commit Graph

242 Commits

Author SHA1 Message Date
Gerolf Seitz
8c78c00c50
Add metrics to Ledger API Server (#3523)
Fixes #3513.

* Add metrics to track commands
- Meter: CommandSubmission.failedCommandInterpretations
- Timer: CommandSubmission.submittedTransactions

* Add metrics to JdbcIndexer
- Gauge: JdbcIndexer.lastReceivedRecordTime
- Gauge: JdbcIndexer.lastReceivedOffset
- Gauge: JdbcIndexer.currentRecordTimeLag
- Timer: JdbcIndexer.processedStateUpdates


* Allow setting a custom JMX domain.
We don't want to use com.digitalasset.platform.sandbox
for the ledger-api server and indexer.

* Add interceptor that automatically meters incoming grpc service calls.

CHANGELOG_BEGIN

- [Ledger] Add various metrics to track gRPC requests, command submissions, and state update processing. See `#3513 <https://github.com/digital-asset/daml/issues/3513>`__.

CHANGELOG_END
2019-11-20 18:26:25 +01:00
mziolekda
a217187b26
add error codes for overloaded and internal error to participant state (#3524)
* add error codes for overloaded and internal error

* change wording in error description strings

* scala formatting

* use string interpolation intead of concatenation

* address issues found in peer review
2019-11-20 14:37:00 +01:00
Remy
fedc49dd12 leger-api: add GenMap support (#3506)
* leger-api: add GenMap support

* cosmetic

* Address Gerolf's  comment

* add a point in the release notes

* Address Fran's comments
2019-11-18 18:13:25 +00:00
Remy
4d36c01682 Daml lf genmap (#3453)
* shortcup for SBMapEmpty

* daml-lf: add GenMap in the interpreter.
2019-11-15 10:36:41 +00:00
Gerolf Seitz
e760d4749f Check internal dependencies of maven artifacts (#3454)
* Check internal dependencies of maven artifacts

All artifacts that are uploaded to maven need to also have
their dependencies uploaded to maven.

* inline tuple matching

* remove unnecessary parenthesis

* mark missing artifacts for maven upload
2019-11-14 14:18:54 +01:00
Samir Talwar
5b3dfc2614 reference-v2, sandbox: Add the dependency on PostgreSQL where required. (#3452)
And remove it from the tests, as they now pick it up from the binary.
2019-11-13 16:45:37 +00:00
Samir Talwar
c5d9d1014e
ledger-api-test-tool: Run tests on Canton, and fix a few issues. (#3446)
* ledger-api-test-tool-on-canton: Run Canton.

* ledger-api-test-tool-on-canton: Run the SemanticTests against Canton.

This was _so_ much work.

These will probably be flaky, so can't merge them in until we fix the
underlying issues with the tests around multi-participant allocation.

* ledger-api-test-tool: Wait for parties to arrive on all participants.

Thanks to Canton for exacerbating this bug.

Can't turn on all the tests on Canton yet as there are other spurious
failures. Will investigate next.

* ledger-api-test-tool: Move all contract key tests to ContractKeys.

If a ledger doesn't support ContractKeys, they need to be able to turn
these tests off.

* ledger-api-test-tool: If a test name is misspelled, fail immediately.

I keep getting names slightly wrong in the `--exclude` arguments and
wondering why it didn't work.

* client_server: Revert client_server_test.bzl.

Turns out I don't know what I'm doing. ¯\_(ツ)_/¯

* sandbox: Don't call `.toString` on an array. Doesn't do much.

* dev-env: Don't untar netcat automatically.

It needs to be installed with Pacman.
2019-11-13 17:27:28 +01:00
Jussi Mäki
b57ef848aa
Use TreeMap for storing transaction nodes (#3418)
* Use TreeMap for storing transaction nodes

Going forward we require deterministic serialization for transaction nodes.
This PR switches the `Transaction.nodes` to use a TreeMap instead of HashMap,
which gives us deterministic serialization order for the transaction nodes.

An alternative would be to sort the transaction nodes when serializing, but
I feel avoiding HashMap altogether is the safer option as this may bite us
elsewhere as well (e.g. tests, new serialization code, etc.).

* Address review

* Remove unused import
2019-11-12 13:55:03 +01:00
Brian Healey
a5320d3173
Hotfix resolve assorted warnings around kvutils participant read/write path (#3417)
* address warning: add type annotations, shortened syntax, optimise imports

* Specify test size to avoid bazel warning
address warning: add type annotation

* make bazel buildifier happier with call order

* no parens for a no side effect pure method
2019-11-11 13:20:39 -05:00
Stefano Baghino
377b43f2d6
Pass token in individual calls, remove default location for client token (#3403)
* Pass token in individual calls, remove default location for client token

* Fix things for AuthorizationIT

* Fix ledger-service usages of LedgerClient

* Fix remaining compilation errors
2019-11-11 16:22:25 +01:00
Gerolf Seitz
d30b6eb94b
Sandbox: fix excessive memory consumption (#3362)
* Implement proper stream pagination

The previous pagination mechanism for streaming ledger entries was implemented
as a recursive method call with manually concatenating akka Sources.
However, this didn't work properly and resulted in all the subsources being
forced immediately, resulting in parallel requests for all pages
(0-100, 100-200, 200-300, ...) instead of the expected mechanism of loading
the first page and on upstream request (i.e. client requests for more data
over grpc) loading the next page of data.

The current mechanism uses Source.unfoldAsync which makes the paging
mechanism work as expected: sequential loading of pages on demand.

* Serialize and deserialize Transactions outside the SQL Executor

This frees up the SQL Executor threads sooner for other work
and the conversion work only happens on a by need basis when
the consumer requests more data.
2019-11-08 10:25:29 +01:00
Robert Autenrieth
89d6c7375c
Add a JWT authentication to sandbox (#3283)
Fixes #3363
2019-11-07 23:04:16 +01:00
Gary Verhaegen
7b897d2507
sandbox: specify dar to load as option (#3347) 2019-11-07 20:38:35 +00:00
Oliver Seeliger
0df351b2f7
Multi domain ledger api server fixes (#3359)
* Divulged contract visibility in multi-participant environments #3351
* Ledger api server time service optional ability for testing #3225
* Allow ledger api server to share DAML-on-X DAML engine #2975
* Allow ledger api server participant ids with LedgerString chars #3327
* Ledger api server includes SQL description in errors #3324
2019-11-07 16:15:17 +01:00
Samir Talwar
64f1b3ae8d ledger-api-test-tool: Correct test timing output and improve times a little. (#3364)
* ledger-api-test-tool: Use Scala's `Duration` for timeouts.

* ledger-api-test-tool: Remove the parentheses from a getter.

* ledger-api-test-tool: Run tests sequentially.

Using Akka Streams to manage the concurrency.

* ledger-api-test-tool: Parallelize across available processors.

* sandbox/reference-v2: The test timeout scale factor is no longer needed.

Now that we don't run all tests at once, the measurements are much more
accurate.

* sandbox/reference-v2: Run LotsOfPartiesIT 11 times instead of 16.

* ledger-api-test-tool: Highlight slow tests in yellow and red.

* ledger-api-test-tool: Fix some warnings in the Reporter.

* ledger-api-test-tool: Sort the tests afterwards for better concurrency.

Turns out that Akka Streams tries to maintain order at the expense of
running more things, which is not ideal. This is a hack to let us use
`.mapAsyncUnordered` and then re-sort into the original order at the
end.

Ideally `.mapAsync` would detect when subsequent futures have finished
and start running more, even if the first hasn't finished yet.

* ledger-api-test-tool: Inline `availableProcessors` into Config.
2019-11-06 21:22:48 +00:00
Stephen Compall
d0ec381925 json-api: store contracts similar to Extractor's single-table (#3192)
* new library ledger-service/db-backend

* borrow contracts table schema from extractor

* borrow contract insertion, removing some data to be unused

* match contract schema with insert function

* factor insertContract arguments

* offset table declarations

* CLI argument for query store

* surrogate template IDs

* compute surrogate template IDs on-the-fly

* database init action

* incoherent typeclasses, eh

* newtype SurrogateTpId

* offset fetch/update functions

* bad sql

* bulk insert contracts, function for selecting contracts

* expose contract column name for query's usage

* Initializing DB on startup if configured

* dropping existing tables as part of initialization

* fix some query syntax errors

* createSchema flag

* function for streaming transactions with jwt party selected

* formatting

* usage

* collect acs contracts and the ledger offset at the end

* lastOffset

* fixing merge conflicts, updating the way 3rd party deps are specified

* Moving ContractDao into http-json module

so it can take domain AST as an input

* cleanup

* injecting new dependencies

* split transaction batches into inserts and deletes

* generate sql for deleting contracts

* `fetch_sources = True` for java_deps

* make the delete-constructed fragment more efficient; handle empty list here

* pass logHandler for insertContracts

* ContractDao returns ConnectionIO, it's up to the caller to wrap query into a transaction

* fixing typo

* minor cleanup, moving fromLedgerApi factory function into corresponding companion objects

* don't need it any more

* GetActiveContractsResponse => domain.Contract factory

* make concatFragment private

* add partition graph; move other contract-fetching experiments to ContractsFetch

* experimenting with akka sources

* introducing domain.Offset to work around API's empty/null offset cases

* minor cleanup

* decompose fetchActiveContractsFromOffset

* missed via

* ACS splitting graph

* finish doc for ACS splitting graph

* remove unneeded stages

* WIP

* lazily read a stream of ConnectionIO into a single ConnectionIO

* cancel on IO error

* figuring out how to put all the pieces together

* graph WIP

* Removing workflowId from the JSON API

* simplify acsAndBoundary; describe other flow pieces

* WIP

* use Vector in InsertDeleteStep; add variant for ACS (no deletes)

* `org.wartremover.warts.NonUnitStatements` enforced in `http-json` module

* evaluate InsertDeleteStep to a ConnectionIO

* database variant of LfValueCodec, using numbers for numbers

* convert input to JSON, combine insert plans, connect rest of contractsToOffsetIo

* remove strict contractsToOffset sink

* moving dao methods into an object

* putting pieces together

* contractsFromOffset WIP

* should be it

* cleanup

* cleanup

* contractsIo that takes List[domain.TemplateId.RequiredPkg])

* contractsIo that takes List[domain.TemplateId.RequiredPkg])

* cleanup

* put all pieces together, testing

something does not work yet

* diff is not required to return anything

that is why Sink.lastOption that gives Option[domain.Offset]

* factor out tuple split

* use traverse syntax in contractsIo2

* factor explicit flow steps out of graph DSL; remove aggregate

* locally model the Absolute/Begin distinction for offset bookmarking in DB

* Adding test cases to run HTTP Service with Postgres backend

the same set of test cases, run with and without DB backend

* make better use of domain.Offset in OffsetBoundary

* monomorphize InsertDeleteStep#append

* Disabling a test that fails with DB backend

* add release note

* add release note about workflowId

* a test case that checks the number or stored contracts

* trying to figure out why Postgres test fails on Windows with NPE
2019-11-06 13:53:16 -05:00
Gerolf Seitz
7a15706101
Added a missing index to the disclosures table (#3343) 2019-11-06 13:48:36 +01:00
Samir Talwar
fddaeb1c4a ledger-api-test-tool: Port LotsOfPartiesIT. (#3328)
* ledger-api-test-tool: Port LotsOfPartiesIT.

* ledger-api-test-tool: Run LotsOfPartiesIT with multiple participants.

Odds of me getting this wrong: 80%. Let's find out!

* ledger-api-test-tool: More underscores, methinks.

* ledger-api-test-tool: Improve the readability of the LotsOfParties test.

Instead of all the functional magic, just do things twice. It's even
shorter in some cases.

* ledger-api-test-tool: Not so many parties. :-(

* sandbox: Extract duplication between conformance test definitions.

* sandbox: Run the LotsOfPartiesIT conformance test separately.

* Revert "ledger-api-test-tool: Not so many parties. :-("

This reverts commit 8039a7cc9b.

* sandbox: Add the copyright header to sandbox_conformance_test.bzl.

* Run `./fmt.sh`.

* ledger-api-test-tool: Generalize `sandbox_conformance_test`.

I want to use it with the DAML-on-X reference v2.

* api-server-damlonx/reference-v2: Use `server_conformance_test`.

* api-server-damlonx/reference-v2: Run LotsOfPartiesIT separately.
2019-11-05 19:54:21 +00:00
mziolekda
a6af3fac97
add InternalError to values returned by SubmissionResult (#3331)
* add InternalError to values returned by SubmissionResult

* fix scalafmt issue

* Update ledger/sandbox/src/main/scala/com/digitalasset/platform/sandbox/services/ApiSubmissionService.scala

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

* Update ledger/sandbox/src/main/scala/com/digitalasset/platform/sandbox/services/ApiSubmissionService.scala

Co-Authored-By: Stefano Baghino <43749967+stefanobaghino-da@users.noreply.github.com>
2019-11-05 10:44:26 +01:00
Stefano Baghino
edb2d15cec
Port command-related integration tests (#3320)
* Pre-port cleanup of helpers

* Further clean-up

* Remove dead code

* More cleaning and flattening

* Port first tests from CommandClientIT

* More cleanup and more dead code removal

* Port exercise by key test

* Port observer disclosure tests

* Port tests, remove duplicates and dead code

* Fix compilation error and remove more dead code

* Remove unused import

* Spread helpers to single users, remove materializer from helpers

* More test porting and cleanup

* Remove more dead code

* Restore tests deleted by mistake

* Restore final qualifier removed by mistake

* Fix typo

* Optimize imports

* Move timeout from helper to tests

* Remove unused class

* Never gonna give you up

* Address https://github.com/digital-asset/daml/pull/3320#discussion_r342018581

* Address https://github.com/digital-asset/daml/pull/3320#discussion_r342025161

* Remove removed test :)
2019-11-04 17:30:31 +01:00
Stefano Baghino
96622c9fe7 Expose DB wait/exec times over JMX as well as logs (#3310)
* Expose DB wait/exec times over JMX

* Fix compilation errors

* Fix more compilation errors

* Update unreleased.rst

* Address https://github.com/digital-asset/daml/pull/3310#pullrequestreview-310346159

* Address https://github.com/digital-asset/daml/pull/3310#discussion_r341641717
2019-11-01 17:34:44 +00:00
Jussi Mäki
0ca8580914 Fix the import paths of {value,transaction,blindinginfo}.proto (#3312)
* Fix the import paths of {value,transaction,blindinginfo}.proto

This cleans the imports in daml_kvutils.proto:

  -import "daml-lf/transaction/src/main/protobuf/transaction.proto";
  +import "com/digitalasset/daml/lf/transaction.proto";

This shouldn't be a breaking change to the outside as the proto files
themselves are not published, only the java libraries generated from them.

* Update missed deps
2019-11-01 14:54:55 +00:00
Stefano Baghino
42051ae037
Add and validate expiration on claims (#3286)
* Add and validate expiration on claims

* Address review comments

* Test existing services for token expiration

* Test expiration mid-stream

* Address https://github.com/digital-asset/daml/pull/3286#pullrequestreview-309710454
2019-10-31 13:14:44 -04:00
Gerolf Seitz
8650d38c78
Fixed a bug in the DB migration script 10.1 (#3287)
The script would throw an exception for contracts without observers.

Fixes #3284.
2019-10-30 10:58:21 +01:00
Robert Autenrieth
e887318f4f Move AuthService (#3272)
* Move AuthService and Claims

* Move interceptor and authorization wrappers

* Add artifact

* Address review comments
2019-10-29 15:46:43 +00:00
Robert Autenrieth
bc63f2f8de Add missing contract id hash (#3256)
The global implicit disclosure map was missing the `#` prefix for contract ids, which caused subsequent contract id lookups to not find the right contract.
2019-10-29 09:09:21 +01:00
Stefano Baghino
d803768405
Remove duplicates of TestExecutionSequencerFactory (#3264)
Fixes #9
2019-10-28 15:56:33 -04:00
Gerolf Seitz
fe7e5615b8
Improve performance of stakeholder retrieval from SQL (#3207)
Instead of loading and deserializing the transaction, we store the
stakeholders in tables contract_signatories and contract_observers.

To avoid having to do an extra roundtrip for fetching the stakeholders,
we aggregate the parties at query time into a % separated string (% is
not a valid character for parties), which we then split again in the
application.

Fixes #2330.
2019-10-28 14:16:21 +01: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
Remy
f3b98ca31d DAML LF: limit allocations for trivial constants (#3212)
* speedy: limit allocation of trivial SValue constants

* daml-lf: limit allocation of constants for Value, Exp, Type

* weaken numeric equality in ledger service test
2019-10-18 15:00:49 +00:00
Gerolf Seitz
8026297b96
Added Sandbox CLI parameter --max-ttl-seconds (#3223)
This CLI parameter can be used to modify the maximum allowed TTL used by
commands.
2019-10-18 14:14:59 +02:00
Robert Autenrieth
d320f93702
Add integration test for ledger API authorization (#3187)
Fixes #3023
2019-10-17 12:09:35 +02:00
Gerolf Seitz
a5921e0274 Properly fill eventId for active contracts (#3126)
* Properly fill eventId for active contracts

This gets rid of the last remaining bit that assumes
contractId==eventId.

Fixes #65.
Contributes to #2068.

* Do not conflate eventId and contractId in the daml-lf interpreter

* Do not treat contractId as eventId in Ledger.scala

* Remember the transaction that divulged a contract.

* In this scope we can treat divulged contracts the same as disclosed ones

* revert a few more syntactical changes to make the overall diff smaller

* retain the same behavior on the scenario service api

* fix unreleased after rebase
2019-10-16 17:02:04 +00:00
Leonid Shlyapnikov
2a89ce8bb2 JSON API parties endpoint + Sandbox party management fix (#3193)
* Parties endpoint

`PartyManagementClient#listKnownParties` returns an empty List. Why?

* Fix for sandbox parties management (#3177) + JSON API `/parties` endpoint

* release notes

* updating release notes
2019-10-16 15:02:27 +00:00
Gerolf Seitz
e0cfb84681
Filter the contracts for the ACS already in the database. (#3180)
This avoids unnecessarily loading contracts from the database
that would anyway get discarded later on.
2019-10-15 11:39:45 +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
Gerolf Seitz
5592092cc7
Remove DAML-on-X IndexServer and Reference Server (#3108)
It is not needed anymore and can therefore be deleted.
2019-10-08 11:47:21 +02:00
Oliver Seeliger
52302e2a1f
Ledger api index server starts only after indexer initializes db #2974 (#3087) 2019-10-08 10:57:50 +02:00
Robert Autenrieth
284a6d8197
Introduce ledger API authorization (#3051)
... by introducing an AuthService and checking authorization claims in all ledger API services
2019-10-07 22:29:46 +02:00
Oliver Seeliger
7dd482861b
Ledger api server fixes to persist divulged, otherwise unknown contracts #2946 (#3101) 2019-10-04 11:25:50 +02:00
Oliver Seeliger
cd915b64d7
Ledger api server indexer closes akka system on shutdown #2624 (#3089) 2019-10-03 18:57:14 +02:00
Oliver Seeliger
c9658c7813
Multi participant node named logging (#2647) (#3080)
* Upgrade scala-logging and slf4j

* Named logging for multi-participant tests (#2647)
2019-10-03 18:20:57 +02:00
Robert Autenrieth
9583c1f470 Improve ledger sql backend performance (#2998)
* Remove extra key lookup

... when removing contracts

* Only look up contract LET

* Add ADT for let lookups

* Add release notes

Fixes #2888
2019-09-25 12:46:13 +00:00
Gerolf Seitz
52efe9ccf9 Use the SQL-backend to testing the postgres-backend (#2954) 2019-09-18 12:28:02 +00:00
mziolekda
bf9ae046ba
ignore ledger updates that contain commands rejected due to de-duplication (#2939) 2019-09-18 12:21:30 +02:00
Robert Autenrieth
b97ef28de1
Rename BlindingInfo fields (#2883) 2019-09-18 00:28:53 +02:00
Gerolf Seitz
f32f1b975e
Filter the contracts for the ACS already in the database. (#2931)
This avoids unnecessarily loading contracts from the database
that would anyway get discarded later on.
2019-09-17 15:30:45 +02:00
Gerolf Seitz
ad1b885494
Properly adhere to DbType#supportsParallelWrites in SqlLedger (#2902)
Since we still have issues with parallel writes when using H2,
we should properly only use a single DB connection and executor thread
for that.

Because we didn't do that before for Sandbox, tests like PackageManagement
appeared to be flaky due to racy inserts in H2.
2019-09-16 11:29:07 +02:00