Commit Graph

986 Commits

Author SHA1 Message Date
Remy
5e1ddfbd5e
LF: Fix specification of ArithmeticError (#9949)
CHANGELOG_BEGIN
CHANGELOG_END
2021-06-10 13:37:16 +02:00
Remy
bd26c43767
LF: fix TransactionCoderSpec (#9922)
This modifies a test about version encoding that should not be run
with Rollback nodes as those do no have explicit version.

CHANGELOG_BEGIN
CHANGELOG_END
2021-06-08 12:58:47 +00:00
Remy
cbcec32e70
LF: clean up the remaining Exception TODOs (#9913)
CHANGELOG_BEGIN
CHANGELOG_END
2021-06-08 11:49:02 +02:00
Remy
db1453640f
LF: Freeze archive proto for LF 1.14 (#9912)
CHANGELOG_BEGIN
CHANGELOG_END
2021-06-07 12:44:20 +00:00
Remy
512f1fd87d
LF: Preview version of LF 1.14 (#9906)
+ Preview support for Exceptions.
+ byKey flag for transaction nodes.

CHANGELOG_BEGIN
CHANGELOG_END
2021-06-03 20:40:53 +02:00
Remy
3dee3d042d
LF: Fix encoder for Exception (#9904)
* LF: Fix encoder for Exception

CHANGELOG_BEGIN
CHANGELOG_END

* Update daml-lf/encoder/src/main/scala/com/digitalasset/daml/lf/archive/testing/EncodeV1.scala

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

Co-authored-by: Sofia Faro <sofia.faro@digitalasset.com>
2021-06-03 13:03:08 +00: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
Moritz Kiefer
850c7310e8
Include PackageMetadata in LF interface (#9892)
* Include PackageMetadata in LF interface

I want to use this in codegens but more generally, I think it also
fits well into the scope of the iface library in that it’s only
metadata and relatively stable.

changelog_begin
changelog_end

* Iterating more is less

changelog_begin
changelog_end

* fix tests

changelog_begin
changelog_end

* fmt

changelog_begin
changelog_end

* fix scala 2.12

changelog_begin
changelog_end
2021-06-03 09:06:23 +00:00
Sofia Faro
41266c35e2
Fix the formatting on the LF spec. (#9889)
changelog_begin
changelog_end
2021-06-03 09:51:50 +01:00
Oliver Seeliger
fd8f8a6ad9
Daml-lf suffixCid ignores V0 contract ids rather than erroring (#9867)
* Daml-lf suffixCid ignores V0 contract ids rather than erroring

- canton currently ignores v0 contracts upon suffixing as those may still appear in value parameters. Ignoring rather erroring on such contract ids will make it possible for canton to adopt the lf-based suffixer
- corda appears to work with v1 contract ids, assuming that suffixing always results in a Right:
  https://github.com/DACH-NY/daml-on-corda/blob/main/engine/src/main/scala/com/digitalasset/platform/corda/engine/VaultBackedDamlState.scala#L101

CHANGELOG_BEGIN
CHANGELOG_END

* Review feedback
2021-06-01 13:59:34 +00:00
Moritz Kiefer
94129b2254
Add tests for decoding of UpdateTryCatch (#9865)
changelog_begin
changelog_end
2021-06-01 14:55:34 +02:00
Moritz Kiefer
1cc0906267
Adda test for an unhandled builtin exception to ExceptionTest.scala (#9866)
changelog_begin
changelog_end
2021-06-01 14:55:15 +02:00
nickchapman-da
3a0b2f9ccc
remove 2x 8020 todo tags (#9868)
changelog_begin
changelog_end
2021-06-01 12:06:28 +00:00
Moritz Kiefer
590b8b3367
Reshuffle tests for AnyExceptionMessage (#9863)
Splitting the test between ExceptionTest and SBuiltinTest is just
confusing so this PR drops the test from ExceptionTest and moves it to
SBuiltinTest. We should probably do the same for From/ToAnyException
but I’ll leave that for #9861 or a follow-up PR.

changelog_begin
changelog_end
2021-06-01 10:40:58 +00:00
Moritz Kiefer
89bd478949
Reenable AnyException tests in ExceptionTest.scala (#9861)
* Reenable AnyException tests in ExceptionTest.scala

changelog_begin
changelog_end

* Move to SBuiltinTest

changelog_begin
changelog_end
2021-06-01 11:28:30 +02:00
Moritz Kiefer
1573984673
Include rollback nodes in danglingRefGenNode (#9851)
This PR fixes the todo in danglingRefGenNode to include rollback
nodes.

Some tests simply don’t work on rollback nodes so I added
danglingRefGenActionNode. For other tests, we just need to switch how
we generate nodes and versions to be a bit more sensible.

changelog_begin
changelog_end
2021-06-01 11:27:44 +02:00
Moritz Kiefer
972af2a1ae
Test To/FromAnyException primitives in DecodeV1Spec (#9852)
changelog_begin
changelog_end
2021-06-01 09:55:22 +02:00
Moritz Kiefer
f5f2a8a3f7
Remove obsolete transaction todo (#9853)
We have no intention of relaxing this for now so no point in keeping
this todo.

changelog_begin
changelog_end
2021-06-01 09:43:53 +02:00
nickchapman-da
ffe55863ff
Track oldChild in PartialTransaction context (#9815)
* Track minChildVersion when building transactions

Track in the `Context` if we have seen any _old_ children (predating `minException`).

Avoiding potential quadratic blowup of `smallestContainedVersion` in `PartialTransaction`.

Also make a small cleanup of the `Context` code, to avoid code duplication when creating a new _empty_ context.

changelog_begin
changelog_end

prefer to track minChildVersion:TxVersion instead of oldChild:Boolean in PartialTransaction.Context

propagate minChildVersion up through exercise nodes

* test that old-contracts created within new-exercises cannot be contained in a rollback node

* add some comments; propogate minChildVersion through rollback

* fmt
2021-05-28 13:23:19 +00:00
Remy
9626a5952d
Speedy: Clean SBuiltin (#9829)
CHANGELOG_BEGIN
CHANGELOG_END
2021-05-28 13:17:28 +02:00
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