Skip to content

Commit

Permalink
daml-lf: freeze daml-lf 1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
remyhaemmerle-da committed Nov 5, 2019
1 parent 0a2641b commit c2c8b0e
Show file tree
Hide file tree
Showing 13 changed files with 172 additions and 178 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -76,28 +76,26 @@ class DecodeV1Spec
List(1, 4, 6).map(i => LV.Minor.Stable(i.toString)): _*
)

// FixMe: https://github.com/digital-asset/daml/issues/2289
// add stable version when numerics are released
private val postNumericMinVersions = Table(
"minVersion",
LV.Minor.Stable("7"),
LV.Minor.Dev
)

private val preAnyTypeVersions = Table(
"minVersion",
List(1, 4, 6).map(i => LV.Minor.Stable(i.toString)): _*
List("1", "4", "6").map(LV.Minor.Stable): _*
)

// FixMe: https://github.com/digital-asset/daml/issues/2876
// add stable version when Any is released
private val postAnyTypeVersions = Table(
"minVersion",
LV.Minor.Dev
LV.Minor.Stable("7"),
LV.Minor.Dev,
)

"decodeKind" should {

"reject nat kind if lf version < 1.dev" in {
"reject nat kind if lf version < 1.7" in {

val input = DamlLf1.Kind.newBuilder().setNat(DamlLf1.Unit.newBuilder()).build()

Expand All @@ -106,7 +104,7 @@ class DecodeV1Spec
}
}

"accept nat kind if lf version >= 1.dev" in {
"accept nat kind if lf version >= 1.7" in {
val input = DamlLf1.Kind.newBuilder().setNat(DamlLf1.Unit.newBuilder()).build()

forEvery(postNumericMinVersions) { minVersion =>
Expand All @@ -124,7 +122,7 @@ class DecodeV1Spec
val validNatTypes = List(0, 1, 2, 5, 11, 35, 36, 37)
val invalidNatTypes = List(Long.MinValue, -100, -2, -1, 38, 39, 200, Long.MaxValue)

"reject nat type if lf version < 1.dev" in {
"reject nat type if lf version < 1.7" in {

val testCases =
Table("proto nat type", (validNatTypes.map(_.toLong) ++ invalidNatTypes).map(buildNat): _*)
Expand All @@ -137,7 +135,7 @@ class DecodeV1Spec
}
}

"accept only valid nat types if lf version >= 1.dev" in {
"accept only valid nat types if lf version >= 1.7" in {
val positiveTestCases =
Table("proto nat type" -> "nat", validNatTypes.map(v => buildNat(v.toLong) -> v): _*)
val negativeTestCases = Table("proto nat type", invalidNatTypes.map(buildNat): _*)
Expand Down Expand Up @@ -190,7 +188,7 @@ class DecodeV1Spec
}
}

"reject Numeric types if version < 1.dev" in {
"reject Numeric types if version < 1.7" in {
forEvery(preNumericMinVersions) { version =>
val decoder = moduleDecoder(version)
forEvery(numericTestCases) { (input, _) =>
Expand All @@ -199,7 +197,7 @@ class DecodeV1Spec
}
}

"translate TNumeric as is if version >= 1.dev" in {
"translate TNumeric as is if version >= 1.7" in {
forEvery(postNumericMinVersions) { minVersion =>
val decoder = moduleDecoder(minVersion)
forEvery(numericTestCases) { (input, expectedOutput) =>
Expand All @@ -208,7 +206,7 @@ class DecodeV1Spec
}
}

"reject Decimal types if version >= 1.dev" in {
"reject Decimal types if version >= 1.7" in {
forEvery(postNumericMinVersions) { version =>
val decoder = moduleDecoder(version)
forEvery(decimalTestCases) { (input, _) =>
Expand All @@ -217,14 +215,14 @@ class DecodeV1Spec
}
}

"reject Any if version < 1.dev" in {
"reject Any if version < 1.7" in {
forEvery(preAnyTypeVersions) { version =>
val decoder = moduleDecoder(version)
a[ParseError] shouldBe thrownBy(decoder.decodeType(buildPrimType(ANY)))
}
}

"accept Any if version >= 1.dev" in {
"accept Any if version >= 1.7" in {
forEvery(postAnyTypeVersions) { minVersion =>
val decoder = moduleDecoder(minVersion)
decoder.decodeType(buildPrimType(ANY)) shouldBe TAny
Expand Down Expand Up @@ -349,7 +347,7 @@ class DecodeV1Spec
}
}

"transparently apply TNat(10) to Decimal builtins if version < 1.dev" in {
"transparently apply TNat(10) to Decimal builtins if version < 1.7" in {

forEvery(preNumericMinVersions) { version =>
val decoder = moduleDecoder(version)
Expand All @@ -361,7 +359,7 @@ class DecodeV1Spec
}
}

"reject Numeric builtins if version < 1.dev" in {
"reject Numeric builtins if version < 1.7" in {

forEvery(preNumericMinVersions) { version =>
val decoder = moduleDecoder(version)
Expand All @@ -372,7 +370,7 @@ class DecodeV1Spec
}
}

"translate Numeric builtins as is if version >= 1.dev" in {
"translate Numeric builtins as is if version >= 1.7" in {

forEvery(postNumericMinVersions) { version =>
val decoder = moduleDecoder(version)
Expand All @@ -383,7 +381,7 @@ class DecodeV1Spec
}
}

"reject Decimal builtins if version >= 1.dev" in {
"reject Decimal builtins if version >= 1.7" in {

forEvery(postNumericMinVersions) { version =>
val decoder = moduleDecoder(version)
Expand Down Expand Up @@ -443,7 +441,7 @@ class DecodeV1Spec
}
}

"reject numeric literal if version < 1.dev" in {
"reject numeric literal if version < 1.7" in {

val decoder = moduleDecoder(LV.Features.numeric.minor, ImmArraySeq("0.0"))
decoder.decodeExpr(toNumericProto(0), "test")
Expand Down
3 changes: 2 additions & 1 deletion daml-lf/encoder/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ lf_targets = [
"1.1",
"1.3",
"1.6",
"1.7",
"1.dev",
]

lf_latest = "1.6"
lf_latest = "1.7"

da_scala_library(
name = "encoder",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ class DamlLfEncoderTest

val modules_1_1 = modules_1_0 + "Option"
val modules_1_3 = modules_1_1 + "Map"
val modules_1_dev = modules_1_3 + "Enum"
val module_1_7 = modules_1_3 + "Enum"
val modules_1_dev = module_1_7

val versions = Table(
"versions" -> "modues",
"1.0" -> modules_1_0,
"1.1" -> modules_1_1,
"1.3" -> modules_1_3,
"1.7" -> module_1_7,
"1.dev" -> modules_1_dev
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class EncodeV1Spec extends WordSpec with Matchers with TableDrivenPropertyChecks
val defaultParserParameters: ParserParameters[this.type] =
ParserParameters(
pkgId,
LanguageVersion(V1, "dev")
LanguageVersion(V1, "7")
)

"Encode and Decode" should {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class EngineInfoTest extends WordSpec with Matchers {
EngineInfo.getClass.getSimpleName should {
"show supported LF, Transaction and Value versions" in {
EngineInfo.show shouldBe
"DAML LF Engine supports LF versions: 0, 0.dev, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.dev; Transaction versions: 1, 2, 3, 4, 5, 6, 7, 8; Value versions: 1, 2, 3, 4, 5, 6"
"DAML LF Engine supports LF versions: 0, 0.dev, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.dev; Transaction versions: 1, 2, 3, 4, 5, 6, 7, 8; Value versions: 1, 2, 3, 4, 5, 6"
}

"toString returns the same value as show" in {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ object LanguageMajorVersion {
case object V1
extends LanguageMajorVersion(
pretty = "1",
stableAscending = NonEmptyList("0", "1", "2", "3", "4", "5", "6"))
stableAscending = NonEmptyList("0", "1", "2", "3", "4", "5", "6", "7"))

val All: List[LanguageMajorVersion] = List(V0, V1)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ final case class LanguageVersion(major: LanguageMajorVersion, minor: LanguageMin
}

object LanguageVersion {

type Major = LanguageMajorVersion
val Major = LanguageMajorVersion

Expand Down Expand Up @@ -37,13 +38,9 @@ object LanguageVersion {
}
object Features {

private val List(v1_0, v1_1, v1_2, v1_3, v1_4, v1_5, v1_6, v1_dev) =
private val List(v1_0, v1_1, v1_2, v1_3, v1_4, v1_5, v1_6, v1_7, v1_dev) =
Major.V1.supportedMinorVersions.map(LanguageVersion(Major.V1, _))

// FIXME https://github.com/digital-asset/daml/issues/2289
// Change the following line LF 1.7 freeze
val v1_7 = v1_dev

val default = v1_0
val arrowType = v1_1
val optional = v1_1
Expand Down
68 changes: 32 additions & 36 deletions daml-lf/spec/daml-lf-1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,8 @@ Version: 1.6

* **Add** package IDs interning in external package references.

Version: 1.dev
..............

* **Change** Transaction submitter must be in the contract key
maintainers when performing lookup or fetches by key. See
`issue #1866 <https://github.com/digital-asset/daml/issues/1866>`_
Version: 1.7
............

* **Add** Nat kind and Nat type.

Expand All @@ -247,6 +243,13 @@ Version: 1.dev

* **Add** ``type_rep``, a value presenting a type.

Version: 1.dev
..............

* **Change** Transaction submitter must be in the contract key
maintainers when performing lookup or fetches by key. See
`issue #1866 <https://github.com/digital-asset/daml/issues/1866>`_

Abstract syntax
^^^^^^^^^^^^^^^

Expand Down Expand Up @@ -627,10 +630,6 @@ In the following, we will use ``τ₁ → τ₂`` as syntactic sugar for the
type application ``('TArrow' τ₁ τ₂)`` where ``τ₁`` and ``τ₂`` are
types.

*Note that the type* ``'Option'`` *together with the
constructors/patterns* ``'None'`` *and* ``'Some'`` *are available
since version 1.1*.


Definitions
~~~~~~~~~~~
Expand Down Expand Up @@ -2078,9 +2077,9 @@ straightforward way by following the left-to-right evaluation order.
Built-in functions
^^^^^^^^^^^^^^^^^^

This section lists the built-in functions supported by DAML 1.1 or
earlier. The functions come with their types and a description of
their behavior.
This section lists the built-in functions supported by DAML LF 1.
The functions come with their types and a description of their
behavior.


Boolean functions
Expand Down Expand Up @@ -2571,7 +2570,7 @@ Type Representation function
Returns ``'True'`` if the first type representation is syntactically equal to
the second one, ``'False'`` otherwise.

[*Available in versions >= 1.dev*]
[*Available in versions >= 1.7*]

Conversions functions
~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -2932,20 +2931,20 @@ Starting from DAML-LF 1.6, the field
1.6*] may be used instead of ``PackageRef.package_id_str`` and it
must be a valid *interned packageId*.

Starting from DAML-LF 1.dev, all ``string`` (or ``repeated string``)
Starting from DAML-LF 1.7, all ``string`` (or ``repeated string``)
fields with the suffix ``_str`` are forbidden. Alternative fields of
type ``int32`` (or ``repeated int32``) with the suffix
``_interned_str`` must be used instead. Except
``PackageRef.package_id_interned_str`` which is [*Available in
versions >= 1.6*], all fields with suffix ``_interned_str`` are
[*Available in versions >= 1.dev*]. The deserialization process will
reject any DAML-LF 1.dev (or later) that does not comply with this
[*Available in versions >= 1.7*]. The deserialization process will
reject any DAML-LF 1.7 (or later) that does not comply with this
restriction.

Name Interning
..............

[*Available in versions >= 1.dev*]
[*Available in versions >= 1.7*]

To provide sharing of `names <Identifiers_>`_, the so-called *name
interning* mechanism allows the *names* within messages to be stored
Expand All @@ -2959,22 +2958,22 @@ so-called `interned name` is a valid zero-based index of this list. An
`interned name` is interpreted as the name built form the `name` it
points to in ``Package.interned_dotted_names``.

Starting from DAML-LF 1.dev, all ``DottedName`` (or ``repeated
Starting from DAML-LF 1.7, all ``DottedName`` (or ``repeated
string``) fields with the suffix ``_dname`` are forbidden. Alternative
fields of type ``int32`` with the suffix ``_interned_dname``
[*Available in versions >= 1.dev*] must be used instead. The
deserialization process will reject any DAML-LF 1.dev (or later) that
[*Available in versions >= 1.7*] must be used instead. The
deserialization process will reject any DAML-LF 1.7 (or later) that
that does not comply this restriction.

Nat kind and Nat types
......................

[*Available in versions >= 1.dev*]
[*Available in versions >= 1.7*]

The deserialization process will reject any DAML-LF 1.6 (or earlier)
that uses ``nat`` field in ``Kind`` or ``Type`` messages.

Starting from DAML-LF 1.dev those messages are deserialized to ``nat``
Starting from DAML-LF 1.7 those messages are deserialized to ``nat``
kind and ``nat`` type respectively. The field ``nat`` of ``Type``
message must be a positive integer.

Expand All @@ -2986,9 +2985,9 @@ section.
Parametric scaled Decimals
..........................

[*Available in versions >= 1.dev*]
[*Available in versions >= 1.7*]

DAML-LF 1.dev is the first version that supports parametric scaled
DAML-LF 1.7 is the first version that supports parametric scaled
decimals. Prior versions have decimal number with a fixed scale of 10
called Decimal. Backward compatibility with the current specification
is achieved as follows:
Expand Down Expand Up @@ -3032,7 +3031,7 @@ On the one hand, in case of DAML-LF 1.6 (or earlier) archive:
deserialization process will reject any DAML-LF 1.6 (or earlier)
that does not comply those restrictions.

On the other hand, starting from DAML-LF 1.dev:
On the other hand, starting from DAML-LF 1.7:

- The ``numeric`` field of the ``PrimLit`` message must match the
regexp:
Expand All @@ -3049,20 +3048,17 @@ On the other hand, starting from DAML-LF 1.dev:
In other words ``decimal`` fields in ``PrimLit`` and ``PrimType``
messages must remain unset and Decimal ``BuiltinFunction`` (those
containing ``DECIMAL`` in their name are forbidden). The
deserialization process will reject any DAML-LF 1.dev (or later)
deserialization process will reject any DAML-LF 1.7 (or later)
that does not comply those restrictions.

Any template
............

[*Available in versions >= 1.dev*]
Any type and type representation
................................

This is an experimental feature used in DAML Triggers.
More details will be provided in a near future.
DAML-LF 1.7 is the first version that supports any type and
type representation.

The curious reader can temporarily refer to the following PRs for more details:
* https://github.com/digital-asset/daml/issues/2876
* https://github.com/digital-asset/daml/issues/3072
The deserialization process will reject any DAML-LF 1.0 program using
this data structure.



Expand Down
Loading

0 comments on commit c2c8b0e

Please sign in to comment.