Commit Graph

174 Commits

Author SHA1 Message Date
Samir Talwar
3c6f8ed627
kvutils: Avoid casting ArgumentCaptor and friends in tests. (#4928)
* kvutils: Avoid casting `ArgumentCaptor` and friends in tests.

Instead, use generics the way they're intended.

CHANGELOG_BEGIN
CHANGELOG_END

* kvutils: In KeyValueParticipantStateWriterSpec, drop the Option.
2020-03-11 09:38:43 +00:00
Robert Autenrieth
9fd484469a
Add maxDeduplicationTime to the participant state API (#4722)
* Add max deduplication time to ledger configuration

* Add TTL to participant state API

CHANGELOG_BEGIN
CHANGELOG_END
2020-03-11 09:49:37 +01:00
Samir Talwar
51f596daa7
Sandbox Next: Implicit party allocation. (#4894)
* ledger-api-test-tool: Fix warnings flagged by IntelliJ IDEA.

* ledger-api-test-tool: Open-world mode.

In open-world mode, parties aren't allocated; their names are just
reserved for the test case, so that no other test will accidentally use
the same party name.

This is so we can test ledgers which dynamically allocate parties, such
as Sandbox.

* sandbox: Run conformance tests in "open-world" mode.

This means that the tests don't explicitly allocate parties (except for
a few), instead relying on Sandbox's implicit party allocation feature.

This is not enabled for Sandbox Next yet.

* sandbox-next: Implicit party allocation.

This is added to the command submission service.

CHANGELOG_BEGIN
CHANGELOG_END

* sandbox-next: Don't implicitly allocate pre-existing parties.

* ledger-api-test-tool: Move pre-allocation into ParticipantTestContext.

* ledger-api-test-tool: We can reserve parties or wait for them. Not both.

Make illegal states unrepresentable as early as possible.

* sandbox: Name ApiSubmissionService's private methods a little better.

* sandbox: Move ApiSubmissionService's conditional logic into methods.

* sandbox: Document why we set `implicitPartyAllocation` to `false`.

* sandbox: Document why `implicitPartyAllocation` is dangerous.
2020-03-09 15:49:11 +00:00
Samir Talwar
82c40f2ecb
kvutils: Throw meaningful errors when dealing with a Left. (#4835)
* kvutils: On error opening an envelope, throw the correct message.

CHANGELOG_BEGIN
CHANGELOG_END

* ledger-on-sql: On error when querying state, throw the correct error.

* kvutils|ledger-on-sql: Remove unnecessary curly braces around `throw`.
2020-03-06 13:53:34 +00:00
fabiotudone-da
9635e14d56
Restore LedgerFactory inheritors' ability to use Config for setups (#4860)
CHANGELOG_BEGIN
CHANGELOG_END
2020-03-06 08:25:27 +00:00
mergify[bot]
e785bb7402
Sandbox: Re-use actor systems between the StandaloneApiServer and StandaloneIndexerServer. (#4827)
* sandbox: Re-use the root actor system in the StandaloneIndexerServer.

* kvutils/app: Don't use the ActorSystem execution context randomly.

Instead, make `Runner` a proper ResourceOwner, with an `acquire` method.

* sandbox: Re-use the root actor system in the StandaloneApiServer.

CHANGELOG_BEGIN
CHANGELOG_END

* resources: Remove the now-unused `ResourceOwner.sequence` functions.

They weren't well-thought-out anyway; they acquire resources
sequentially, rather than in parallel.
2020-03-05 14:50:18 +00:00
mergify[bot]
95c1e5edaa
Allow LedgerFactory to provide a full-blown ReadWriterService (#4792)
* Allow `LedgerFactory` to provide a full-blown `ReadWriterService` rather than a `LedgerReaderWriter` (needed by at least vDAML)

CHANGELOG_BEGIN
CHANGELOG_END

* Address review points

* Address Samir's review point in `SqlLedgerFactory`

* Finish addressing Samir's review point in `SqlLedgerFactory`

* Split reader and writer owners in `LedgerFactory` as suggested by Gerolf

* Remove unneeded `val` from `KeyvalueParticipantState[Reader|Writer]` constructor params

* Remove unneeded type parameter from `app.Runner`

* Leave `LedgerFactory` a full ledger builder but split hierarchy upwards and clarify responsibilities

* Rename `SimpleLedgerFactory` to `KeyValueLedgerFactory`
2020-03-05 12:02:23 +00:00
Samir Talwar
85998f8f06
Sandbox-Next: Add the ResetService. (#4802)
* sandbox-next: Make the Runner a real ResourceOwner.

* sandbox: Don't construct the ResetService twice.

* sandbox: Inline and simplify methods in StandaloneApiServer.

* resources: Define a `ResettableResource`, which can be `reset()`.

`reset()` releases the resource, performs an optional reset operation,
and then re-acquires it, binding it to the same variable.

* resources: Pass the resource value into the reset operation.

* sandbox: Fix warnings in `TestCommands`.

* sandbox-next: Add the ResetService.

CHANGELOG_BEGIN
CHANGELOG_END

* sandbox: Make sure the SandboxResetService resets asynchronously.

It was being too clever and negating its own asynchronous behavior.

* sandbox-next: Forbid no seeding.

This double negative is really hard to phrase well.

* sandbox-next: Implement ResetService for a persistent ledger.

* sandbox: Delete the comment heading StandaloneIndexerServer.

It's no longer meaningful.

* sandbox-next: No need to wrap the SandboxResetService in an owner.

* sandbox-next: Bump the ResetService test timeouts.

It looks like it's definitely slower than on Sandbox Classic™. Gonna
look into this as part of future work.

* Revert to previous asynchronous reset behavior

Co-authored-by: Gerolf Seitz <gerolf.seitz@digitalasset.com>
2020-03-04 14:40:35 +00:00
Remy
bb0d3f24cb
[engine] refactor transaction's usedPackages (#4793)
* [engine] refactor transaction's usedPackages

* Address Gerolf's comment

* changelog

CHANGELOG_BEGIN
CHANGELOG_END
2020-03-03 13:59:40 +00: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
Samir Talwar
89c23ef85d
Heartbeats for Sandbox-Next, ledger-on-sql, and ledger-on-memory. (#4755)
* kvutils: Make the `KeyValueParticipantStateReader` tests more rigorous.

If the `offset` is specified as `None`, expect it to be `None`, not
just anything.

* kvutils: Simplify `KeyValueParticipantStateReader#stateUpdates`.

Construct the Source with `Source.apply`, not `Source.fromIterator`.

* kvutils: Use multiple entry IDs in `KeyValueParticipantStateReaderSpec`.

* kvutils: Add basic tests to `KeyValueParticipantStateReaderSpec`.

* kvutils: Add heartbeats to `LedgerReader`'s `events` output.

Heartbeats are optional, to be delivered by the ledger if and when it
deems necessary.

* sandbox-next: An observing time service backend using Akka streams.

* sandbox-next: A regular heartbeat based on Akka Streams' `tick`.

* sandbox: Replace `TimeServiceBackend.withObserver` with `.observing`.

More code, but it's more decoupled, so can more easily be sent to the
underlying backend in Sandbox Next.

CHANGELOG_BEGIN
- [Sandbox] Fixed a bug in the command completions stream when running
  Sandbox in static time. Previously, upon updating the time, the old
  time was emitted on the completions stream. The new time is now
  emitted.
CHANGELOG_END

* sandbox: TimeServiceBackend should only emit accepted changes.

* ledger-on-memory: Use `LedgerRecord` directly.

* ledger-on-memory: Stream heartbeats to the log.

* ledger-on-memory: Encapsulate mutations behind locks at all times.

* ledger-on-memory: Differentiate between reading and writing.

* ledger-on-memory: Factor out appending to the log.

* kvutils: Move the heartbeat test into the base from ledger-on-memory.

* kvutils: Log when the submission validation fails unexpectedly.

* ledger-on-sql: Add a script to hash all migrations.

* ledger-on-sql: Publish heartbeats to the log, and stream them out.

* ledger-on-sql: Log if publishing the heartbeat failed.

* ledger-on-sql: Wrap all queries in `Try`.

Just to make sure that we don't throw from a function that returns `Try`
or `Future`.

* ledger-on-sql: Allow `Long` values as the heartbeat timestamp.

`INTEGER` really does mean 32-bit, apparently.

* sandbox-next: Pipe heartbeats to the ledger.

* ledger-on-sql: Make sure we publish the correct head after a heartbeat.

Off-by-one errors are the best errors.

* ledger-on-(memory|sql): Just accept heartbeats, not their owner.

* sandbox: Update CIDs in tests to account for the extra heartbeat.

* ledger-on-memory: Fix a reference to variable in a comment.

Co-Authored-By: Gerolf Seitz <gerolf.seitz@digitalasset.com>

* ledger-on-sql: `flatMap` over `Try` rather than `Future` when possible.

* sandbox: Make sure the heartbeat queues are thread-safe.

* kvutils: Remove `LoggingContext` from the interfaces.

Keep it internally. This means we'll drop any context, but otherwise
things should work as expected.

* sandbox-next: Pull out the heartbeat interval into a constant.

* ledger-on-sql|sandbox: Clarify large levels of nesting.

Co-authored-by: Gerolf Seitz <gerolf.seitz@digitalasset.com>
2020-03-02 19:44:42 +00:00
Moritz Kiefer
d68d3eb74a
Freeze DAML-LF 1.8 (#4770)
* Freeze DAML-LF 1.8

Two minor points that I did not mention in the previous PR:

We also include the renaming of structural records to `struct` and the
renaming of `Map` to `TextMap`.

There are some minor changes around the LF encoder tests which need to
be able to emit package metadata properly so I’ve added it to the
parser. Sorry for not splitting that out.

Following the process used for the DAML-LF 1.7 release, this does not
yet include the frozen proto file.

changelog_begin

- [DAML-LF] Release DAML-LF 1.8:

  * Rename structural records to ``Struct``. Note that
    structural records are not exposed in DAML.
  * Rename ``Map`` to ``TextMap``.
  * Add type synonyms. Note that type synonyms are not serializable.
  * Add package metadata, i.e., package names and versions.

  Note that the default output of ``damlc`` is stil DAML-LF 1.7. You
  can produce DAML-LF 1.8 by passing ``--target=1.8``.

changelog_end

* Update encoder

* Update java codegen tests

* Update comment in scala codegen

* Handle TSynApp in interface reader

* Bump lf_stable_version to 1.7

* Fix kvutils tests
2020-03-02 18:29:26 +01:00
Remy
e7ee8143cb
[kvutils] use new contract id scheme (#4741)
* Make kvutils work with the new contract id scheme

CHANGELOG_BEGIN
- [KVUtils] uses random contract id. Contract ids are made of 65 hexa decimal characters.
CHANGELOG_END

Co-authored-by: Jussi Mäki <jussi.maki@digitalasset.com>
2020-03-02 17:50:38 +01:00
Samir Talwar
cf8cb61327
Sandbox-Next: Wire up missing configuration. (#4728)
* sandbox: Name the arguments to `ApiServices.create` for clarity.

* sandbox: Clarify numbers and types in configuration classes.

* sandbox-next: Log the correct port on startup.

* sandbox-next: Connect up the command configuration.

CHANGELOG_BEGIN
CHANGELOG_END

* sandbox-next: Wire up TLS configuration.

* sandbox-next: Wire up the maximum inbound message size.

* sandbox-next: Set the global log level if specified.

And if it's not specified, default to the level in logback.xml, INFO.

* sandbox-next: Connect up the submission configuration.

* sandbox-next: Log the correct ledger ID.

* sandbox-next: Use `TimeProvider.UTC`.
2020-02-27 09:49:26 +00:00
Gerolf Seitz
d617922618
Remove InMemoryKVParticipantState (#4674)
This removes the sample/reference implementation of kvutils
InMemoryKVParticipantState.
This used to be the only implementation of kvutils, but now with the
simplified kvutils api we have ledger-on-memory and ledger-on-sql.

InMemoryKVParticipantState was also used for the ledger dump utility,
which now uses ledger-on-memory.

* Runner now supports a multi participant configuration
This change removes the "extra participants" config and goes for consistent
participant setup with --participant.

* Run all conformance tests in the repository in verbose mode.

This means we'll print stack traces on error, which should make it
easier to figure out what's going on with flaky tests on CI.

This doesn't change the default for other users of the
ledger-api-test-tool; we just add the flag for:

  - ledger-api-test-tool-on-canton
  - ledger-on-memory
  - ledger-on-sql
  - sandbox




Fixes #4225.

CHANGELOG_BEGIN
CHANGELOG_END
2020-02-26 15:45:35 +01:00
fabiotudone-da
b2a79df0d8
Expand Runner's flexibility as a basis for participant servers (#4669)
* Add overridable indexer, api and auth configuration to `LedgerFactory`

CHANGELOG_BEGIN
CHANGELOG_END

* Add overridable indexer and api metrics creation to `LedgerFactory`

CHANGELOG_BEGIN
CHANGELOG_END

* Add overridable api's `TimeServiceBackend` to `LedgerFactory`

* 🎨 Fix formatting

* Port SDK ledgers based on `Runner` (and the sandbox) to `TimeServiceBackend`

* Revert to `TimeProvider` for committer usage and to `None` default for API server.
Also removed now unused `TimeServiceProvider.wallClock()`.

* Move TimeServiceBackend back to the API server.

* 🎨 Remove unneeded argument passed for parameter w/default

* Restore sandbox ledger time support

* Simplify passing a `TimeProvider` to the sandbox ledger

Co-authored-by: Samir Talwar <samir.talwar@digitalasset.com>
2020-02-26 09:31:26 +01:00
Remy
0321a1bb32
[Engine] push absolute contract ids inside the evaluation (#4652)
* [Engine] push absolute contract inside the evaluation
* Remove discriminator fom relative contract id

CHANGELOG_BEGIN
CHANGELOG_END
2020-02-21 20:21:35 +01:00
Samir Talwar
2ec710b0e3
Sandbox & kvutils: Use the existing ledger ID if no ledger ID is specified. (#4607)
* sandbox: If the ledger ID isn't provided, use the one in the database.

Previously, we would fail if working against an existing ledger, and not
explicitly providing the ledger ID. This was the case even if the ledger
ID was randomly generated initially.

CHANGELOG_BEGIN
- [Sandbox] If no ledger ID is provided when running against an existing
  ledger, use the existing ID. Previously, Sandbox would fail to start.
CHANGELOG_END

* sandbox: The ReadOnlySqlLedger should always receive a ledger ID.

It's read-only; it can't create one.

* sandbox: Stop using `equal` in SqlLedgerSpec.

* sandbox: Test that the ledger ID is as specified in SqlLedgerSpec.

* sandbox: Let the top-level runner handle a ledger ID mismatch.

And clean up the log text.

* sandbox: Initialize the ledger properly when the ID is dynamic.

* sandbox: Use `Vector`, not `List`, for SqlLedger initialization.

Append with Vector, good. List, bad.

* ledger-api-common: Make `LedgerApiMode.Dynamic` an object.

And add Java-style static factory methods.

* kvutils/app | ledger-on-{memory,sql}: Make `ledgerId` optional.

It should be generated or retrieved from the persistence layer by the
ledger itself.

* kvutils: Make the ledger ID optional in the tests.

* ledger-on-sql: Store the ledger ID, and reject conflicting IDs.

* ledger-on-sql: Make more things final.

* ledger-on-sql: Document the `ledger_meta.table_key` column better.

* sandbox: Don't hardcode the number of packages in the test DAR.

It changes.

* ledger-on-sql: Merge the `head` resource owner with the `dispatcher`.

* sandbox: Use backticks to simplify pattern match in ReadOnlySqlLedger.

* ledger-on-sql: Extract methods in `owner`.
2020-02-20 10:35:16 +00:00
Moritz Kiefer
126e9c68d8
Remove hardcode number of packages from kvutils tests (#4605)
This breaks everytime we add another package to damlc’s default output
which is unnecessary.

changelog_begin
changelog_end
2020-02-19 15:07:39 +01:00
associahedron
5db4ac8b0e
Support type-level strings in DAML. (#4571)
* Add type-level strings in DAML.

This PR adds a `PromotedText` stable package, with `PromotedText` type, which is used to encode type-level strings from DAML into DAML-LF. The reason for this is to preserve the `HasField` instance argument. This PR adds a test that `HasField` is succesfully reconstructed incontexts, during data-dependencies, which wasn't possible before.

changelog_begin
changelog_end

* adresss comments

* fix overly specific tests
2020-02-19 13:10:36 +00:00
Jussi Mäki
61a65fe16f
Use the contract key hasher in kvutils (#4542)
* Use KeyHasher to serialize contract keys in kvutils

- Use Value instead of VersionedValue in GlobalKey as the versioning does not make sense here
  and may be misleading as the a value with a different version but same meaning would still
  be the same key.

- Relocate the KeyHasher to ledger-api-common so kvutils can use it (otherwise cyclic dependencies)

- Replace storing of the contract key as a VersionedValue with the hash produced by KeyHasher.
  This is backwards incompatible. A compatible option would require us to query the key with both
  the old way and the new way which is unattenable. We're making a calculated breaking change.

CHANGELOG_BEGIN
- [DAML Ledger Integration Kit] Serialize contract keys using a hash instead of the value in kvutils.
  This is a backwards incompatible change to kvutils.
CHANGELOG_END

* Use proper hasher for contract keys and not KeyHasher

- Use Hash.scala, not KeyHasher.scala.
- Add hash to GlobalKey as we want the hash to be computed from the inside.
  The use of KeyHasher will be later deprecated and replaced by this.

* Use "sealed abstract case class" trick instead of private ctor

and rebase fix

* Revert change to unsupported value version decode error

* Reformat code

* Add kvutils changelog entry and bump the version
2020-02-19 11:56:31 +00:00
Robert Autenrieth
ba7d23bea0
Introduce new time model fields (#4558)
Those will be used for the new time model.

Fixes #4346.

CHANGELOG_BEGIN
CHANGELOG_END
2020-02-19 09:22:43 +01:00
Miklos
4ee5abc550
Allow custom commit workflow to be implemented for SubmissionValidator (#4587)
* Allow transformations to be written that have access to the ledger state.

CHANGELOG_BEGIN
CHANGELOG_END

* Added missing parameter description.
2020-02-18 18:13:35 +00: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
fabiotudone-da
c7d370025e
Fix validator accepting transactions with unallocated informees (#4551)
* Fix validator accepting transactions with unallocated informees.

CHANGELOG_BEGIN
[DAML Ledger Integration Kit] Enforce that all parties referenced as stakeholders, actors, or maintainers in a transaction have been allocated
CHANGELOG_END

* Remove unused `InputsAndEffects.subValues`

* Add unallocated informee failure `KVUtilsTransactionSpec` test

* 📝 Improve documentation of `ClosedWorldIT`

* 🎨 Better names and remove irrelevant formatting changes

* 🎨 Better names and remove useless bindings

* 🎨 Remove irrelevant formatting changes

* 🐛 Fix merge
2020-02-18 15:40:54 +00:00
Samir Talwar
b203ccaade
kvutils & ledger-on-sql: Avoid a race condition in dispatching. (#4546)
* kvutils/ledger-on-sql: Avoid a race condition in dispatching.

This changes the API of kvutils to allow for passing data out of the
transaction, which makes it much easier to ensure the new head makes it
to the dispatcher. Previously, we would use an `AtomicLong` to
communicate the data, but this was problematic because values could
arrive out in the wrong order. For example:

  - log index 5 is committed
  - `head` is updated to 6
  - the dispatcher is signalled with a head of 6
  - log index 6 is committed
  - log index 7 is committed
  - `head` is updated to 8
  - `head` is updated to 7
  - the dispatcher is signalled with a head of 7

In this scenario, we would have to wait until a new commit comes in
before the indexer finds out about log index 7.

* kvutils: Just return an `Either`from `SubmissionValidator`.

It was either that or introduce yet another type to split
`SubmissionValidated` into two.

CHANGELOG_BEGIN
CHANGELOG_END

* kvutils: Make ValidationFailed extend NoStackTrace.
2020-02-18 09:08:16 +00:00
Remy
8de42ce062
[Sanbox] use new ContractId scheme (#4533)
CHANGELOG_BEGIN
CHANGELOG_END
2020-02-17 13:30:47 +00:00
Samir Talwar
6577ae2556
ledger-on-sql: Switch to the extra-simplified KVUtils API. (#4532)
* kvutils: Make it easier to import the Key and Value types.

Moved them into a companion object.

* kvutils: Flatten the nested `for` comprehensions in SubmissionValidator.

* kvutils: Test that results succeed before querying state updates.

If they don't, we get idle timeouts and we don't see the error, which is
unhelpful.

* sandbox: Increase log levels for failed submissions.

* kvutils: Avoid converting DamlStateKey -> ByteString -> Array[Byte].

Just convert once.

* ledger-on-sql: Use the `SubmissionValidator` from kvutils.

CHANGELOG_BEGIN
CHANGELOG_END

* sandbox: Remove unnecessary interpolation in ApiSubmissionService.
2020-02-15 22:00:04 +00:00
Remy
8394f4ba7d
[DAML-LF] Version new contractId in Proto values (#4460)
* version new contractId

CHANGELOG_BEGIN
CHANGELOG_END
2020-02-13 20:45:46 +01:00
Miklos
a440a3fabd
Simplified API fixes (#4505)
Removed LedgerStateAccess.participantId and renamed LedgerReader.retrieveLedgerId => ledgerId.

CHANGELOG_BEGIN
CHANGELOG_END
2020-02-13 19:17:07 +01:00
Remy
4137ff510b
[Engine] Adding a specific type for ParticipantId (#4504)
CHANGELOG_BEGIN
CHANGELOG_END
2020-02-13 17:15:34 +01:00
Miklos
34eec2399a
Index doesn't know about ReadService (#4475)
Made JdbcIndex not depend on ReadService.

CHANGELOG_BEGIN
CHANGELOG_END
2020-02-12 15:49:12 +01:00
Moritz Kiefer
36e188cac8
Translate unsupported kinds to a special Erased type (#4474)
* Translate unsupported kinds to a special Erased type

This should simplify `data-dependencies` and avoid issues like #4470
since we can match on the type instead of having to guess which types
can and which cannot be translated back to DAML.

changelog_begin
changelog_end
2020-02-12 09:03:19 +01:00
Miklos
c7183979fd
Added submission validator (#4437)
CHANGELOG_BEGIN
CHANGELOG_END
2020-02-10 17:07:16 +01:00
Remy
e02e5d61bc
Engine: fork method to resolve contractIds (#4411)
* engine: fork method to resolve relative contractId

CHANGELOG_BEGIN
CHANGELOG_END
2020-02-10 16:52:06 +01:00
Remy
8d9e65c5ef
DAML-LF: limit the instanciation of Proto en/de-coders of Cid, Val, and Nid. (#4425)
* Prevent building of  en/de-coders of Cid, Val, and Nid outside Value/Transaction Coder

* DAML-LF: remove constrains on Cid for LF encoder/decoder

* Address Samir coments
2020-02-07 13:06:28 +01:00
Samir Talwar
6fd402f634
Sandbox: Preliminary work to rebuild Sandbox on top of kvutils. (#4422)
* resources: Allow for startup exceptions without no stack trace.

* sandbox: Remove dependency duplication in the BUILD file.

* ledger-on-(memory|sql): Extract `Main` into its own file tree.

This is so we can remove the dependency on kvutils/app from the library.

logback.xml goes with it.

* sandbox: Implement "Sandbox Next" on top of ledger-on-sql.

CHANGELOG_BEGIN
- [Sandbox] Preliminary work to rebuild Sandbox on top of the DAML
  Ledger Integration Kit. Currently not exposed through the CLI.
CHANGELOG_END

* ledger-on-sql: Publish to Maven Central.

* sandbox: If an unknown database is passed to Sandbox Next, handle it.

* resources: Catch errors in owner construction or acquisition.

Sometimes we're not in a future yet.

* resources: Don't run ProgramResource error handling inside the EC.

Otherwise we end up in deadlock which is only broken by
`awaitTermination` timing out.
2020-02-06 17:34:17 +00:00
Remy
30afc76d23
DAML-LF: constrain cid in transaction/value decode/encoder (#4414)
* DAML-LF: constrain cid in transaction/value decode/encoder

* address Gerolf's comments

* fix test

* changelog

CHANGELOG_BEGIN
CHANGELOG_END
2020-02-06 13:50:03 +00:00
Remy
5fa173ea19
Engine: make Transaction/Node/VersionnedValue mapContractId LF private (#4364)
CHANGELOG_BEGIN
CHANGELOG_END
2020-02-05 16:25:39 +00:00
Remy
16f43b0be6
DAML-LF: Remove node seed from nodeId (#4401)
CHANGELOG_BEGIN
CHANGELOG_END
2020-02-05 13:41:18 +01:00
Samir Talwar
5aa9f23404
kvutils: Add idle timeouts to all participant state tests, and reword test names. (#4404)
* kvutils: Add idle timeouts to all participant state tests.

CHANGELOG_BEGIN
CHANGELOG_END

* kvutils: Add nesting to test names in the participant state tests.

And clean up the names.
2020-02-05 12:38:58 +00:00
Samir Talwar
784a90b1a0
Fix the flaky ledger-on-sql test on Windows. (#4402)
* kvutils: Use durations in participant state tests.

Makes it way easier to read than `addMicros(…)` calls.

* daml-lf/data: Fix warnings in Time.scala.

* daml-lf/data: Add `Timestamp#add`.

* kvutils: An MRT of (start time + 1 second) is too short for CI.

Increasing the MRT to (now + 10 seconds).

CHANGELOG_BEGIN
CHANGELOG_END
2020-02-05 11:32:13 +00:00
Samir Talwar
e6f890282e
ledger-on-sql: Run the indexer on PostgreSQL when possible. (#4398)
* ledger-on-sql: Add a prefix of "ledger_" to the Flyway migrations table.

And while we're at it, make this a constant in the code and use Flyway
placeholders to substitute it in.

We don't have any users right now, so changing the migrations should be
fine.

CHANGELOG_BEGIN
CHANGELOG_END

* ledger-on-sql: Run the indexer on PostgreSQL when possible.

Specifically, when running the PostgreSQL conformance tests.

It will also work when running it as a binary, but you need to specify
both the `--server-jdbc-url` and `--jdbc-url` switches. This is to keep
kvutils/app simple.

* ledger-on-sql: Make `ExtraConfig` final.

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

* resources: Revert `ResourceOwner.failed` to `ResourceOwner[Nothing]`.

Co-authored-by: Stefano Baghino <43749967+stefanobaghino-da@users.noreply.github.com>
2020-02-05 11:12:46 +00:00
Samir Talwar
1df292cece
kvutils|ledger: Don't use Scala's global execution context. (#4374)
* kvutils|ledger: Don't use Scala's global execution context.

I have just discovered that Scala's global execution context uses daemon
threads, which means they don't stick around past the end of the `main`
function. This is bad when application startup fails and we end up with
no other threads; the application terminates before it has a chance to
print the error message, which is very unhelpful.

We resolve this by creating a cached thread pool in the
`ProgramResource` class, specifically used for acquisition and release
of resources.

To do this, we need to pass the execution context through to the
resource constructors, which makes usage a little more verbose, because
now we can't use lambda functions (which can't take implicit arguments
such as the `executionContext`).

CHANGELOG_BEGIN
CHANGELOG_END

* kvutils-app|reference-v2: Sort `Runner` and `ReferenceServer` methods.
2020-02-05 09:15:29 +00:00
Stefano Baghino
9d3a0f8a3b
Resource refactorings (#4382)
* Refactor ResourceOwner convenience methods

CHANGELOG_BEGIN
CHANGELOG_END

* Add the unreleasable Resource constructor

* Refactor reference server, reduce nesting

* Refactor kvutils runner, reduce nesting

* Refactor usages of ResourceOwner.fromFuture as Resource.unreleasable

* Replace vary method with covariance annotation in Resource

* Replace vary method with covariance annotation in ResourceOwner

* Address https://github.com/digital-asset/daml/pull/4382#discussion_r374758832
2020-02-04 17:20:24 +00:00
Miklos
dc0bca5a2f
Fix missing interpolators (#4372)
CHANGELOG_BEGIN
CHANGELOG_END
2020-02-04 17:09:49 +01:00
Samir Talwar
e203fdea90
resources: Pull out the shutdown hook logic into ProgramResource. (#4356)
It's not trivial, so it's almost certainly less error-prone to just
define it once.

CHANGELOG_BEGIN
CHANGELOG_END
2020-02-04 09:32:35 +00:00
Remy
93a613ff42
daml-lf: cleanup StringIds (#4221)
clean up String Identifier in daml-lf 

- Separate LedgerString from ContractIdString
- Drop TransactionIdString from daml-lf 
- Create a new ContractIdString (aka. ContractIdStringV1) for new contractId comparable with  relative contractIds

CHANGELOG_BEGIN
CHANGELOG_END
2020-02-04 09:30:53 +01:00
Remy
2f3ff2f0d3
daml-lf: drop TransactionIdString (#4343)
CHANGELOG_BEGIN
CHANGELOG_END
2020-02-03 14:52:33 +00:00
Samir Talwar
791fad5309
kvutils: Test that the ledger can be restarted and will resume where it left off. (#4321)
* kvutils: Use `ResourceOwner#use` to simplify tests.

* kvutils: Merge in `RestartSpec` from ledger-on-sql.

CHANGELOG_BEGIN
- [KVUtils] Added a test case to the participant state tests to ensure
  your ledger state is resumable upon restart.
CHANGELOG_END

* ledger-on-posix-filesystem: Extract paths into their own class.

* ledger-on-posix-filesystem: Seed the dispatcher with the correct head.

* kvutils: In participant state tests, be clear about different strings.

Co-authored-by: Samir Talwar <samir.talwar@digitalasset.com>
2020-01-31 16:26:36 +00:00