Commit Graph

1016 Commits

Author SHA1 Message Date
Moritz Kiefer
269237ea76
Fix authorization in try contexts (#9823)
wildcard pattern matches bite once again. We clearly do not want to
use the committers here.

I tried to move most of the logic to PartialTransaction but
unfortunately moving the submitters to PartialTransaction doesn’t
quite work since as usual scenarios make things difficult because
submitters change at weird places and we reset the partial transaction
in weird places.

changelog_begin
changelog_end
2021-05-28 12:28:43 +02:00
daravep
a166e79aca
Added maxlength information to id string (#9826)
Before this change, when converting a string which exceeds the max
length, the application return the error "too long" without saying what
the bounds are, requiring a user to lookup the bounds in code. Now, the
user gets the actual length that is enforced as part of the error
message.

CHANGELOG_BEGIN
CHANGELOG_END
2021-05-28 08:30:19 +02:00
Remy
0c12259c04
Speedy: Use SAny instead of SAnyException to reperesent AnyExcpetion (#9819)
This PR simplifies the internal of Speedy by factorizing SAny and
SAnyException. By side effect we also get the comparison of LF
AnyException values that was not implemented before.

CHANGELOG_BEGIN
CHANGELOG_END
2021-05-27 23:43:26 +00:00
Remy
a3b10dc6f9
LF: fix parser (#9809)
CHANGELOG_BEGIN
CHANGELOG_END
2021-05-27 11:57:49 +02:00
Remy
1f021b25c6
LF: Drop Builtin Exceptions completly (#9790)
CHANGELOG_BEGIN
CHANGELOG_END
2021-05-26 19:30:44 +02:00
Remy
6b67ba06f2
LF: SBAnyExceptionMessage queries for unknown packages. (#9804)
* LF: SBAnyExceptionMessage queries for unknown packages.

CHANGELOG_BEGIN
CHANGELOG_END
2021-05-26 16:43:58 +02:00
Sofia Faro
4e9c86ccd0
Fix a typo in LF spec normalization section. (#9797)
changelog_begin
changelog_end
2021-05-26 08:19:45 +01:00
Sofia Faro
d024efeffc
Add a section on transaction normalization in the LF spec. (#9788)
Note that it only has rules for normalizing `create` and `exercise`, but that's because the LF spec only has `create` and `exercise` actions for now.

changelog_begin
changelog_end
2021-05-26 07:45:54 +01:00
nickchapman-da
2710fad0e1
Normalize rollback nodes when a transaction is constructed (#9712)
* Normalize rollbacks: first draft

CHANGELOG_BEGIN
CHANGELOG_END

NormalizeRollbackSpec, WIP

WIP2

adapt to asVersionedTransaction

first stab at traversal for normalize-rollbacks... implement normalization rule #1

adapt existing testcase for rollback normalization rule #1

pluralize spec filename

temp disable rollback normalization

methodically test normalization rule #1

lots more tests

spec: check all 3 norm conditions

cleanup test/Shape code a bit

implement normalization rules #2 and #3 (using canonical types) and enable tests

add some comments and some 8020 todo markers

* add 2 more testcases from Sofia

* ensure tx produced when normalizing rollbacks has increasing node-ids when listed in pre-order

* enable rollback normalization in interpreter

* manage state functionaly for the created tx (counter & node-map)

* un-nest sub defs from normalizeTx (we can because we removed the mutable state)

* rename: force* --> push*

* introduce CPS for push functions

* introduce trampolines for push functions to be stack safe

* one more bounce

* ensure generated node-ids start from 0

* test that transaction node-ids start from 0

* add commets about pass1/2; move makeRoll (part of pass 1) earlier in file

* intro CPS for pass-1 over original tx

* intro trampolines for pass-1. everything is stack safe now

* clarify comment

* remove make stack-safe todo

* be more private

* factorize/share Trampoline implementation with previous implementation in speedy.Anf

* prefer Vector over List, for better algorithmic complexity

* make Trampoline private to lf
2021-05-25 17:00:31 +00:00
Remy
8ef93611fa
Scenario: Test ArithemticError (#9757)
Two integration-type tests:

- An uncaught arithmetic error
- A caught arithmetic error

This is part of #8020

CHANGELOG_BEGIN
CHANGELOG_END
2021-05-25 14:43:27 +02:00
Sofia Faro
abb7142072
Update LF spec for exceptions. (#9784)
* Update LF spec for exceptions.

The changes here are:

* Removing the built-in exception types
* Changing the result in the operational semantics to include both an "exception thrown" case and a "fatal error" case.
* Cleaning up the semantics of create/exercise/etc and try/catch.

Not included in this PR is anything to do with built-in arithmetic exceptions. There's room to add it in the future (as a value of AnyException type), but I would do it in a follow-up PR.

changelog_begin
changelog_end

* finish renaming Throw cases

* Update type ordering for AnyException.
2021-05-25 10:33:44 +00:00
Remy
5855a9941f
LF: Drop CONTRACT_ERROR (#9754)
CHANGELOG_BEGIN
CHANGELOG_END
2021-05-21 09:12:29 +00:00
Remy
a2775605d8
LF: change format of ArithmeticError message (#9761)
in order to follow LF conventional syntax.

CHANGELOG_BEGIN
CHANGELOG_END
2021-05-20 20:10:31 +02:00
Moritz Kiefer
3827f82a7a
Fix consumedBy in rollback nodes for scenario service (#9746)
changelog_begin
changelog_end
2021-05-20 12:07:13 +00:00
Miklos
f5c84a2aa4
Daml-LF: Damlification of Scala/Haskell files (#9666)
CHANGELOG_BEGIN
CHANGELOG_END
2021-05-20 09:52:33 +02:00
Remy
0d931b2f4b
Speedy: implement Arithmetic builtin exceptions (#9653)
part of #8020

CHANGELOG_BEGIN
CHANGELOG_END
2021-05-19 21:46:48 +02:00
Remy
2e9bb21091
Engine: clean conversion builtin names (#9726)
Rename conversion builtins in the engine to follow
archive conventions.

This follows up #9716

CHANGELOG_BEGIN
CHANGELOG_END
2021-05-19 13:02:16 +00:00
Remy
fcbba1cd95
LF: rename convertion builtins to be more obvious (#9716)
The name of some builtins will be exposed as part of the Exception
message. This PR, try to make conversion builtins more consistent and
more obvious, before we could not rename those.

This is part of #8020

CHANGELOG_BEGIN
CHANGELOG_END
2021-05-19 10:11:26 +00:00
Remy
a6c7b86afc
LF: Drop support of TO_QUOTED_TEXT_PARTY (#9721)
CHANGELOG_BEGIN
CHANGELOG_END
2021-05-18 21:29:04 +02:00
Sofia Faro
9d23b4337f
Split DA.Internal.Exception.Types into three packages. (#9709)
* Split DA.Internal.Exception.Types into three packages.

I think this is a good idea because it means the user can disambiguate between these modules in daml. All three types define a `message` field, so if the programmer wants to refer to the field for one of these types specifically, it's nice to have a canonical way to disambiguate them (by module name).

Also the module names show up in the error message for uncaught exceptions. These names are a bit nicer than "DA.Internal.Exception.Types".

Decoupling these types just sounds like a good idea going forward.

changelog_begin
changelog_end

* buildifier-fix

* update isInternal

* Update tests

* Use more general pattern in CommandServiceIT

* Update DarReaderTest
2021-05-18 18:42:11 +00:00
Remy
679ce3b7d3
LF: Release LF 1.13 (#9705)
CHANGELOG_BEGIN

- LF: make LF 1.13 stable
   Add support for BigNumeric

- Ledger API: Bump Ledger API version for LF 1.12

CHANGELOG_END
2021-05-18 17:30:34 +02:00
Remy
d4fca0305b
LF: Change error exception for Arithmetic builtins (#9692)
This PR is a priliminary step toward making Arithmetic Builtin
throwing proper Daml Excetpions.

This is part of #8020.

CHANGELOG_BEGIN
CHANGELOG_END
2021-05-18 10:41:44 +02:00
Remy
fc745f2224
LF: clean shifting BigNumeric builtin (#9704)
CHANGELOG_BEGIN
CHANGELOG_END
2021-05-17 19:26:14 +02:00
Sofia Faro
69f51e4b5e
speedy: Compile new AnyException primitives (#9700)
* speedy: Compile new AnyException primitives

changelog_begin
changelog_end

* s/Contract/ContractError

* remove random eszett

* fix booleans

* Combine some cases!

* define and use getSException

* use SException directly in pattern match
2021-05-17 12:47:22 +01:00
nickchapman-da
6d9490c0bb
Never create a rollback node containing pre-exception descendants. (#9679)
* Never create a rollback node containing descendants nodes with versions older than minExceptions. Instead throw an (old-style) uncatchable exception.

changelog_begin
changelog_end

* avoid wildcard import; fixes scala_2_13 build?

* extend example: add exercise within the potential rollback

* comment inefficiency
2021-05-17 10:42:29 +00:00
Moritz Kiefer
9b53251c74
Differentiate between negative inputs & errors in contractKeyInputs (#9683)
For better or for worse, kvutils validation insists on treating a
negative input from a create different to a negative key lookup (and
to make things more annoying the first one will never blow up during
submission only during validation).

While, nobody seems to argue all that strongly that the current errors
are very sensible, we agreed to do it in two steps:

1. Expose enough information in `contractKeyInputs` so that we can use
   it in kvutils while preserving the current error semantics.
2. Revisit contract key error handling across ledgers which is
   currently an inconsistent mess.

changelog_begin
changelog_end

.

changelog_begin
changelog_end
2021-05-17 10:29:04 +02:00
Remy
80f65b4734
LF: clean compilation of SToTextXXX builtins (#9682)
CHANGELOG_BEGIN
CHANGELOG_END
2021-05-14 14:30:45 +02:00
Moritz Kiefer
5d181c6ef4
Throw on internal errors instead of setting ptx to aborted (#9654)
* Throw on internal errors instead of setting ptx to aborted

The main purpose of aborted is to be able to get out a ptx in the
scenario service. However, for internal errors that makes no
sense. Users should never encounter them. And the use of `aborted`
here has swallowed these errors silently in a few places before which
is clearly bad.

changelog_begin
changelog_end

* Fix tryHandleSubmitMustFail

changelog_begin
changelog_end
2021-05-13 07:29:53 +02:00
Sofia Faro
cc01e933e5
Update error message in interface reader. (#9657)
BigNumeric / RoundingMode are not related to exceptions.
In any case, these are all unserializable.

changelog_begin
changelog_end
2021-05-12 13:35:07 +00:00
nickchapman-da
2dc8b8f1de
Remove version field from rollback node. (#9627)
* Remove version field from rollback node.

changelog_begin
changelog_end

fix transaction decode & testcases
reinstate/adapt testcases
fmt
rebase change to fix conflicts

* treat missing version on transaction node as being version minExceptions when computing tx version

* add 8020 marker for grepability

* reinstate Node.version to avoid logic duplication

* Revert "reinstate Node.version to avoid logic duplication"

This reverts commit 00dacb453d.

* remove Node.updateVersion

* remove comments with dubious utility
2021-05-12 12:58:51 +00:00
Moritz Kiefer
931274a14e
Drop version check from TransactionPreprocessor (#9651)
* Drop version check from TransactionPreprocessor

This is only supposed to be run on nodes that have been normalized via
de(serialization) so this is just useless shotgun validation.

changelog_begin
changelog_end

* Fix test

changelog_begin
changelog_end
2021-05-12 10:49:13 +00:00
Stephen Compall
ca9e89b3da
check whether collection.compat is unused when compiling for Scala 2.12 (#9604)
* check whether collection.compat is unused when compiling for Scala 2.12

- Instead of always suppressing warnings for collection.compat._,
  we should only do it for Scala 2.13

- We can also reduce boilerplate by automatically adding this
  option when both silencer_plugin and collection-compat are
  present

CHANGELOG_BEGIN
CHANGELOG_END

* remove unused import

* remove another unused import

* remove even more unused imports

* missed compat dependency

* more missed compat dependencies

* missed compat dependency

* use scala_deps in scaladoc_jar

- #8423 inlined the major version expansion, but this seems to
  have been prior to proper support by scaladoc_jar

* restore custom handling of participant-integration-api

- fixing scaladoc_jar isn't worth it for a single case, as with
  deps vs scala_deps
2021-05-11 21:54:14 +00:00
Moritz Kiefer
c757b61516
Check byKey in transaction validation (#9641)
* Check byKey in transaction validation

No tests because validation has no tests in general :(

part of #7622

changelog_begin
changelog_end

* Fix preprocessing of transaction root nodes

changelog_begin
changelog_end
2021-05-11 16:22:37 +00:00
Moritz Kiefer
22b36b0b01
Include byKey in LF transaction spec (#9642)
changelog_begin
changelog_end
2021-05-11 14:19:36 +02:00
Moritz Kiefer
ca027e3dde
Add Transaction.contractKeyInputs to inputs of a transaction (#9631)
* Add Transaction.contractKeyInputs to inputs of a transaction

changelog_begin
changelog_end

* Apply suggestions from code review

Co-authored-by: Remy <remy.haemmerle@daml.com>

Co-authored-by: Remy <remy.haemmerle@daml.com>
2021-05-11 11:13:06 +00:00
Moritz Kiefer
3750b16a11
Serializalize byKey flag in Daml-LF transactions (#9632)
This keeps screwing us over so I finally got sufficiently annoyed to
fix it.

progress towards #7622

changelog_begin
changelog_end
2021-05-11 10:31:10 +02:00
Remy
0d1f3db8a4
LF: refactor builtin exceptions in Speedy (#9605)
follow up #9595.

part of #8020

CHANGELOG_BEGIN
CHANGELOG_END
2021-05-11 09:18:27 +02:00
Moritz Kiefer
d6d01b04ef
Swap order SEScopeExercise and SBUBeginExercise (#9621)
* Swap order SEScopeExercise and SBUBeginExercise

SEScopeExercise pushes the KCloseExercise continuation. However, the
corresponding transaction node is only inserted when SBUBeginExercise
finishes. This causes an issue if SBUBeginExercise crashes/throws an
exception.

changelog_begin
changelog_end

remove weird comment

changelog_begin
changelog_end

Reenable another test

changelog_begin
changelog_end

* Update failing test

changelog_begin
changelog_end
2021-05-10 19:25:55 +02:00
Moritz Kiefer
4c1fbeb194
Add duplicate contract key checks to Speedy (#9607)
changelog_begin
changelog_end
2021-05-07 17:24:42 +00:00
Remy
871279f3a6
LF: extends LF command with Fetch and Lookup (#9587)
This PR includes  :

- Adding ApiCommand to distinguish between generic command (that are
  accepted by the engine) and command that are accepted by the ledger
  API.

- Reimplement Canton's reinterpret method using commands instead of
  node.

CHANGELOG_BEGIN
CHANGELOG_END
2021-05-07 19:19:25 +02:00
Moritz Kiefer
560653a5d7
Unwind partial transaction on mustFail (#9608)
This PR fixes a very confusing and subtle bug in the handling of
submitMustFail in scenarios:

submitMustFail did not properly unwind the transaction. Afaict, this
only matters for contract id derivation in this context.
It also only matters for errors during interpretation not errors that
happen when committing to the ledger (global duplicate key errors).

Specifically what happens is that we end up leaking the exercise
context that we were in when we hit the failure into the next
submission. I’m not sure if this actually breaks anything (if it does,
doesn’t really matter, it’s scenarios) but it is definitely not what
should be happening.

I hit this when adding uck checks to the engine since that turns some
commit errors into interpretation errors and changed contract ids in
tests that really shouldn’t have changed.

changelog_begin
changelog_end
2021-05-07 14:56:45 +00:00
Moritz Kiefer
ab29f7c07c
Move activeness check of globalKeyInputs into archive (#9610)
* Move activeness check of globalKeyInputs into archive

This is semantically equivalent but it seems slightly simpler and more
importantly it leads to slightly nicer semantics by reducing the
number of cases where we have to worry about accidentally skipping an
activeness check.

changelog_begin
changelog_end

* s/optCid/keyMapping/

changelog_begin
changelog_end

* review feedback

changelog_begin
changelog_end
2021-05-07 09:12:31 +00:00
Sofia Faro
22ba5fddd2
Remove builtin exception types from protobuf and ASTs. (#9595)
* Remove builtin exception types from protobuf/AST.

changelog_begin
changelog_end

* Remove builtin exxceptions from protobuf/ast.

* remove unecessary s"

* scalafmt

* syntax error

* Add TODOs

* Apply suggestions from code review

Co-authored-by: Remy <remy.haemmerle@daml.com>

* Add AnyException builtins in typing spec.

* Update protobuf "Next id" comment.

Co-authored-by: Remy <remy.haemmerle@daml.com>
2021-05-06 21:26:12 +00:00
Moritz Kiefer
2fc7489e44
Filter divulgence to an empty set of parties (#9600)
* Filter divulgence to an empty set of parties

As @nmarton-da noticed painfully, we currently include divulgence to
an empty set of parties. While this is arguably not wrong it is at
least confusing and useless. The whole point of divulgence is to track
visibility. Divulging to an empty set of parties does not affect
visibility so it is not meaningfully different from no
divulgence. Therefore this PR filters it out and adds a doc comment
that the list of divulgees is always non-empty.

changelog_begin
changelog_end

* Fix tests

changelog_begin
changelog_end
2021-05-06 18:33:30 +00:00
Sofia Faro
2176173ba2
Remove 1.dev-only things from LF 1.13 protofile. (#9599)
* Remove 1.dev stuff from 1.13 LF protofile.

changelog_begin
changelog_end

* Remove Experimental

* update hashes
2021-05-06 17:30:18 +01:00
Moritz Kiefer
e584fecd3c
Drop com.daml.lf.engine.Event.collectEvents (#9596)
This looks like an attempt at moving the conversion from transactions
to Ledger API events to the Ledger API. However, that attempt is not
used anywhere (checked pkvutils, corda & canton).

I don’t think we benefit from having an unused method sitting around
here so this PR kills that method.

changelog_begin
changelog_end
2021-05-06 14:21:04 +00:00
Moritz Kiefer
80b07da309
Only archive a key if it was brought into scope before (#9546)
* Only archive a key if it was brought into scope before

This PR implements the semantics we agreed on in
https://github.com/digital-asset/daml/pull/9472#discussion_r620097844.

Before, archive always marked the key as inactive in `keys`. This is
weirdly inconsistent with other operations. For example, a regular
fetch does not bring a key in scope in `keys`. This PR changes this to
a more consistent model where `keys` is modified exactly under the
following circumstances:

1. A create with a key always overwrites.
2. An archive will only mark a key as inactive if there was an entry
   in `keys` with the same contract id.
3. Lookup/fetch by key first check if we currently have an entry in `keys`.
   If so, we use that.
   If not, we need to ask the ledger. We first check if we have a
   ceched entry in `globalKeyInputs`. If we do use that.
   If we don’t, we ask the ledger.
   If the result is not active or not visible we proceed updating `keys`
   and `globalKeyInputs`.
   If the result was a cid, we check if it’s still active.

changelog_begin
changelog_end

* Review comments

changelog_begin
changelog_end

* Apply suggestions from code review

Co-authored-by: Remy <remy.haemmerle@daml.com>

* fmt

changelog_begin
changelog_end

Co-authored-by: Remy <remy.haemmerle@daml.com>
2021-05-06 14:11:32 +00:00
Moritz Kiefer
45fbdefb06
Handle rollback nodes in protoNodeInfo (#9589)
This PR clarifies that NodeInfo is only intended for actions by
renaming it to ActionNodeInfo and correspondingly also changes
protoNodeInfo to protoActionNodeInfo and makes it return a `Left` for
rollback nodes.

changelog_begin
changelog_end
2021-05-06 12:19:20 +02:00
Moritz Kiefer
42d189dbbe
Support exceptions in Daml-LF encoder (#9590)
changelog_begin
changelog_end
2021-05-06 12:18:57 +02:00
Remy
9c3913a3d6
LF: SBUKeyBuiltin clean up. (#9572)
This PR some minor clean up for #9537 and #9538.

In particular it:

- Remove the unecessary class KeyOperation (SBUKeyBuiltin is already a
  somehow a key Operation)

- Rename and refactor methods handleKeyFound, handleKeyArchived,
  cidToSValue and cidToSExpr to gave them a more obvious meaning.

- Replace immutable.Map#+ by immutable.Map#updated (cosmetic)

- Replace trait by abstract class (cosmetic)

CHANGELOG_BEGIN
CHANGELOG_END
2021-05-06 10:34:28 +02:00
Moritz Kiefer
a27b2c56bc
Address more exception todos (#9582)
* Address more exception todos

A bit of a kitchen sink PR to address a bunch of the trivial todos
that didn’t seem worth splitting out into separate PRs.

changelog_begin
changelog_end

* Revert changes to TransactionSpec

changelog_begin
changelog_end
2021-05-05 16:00:08 +02:00
Remy
81d508b775
LF: make SBuiltins pure (#9580)
CHANGELOG_BEGIN
CHANGELOG_END
2021-05-05 10:39:45 +00:00
Moritz Kiefer
de80a6dc60
Drop ValueBuiltinException (#9576)
As discussed, we don’t want to expose this via serializable values at
least for now (and it’s not exposed on the ledger API anyway) so this
PR drops the type.

changelog_begin
changelog_end
2021-05-05 12:32:58 +02:00
Moritz Kiefer
9ae787d005
Cache global key inputs (#9538)
* Cache global key inputs

This PR changes speedy such that it will query at most once for a global
key. This is a prerequisite for a (sensible) duplicate key detection
and for sensible multi-key semantics.

Note that there is one outstanding issue here:

As a general rule, we only want by-key operations to bring a key in
scope not just a random operation like an exercise or a fetch that
happens to have a key.

However, for consuming exercises this is currently not the case. They
always bring the key in scope. The plan here is for an archive to not
block a further lookup and instead add an activeness check to the
lookup afterwards.

changelog_begin
changelog_end

* Update daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/speedy/SBuiltin.scala

Co-authored-by: Remy <remy.haemmerle@daml.com>

* s/CtrlImportValue/SEImportValue/

changelog_begin
changelog_end

* .

changelog_begin
changelog_end

* Use a custom Scala type instead of Option[Value.ContractId]

changelog_begin
changelog_end

Co-authored-by: Remy <remy.haemmerle@daml.com>
2021-05-04 13:49:58 +00:00
Moritz Kiefer
6e3312b719
Remove rollback todo from ScenarioLedger (#9566)
No need to treat rollback nodes any differently here. A lookup for a
cid -> node mapping that does not point to a create node is borked and
we turn it into notfound.

changelog_begin
changelog_end
2021-05-04 12:40:45 +00:00
Moritz Kiefer
2935b6fe84
Kill InMemoryPrivateLedgerData (#9569)
This is only used in one test where we can just reuse the scenario
ledger. I really don’t want more broken ledger implementations.

This also removes the need to address the TODO around rollback nodes.

changelog_begin
changelog_end
2021-05-04 14:31:09 +02:00
Remy
fcece8b7e8
LF ValueGenerators: fix transaction version generator (#9552)
CHANGELOG_BEGIN
CHANGELOG_END
2021-05-04 09:13:20 +02:00
Moritz Kiefer
dce6a16649
Add Ledger API test tool tests for exceptions (#9400)
* Add Ledger API test tool tests for exceptions

changelog_begin
changelog_end

* Update daml-lf/language/daml-lf.bzl

Co-authored-by: Sofia Faro <sofia.faro@digitalasset.com>

* Address review comments

changelog_begin
changelog_end

* Shuffle around test

changelog_begin
changelog_end

Co-authored-by: Sofia Faro <sofia.faro@digitalasset.com>
2021-05-03 18:40:52 +02:00
Moritz Kiefer
55c3e1cf45
Test multi-keys behavior (#9472)
* Document and test multi-key semantics

Canton relies on the Engine working correctly even in a setting where
we do not have multiple keys. So far this worked by accident but the
semantics of this are rather unclear. To make things worse, Canton
upgrades rely on those semantics being stable so we really do care
about the choices we make here.

This PR adds a bunch of tests as an executable documentation of the
current behavior. However, we do not provide stability guarantees for
the current behavior and therefore these tests can be changed as
needed. But at least we are aware of those changes rather than doing
them by accident.

changelog_begin
changelog_end

* Update daml-lf/engine/src/test/scala/com/digitalasset/daml/lf/engine/EngineTest.scala

Co-authored-by: Sofia Faro <sofia.faro@digitalasset.com>

* Update daml-lf/tests/MultiKeys.daml

Co-authored-by: Sofia Faro <sofia.faro@digitalasset.com>

* Update daml-lf/tests/MultiKeys.daml

Co-authored-by: Sofia Faro <sofia.faro@digitalasset.com>

Co-authored-by: Sofia Faro <sofia.faro@digitalasset.com>
2021-05-03 12:59:57 +02:00
Moritz Kiefer
ae2cd41766
Share code between SBUFetchKey and SBULookupKey (#9537)
* Share code between SBUFetchKey and SBULookupKey

Those do almost the same and the logic is growing increasingly complex
so I really want to share it. This also makes it easier to see the
things that are different.

Along the way I’ve also discovered a bug:
SBUFetchKey called crash where it should produce a proper error that
can be caught by submitMustFail. Not going to resolve that in this PR
though so I just added a TODO.

changelog_begin
changelog_end

* review comments

changelog_begin
changelog_end
2021-04-30 17:53:31 +00:00
Moritz Kiefer
4aca199bbd
Upgrade to Scala 2.13.5 (#9528)
changelog_begin
changelog_end
2021-04-29 13:05:57 +00:00
Sofia Faro
a5d1e185ab
Move builtin exceptions to a stable package. (#9523)
* Move builtin exceptions to a stable package.

This PR moves the built-in exceptions (GeneralError, ArithmeticError, ContractError) to a stable package in daml-prim, in preparation for removing them from LF proper.

Part of #8020.

changelog_begin
changelog_end

* Update tests

* rename the module

* couple that got away

* update hash

* Update dar reader test.

* typo

* questionable lint
2021-04-29 10:19:20 +00:00
nickchapman-da
81a4557d18
Allow missing exercise results when version >= minExceptions (#9531)
* Allow missing exercise results when version >= minExceptions

imp:
- adapt encode & decode implementations
- add version dependant checks for version < `minExceptions`

testing:
- update scalacheck `ValueGenerators` to produce exercise nodes with the missing result value guarded by the versions
- update `normalizeExe` in `TransactionCoderSpec`
- update `transactionVersionGen` to be inclusive on upper bound
- unhappy-path test for encode/missing-exercise-result when not allowed
- unhappy-path test for decode/missing-exercise-result when not allowed

changelog_begin
changelog_end
2021-04-29 10:32:53 +01:00
Moritz Kiefer
2f54be4f11
Fix ImmArray.copyToArray (#9527)
changelog_begin
changelog_end
2021-04-28 20:47:55 +00:00
Sofia Faro
1d47b27304
Update LF spec transaction structure. (#9510)
Just some small changes to take into account the new ledger model transaction structure (see #9396). This PR doesn't fix all the issues with the LF spec not matching the ledger model, but it tries to avoid widening that gap.

* Removed itr, iexercise which we don't need.
* Removed the exception type and value from the rollback node.
* We're not calling rollback nodes ledger actions anymore, so separate it out.

Part of #8020

changelog_begin
changelog_end
2021-04-28 09:23:53 +01:00
Samir Talwar
e1af564bcc
Switch from @silent to @nowarn. (#9498)
* Switch from `@silent` to `@nowarn`.

This annotation is native to Scala 2.12.13+ and 2.13.2+. It replaces
most usages of `@silent`.

I had to get creative about a couple of use cases that didn't work.
Specifically:

  1.  Suppressing deprecation warnings works, but Scala 2.12 erroneously
      complains that the `@nowarn` is unnecessary.  I had to suppress
      this warning too with `-Ywarn-unused:-nowarn`.
  2.  I can't seem to suppress the warning, "The outer reference in this
      type test cannot be checked at run time." Instead, I have
      refactored the code to remove the warning.

We still need to use the silencer plugin to suppress some warnings about
unused imports (because of compatibility between Scala 2.12 and 2.13),
but this means we no longer need the library, and therefore it is not a
transitive dependency that downstream consumers need to worry about.

CHANGELOG_BEGIN
CHANGELOG_END

* Add some comments around `@nowarn` support.

* language-support/scala: Fix a warning suppression.

* Revert to the default warnings.

Compatibility was complaining.
2021-04-26 19:46:14 +00:00
Moritz Kiefer
0106116d43
Add a helper for getting all inactive contracts to Transaction (#9503)
* Add a helper for getting all inactive contracts to Transaction

This comes up in a few places and rather than inlining the
implementation everywhere, I’d rather rely on this.

changelog_begin
changelog_end

* 2.13

changelog_begin
changelog_end
2021-04-26 21:19:07 +02:00
Stephen Compall
dc2a79fd8f
deprecate InsertOrdMap (#9491)
CHANGELOG_BEGIN
- [Scala bindings] ``InsertOrdMap`` is deprecated; it was never
  needed for the release version of ``GenMap``.  Use an ordinary
  ``Map``, or ``Primitive.GenMap`` for Scala codegen, instead.
CHANGELOG_END
2021-04-26 12:16:37 -04:00
Moritz Kiefer
d24f4796bb
Fix validation of rollback nodes (#9479)
* Fix validation of rollback nodes

To my own embarassment there is no test in this PR. We don’t have any
direct tests for validation atm. We absolutely need some and I already
discussed with Remy that this is something we should focus on once
exceptions are done but for now I’ll stick to being sad.

changelog_begin
changelog_end

* Fix bug

changelog_begin
changelog_end
2021-04-26 10:59:06 +00:00
Moritz Kiefer
e3f1f55ef9
Fix broken merge (#9480)
changelog_begin
changelog_end
2021-04-23 05:44:09 +00:00
Moritz Kiefer
176b17ae47
Move localContracts to PartialTransaction (#9475)
This makes it easier to do a bunch of other checks around contract
keys in PartialTransaction.

changelog_begin
changelog_end
2021-04-22 22:11:50 +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
nickchapman-da
8ba7ea99d9
Extend Transaction proto format for rollback nodes. (#9468)
* Extend Transaction proto format for rollback nodes.

- proto format
- encode/decode
- testcase
- always `allowRollback` from scalagen testing; and so remove control flag
- two more `8020` TODOs, for other code which matches `node.getNodeTypeCase` and sees `ROLLBACK`

changelog_begin
changelog_end

* add comments about version of rollback nodes in transaction.proto

* check rollback node version during encode & encode

* factor out code to decode children for exercise & rollback node

* test decode check for unexpected rollback node in old version
2021-04-22 18:00:57 +00:00
Moritz Kiefer
524d43eacb
Support rollback nodes in scenario service (#9410)
This focuses on the semantics rather than the display in Daml Studio
which needs more work (and seems not all that important at this
stage).

This already uncovered a bug which also applies outside of scenarios:

The consumedBy field was not affected by rollbacks which breaks the
mustBeActive check in partial transactions. This PR fixes this by
caching on try and restoring on rollback.

changelog_begin
changelog_end
2021-04-22 12:52:33 +02:00
Moritz Kiefer
cf2be78166
Support rollback nodes in BlindingInfo (#9445)
changelog_begin
changelog_end
2021-04-20 20:29:45 +02:00
Remy
adde90b5ba
KV: do not use "Effects" part of InputsAndEffects (#9433)
* KV: do not use "Effects" part of InputsAndEffects

The PR is based #9429.

changelog_begin
changelog_end

* Factor out helpers

changelog_begin
changelog_end

* Apply suggestions from code review

Co-authored-by: Miklos <57664299+miklos-da@users.noreply.github.com>

* review comments

changelog_begin
changelog_end

* fmt

changelog_begin
changelog_end

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
Co-authored-by: Miklos <57664299+miklos-da@users.noreply.github.com>
2021-04-20 19:08:55 +02:00
Moritz Kiefer
14661a8b6e
Clearer variable name for subtype evidence (#9442)
changelog_begin
changelog_end
2021-04-19 15:11:38 +00:00
Remy
1cb907c55c
KV: do not use "Inputs" part of InputsAndEffects (#9429)
* KV: refactor transactionToSubmission to not use InputsAndEffects

CHANGELOG_BEGIN
CHANGELOG_END

* cosmetic

* Address Moritz' review

* cleanup

* delete wrong files

* Update daml-lf/transaction/src/test/scala/com/digitalasset/daml/lf/transaction/TransactionSpec.scala

Co-authored-by: Samir Talwar <samir.talwar@digitalasset.com>

* Fix borked merge

changelog_begin
changelog_end

* Apply suggestions from code review

Co-authored-by: fabiotudone-da <fabio.tudone@digitalasset.com>

* Extract submissionParties

changelog_begin
changelog_end

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
Co-authored-by: Samir Talwar <samir.talwar@digitalasset.com>
Co-authored-by: fabiotudone-da <fabio.tudone@digitalasset.com>
2021-04-19 11:11:12 +00:00
Moritz Kiefer
991225e1bb
Fix flakiness in //daml-lf/transaction (#9438)
The current generators are a bit too dumb and relatively
frequently (~1/10) fail to generate 5 successful results before
failing forever. This PR changes things slightly to avoid this. We
could be even more clever and draw the second version after having
selected the first one so we cannot even draw the same but that
doesn’t seem worth the complexity for now.

changelog_begin
changelog_end
2021-04-19 10:38:11 +02:00
Moritz Kiefer
23fb973da2
Delete CheckAuthorizationMode (#9435)
Originally added to ease migration for Canton but they switched away
from it months ago.

changelog_begin
changelog_end
2021-04-19 09:26:08 +02:00
Moritz Kiefer
a93a9981c6
Add tests for blinding info (#9431)
changelog_begin
changelog_end
2021-04-16 18:30:59 +02:00
Moritz Kiefer
86c1630660
Fix handling of consumedBy and keys in partial transaction rollbacks (#9430)
Spun out from #9410 for ease of review and to force to write proper
tests :)

changelog_begin
changelog_end
2021-04-16 16:43:02 +02:00
Hubert Slojewski
802362b598
KVL-861 Update normalizers for the integrity checker (#9384)
* Move existing normalization methods to UpdateNormalizers

CHANGELOG_BEGIN
CHANGELOG_END

* Normalize exported updates
2021-04-15 17:04:25 +02:00
Remy
45697953e1
LF: Add method to compute transaction informees. (#9420)
Part of #8020.
Follow up #9416.

CHANGELOG_BEGIN
CHANGELOG_END
2021-04-15 13:43:39 +02:00
Remy
c52f9799e3
LF: distninguish Rollback from Action Nodes (#9416)
CHANGELOG_BEGIN
CHANGELOG_END
2021-04-15 09:31:55 +02:00
nickchapman-da
ffdb71d32a
Create rollback nodes (#9367)
* recode contractValuesInOrder in RollbackTest

* first stab at creating rollback node; tests updated

* Rollback nodes are transparent for the cid scheme

* deativate failing exception tests

changelog_begin
changelog_end

Co-authored-by: Remy Haemmerle <Remy.Haemmerle@daml.com>
2021-04-14 18:51:35 +02:00
Remy
2dc09ba2de
LF: fix contract ID freshness check (#9370)
Local contract IDs are collected in exercise children during preprocessing transaction for replay.

CHANGELOG_BEGIN
- [Engine] Fix contract ID freshness check when validating transaction
CHANGELOG_END
2021-04-13 18:45:44 +02:00
Sofia Faro
1627b70427
Pattern matching for RoundingMode (#9381)
* Pattern matching for RoundingMode

- Fix the order of RoundingMode constructors in GHC.Types to match the LF built-in order. Try to match this order across all code and documentation, and added a test for this order.
- Implements pattern matching for RoundingMode. The added machinery could also be useful for solving #5753 in the future.
- Implements Show instance for RoundingMode. (Mainly so we can use them in tests.) Moved BigNumeric Show instance to GHC.Show.

changelog_begin
changelog_end

* mkScrutineeEquality typo

* fix roundingModeLiteralMap order

* Use custom type for building case body

* Factor GeneralisedCaseAlternative into GeneralisedCasePattern

* Fix finalize

* Remove unused bindings
2021-04-13 15:47:16 +00:00
Gary Verhaegen
b41e1ed9f3
fix daml-lf/governance.rst (#9399)
There have been a few changes and the names in the current version are
no longer valid.

CHANGELOG_BEGIN
CHANGELOG_END

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2021-04-13 16:19:42 +02:00
Sofia Faro
06701f7d5e
Expose rounding modes as constructors + add BigNumeric docs. (#9336)
* Expose rounding modes as constructors.

This PR exposes the rounding modes as constructors for RoundingMode. Pattern matching for RoundingMode is not implemented and not critical (will open a separate issue).

This PR also adds documentation for BigNumeric.

changelog_begin
changelog_end

* Fix rounding mode literals

* Update data-types.rst

* expose constructors

* expose constructors (part 2)

* Update compiler/damlc/daml-prim-src/GHC/Types.daml

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

* Try to improve `Numeric n` description.

* Add message for RoundingMode match and a test.

* Restrict RoundingMode test to 1.dev

* Update version numbers to 1.13

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2021-04-07 14:58:31 +00:00
Moritz Kiefer
b90a9c3511
Remove exception message from AnyException (#9328)
This doesn’t really make that much sense in there and it makes some
things like Daml Script harder because I need to duplicate the logic
to get the exception message.

changelog_begin
changelog_end
2021-04-07 16:23:35 +02:00
Remy
35759fc83a
LF: Freeze archive proto for LF 1.13 (#9345)
CHANGELOG_BEGIN
CHANGELOG_END
2021-04-07 15:25:17 +02:00
nickchapman-da
0251e930a2
Improve TX normalization. (#9341)
* Improve TX normalization.

Extend `foreachInExecutionOrder` / `foldInExecutionOrder` to handle rollback nodes. Two new args control behaviour when entering/leaving rollback nodes. Caller can control (with a bool) if the traversal continues under exercise/rollback nodes. Update existing callers.

Use `foldInExecutionOrder` to define `reachableNodeIds`. And test.

Use `foldInExecutionOrder` to improve the behaviour of `NormalizeTransaction` so that all nodes within a rollback node are dropped. Also completely reworking the spec/test for the new behaviour.

changelog_begin
changelog_end

* fix build
2021-04-07 12:49:54 +01:00
Remy
568a8528a8
LF: release preview of LF 1.13 (#9329)
CHANGELOG_BEGIN
- Daml: (Early access) add support for BigNumeric
CHANGELOG_END
2021-04-07 12:42:54 +02:00
Remy
74956e2459
LF: BigNumeric spec. (#8899)
CHANGELOG_BEGIN
CHANGELOG_END

Co-authored-by: Sofia Faro <sofia.faro@digitalasset.com>
Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2021-04-06 17:08:01 +02:00
Remy
7b3b669eb7
LF: add test for bigNumeric operations (#9310)
CHANGELOG_BEGIN
CHANGELOG_END
2021-04-06 14:59:06 +02:00
nickchapman-da
3c1bfc49c8
Extend scalacheck testing to generate NodeRollback nodes (#9250)
- temporarily controlled by `allowRollback`
- set `allowRollback = false` for tests which dont yet work. Marked by `TODO`
- `allowRollback = true` used in `NormalizerSpec` tests
- implement `version` support in `NodeRollback` (so `NormalizerSpec` test will pass)

changelog_begin
changelog_end
2021-04-06 09:01:34 +01:00
Remy
451181e42f
Speedy: Cleanup Map litereals (#9242)
* Rename SGenMap to Map
* Fix complexity of SMapInsert and SMapDelete

CHANGELOG_BEGIN
CHANGELOG_END
2021-03-31 16:08:29 +02:00
Sofia Faro
f2e0464227
Add BigNumeric literals in Daml. (#9289)
* Add BigNumeric literals in Daml.

Adds support for BigNumeric literals (when available). Only literals that will fit in a single Numeric are supported for now.

I introduced the `IsNumeric t` typeclass because this is an easy way to restrict `fromRational` without moving it into its own typeclass. (Moving it into a typeclass causes some gnarly problems with the specializer -- it starts creating references to GHC.Real in an attempt to optimize the invocation, and that's a problem because  GHC.Real doesn't exist in LF.)

I then added the "fromNumeric" and "fromBigNumeric" conversion functions in that class, since they seem really convenient, and it also means we could in the future make it so that any type that implements `IsNumeric` gains literals (via Numeric or BigNumeric literals). This would improve a lot of Numeric code, since it eliminates the need to annotate types so often! But for now only Numeric and BigNumeric literals are supported.

changelog_begin
changelog_end

* lint

* Add test for too large bigNumeric
2021-03-31 13:39:39 +00:00
Remy
6c1f404c7d
LF: Add TO_TEXT_BIGNUMERIC (#9276)
This is part of #8719.

CHANGELOG_BEGIN
CHANGELOG_END
2021-03-30 13:31:42 +02:00