Commit Graph

61 Commits

Author SHA1 Message Date
Remy
9582e019ec
LF: Refactor PreprocessorSpec test (#10909)
Just moving stuff arround

CHANGELOG_BEGIN
CHANGELOG_END
2021-09-16 13:58:47 +00:00
Moritz Kiefer
8e22bb6b2d
Drop ContractId typeparameter from Value (#10827)
99% of our usecases use Value[ContractId] so this PR just fixes it.

The few other usescases are:

1. Value[Nothing] which we use for keys. This is technically more
precise but we benefit very little from it.
2. Value[String] mostly because in a few places we are lazy.

We don’t have any code which benefits from being polymorphic in the
contract id type.

changelog_begin
changelog_end
2021-09-16 08:46:57 +00:00
Remy
1e1c452b36
LF: drop ad-hoc FrontStack builders (#10839)
Following #10763, we drop the ad-hoc builders for `FrontStack`.

* Building a `Fronstack` from individuals elements should be done with
  standard scala buidler.

* Building a `Fronstack` from a `TraversableOne` should be done with
  the scala 2.13 `.to(FrontStack)` methd

* Building a `Fronstack` from a `ImmArray` should be done with the
  `toImmArray` method.

CHANGELOG_BEGIN
CHANGELOG_END
2021-09-13 17:49:09 +02:00
Remy
24fff88992
LF: Simplify TransactionBuilder (#10753)
CHANGELOG_BEGIN
CHANGELOG_END
2021-09-13 15:37:46 +02:00
Remy
c4e0a755d4
LF: drop ad-hoc ImmArray builders (#10763)
Since we switch to scala 2.13, ImmArray companion object extends
`Factory`. Hence:

- the `apply` methods of `ImmArray` override the one from `Factory`

- we can use the notation `.to(ImmArray)` to convert an `Iterable` to
  `ImmArray`

This PR drops those `apply` ImmArray. Conversion from Iterable to
`ImmArray` should use the `.to(ImmArray)`.

CHANGELOG_BEGIN
CHANGELOG_END
2021-09-04 16:10:07 +02:00
nickchapman-da
aec601f929
Fix badly versioned empty tx (#10596)
* build correctly versioned empty tx

* dont call normalizeTx from Engine.validate

* dont recalc the tx-version in normalizeTx; just assume it is correct

CHANGELOG_BEGIN
CHANGELOG_END
2021-08-17 13:58:58 +01:00
Moritz Kiefer
66284c17f2
Limit length of package ids to 64 characters (#10368)
* Limit length of package ids to 64 characters

In practice, you cannot use a package id that is not a valid sha256
outside of a test anyway since we validate them. However, we didn’t
enforce it at the daml-lf level which is a bit annoying.

This PR fixes this and adds a length restriction of 64
characters (i.e. 256 bytes for sha256).

We could go a bit further and also restrict the characters to valid
sha256 hashes (i.e. 64 character hex strings). I don’t feel all that
strongly about that either way. We use other characters in tests but
fixing that shouldn’t be particularly hard either. The extra
characters don’t seem to cause problem so far, so I think it’s fine to
keep that.

No changelog entry since I don’t see how a user can be affected by this.

changelog_begin
changelog_end

* Update daml-lf/encoder/src/main/scala/com/digitalasset/daml/lf/archive/testing/DamlLfEncoder.scala
2021-07-22 10:50:11 +00:00
nickchapman-da
0e09f3ba08
Remove optLocation field from transaction nodes. (#10301)
* Remove Optional[Location] field from transaction nodes.

xoptLocation

working but very messy!

cleanup PartialTransaction code

pass locationInfo in CompleteTransaction

dont pass locationInfo in SumittedTransaction

pass optLocation to CheckAuthorization

temp reinstate xoptLocation in ExerciseContextInfo

cleanup Conversions.scala

remove Optional[Location] field from transaction nodes.

CHANGELOG_BEGIN
CHANGELOG_END

* fix bad merge

* fix build after merge

* rename

* doc comment, and question
2021-07-19 13:03:30 +00:00
Remy
6e8ec1d618
LF: Drop old depreated code (#10251)
CHANGELOG_BEGIN
CHANGELOG_END
2021-07-13 13:10:00 +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
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
Miklos
f5c84a2aa4
Daml-LF: Damlification of Scala/Haskell files (#9666)
CHANGELOG_BEGIN
CHANGELOG_END
2021-05-20 09:52:33 +02: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
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
Remy
fcece8b7e8
LF ValueGenerators: fix transaction version generator (#9552)
CHANGELOG_BEGIN
CHANGELOG_END
2021-05-04 09:13:20 +02: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
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
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
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
a93a9981c6
Add tests for blinding info (#9431)
changelog_begin
changelog_end
2021-04-16 18:30:59 +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
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
nickchapman-da
288a6cad9f
Implement structural cases for NodeRollback (#9212)
* Implement match-handling for `NodeRollback` in _structural cases_

where what the code has to do is in some sense _obvious_.

changelog_begin
changelog_end

* do cases in daml-lf/interpreter

* do cases in daml-lf/engine

* fix spello in comment

* drop Rollback nodes when normalizing for KV

* reinstate one 8020 todo

* more 8020 TODOs
2021-03-25 09:37:54 +00:00
nickchapman-da
c1cf2756a8
add rollback node to transactions (#9178)
* New transaction node: NodeRollback. Fixup every match with a crash + TODO.

changelog_begin
changelog_end

* remove 3 methods from NodeRollback which are not needed to fulfill its interface

* add override to remaining 4 methods implemented in body of NodeRollback

* remove unrequired 2nd type parameter (Cid) from NodeRollback

* add missing 8020 marker
2021-03-23 08:49:25 +00:00
nickchapman-da
9b2158508b
Add new variant to Value.scala for builtin-exceptions. (#9084)
* Add new variant to Value.scala for builtin-exceptions.

final case class ValueBuiltinException[+Cid](tag: String, value: Value[Cid]) extends Value[Cid]

And push through the code consequences.
Most places fixed up.
A couple more things to do in this PR (marked NICK)
A couple of things which can be left for later (marked 8020)

fix build

fix another scala match

changelog_begin
changelog_end

* fix any match

* add marker of code which needs attending to in the PR

* extend ledger-api value.proto & fix LfEngineToApi

* undo/comment-out the change to value.proto

* add tests in HashSpec for BuiltinException

* code but dont yet enable value-gen for builtin exceptions

* address comments which suggest we crash in various places

* support BuiltinException in scenario_service.proto

* one more TODO 8020 tag
2021-03-16 13:15:33 +00:00
Remy
6e65b9b038
LF: move value normalizer to transaction module. (#9072)
Like that people can use it outside test.

CHANGELOG_BEGIN
CHANGELOG_END
2021-03-11 13:30:53 +01:00
Remy
ef8264408f
LF: do not serialized type and field in transaction values. (#8062)
CHANGELOG_BEGIN
CHANGELOG_END
2021-01-27 15:45:10 +01:00
Remy
0757f2e7eb
LF: remove versionning of the individual values in transaction proto. (#8519)
We now use directly the version from the node.

CHANGELOG_BEGIN
CHANGELOG_END
2021-01-22 17:32:31 +01:00
Remy
441f503a95
LF: Flatten ContractInstance inside NodeCreate (#8526)
The ContractInstance is a concept a bit off. For instance it is not
clear why `agreementText` is more important for a contract that the
signatories, the stackholder or the key. In this PR, we get ride of
the ContractInstance inside LF code, except from the Engine/Ledger API
(com.daml.lf.engine.ResultNeedContract$)

CHANGELOG_BEGIN
CHANGELOG_END
2021-01-18 17:29:32 +01:00
Remy
dc5b22976f
LF: fix Transaction Decoder/Encoder (#8512)
This includes the following changes:

1.  The Decoder was not verifying the value inside a node use the exact
    same version as the node itself.

2.  We use the node version directly in the node encoder (instead of
    used versionedX node methods).

3.  We avoid used of .asJava in the encoder.

4.  We add test for testing the decode verify 1.

CHANGELOG_BEGIN
CHANGELOG_END
2021-01-15 11:44:05 +01:00
Remy
77bec01db3
LF: provide methods to enrich LF values missing type and field names (#8493)
CHANGELOG_BEGIN
CHANGELOG_END
2021-01-13 19:02:51 +01:00
Moritz Kiefer
22ce940954
Upgrade scalafmt and enable trailing commas (#8437)
This PR updates scalafmt and enables trailingCommas =
multiple. Unfortunately, scalafmt broke the version field which means
we cannot fully preserve the rest of the config. I’ve made some
attempts to stay reasonably close to the original config but couldn’t
find an exact equivalent in a lot of cases. I don’t feel strongly
about any of the settings so happy to change them to something else.

As announced, this will be merged on Saturday to avoid too many conflicts.

changelog_begin
changelog_end
2021-01-09 11:37:37 +01:00
Moritz Kiefer
0549d07bdc
Port //daml-lf/interpreter to Scala 2.13 (#8421)
* Port //daml-lf/interpreter to Scala 2.13

For now the perf tests are left out since they depend on a DAR built
by damlc which depends on daml script which depends on the world
:exploding-head:

changelog_begin
changelog_end

* Scala 2.13-style to for ImmArray and FrontStack

changelog_begin
changelog_end

* Avoid extra conversion

changelog_begin
changelog_end
2021-01-07 10:13:08 +00:00
Moritz Kiefer
b324fc4551
Port //daml-lf/(transaction|language) to Scala 2.13 (#8343)
changelog_begin
changelog_end
2021-01-04 10:54:38 +01:00
Gary Verhaegen
a925f0174c
update copyright notices for 2021 (#8257)
* update copyright notices for 2021

To be merged on 2021-01-01.

CHANGELOG_BEGIN
CHANGELOG_END

* patch-bazel-windows & da-ghc-lib
2021-01-01 19:49:51 +01:00
Remy
649f740efd
LF: retire ValueVersion (#8303)
use TransactionVersion instead.

This is part of #7788

CHANGELOG_BEGIN
CHANGELOG_END
2020-12-17 17:35:43 +01:00
Remy
fe44764e61
LF: Refactor TransactionVersion (#8299)
Simplify transaction version. In particular we drop the dependency to LfVersions abstract class.

CHANGELOG_BEGIN
CHANGELOG_END
2020-12-16 11:27:54 +01:00
Remy
9bc2e4bd2c
LF: fix some of the choice-observer FIXMEs (#8281)
CHANGELOG_BEGIN
CHANGELOG_END
2020-12-14 18:26:49 +01:00
Remy
7d31135645
LF: retire VersionTimeline (#8273)
CHANGELOG_BEGIN
CHANGELOG_END
2020-12-14 16:56:47 +01:00
Moritz Kiefer
76b6fd86fb
Upgrade Scala dependencies for 2.13 compatibility (#8268)
* Upgrade Scala dependencies for 2.13 compatibility

This upgrades a bunch of Scala libraries to versions that have 2.13
support. There are two libraries that are still missing:

- diffson, this has a new version but with significant breaking
  changes and it is only used in Naigator console which I hope to kill
  before I have to worry about this.

- ai.x:diff, this is used in the ledger API test tool. The library is
  abondened but there are a few alternatives.

changelog_begin
changelog_end

* Fix pureconfig

changelog_begin
changelog_end

* Fix Navigator

changelog_begin
changelog_end
2020-12-14 09:59:00 +01:00
Remy
44c5b8a777
LF: remove version from value nested in GenNode. (#8217)
CHANGELOG_BEGIN
CHANGELOG_END
2020-12-11 17:12:14 +01:00
Remy
8f3c6a4494
LF: Add version directly in GenNode (#8154)
CHANGELOG_BEGIN
CHANGELOG_END
2020-12-08 16:12:12 +01:00
Samir Talwar
5943e1ae8d
daml-lf: Simplify types in the TransactionBuilder test helper. (#8178)
CHANGELOG_BEGIN
CHANGELOG_END
2020-12-07 09:46:24 +00:00
Remy
68c92b479c
LF: version transaction node independently in proto (#7925)
This advances the state of #7788.

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-24 14:07:33 +01:00
Remy
732c1ac792
LF: Make node validation taking into account version (#7947)
We introduce in #7835 VersionedNode which associate to each node a
version. In this PR, we update Transaction validation to take into
account this version when comparing nodes.

This advances the state of #7788

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-13 10:46:29 +01:00
Remy
51d134f925
LF: fix complexity of TransactionBuilder#addNode (#7930)
Fix issue with slowSnoc underlines by Martin in #7835

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-11 12:57:59 +01:00
Remy
a8902a75db
LF: version transaction node independently (#7835)
This PR prepares the change of inference algorithm described #7788
where each node is version independently. This PR associates to each
node of `VersionedTransaction` a version. In the current state, all
nodes are associated to the version of the transaction itself. The
inference algorithm (that will make those versions potentially
distinct) will be implemented in an upcoming PR.

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-10 12:12:16 +01:00
Remy
37eb1d4c4c
LF: Kill deprecated Transaction version. (#7785)
This PR drops support for Transaction version 1 to 9. This is a
breaking change that may affect only ledger created with a pre SDK
1.0.0. No Sandbox-based ledger is affected by this change.

This advances the state of #7788

This breaking change was approved by the architecture committed.

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-04 15:45:42 +01:00
Remy
93a098612e
LF: add TransactionCoder test for choiceObservers (#7795)
advances the state of #7709.

CHANGELOG_BEGIN
CHANGELOG_END
2020-10-26 09:42:46 +01:00