Commit Graph

1000 Commits

Author SHA1 Message Date
nickchapman-da
5b73813dfd
Support reinterpretation for failing commands (#9993)
* WIP: reinterpret must fail

changelog_begin
changelog_end

EXPLORE: add x/y prefix to reinterpret

MiniEngineTest.scala

MiniTests.daml

setup reinterpret testing one step down, to be able to see rollback nodes

MiniEngineTest.scala - refactor yreinterpret

first minimal reinterpret test

setup testcase for reinterpret on a command which throws

catch exception during reinterpret; and test

introduce type for Validating; avoid boolean blindness

remove exploratory MiniTests

remove exploratory x/y prefix on reinterpret

question

fix build

* small cleanup

* add `unsafeCompileForReinterpretation`; preserve interface of existing `unsafeCompile` (command list)

* remove the Validating type (not needed for this work)

* undo format change

* more private

* update comment for Engine.reinterpret

* test ensure failure works correctly; no rollback expected

* refactor to share duplicated code in reinterpret tests

* remove unhelpful create/ensure tests

* test that reinterpretation of an uncatchable error remains a failure

* test that rollback-version-check-error remains a failure for reinterpretation

* remove dev comment left in by accident
2021-06-23 10:39:10 +00:00
Remy
58b1c4e771
Speedy: Refactor contract Id/Key callback (#10033)
CHANGELOG_BEGIN
CHANGELOG_END
2021-06-22 16:34:28 +02:00
Moritz Kiefer
e4c1c58317
Run scenarios in off-ledger machine (#10070)
* Run scenarios in off-ledger machine

This PR builds on the previous PR that split scenario execution in two
different speedy machines and now actually makes the machine that runs
scenarios run in off-ledger mode just like we handle Daml Script.

This required a bunch of refactoring to make it nice so apologies for
the slightly large PR. Hopefully it’s still relatively easy to follow
and luckily it deletes more code than it adds.

changelog_begin
changelog_end

* Apply suggestions from code review

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

* review comments

changelog_begin
changelog_end

Co-authored-by: Stefano Baghino <43749967+stefanobaghino-da@users.noreply.github.com>
2021-06-22 12:11:00 +02:00
Moritz Kiefer
fb757d8ed9
Handle visibility outside of speedy (#10056)
It makes no sense to pass NotVisible to Speedy especially since that
is not how visibility is handled for the Engine. Also it lets us
delete code and I like deleted code.

changelog_begin
changelog_end
2021-06-21 17:31:37 +02:00
Moritz Kiefer
febca5d62d
Use ScenarioRunner.submit in Daml Script (#10053)
* Use ScenarioRunner.submit in Daml Script

changelog_begin
changelog_end

* privatize ledger variable

changelog_begin
changelog_end

* drop space

changelog_begin
changelog_end
2021-06-17 17:12:45 +00:00
Moritz Kiefer
2b915e93da
Split scenario & ledger execution (#10039)
* Split scenario & ledger execution

This PR by no means aims to solve everything we can do here. It is
rather the minimal change that I could get to work that provides us
with one Speedy machine for scenario execution (which is still an
on-ledger machine to avoid having to change the callsites to much in
this PR) and one speedy machine per submission.

There is tons of cleanup we can do afterwards but this should
hopefully set the right foundations.

changelog_begin
changelog_end
2021-06-17 12:45:35 +02:00
Remy
3532460675
LF: Structure Preprocessing Errors (#10013)
part of #9974.

CHANGELOG_BEGIN
CHANGELOG_END
2021-06-17 09:20:27 +02:00
Stephen Compall
401069ef00
prepare for upgrade to Scalaz 7.3.3 (#9997)
* upgrade scalacheck to 1.14.3

* regenerate maven_install files

* some different names and implicits

* remove some fromTryCatchNonFatal

* more porting

* port fromTryCatchNonFatal to attempt

* factor the assertions in SignatureSpec to avoid \/

* deal with invariant \/

* make partial unification do what we want

* \/, parse*, and toNel

* many uses of the .right method

* a legitimate use of fromTryCatchThrowable

* rebuild maven pins

* further invariant \/

* OneAnd and Nel interface changes

* further Either games

* \/ and reformatting

* \/ in http-json

* \/ in http-json

* deprecations

* more invariance

* cleanup unused

* more invariance; http-json compiles

* final either follies

* small 2.12 extra incompatibility

* rebuild deps

* revisit a couple earlier fixes using nicer expressions I learned later

* no changelog

CHANGELOG_BEGIN
CHANGELOG_END

* repin 2.12
2021-06-15 14:41:48 -04:00
Remy
af144e8592
LF: Structure package loading errors (#9980)
part of #9974.

CHANGELOG_BEGIN
CHANGELOG_END
2021-06-15 18:39:26 +02:00
Sofia Faro
0c32cf2968
Clarify the semantics of DIV_INT64 in LF spec. (#10003)
* Clarify semantics of DIV_INT64 in LF spec.

Especially around negative operands. Adds a couple of unit tests to make sure the behavior stays this way, and that MOD_INT64 is consistent with DIV_INT64.

changelog_begin
changelog_end

* spelling

* scalafmt

* hardcode numbers in MOD_INT64 test
2021-06-15 10:22:13 +00:00
Moritz Kiefer
998f106ee6
Drop pkgIds argument from Engine.validatePackages (#9986)
* Drop pkgIds argument from Engine.validatePackages

Doesn’t do anything useful, we just use it to validate that it matches
the keys of pkgs.

changelog_begin
changelog_end

* add test showing broken behavior

* Fix buggy tests

changelog_begin
changelog_end

Co-authored-by: Remy Haemmerle <Remy.Haemmerle@daml.com>
2021-06-15 10:58:43 +02:00
Moritz Kiefer
836a82a6b6
Add proper error handling for missing contract keys (#9972)
* Add proper error handling for missing contract keys

These are clearly not internal errors so we should not be calling
`crash` here. Canton in fact already started string matching on the
crash message which is definitely not what we want.

changelog_begin
changelog_end

* backwards compat

changelog_begin
changelog_end

* fix tests

changelog_begin
changelog_end
2021-06-14 09:12:30 +00:00
Remy
d7d6e37785
LF: Structure Engine Errors. (#9971)
This PR is part of the effort to improve engine Errors.  Here we
classify all the errors the engine can report in 4 categories:

- Errors happening during package loading

- Error happening during command/transaction preprocessing

- Error happening during interpretation

- Error happening during transaction validation


part of #9974

CHANGELOG_BEGIN
CHANGELOG_END
2021-06-14 08:43:00 +02:00
nickchapman-da
5f0f5756bf
Define IncompleteTransaction for use by scenario-service (#9952)
* Define IncompleteTransaction for use by scenario-service

changelog_begin
changelog_end

* improve names as per review comments
2021-06-10 15:06:58 +00:00
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