Commit Graph

80 Commits

Author SHA1 Message Date
Brian Healey
f3f6f3b678 correct package path for ReferenceServer (#3439) 2019-11-12 22:39:41 +00: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
Jussi Mäki
8b5eecb6b1
Fix contract key visibility check in kvutils (#3421)
The contract keys accessed in the context of a `fetchByKey` were not
properly checking that the contract was active and visible.

The checks for contract's visibility and activeness are now done from
one place.
2019-11-12 11:37:02 +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
Jussi Mäki
4c932b1f0c Do not re-register loaded-packages metric in PackageCommitter (#3420)
This caused an exception in the preload thread, and presumably
broke the preloading.
2019-11-11 16:29:00 +00: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
Jussi Mäki
c599f24cac
Refactor proposal for "KeyValueCommitting" (#3116)
* Refactor proposal for "KeyValueCommitting"

This only changes the package uploads as an example.

Embrace the imperative style:
  * we carry a lot of state through the commit steps anyway and immutable maps are actually
    dangerous: we may end up reading from the wrong one etc (has happened).
  * performs much better with transactions that have thousands of outputs (the current monadic commit would
    have quite a lot of overhead for setting all these).

Drop the "Option[DamlStateValue]". This was only for dedup value and the extra complexity for catching the case
where some inputs weren't fetched isn't worth the complexity (tests will catch this anyway).

Return an Iterable[(DamlStateKey, DamlStateValue)]. This way we're clear about the ordering of the outputs.

* Address review and simplify

* Port the change to use daemon thread for preload executor

So that JVM doesn't get stuck when exiting.

* Fix typo
2019-11-07 13:03:19 +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
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
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
Brian Healey
9d71a408a0
Make Err an abstract class so it is throwable when used from Java (#3297)
* Make Err an abstract class so it is throwable when used from Java

* Update ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/Err.scala

bring back sealed

Co-Authored-By: Stefano Baghino <43749967+stefanobaghino-da@users.noreply.github.com>
2019-10-31 11:02:00 -04:00
Jussi Mäki
4e440bd0a6 Add kvutils ledger dumps and integrity checker (#3167)
kvutils now supports dumping the ledger to a file via environment
variable: "KVUTILS_LEDGER_DUMP=/tmp/ledger.dump".

The integrity checker tool allows re-processing of ledger dumps to
validate that all submissions, state and log entries can be parsed
and processed. This forms the basis of kvutils data continuity test
suite.

Currently the checker strictly enforces that re-processed
outputs match the inputs exactly, which for now guarantees forwards
and backwards compatibility. The checker will be adapted when
forwards-incompatible changes or new kvutils message versions arise.

A select collection of ledger dumps will be maintained in a separate
repository (to be decided) and these dumps are to be validated by
the DAML CI.
2019-10-30 17:02:00 +00: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
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
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
Remy
217405e883 daml-lf: Move archive protofile to a more usual place. (#3166)
* move daml-lf archive protobug to a more usual place

* formatting

* fix kvutils proto

* fix csharp namespace
2019-10-14 13:22:22 +00: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
Jussi Mäki
09e93a6cdc
Fix handling of transient contract keys in kvutils (#3110)
* Add failing test case for transient contract keys

* Add kvutils tests for transient contracts and keys

* Fix handling of transient contracts and keys in kvutils
2019-10-04 14:00:54 +02:00
Jussi Mäki
0c72eeaf32
kvutils metrics (#3065)
* Add initial metrics to kvutils

* Improve metrics. Use InsertOrdMap by default in kvutils.

* Add VarGauge
2019-10-03 14:34:12 +02:00
Remy
337c5ff215 Engine: drop value versioning in commands (#2995)
* daml-lf: remove value Version from commands

* ledger-api: fix ledger api

* ledger: fix tests

* leger: drop dead code

* Address Gerolf's comment
2019-09-24 12:38:56 +00:00
Robert Autenrieth
b97ef28de1
Rename BlindingInfo fields (#2883) 2019-09-18 00:28:53 +02:00
Jussi Mäki
11f1735613 Fix contract key uniqueness check in kvutils (#2933)
* Fix contract key uniqueness check in kvutils

Archival of a contract with a key and recreation within the
same transaction is now allowed in kvutils.

* Add assertions to check that new contract has been created with same key
2019-09-17 18:21:41 +02:00
mziolekda
7c4cc96371
Use separate thread to preload dars in KVBC committer (#2924)
* use separate thread to preload dars in KVBC committer

* fix formatting
2019-09-17 14:48:36 +02:00
Jussi Mäki
ae6f0fd631
Revert "Do not consider archives that are already loaded in engine (#2898)" (#2910)
This reverts commit 6ed6e0e990.
2019-09-16 15:26:21 +02:00
Jussi Mäki
6ed6e0e990 Do not consider archives that are already loaded in engine (#2898) 2019-09-13 15:44:18 +00:00
Jussi Mäki
868cb785ad
Preload packages to engine during upload (#2860)
* Preload packages to engine during upload

* Improve logging in KeyValueCommitting and add timing information

* Fix scenario service tests now that logging is done in interpreter
2019-09-13 14:31:52 +02:00
Oliver Seeliger
a0a7a81cde
Add participant state v1 participantId and TransactionId vals (#2821)
for easier code reuse
2019-09-09 16:21:16 +02:00
Jussi Mäki
2a20a37139 Rename referencedContracts to divulgedContracts (#2741)
* Rename referencedContracts to divulgedContracts

We do not want to provide all referenced contracts as that would
require the ReadService to be able to read all those contracts, or
we would need to bundle the referenced contracts with the transaction.

The new type should match what was discussed in #2488.

* Add changelog entry to participant.state.v1.Version

* Remove divulgedTo from DivulgedContract

We decided not to prematurely add this feature.
2019-09-05 13:27:41 +00:00
Jussi Mäki
07fef0d784 Dispatcher: Provide sub-source in startingAt (#2715)
This allows using the dispatcher in situations where the index is common,
but different data streams are materialized from it.

The practical reason for this is to allow using a single dispatcher to read
from both the ledger_entries and configuration_entries tables, which share
the same ledger offset construction.
2019-09-02 09:05:08 +00:00
Jussi Mäki
a96f3fb736 Disable the checkTtl validation in kvutils (#2714)
The time model is being reworked and the current stack is not prepared
to handle this additional check well.

We will reimplement time model related checks once the redesign has been
completed.
2019-09-02 02:57:40 +00:00
Jussi Mäki
93f39508a3
Add kvutils envelope (#2709)
The kvutils envelope is meant to be used whenever a kvutils produced
data is stored and transmitted over the network. It adds both versioning
and compression to the original message.
2019-08-30 13:28:56 +02:00
Jussi Mäki
aaeb58b44f
kvutils: Add authorization checks (#2622) 2019-08-22 13:01:18 +02:00
Jussi Mäki
4ecf070860
kvutils: Authorization and config submissions (#2433)
* Initial version for configuration submissions and authorization

* Refactor config submission based on review. Add tests.

* Cleanup test output and comments

* kvutils test-suite

- Add unit tests for kvutils
- Thread the input state into Commit monad
- Fix a bug in handling rejected transactions (from previous refactoring)

* Address PR review

- Add submissionId to configuration changes.
- Revert the dedup of the ParticipantNotAuthorized message. This did not buy much
  and we need to duplicate it anyway when modularizing kvutils.
2019-08-21 18:24:16 +02:00
Gary Verhaegen
99ea93168d
update copyright notices (#2499) 2019-08-13 17:23:03 +01:00
Jussi Mäki
689d969038
kvutils commit refactoring (#2393)
* kvutils refactoring

Move transaction submission processing to its own class and refactor to
stop early on errors.

Throw a known error rather than use sys.error.

* Refactor package and party allocation

* Introduce "Commit" computation abstraction

This also fixes an issue where the command dedup entry was not created
when a later validation failed and a rejection log entry was created.

* Drop input_log_entries. Add contract instance to DamlContractState.

* Add copyright headers

* Add KeyValueCommitting.submissionOutputs

This cleans up implementations that need to know the outputs of a submission
up-front.
2019-08-05 16:30:21 +02:00
Jussi Mäki
3724a5789e
Contract keys for kvutils (#2304)
* Support for contract keys to kvutils

* Fix handling of CreateEvents with contract keys in semantic tester

* Add ContractKeysIT to tests and fix issues related to fetchByKey

* Address code review
2019-07-29 16:45:24 +02:00
mziolekda
ac06bef329
eliminate v2 version of the participant-state interface (#2255)
* eliminate v2 version of the participant-state interface

* remove participant-state-v1 from release artifacts
2019-07-23 14:59:15 +02:00
Stefano Baghino
4ff9a6b7ea
Run PartyManagementServiceIT in conformance tests (#2040)
* Run PartyManagementServiceIT in conformance tests

* Poll for persisted user without using Await

Addresses https://github.com/digital-asset/daml/pull/2040#discussion_r301441379

* Remove unnecessary call to ledger end

Address https://github.com/digital-asset/daml/pull/2040#discussion_r301435726

* Review and improve test when endpoint is not implemented

Address https://github.com/digital-asset/daml/pull/2040#discussion_r301480120

* Fix typo in docstring

Address https://github.com/digital-asset/daml/pull/2040#discussion_r301475151

* Adopt exponential backoff for readability polling

Address https://github.com/digital-asset/daml/pull/2040#discussion_r301586140

* Disable PackageManagementServiceIT

* Restore previous testing of party names

* Replace blocking sleep with Akka's after
2019-07-09 18:44:18 +02:00
mziolekda
71e3edb21c clean up versions v1 and v2 of participant-state (#2036) 2019-07-08 15:04:17 +00:00
mziolekda
36ef2d1d1b Generate a list of single package updates for an upload message containing multiple packages (#2031)
* make every PublicPackageUploaded update contain exactly one package

* implement update subscriptions that start with offsets with the same major number

* address review comments
2019-07-08 11:22:28 +00:00
mziolekda
7e3d580768 Connect LedgerAPI party and package management with KVUtils (#1985)
* connenct LedgerAPI party and package management with KVUtils

* formatting

* address review comments

* add participantId parameter to sandbox and indexer

* annotate TODO's with github issue numbers
2019-07-05 15:31:17 +00:00
Gerolf Seitz
a449d86ee0
Initial Ledger API Server (#1978)
* Add external offset column to parameters

We only ever need to use the external offset when restarting the api
server from a persistent data store to resume the ReadService state
update stream from the last processed offset.

In the PostgresIndexer we then need to store the external offset while
adding a new ledger entry.

* Allow disabling the jmx reporter in metricsmanager

* Implement PostgresIndexer component

* Introduce read-only Ledger and Dao

* SandboxEventIdFormatter treats transactionId as opaque string

* Introduce LedgerBackedIndexService

This can be reused both in the Sandbox and the ApiServer

* Implement PostgresIndex component

* Reference Service based on kvutils-v2 and postgres(index|indexer)

* Disable conformance test for ReferenceServer
2019-07-03 15:25:22 +02:00
mziolekda
02e94ec845 provide party and package management in KVUtils and participant-state v1 (#1553)
* provide asynchronous interfaces for party and package management on the participant-state

* provide submission id for correlating req with resp on Write- and ReadService

* add asynchronous party allocation in KVUtils

* start conversion of the package upload and party allocation to synchronous paradigm

* implement synchronous versions of party allocamtion and packacge update

* document recent changes and unify concepts between v1 and v2 versions of
the participant-state interface

* scala formatting

* address review comments
2019-07-01 12:57:33 +00:00
Remy
c412d4e3d2 Add pretty C# namespaces in archive and leger-api protos (#1911)
* add nice C# namespace for in leger-api proto

fixes #1901

* add pretty C# namespace for archive protos

fix #1900
2019-06-27 11:39:33 +00:00
Robert Autenrieth
77d916288a
Update participant state v2 interfaces (#1800)
Moves party allocation to its own WriteService trait (similar to package upload).

Changes uploadDar to uploadPackages, so that the write service does not depend on the DAR file format.

Adds or improves many comments.
2019-06-27 11:44:15 +02:00
Jussi Mäki
c23af0eaa0
Introduce contract key to exercise node (#1783)
* Introduce contract key to exercise node

Track the contract key in NodeExercises. This is in
preparation for adding the key into exercise events, and
for support for contract keys in kvutils, where we need
to be able to compute the outputs of the submission, e.g.
the contract key that would be unset by a consuming exercise.

This introduces transaction version 8.

* Move release note on contract keys in exercises to unreleased.rst

* Address Stephen's review

- Drop changelog entry for this change as it is not user facing
- Add info on version 8 to transaction.rst. Fix typo in version 7.
- Reorder VersionTimeline as per review
- Only compare the NodeExercise 'key' if it is set in the original
  transaction (in order to compare transactions in a backwards
  compatible manner)

* Unbork unreleased.rst
2019-06-27 09:57:40 +02:00
Robert Autenrieth
439830b5bc
Update participant state v2 interfaces (#1767)
... with recent changes done to v1
2019-06-20 13:03:46 +02:00
Gerolf Seitz
0ab4199bc6
Preparations for Index + Indexer (#1766)
* Add missing domain.RejectionReason cases
* Use java.time.Instant instead of damlf Timestamp
* Make applicationId, submitterParty, commandId optional in LedgerEntry.Transaction
2019-06-19 16:28:28 +02:00