Commit Graph

107 Commits

Author SHA1 Message Date
Moritz Kiefer
751587125f
Fix exclusions for command dedup in compat tests (#10767)
We need to differentiate between 3 cases:

1. Ledger API test tool versions that only support exclusion of whole
suites.
2. Ledger API test tool versions where the tests had different names.
3. and the current state

changelog_begin
changelog_end
2021-09-03 14:04:46 +00:00
Moritz Kiefer
50fecfb9ef
Wrap missing label names in quotes (#10749)
* Wrap missing label names in quotes

See
https://discuss.daml.com/t/why-might-i-be-getting-missing-record-label-identity-from-the-ledger-api-when-submitting-a-command/3059/5
this has caused some confusion for users since it’s not obvious that
it is the label name if you have a very generic label name like
`identity`.

I have no strong feelings on whether this should be single or double
quotes so happy to change it.

changelog_begin
changelog_end
2021-09-03 13:52:55 +00:00
Victor Peter Rouven Müller
5595d55c79
[JSON-API] Use the token from incoming requests to update the package list (#10602)
* Use the token from incoming requests to update the package list

changelog_begin
changelog_end

* Lazily initialize the ledger client

* Fix ee integration tests

* Fix package reloading behaviour by using a semaphore to check for ongoing updates

* Refactor out the semaphore code into a concurrency utility class

* Use correct locking for the updateTask so every thread always uses an up to date task

* Remove unused imports in utils.Concurrent & remove packages from the tests

* Hide & mark the token file cli option deprecated because we dont need it anymore and only keep it so client deployment code doesn't break

* Fix scala 2.12 build by adding more type annotations

* Update ledger-service/http-json-cli/src/main/scala/com/daml/http/OptionParser.scala

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

* Update ledger-service/http-json/src/main/scala/com/digitalasset/http/PackageService.scala

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

* Readd pgkManagementClient after it was removed accidentally (but now it's lazy)

* Remove concurrent object & use atomic boolean instead of a mutex because it makes more sense

* Replace semaphore with countdownlatch

* Refactor the caching into a separate class

* Use Instant instead of LocalDateTime

* Remove that ** of bad synchonization and do stupid simple synchronization because it JUST WORKS, besides adapt when we want to reload

* Remove await in tests because it can result in buggy tests

* remove unused code in WebSocketService.scala

* Unhide the access-token-file option as per request of Stefano

* Less implicit jwts per request of Stefano

* Try making some code more readable as by request of Akshay

* Use more shark because it expresses better than flatMaps if I don't need the arg

* Move defs in predicate in WebsocketService.scala around

* Try to minimize diff further in WebsocketService.scala

* Fix build and minimize diff in WebSocketService.scala further

* Minimize diff of function getTransactionSourceForParty in WebSocketService.scala

* Share the ec in WebSocketService.scala to minimize the diff

* Minimize in function predicate in WebSocketService.scala

* Further minimize in function predicate in WebSocketService.scala

* Change some case classes to be normal classes but with apply method

* Update ledger-service/http-json/src/main/scala/com/digitalasset/http/PackageService.scala

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

* Update ledger-service/http-json/src/main/scala/com/digitalasset/http/Endpoints.scala

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

* Get rid of implicit jwt tokens, the world is already confusing and full of implicits enough

* Improve readability

* Integrate the new LedgerClient which does not depend on a leder id

* Fix tests

* Apply suggestions from code review

thanks to @S11001001

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

* Apply further review comments

* Remove outcommented code

* Deprecate access token file option in the description too

changelog_begin

- [JSON API] The cli option `--access-token-file` is now deprecated. It
    is not needed anymore and you can safely remove it. Reason is that
    the operations which prior required a token at startup are now done
    on demand using the token of the incoming request.

changelog_end

Co-authored-by: Stefano Baghino <43749967+stefanobaghino-da@users.noreply.github.com>
Co-authored-by: Stephen Compall <stephen.compall@daml.com>
2021-09-03 10:12:01 +00:00
nicu-da
d2180cf60b
Update exclusion for command deduplication to include full version range (#10750)
CHANGELOG_BEGIN

CHANGELOG_END
2021-09-02 05:56:44 -07:00
nicu-da
41881ba2ba
Command dedup: migrate kvutils to use v2 services [KVL-1049] (#10679)
* Add deduplication and submission id to the proto submitter info so we can build the v2 completion info

* Use v2 rejections and store the enriched model in protobuf

* Update v1 SubmissionResult to v2 SubmissionResult

* Update v1 imports to v2 imports

* Enable API deduplication for ledgers that don't have it implemented yet (all kv)

* Update tests for new rejections

* Disable buf check for oneof

* Code review - fix formatting and test assertions

* Update imports for proto changes

* Add tests for rejection conversions

* Use entry id as submission id when submission id is missing

* Calculate deduplication period for rejection based on the set deduplicate until by calculating the duration relative to record time

* Code review consistent naming and comments
* Submission id is optional in the completion info

the submissionId is not set for participant.state.v1 entries, therefore for the transition from v1 to the v2 API we need to account for the missing submission ids by making it optional in the completion info.

* Update messages and grpc status codes for rejections to keep backward compatibility

* Deprecate proto deduplicate_until
* Set deduplication value in the commit context for all the deduplication periods. This change allows us to re-enable the committer deduplication tests

* Set ledger configuration for tests

* Command dedup: In the committer set the deduplicate until context value based on the given deduplication period [KVL-1049] (#10743)


CHANGELOG_BEGIN
participant-state:  
- Migrate to use only v2 Read/Write Services. This includes the use of new models for rejections/updates/submission results.
- Calculate deduplicate until for committer side deduplication based on the submitter given deduplication period
   -  if using the deprecated deduplicateUntil then just set the given timestamp
   -  if using duration then calculate the new deduplicateUntil by using the formula (submissionTime + deduplicationDuration + minSkew)
  -   if using offset deduplication then calculate deduplicateUntil by using the formula (submissionTime + maxDeduplicationDuration + minSkew)
  -  if the deduplication period is not set then we don't set deduplicateUntil
- Emit completions with status `ALREADY_EXISTS` for duplicate commands

CHANGELOG_END
2021-09-02 04:44:55 -07:00
Remy
a929b25b41
Fix compatibility test (#10446)
* Fix compatibility test

CHANGELOG_BEGIN
CHANGELOG_END

* a bit more fixes
2021-07-29 18:33:53 +02:00
Remy
cf7b1bb8b5
LF: ValueDecoder set recursion limit for values. (#10393)
CHANGELOG_BEGIN
CHANGELOG_END
2021-07-28 12:14:15 +02:00
mziolekda
2271f93b69
Fix crash on duplicate submissionId (#10242)
* CHANGELOG_BEGIN
Fix crash in ConfigManagement- and PackageManagement- services on duplicate submissionsIds from different participants.
Extend ledger-api-test-tool to cover the duplicate submissionId cases.
CHANGELOG_END

* Addressing review comments and fixing failing tests

* format

* address more review comments

* adopt after rebase to main
2021-07-14 14:12:31 +00:00
Moritz Kiefer
64497f6c10
Only run sandbox(classic)? on postgres tests on Linx (#10178)
They keep causing timeouts on MacOS and nobody seems to consider them
useful enough to investigate. For now I only disabled the postgres
tests because I haven’t seen the others time out but if they do I’ll
add them as well

changelog_begin
changelog_end
2021-07-05 13:41:59 +00:00
Stefano Baghino
bb4641756f
Daml assistant capitalization (#10140)
changelog_begin
changelog_end

- DAML -> daml
- Assistant -> assistant

The capitalization of the latter fixed one occurrence of a capitalized 'A'
which was inconsistent with the vast majority of uncapitalized 'a's.
2021-06-29 14:32:44 +02:00
Moritz Kiefer
46a66e2f2a
Upgrade jest to the latest version (#10107)
This ends up transitively bumping yargs-parser which has a
vulnerability but more generally I also just like being on the latest version.

changelog_begin
changelog_end
2021-06-24 11:16:29 +00:00
Remy
a6b536f3c4
Compiler: Make LF 1.13 the default output (#9907)
* Compiler: Roll LF Version

Fix #8591

CHANGELOG_BEGIN
- [Compiler] Default ouput LF version is now 1.13
CHANGELOG_END
2021-06-24 11:58:50 +02:00
Gary Verhaegen
e12a449c81
s/DABL/Daml Hub/ (#10062)
It's been long enough.

CHANGELOG_BEGIN
CHANGELOG_END
2021-06-21 16:37:17 +02:00
Remy
7bc925e4d2
LF: Factorize the logic for AST lookup (#9871)
Factorize the logic for AST lookup in
 - compiler 
 - type checker 
 - preprocessor
 - script triggers 
 - some tests

CHANGELOG_BEGIN
CHANGELOG_END
2021-06-03 13:32:56 +02:00
azure-pipelines[bot]
192a77a6d8
update compat versions for 1.13.0-snapshot.20210504.6833.0.9ae787d0 (#9575)
* update compat versions for 1.13.0-snapshot.20210504.6833.0.9ae787d0

CHANGELOG_BEGIN
CHANGELOG_END

* fix exclusion

changelog_begin
changelog_end

Co-authored-by: Azure Pipelines DAML Build <support@digitalasset.com>
Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2021-05-05 15:40:12 +02:00
Kamil Bożek
39afcc4857
Fix index size limit issues [DPP-347] (#9477)
* Added a new test suite for testing limit API values - ValueLimitsIT

* Change index on participant_command_completions table
This change fixes issues with commands with large submitters number on sandbox-classic

* Added key_hash column to the ledger *state table
The new column is now the primary key of the table. Its values are hashed values of the 'key' column which allows to mitigate limitations on the index row size

* Backfill key_hash for ledger_state table

* Dynamic state table prefix form the backfill migration

* Removed redundant comments

* Backfill migration for all the db types

* Added missing copyright comment

* Fixed migration order after a rebase

* Added missing checksums for sql migrations

* Temporarily removed copyrights from one of sql migrations

* Removed unnecessary NOT NULL constraint

* Removed submitters from the index participant_command_completion_offset_application_idx in the append-only schema

* Disabled the test for old platforms

* CHANGELOG_BEGIN
- [Integration Kit] - a new test suite ValueLimitsIT for testing edge case values
- [Integration Kit] - modified index on the participant_command_completions table to avoid issuess with a large number of submitters
- [Sandbox] - added the key_hash column to the *state table
CHANGELOG_END

* Disabled concurrent testing for the ValueLimitsIT:VLLargeSubmittersNumberCreateContract test case

* Recomputed migrations checksums for the participant-integration-api

* Increase the sandbox-on-x queue size to 500
The motivation is that running conformance tests failed with RESOURCE_EXHAUSTED error due to 200 limit on the queue.

* Minor improvement

* Inlined key hashing for migrations to avoid external dependencies

* Minor improvement

* Fixed migrations hash
2021-05-04 12:23:37 +02:00
Moritz Kiefer
4e1c5fedb3
Check visibility for by-key operation of local contracts (#9470)
* Check visibility for by-key operation of local contracts

fixes #9454

I tried out two approaches for this:

1. The one here where we add a new callback. This has the advantage
   that the engine remains oblivious to visibility checks. They are all
   done outside and the engine doesn’t even know about the reading
   parties.
2. Make the engine aware of the reading parties. A start of that is in
   #9458.

Both work in principle but I ended up going for 1 in the end. Doing
half of the visibility checks outside the engine and half inside just
seems worse than the current state.

changelog_begin

- [Daml Engine] Fix a bug where it was possible to
  fetch/lookup/exercise a local contract by key even if the reading parties
  are not stakeholders. See #9454 for details.

changelog_end

* Disable new test on Canton

changelog_begin
changelog_end

* Exclude from compat tests

changelog_begin
changelog_end

* s/LocalLookup/LocalFetch/

changelog_begin
changelog_end

* Address review

changelog_begin
changelog_end
2021-04-22 21:39:12 +02:00
Moritz Kiefer
a591accf04
Fix ledger API test tool exclusions (#9264)
This fixes the exclusions added in #9218. There are two issues:

1. Old ledger API test tool versions only support excluding full test
suites.
2. Apparently SDK 1.6.0 renamend SemanticDoubleSpend to SemanticDoubleSpendBasic.

changelog_begin
changelog_end
2021-03-29 10:29:42 +02:00
Hubert Slojewski
cb422e2f67
KVL-810 Report the correct gRPC error code on failures due to concurrent transactions (#9218)
* Fix gRPC status codes for inconsistency rejections and DamlLf errors
Also, add unit tests and exclude failing compatibility and conformance tests

CHANGELOG_BEGIN

- [Integration Kit] Fix gRPC status codes for inconsistency rejections and DamlLf errors (ContractNotFound, ReplayMismatch) by changing them from INVALID_ARGUMENT to ABORTED

CHANGELOG_END
2021-03-26 15:26:33 +01:00
Moritz Kiefer
493e2154fd
Fix flakiness in create-daml-app tests (#9165)
* Fix flakiness in create-daml-app tests

waitForSelector doesn’t do the trick here since one selector is enough
to make this return. We need to wait until we actually have the
expected number. This is what waitForFollowers already did.

changelog_begin
changelog_end

* maybe I should test my code but also I don’t want to

changelog_begin
changelog_end

* fine I tested it

changelog_begin
changelog_end
2021-03-17 09:48:26 +00:00
Remy
8a35528514
LF: Make 1.12 default compiler output (#9058)
CHANGELOG_BEGIN
- [Compiler] The compiler produces LF 1.12 by default. LF 1.12 only reduces transaction size.
CHANGELOG_END
2021-03-10 16:44:29 +00:00
Stefano Baghino
929e0c12d4
Temporarily cut compatibility tests with incompatible versions of Daml-LF (#8959)
* Temporarily cut compatibility tests with incompatible versions of Daml-LF

This adds more tests to the exclusions added as part of #8957

All SDK/platform compatibility tests are not filtered to use compatible
Daml-LF versions, not just those involving the Ledger API Test Tool.

changelog_begin
changelog_end

* Fix Bazel code
2021-02-26 13:47:59 +01:00
Stefano Baghino
72951b8416
Temorarily cut compatibility tests with incompatible versions of Daml-LF (#8957)
These cause spurious failures on CI.

As described in the code, the proper fix is to use the correct Daml-LF version for every pair.

changelog_begin
changelog_end
2021-02-26 09:55:43 +00:00
Remy
a9b035e92e
LF: release LF 1.12 (#8856)
CHANGELOG_BEGIN

    - [LF] Release LF 1.12. This version reduce the size of transaction

    - [Compiler]: Change the default LF output from 1.8 to 1.11.

CHANGELOG_END
2021-02-24 21:17:33 +01:00
azure-pipelines[bot]
6cf854e5ee
update compat versions for 1.10.0-snapshot.20210202.6218.0.c0573678 (#8729)
* update compat versions for 1.10.0-snapshot.20210202.6218.0.c0573678

CHANGELOG_BEGIN
CHANGELOG_END

* .

changelog_begin
changelog_end

* .

changelog_begin
changelog_end

Co-authored-by: Azure Pipelines DAML Build <support@digitalasset.com>
Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2021-02-04 13:16:27 +01:00
Kamil Bożek
7cf1914d6d
Increased compatibility test size for classic-postgresql to large. (#8666)
CHANGELOG_BEGIN
CHANGELOG_END
2021-02-01 15:25:18 +01:00
Moritz Kiefer
1286a6b28e
Port readPortfile changes to compat workspace (#8696)
* Port readPortfile changes to compat workspace

Unfortunately we cannot easily share code between the two workspaces
so there is some stuff that is copied over and that we need to keep in
sync. This PR ports the changes from #8669 to the compat workspace.

changelog_begin
changelog_end

* maybe I should test if my code compiles but also I don’t want to

changelog_begin
changelog_end

* .

changelog_begin
changelog_end
2021-01-29 19:56:24 +00:00
Stefano Baghino
83e9fde1d1
Fix compatibility tests (#8682)
a9793651b3
added a new snapshot that does not include the work done as part of
793fd8fdfc

This change ensure that the compatibility test work again.

changelog_begin
changelog_end
2021-01-29 10:20:51 +00:00
Stefano Baghino
793fd8fdfc
Correctly document and report malformed party names when allocating (#8642)
* Correctly document and report malformed party names when allocating

changelog_begin
[Ledger API] Documented the hard-coded limit of 255 characters for Daml-LF party names.
[Ledger API] Malformed party names are now correctly reported back with an INVALID_ARGUMENT error
changelog_end

* Make sure that what is given is a suggestion

Co-authored-by: Robert Autenrieth <31539813+rautenrieth-da@users.noreply.github.com>

* Use Future.successful where possible

Co-authored-by: Robert Autenrieth <31539813+rautenrieth-da@users.noreply.github.com>

* Address https://github.com/digital-asset/daml/pull/8642#discussion_r565116571

* Address https://github.com/digital-asset/daml/pull/8642#discussion_r565122362

* Keep fields private where possible

* Whitelist new tests on compatibility suite

* Don't run the new tests on Canton

Co-authored-by: Robert Autenrieth <31539813+rautenrieth-da@users.noreply.github.com>
2021-01-27 18:50:19 +00:00
Moritz Kiefer
6326822907
Upgrade grpc and protobuf libraries (#8558)
* Upgrade grpc and protobuf libraries

changelog_begin

- [Dependencies] Upgrade
  iou.grpc:grpc-(api|core|netty|protobuf|services|stub) to
  1.35.0.

- [Dependencies] Upgrade
  io.netty:netty-(codec-http2|handler|handler-proxy|resolver)
  to 4.1.58.Final.

- [Dependencies] Upgrade
  io.netty:netty-tcnative-boringssl-static to 2.0.36.Final.

- [Dependencies] Upgrade com.google.protobuf:protobuf-java to 3.14.0.

changelog_end

* Factor out netty and grpc version

changelog_begin
changelog_end
2021-01-26 14:17:18 +00:00
Bernhard Elsner
cda93db944
Daml case and logo (#8433)
* Replace many occurrences of DAML with Daml

* Update docs logo

* A few more CLI occurrences

CHANGELOG_BEGIN
- Change DAML capitalization and docs logo
CHANGELOG_END

* Fix some over-eager replacements

* A few mor occurrences in md files

* Address comments in *.proto files

* Change case in comments and strings in .ts files

* Revert changes to frozen proto files

* Also revert LF 1.11

* Update get-daml.sh

* Update windows installer

* Include .py files

* Include comments in .daml files

* More instances in the assistant CLI

* some more help texts
2021-01-08 12:50:15 +00:00
Gary Verhaegen
427179ab27
fix (some) copyright headers (#8422)
This commit fixes a few copyright headers that have been missed in the
automatic update on Jan 1, as well as the generation code in the compat
workspace so it generates the right headers.

CHANGELOG_BEGIN
CHANGELOG_END
2021-01-07 11:48:59 +01:00
Gary Verhaegen
a925f0174c
update copyright notices for 2021 (#8257)
* update copyright notices for 2021

To be merged on 2021-01-01.

CHANGELOG_BEGIN
CHANGELOG_END

* patch-bazel-windows & da-ghc-lib
2021-01-01 19:49:51 +01:00
Moritz Kiefer
f4c530abc1
Exclude tests relying on 1.dev (#8100)
follow-up to #8099. If we don’t load the 1.dev dar in sandbox which is
totally sensible, we obviously also cannot run tests against it. In
newer test tool versions that’s not an issue but for older versions we
still need to exclude that one test.

changelog_begin
changelog_end
2020-11-30 09:53:59 +00:00
Moritz Kiefer
81f965fb5f
Exclude dev-dar in sandbox compatiblity tests (#8099)
By definition, dev doesn’t guarantee any kind of compatibility so
trying to load it into Sandbox can fail. somewhat surprisingly it only
started failing now which I guess shows that we haven’t changed LF too
much recently.

changelog_begin
changelog_end
2020-11-28 21:50:16 +01:00
Oliver Seeliger
8cfe6c3744
Remove ParticipantPruningIT from compatibility exceptions (#8072)
As ParticipantPruningIT is not included by default on any ledger.

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-26 14:41:19 +01:00
Oliver Seeliger
83f11aa784
Participant pruning ledger api server support ported from Canton (#7988)
* Participant pruning ledger api server support ported from Canton

CHANGELOG_BEGIN
- [Ledger API]: The preview of `ParticipantPruningService` enables ledger participants to prune the "front" of ledger state at the participant including the ledger api server index.
CHANGELOG_END

* Review feedback from Stefano

* Add pruning tests plus missed command completions change

* Review feedback from Robert

* Improved test readability by having populate helper return offsets

* Review feedback

* Ledger api changes to pruning api and disable canton pruning test

- Change return result to PruneResponse
- Change type of PruneRequest.prune_up_to to string

* Review feedback: Use ApiOffsetSConverter for logged offsets
2020-11-23 15:28:04 +01:00
Robin Krom
5bfff4e9ba
sandbox: fail on already existing port-file. (#7929)
Fixes #7806. This aligns the port file behaviour of the sandbox with the
HTTP JSON API.

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-17 11:08:37 +01:00
azure-pipelines[bot]
5f4ac97b77
update compat versions for 1.7.0-snapshot.20201103.5565.0.e75d42dd (#7872)
CHANGELOG_BEGIN
CHANGELOG_END

Co-authored-by: Azure Pipelines DAML Build <support@digitalasset.com>
2020-11-04 16:38:01 +01:00
Moritz Kiefer
6fdc6af6a7
Fix exclusions for nongranular test tool (#7876)
Older versions of the test tool don’t allow granular exclusion so we
have to exclude the whole suite.

changelog_begin
changelog_end
2020-11-04 09:53:08 +01:00
Andreas Lochbihler
0c38c83b11
sandbox-classic reports contract key lookup mismatches as Inconsistent instead of Disputed (#7829)
CHANGELOG_BEGIN
sandbox-classic reports contract key lookup mismatches as Inconsistent instead of Disputed
CHANGELOG_END

excludes affected contract key tests from compability tests
2020-11-03 08:44:52 +01:00
Moritz Kiefer
90cfe8b955
Extend trigger compat tests to be agnostic to high-level changes (#7828)
The trigger runner (delibaretely) only cares about the high-level
API. This means that we can change the high-level API without breaking
backwards compatibility in the runner. However, we do of course have
to change the trigger code written in the high-level API.

This PR addresses this by making the code depend on the
version. Unfortunately we cannot use CPP here (something I don’t say
very often) so this is done in a Bazel function.

The last low-level breaking change was the change to `CommandId`
generation so we go back to that.

changelog_begin
changelog_end
2020-10-29 14:19:10 +01:00
Stephen Compall
6d39ac6984
allow updating user state from high-level trigger rule (#7674)
* allow updating user state from high-level trigger rule

* fix tests and examples for new rule signature

* fix doc for new rule signature

* add changelog

CHANGELOG_BEGIN
- [Triggers] ``rule`` can now ``get`` and ``put`` the user-defined state just
  like ``updateState`` does.  It no longer accepts the state as an argument.
  You can port your rule function types by replacing ``s -> TriggerA`` with
  ``TriggerA s``, removing the last argument from the function, and using
  ``get`` to retrieve the state at the beginning of the ``rule``'s ``do`` block,
  if needed.
  See `issue #7674 <https://github.com/digital-asset/daml/pull/7674>`__.
CHANGELOG_END

* test that rule userState changes propagate all the way out

* adapt compatibility filtering to #7681
2020-10-14 14:51:25 +00:00
Stephen Compall
bda13392fd
replace getContracts with query Action, usable in initialize, updateState, rule (#7632)
* add ACS reader to TriggerA and TriggerStateA

* propagate changes in TriggerA, TriggerStateA structure

* allow query to be used in updateState and rule

* remove getTemplates

* remove ACS argument from updateState and rule

* fix type parameter order on query

* use query function in all tests and examples

* replace getContracts with query in documentation

* use wildcards instead of otherwise

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

* rename TriggerStateA to TriggerUpdateA

- suggested by @cocreature; thanks

* missed renamings of TriggerStateA to TriggerUpdateA

- suggested by @cocreature; thanks

* make the meaning of the rlift functions clearer

* make initialize a TriggerInitializeA instead of a function; remove getContracts

* update tests and examples for new initialize signature

CHANGELOG_BEGIN
- [Triggers] Trigger ``updateState``, ``rule``, and ``initialize`` functions no
  longer accept an ``ACS`` argument; instead, they must use the ``query`` action
  to query the ACS, similar to the same function in DAML Script.
  See `issue #7632 <https://github.com/digital-asset/daml/pull/7632>`__.
CHANGELOG_END

* disable older compatibility trigger builds

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2020-10-13 13:20:43 -04:00
Stephen Compall
664a0c0076
add Action to high-level trigger updateState (#7621)
* add ActionState to the standard library

* use 1 ActionState, 1 get, 1 put in low-level trigger library

* introduce TriggerStateA for updateState

* fix tests and examples for new updateState signature

CHANGELOG_BEGIN
- [Triggers] The ``updateState`` function now returns a ``TriggerStateA``.  This
  is an action like ``TriggerA``, but doesn't permit emitting commands.  Instead
  of taking the state as an argument and returning a new state, you can
  manipulate the state with ``get``, ``put``, and ``modify``.  Any existing
  ``updateState`` can be ported by replacing ``s -> expr`` in the lambda
  expression with ``-> modify $ \s ->``, and then made to look nicer from there
  as desired.
  See `issue #7621 <https://github.com/digital-asset/daml/pull/7621>`__.
CHANGELOG_END

* some DAML docs for updateState and TriggerStateA
2020-10-09 13:56:24 -04:00
Stephen Compall
a1d8e8dc33
replace commands-in-flight argument to trigger rule with getCommandsInFlight action (#7600)
* add getCommandsInFlight as a TriggerA action

* immediately update commandsInFlight on emitCommands

- delay until the rule had returned made sense before submitCommands was launched
  immediately; this also makes `getCommandsInFlight` more sensible

* remove commands-in-flight argument from high-level Trigger rule

CHANGELOG_BEGIN
- [Triggers] The "commands in flight" or ``Map CommandId [Command]`` argument has been
  removed from high-level trigger ``rule`` functions; instead, the current
  commands-in-flight can be retrieved with the new ``getCommandsInFlight`` function, which
  can be done immediately at the beginning of the rule's ``do`` block to preserve exact
  existing trigger behavior.
  See `issue #7600 <https://github.com/digital-asset/daml/pull/7600>`__.
CHANGELOG_END

* remove commands-in-flight argument from trigger tests

* update doc examples and copy in compatibility

- compatibility change will most likely entail another flag day in compatibility tests,
  replacing last_pre_7456_trigger_version

* update doc text for getCommandsInFlight

* test that getCommandsInFlight gets updated during the rule

* flag day for trigger compatibility tests

sdk-version: 1.7.0-snapshot.20201006.5358.0.0c1cadcf
File:     src/CopyTrigger.daml
Hidden:   no
Range:    55:11-55:19
Source:   typecheck
Severity: DsError
Message:
  src/CopyTrigger.daml:55:12: error:
  • Couldn't match type ‘TriggerA ()’ with ‘() -> TriggerA ()’
  Expected type: Party
-> DA.Next.Map.Map CommandId [Command] -> () -> TriggerA ()
  Actual type: Party -> ACS -> () -> TriggerA ()
  • In the ‘rule’ field of a record
  In the expression:
  Trigger
  {initialize = \ _acs -> (), updateState = \ _acs _message () -> (),
  rule = copyRule, registeredTemplates = AllInDar, heartbeat = None}
  In an equation for ‘copyTrigger’:
  copyTrigger
  = Trigger
  {initialize = \ _acs -> (), updateState = \ _acs _message () -> (),
  rule = copyRule, registeredTemplates = AllInDar, heartbeat = None}

* match docs on TriggerAState to current usage of these fields

* remove emittedCommands, as commandsInFlight is now kept up-to-date

* zoomed from where?

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2020-10-08 12:03:56 -04: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
Sofia Faro
e9cd92f061
Deprecate the "daml 1.2" version header. (#7513)
* changelog_begin

- [DAML] The "daml 1.2" version header is now deprecated.

changelog_end

* fix some line numbers

* fix some more locations
2020-09-29 13:14:59 +00:00
azure-pipelines[bot]
b538c1fb59
update compat versions for 1.6.0-snapshot.20200922.5258.0.cd4a06db (#7473)
* update compat versions for 1.6.0-snapshot.20200922.5258.0.cd4a06db

CHANGELOG_BEGIN
CHANGELOG_END

* Bump to new snapshot

changelog_begin
changelog_end

Co-authored-by: Azure Pipelines DAML Build <support@digitalasset.com>
Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2020-09-24 21:11:25 +02:00
nickchapman-da
96d704b25b
Perform authorization checks during execution and not as a separate post-execution phase. (#7400)
changelog_begin
changelog_end

Adapt test for small error message change. An improvement! Previously an internal message was shown. Make test flexible enough to pass for old & new message.

Adapt expected output file. Only change is the contract-ids for active-contracts when the test ends.

fix small test bugs in testcase where authorization is wrong

temp disabled 3 tests; needs investigation; see TODO markers

temp adapt 1 test for change in error message

temp disable 1 test. needs invesigation

undo accidentally commited change to .bazelrc

add copyright header to new file

remove testcase (badActorCheck2) which is no longer expected behaviour, when authorization occurs during execution

address comments: be mre private & other tiny changes

appease scala formatter

improve expected error message in KeyNotVisibleStakeholders testcase

fix authorization issues and re-enable the 3 failing tests in EngineTest which now pass

fix auth issue and re-enable ledger-test-tool test: WronglyTypedContractIdIT

fix compatibility

re-enable test in KVUtilsTransactionSpec.scala
2020-09-17 17:50:04 +01:00