Commit Graph

1016 Commits

Author SHA1 Message Date
Remy
ebb76dca4c
LF: reorganize errors in com.daml.lf.archive (#10213)
* LF: reorganize errors in com.daml.lf.archive

part of #9974

CHANGELOG_BEGIN
CHANGELOG_END

* fix
2021-07-08 13:03:42 +00:00
nickchapman-da
69646451f2
Improvements for validation tests (#10214)
* prefer Seq to List when generating samples

CHANGELOG_BEGIN
CHANGELOG_END

* use TableDrivenPropertyChecks

* remove count/println
2021-07-08 13:48:07 +01:00
Remy
41b8448b17
LF: Simplify archive reader. (#10208)
* LF: Simplify archive reader.

- decouple Reader and Decoder
- introduce case class to handle hash, proto payload, and version

CHANGELOG_BEGIN
CHANGELOG_END

* Address Moritz' review

* cosmetic
2021-07-07 19:56:40 +00:00
Moritz Kiefer
6586dde11e
Move exercise context computation to the client side (#10199)
We probably want to start displaying the full ptx on the client side
but for now this at least moves things out of speedy and into the
rendering layer where they belong.

It also fixes IncompleteTransaction to unwind properly so the roots
are really the roots.

changelog_begin
changelog_end
2021-07-07 15:44:47 +02:00
nickchapman-da
e2bdca6be9
Use PartialFunction for more concise code. (#10191)
* Use PartialFunction for more concise code.

CHANGELOG_BEGIN
CHANGELOG_END

* tweak to use guards

* blind fix for 2.12

* try fix 2.12 build

* loose if-guard parens

* fixes for 2.12 build (should actually work this time!)
2021-07-06 16:43:49 +00:00
Sofia Faro
98b5ffee01
Add divulgence warning and test in script service. (#10179)
* Add divulgence warning and test in script service.

Part of #9947, building on the key visibility checks from #10136

This PR adds a divulgence warning inside the traceLog.
I wasn't sure whether:

1. these warnings should be kept in a separate structure from the
   traceLog, and therefore transmitted separately, or
2. these warnings should be kept together with traces, but the severity
   should be tracked and also transmitted over grpc, and warnings should
   be logged as warnings instead of as debug messages, or
3. these warnings should be kept together with traces, but
   logged as warnings instead of debug messages,
4. these warnings should be treated exactly like traces

I'm leaning toward #2, but this PR implements #3.

This PR tests the warning via the script service tests.

changelog_begin
changelog_end

* scalafmt

* Address Moritz's review

* Rename traceLog.add to traceLog.addDebug

* fix test

* Add test using exercise

* add single transaction test
2021-07-06 13:05:52 +01:00
nickchapman-da
8578e56aa7
Tests for transaction validation (#10167)
* Testing for Validation.isReplayedBy

changelog_begin
changelog_end

try fix scala 2_12 build

fetch node: samples and tweaks

list sig/insig field tweaks side-by-side so coverage is easier to eyeball

exerciseResult tweak sig & insig

add sig/insig tweak for byKey of Fetch node

add sig/insig tweak for key of Fetch node

must use ImmArray.empty instead of ImmArray() for scala 2.12

another blind attempt to fix scala 2.12

use for/yield instead of flatMap for list-comprehensions

test sig/insig tweaks to LookupByKey nodes

wont attempt to tweak rollbacks

(and shorten trailing dash in comment banners)

comment about how Tweak testing is organized

dont dep/import scalacheck (not used!)

no wild imports

* val --> private def

* def --> val

* prefer fail to println/assert(false)
2021-07-06 11:24:46 +00:00
Samir Talwar
e7e8a5705b
daml-lf/data: Optionally truncate party names in structured logs. [KVL-996] (#10163)
* daml-lf/data: Truncate party names in log output, on request.

The party name can grow quite long, so we offer ledger implementors the
opportunity to truncate it in structured log output.

Unfortunately, because we use Logback through the global
`LoggerFactory`, there is no place to inject logging configuration. This
means we also need to use global, mutable state to configure logging
output. I have added a `LoggingConfiguration` class+object in Daml-LF
Data, which may not be the best place, but I can't think of a better
one right now. I suggest we leave it there until it has reason to grow,
at which point we may want to move it.

CHANGELOG_BEGIN
CHANGELOG_END

* logging-entries: Make `ToLoggingValue` mixin-able.

* participant-integration-api: Truncate parties in filters when logging.

* participant-integration-api: Cast to `Party` for logging.

Invalid input should not break the request at this point. No assertions.

* daml-lf/data: Move `Party to LoggingValue` to a new package.

This avoids the transitive dependency issue most of the time.

* daml-lf-data: Move the `Identifier` logging to another package.

Again, reduces the need for transitively depending on _logging-entries_.
2021-07-01 16:50:49 +00:00
Samir Talwar
eda1245311
daml-lf/data: Add a conversion from Ref.Identifier to LoggingValue. (#10157)
I am getting quite tired of (Bazel + Scala)'s attitude to transitive
dependencies.

CHANGELOG_BEGIN
CHANGELOG_END
2021-06-30 20:05:06 +00:00
Remy
0a6df5c4db
LF: Clean Interpretation Error (#10145)
* LF: Clean Interpretation Error

part of #9974

CHANGELOG_BEGIN
CHANGELOG_END

* fix

* Address Mortiz' review

* fix
2021-06-30 16:49:48 +00:00
Sofia Faro
a6ee10be9a
Move visibility checks into speedy. (#10136)
* pass readAs to Engine.interpret/submit

* rename VisibleByKey -> Visibility

* Stop generating SResultNeedLocalKeyVisible

* engine: Remove localKeyVisible in Result.consume

* Don't run visibility checks during validation.

changelog_begin
changelog_end

* return of the scalafmt

* rename SVisibility -> SVisibleToStakeholders

* Extend documentation in engine for new argument

* sneaky error caused by merge
2021-06-29 11:36:55 +01:00
Remy
3df2566305
Scenario: move Scenario Error Throwable to scenario package (#10075)
com.daml.lf.speedy.SErrorScenario => com.daml.lf.scenario.Error

CHANGELOG_BEGIN
CHANGELOG_END
2021-06-28 12:04:57 +00:00
Remy
398300b76f
LF: Move Speedy Interpretation Error to transaction package (#10091)
to be accessible from any package

part of #9974

CHANGELOG_BEGIN
CHANGELOG_END
2021-06-25 20:50:15 +02:00
nickchapman-da
6af36fe1e3
Fix Tx.Metadata for normalized transactions (#10108)
* fix Tx.Metadata for normalized transactions

changelog_begin
changelog_end

* Fixup action seed normalization

changelog_begin
changelog_end

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2021-06-25 10:53:11 +02:00
Remy
f745f10394
LF: Realease LF 1.14 (#10077)
CHANGELOG_BEGIN
- [LF] Add support for Excepction
CHANGELOG_END
2021-06-24 13:44:09 +02: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
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