default to LF2 in the engine (#18320)

* default to LF2

* fix DamlLfEncoderTest.scala

* fix EngineInfoTest

* fix //daml-lf/encoder:validate-dar-2.1

* remove unused features and obsolete comment
This commit is contained in:
Paul Brauner 2024-01-30 17:22:05 +01:00 committed by GitHub
parent bfa94a40b7
commit f6b49fd430
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
21 changed files with 59 additions and 508 deletions

View File

@ -1,127 +0,0 @@
// Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
module BuiltinMod {
val addNumeric: forall (a: nat). Numeric a -> Numeric a -> Numeric a =
ADD_NUMERIC;
val subNumeric: forall (a: nat). Numeric a -> Numeric a -> Numeric a =
SUB_NUMERIC;
val mulNumericLegacy: forall (a: nat) (b: nat) (g: nat). Numeric a -> Numeric b -> Numeric g =
MUL_NUMERIC_LEGACY;
val divNumericLegacy: forall (a: nat) (b: nat) (g: nat). Numeric a -> Numeric b -> Numeric g =
DIV_NUMERIC_LEGACY;
val roundNumeric: forall (a: nat). Int64 -> Numeric a -> Numeric a =
ROUND_NUMERIC;
val castNumericLegacy: forall (a: nat) (b: nat). Numeric a -> Numeric b =
CAST_NUMERIC_LEGACY;
val shiftNumericLegacy: forall (a: nat) (b: nat). Numeric a -> Numeric b =
SHIFT_NUMERIC_LEGACY;
val addInt64: Int64 -> Int64 -> Int64 =
ADD_INT64;
val subInt64: Int64 -> Int64 -> Int64 =
SUB_INT64;
val mulInt64: Int64 -> Int64 -> Int64 =
MUL_INT64;
val divInt64: Int64 -> Int64 -> Int64 =
DIV_INT64;
val modInt64: Int64 -> Int64 -> Int64 =
MOD_INT64;
val expInt64: Int64 -> Int64 -> Int64 =
EXP_INT64;
val int64ToNumericLegacy: forall (a: nat). Int64 -> Numeric a =
INT64_TO_NUMERIC_LEGACY;
val numericToInt64: forall (a: nat). Numeric a -> Int64 =
NUMERIC_TO_INT64;
val foldl: forall (a: *) (b: *). (b -> a -> b) -> b -> List a -> b =
FOLDL;
val foldr: forall (a: *) (b: *). (a -> b -> b) -> b -> List a -> b =
FOLDR;
val textmapEmpty: forall (a: *). TextMap a =
TEXTMAP_EMPTY;
val textmapInsert: forall (a: *). Text -> a -> TextMap a -> TextMap a =
TEXTMAP_INSERT;
val textmapLookup: forall (a: *). Text -> TextMap a -> Option a =
TEXTMAP_LOOKUP;
val textmapDelete: forall (a: *). Text -> TextMap a -> TextMap a =
TEXTMAP_DELETE;
val textmapToList: forall (a: *). TextMap a -> List <key: Text, value: a> =
TEXTMAP_TO_LIST;
val textmapSize: forall (a: *). TextMap a -> Int64 =
TEXTMAP_SIZE;
val genmapEmpty: forall (a: *) (b: *). GenMap a b =
GENMAP_EMPTY;
val genmapInsert: forall (a: *) (b: *). a -> b -> GenMap a b -> GenMap a b =
GENMAP_INSERT;
val genmapLookup: forall (a: *) (b: *). a -> GenMap a b -> Option b =
GENMAP_LOOKUP;
val genmapDelete: forall (a: *) (b: *). a -> GenMap a b -> GenMap a b =
GENMAP_DELETE;
val genmapKeys: forall (a: *) (b: *). GenMap a b -> List a =
GENMAP_KEYS;
val genmapValues: forall (a: *) (b: *). GenMap a b -> List b =
GENMAP_VALUES;
val genmapSize: forall (a: *) (b: *). GenMap a b -> Int64 =
GENMAP_SIZE;
val appendText: Text -> Text -> Text =
APPEND_TEXT;
val error: forall (a: *). Text -> a =
ERROR;
val int64ToText: Int64 -> Text =
INT64_TO_TEXT;
val numericToText: forall (a: nat). Numeric a -> Text =
NUMERIC_TO_TEXT;
val timestampToText: Timestamp -> Text =
TIMESTAMP_TO_TEXT;
val partyToText: Party -> Text =
PARTY_TO_TEXT;
val textToText: Text -> Text =
TEXT_TO_TEXT;
val contractIdToText: forall (a: *). ContractId a -> Option Text =
CONTRACT_ID_TO_TEXT;
val partyToQuotedText: Party -> Text =
PARTY_TO_QUOTED_TEXT;
val codePointsToText: List Int64 -> Text =
CODE_POINTS_TO_TEXT;
val textToParty: Text -> Option Party =
TEXT_TO_PARTY;
val textToInt64: Text -> Option Int64 =
TEXT_TO_INT64;
val textToNumericLegacy: forall (a: nat). Text -> Option (Numeric a) =
TEXT_TO_NUMERIC_LEGACY;
val textToCodePoints: Text -> List Int64 =
TEXT_TO_CODE_POINTS;
val sha256Text: Text -> Text =
SHA256_TEXT;
val dateToUnixDays: Date -> Int64 =
DATE_TO_UNIX_DAYS;
val explodeText: Text -> List Text =
EXPLODE_TEXT;
val implodeText: List Text -> Text =
IMPLODE_TEXT;
val timestampToUnixMicroseconds: Timestamp -> Int64 =
TIMESTAMP_TO_UNIX_MICROSECONDS;
val dateToText: Date -> Text =
DATE_TO_TEXT;
val unixDaysToDate: Int64 -> Date =
UNIX_DAYS_TO_DATE;
val unixMicrosecondsToTimestamp: Int64 -> Timestamp =
UNIX_MICROSECONDS_TO_TIMESTAMP;
val equal: forall (a: *). a -> a -> Bool =
EQUAL;
val less: forall (a: *). a -> a -> Bool =
LESS;
val lessEq: forall (a: *). a -> a -> Bool =
LESS_EQ;
val greater: forall (a: *). a -> a -> Bool =
GREATER;
val greaterEq: forall (a: *). a -> a -> Bool =
GREATER_EQ;
val equalList: forall (a: *). (a -> a -> Bool) -> List a -> List a -> Bool =
EQUAL_LIST;
val trace: forall (a: *). Text -> a -> a =
TRACE;
val coerceContractId: forall (a: *) (b: *). ContractId a -> ContractId b =
COERCE_CONTRACT_ID;
}

View File

@ -1,147 +0,0 @@
// Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
module BuiltinMod {
val addNumeric: forall (a: nat). Numeric a -> Numeric a -> Numeric a =
ADD_NUMERIC;
val subNumeric: forall (a: nat). Numeric a -> Numeric a -> Numeric a =
SUB_NUMERIC;
val mulNumericLegacy: forall (a: nat) (b: nat) (g: nat). Numeric a -> Numeric b -> Numeric g =
MUL_NUMERIC_LEGACY;
val divNumericLegacy: forall (a: nat) (b: nat) (g: nat). Numeric a -> Numeric b -> Numeric g =
DIV_NUMERIC_LEGACY;
val roundNumeric: forall (a: nat). Int64 -> Numeric a -> Numeric a =
ROUND_NUMERIC;
val castNumericLegacy: forall (a: nat) (b: nat). Numeric a -> Numeric b =
CAST_NUMERIC_LEGACY;
val shiftNumericLegacy: forall (a: nat) (b: nat). Numeric a -> Numeric b =
SHIFT_NUMERIC_LEGACY;
val addInt64: Int64 -> Int64 -> Int64 =
ADD_INT64;
val subInt64: Int64 -> Int64 -> Int64 =
SUB_INT64;
val mulInt64: Int64 -> Int64 -> Int64 =
MUL_INT64;
val divInt64: Int64 -> Int64 -> Int64 =
DIV_INT64;
val modInt64: Int64 -> Int64 -> Int64 =
MOD_INT64;
val expInt64: Int64 -> Int64 -> Int64 =
EXP_INT64;
val int64ToNumericLegacy: forall (a: nat). Int64 -> Numeric a =
INT64_TO_NUMERIC_LEGACY;
val numericToInt64: forall (a: nat). Numeric a -> Int64 =
NUMERIC_TO_INT64;
val foldl: forall (a: *) (b: *). (b -> a -> b) -> b -> List a -> b =
FOLDL;
val foldr: forall (a: *) (b: *). (a -> b -> b) -> b -> List a -> b =
FOLDR;
val textmapEmpty: forall (a: *). TextMap a =
TEXTMAP_EMPTY;
val textmapInsert: forall (a: *). Text -> a -> TextMap a -> TextMap a =
TEXTMAP_INSERT;
val textmapLookup: forall (a: *). Text -> TextMap a -> Option a =
TEXTMAP_LOOKUP;
val textmapDelete: forall (a: *). Text -> TextMap a -> TextMap a =
TEXTMAP_DELETE;
val textmapToList: forall (a: *). TextMap a -> List <key: Text, value: a> =
TEXTMAP_TO_LIST;
val textmapSize: forall (a: *). TextMap a -> Int64 =
TEXTMAP_SIZE;
val genmapEmpty: forall (a: *) (b: *). GenMap a b =
GENMAP_EMPTY;
val genmapInsert: forall (a: *) (b: *). a -> b -> GenMap a b -> GenMap a b =
GENMAP_INSERT;
val genmapLookup: forall (a: *) (b: *). a -> GenMap a b -> Option b =
GENMAP_LOOKUP;
val genmapDelete: forall (a: *) (b: *). a -> GenMap a b -> GenMap a b =
GENMAP_DELETE;
val genmapKeys: forall (a: *) (b: *). GenMap a b -> List a =
GENMAP_KEYS;
val genmapValues: forall (a: *) (b: *). GenMap a b -> List b =
GENMAP_VALUES;
val genmapSize: forall (a: *) (b: *). GenMap a b -> Int64 =
GENMAP_SIZE;
val appendText: Text -> Text -> Text =
APPEND_TEXT;
val error: forall (a: *). Text -> a =
ERROR;
val int64ToText: Int64 -> Text =
INT64_TO_TEXT;
val numericToText: forall (a: nat). Numeric a -> Text =
NUMERIC_TO_TEXT;
val timestampToText: Timestamp -> Text =
TIMESTAMP_TO_TEXT;
val partyToText: Party -> Text =
PARTY_TO_TEXT;
val textToText: Text -> Text =
TEXT_TO_TEXT;
val contractIdToText: forall (a: *). ContractId a -> Option Text =
CONTRACT_ID_TO_TEXT;
val codePointsToText: List Int64 -> Text =
CODE_POINTS_TO_TEXT;
val textToParty: Text -> Option Party =
TEXT_TO_PARTY;
val textToInt64: Text -> Option Int64 =
TEXT_TO_INT64;
val textToNumericLegacy: forall (a: nat). Text -> Option (Numeric a) =
TEXT_TO_NUMERIC_LEGACY;
val textToCodePoints: Text -> List Int64 =
TEXT_TO_CODE_POINTS;
val sha256Text: Text -> Text =
SHA256_TEXT;
val dateToUnixDays: Date -> Int64 =
DATE_TO_UNIX_DAYS;
val explodeText: Text -> List Text =
EXPLODE_TEXT;
val implodeText: List Text -> Text =
IMPLODE_TEXT;
val timestampToUnixMicroseconds: Timestamp -> Int64 =
TIMESTAMP_TO_UNIX_MICROSECONDS;
val dateToText: Date -> Text =
DATE_TO_TEXT;
val unixDaysToDate: Int64 -> Date =
UNIX_DAYS_TO_DATE;
val unixMicrosecondsToTimestamp: Int64 -> Timestamp =
UNIX_MICROSECONDS_TO_TIMESTAMP;
val equal: forall (a: *). a -> a -> Bool =
EQUAL;
val less: forall (a: *). a -> a -> Bool =
LESS;
val lessEq: forall (a: *). a -> a -> Bool =
LESS_EQ;
val greater: forall (a: *). a -> a -> Bool =
GREATER;
val greaterEq: forall (a: *). a -> a -> Bool =
GREATER_EQ;
val equalList: forall (a: *). (a -> a -> Bool) -> List a -> List a -> Bool =
EQUAL_LIST;
val trace: forall (a: *). Text -> a -> a =
TRACE;
val coerceContractId: forall (a: *) (b: *). ContractId a -> ContractId b =
COERCE_CONTRACT_ID;
val partyToQuotedText: Party -> Text =
PARTY_TO_QUOTED_TEXT;
val scaleBignumeric: BigNumeric -> Int64 =
SCALE_BIGNUMERIC;
val precisionBignumeric: BigNumeric -> Int64 =
PRECISION_BIGNUMERIC;
val addBignumeric: BigNumeric -> BigNumeric -> BigNumeric =
ADD_BIGNUMERIC;
val subBignumeric: BigNumeric -> BigNumeric -> BigNumeric =
SUB_BIGNUMERIC;
val mulBignumeric: BigNumeric -> BigNumeric -> BigNumeric =
MUL_BIGNUMERIC;
val divBignumeric: Int64 -> RoundingMode -> BigNumeric -> BigNumeric -> BigNumeric =
DIV_BIGNUMERIC;
val shiftRightBignumeric: Int64 -> BigNumeric -> BigNumeric =
SHIFT_RIGHT_BIGNUMERIC;
val bignumericToNumericLegacy: forall (a: nat). BigNumeric -> Numeric a =
BIGNUMERIC_TO_NUMERIC_LEGACY;
val numericToBignumeric: forall (a: nat). Numeric a -> BigNumeric =
NUMERIC_TO_BIGNUMERIC;
val bignumericToText: BigNumeric -> Text =
BIGNUMERIC_TO_TEXT;
}

View File

@ -1,67 +0,0 @@
// Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
module BuiltinMod {
val equal_int64: Int64 -> Int64 -> Bool =
EQUAL @Int64;
val equal_decimal: (Numeric 10) -> (Numeric 10) -> Bool =
EQUAL @(Numeric 10);
val equal_text: Text -> Text -> Bool =
EQUAL @Text;
val equal_party: Party -> Party -> Bool =
EQUAL @Party;
val equal_timestamp: Timestamp -> Timestamp -> Bool =
EQUAL @Timestamp;
val equal_date: Date -> Date -> Bool =
EQUAL @Date;
val less_eq_int64: Int64 -> Int64 -> Bool =
LESS_EQ @Int64;
val less_eq_decimal: (Numeric 10) -> (Numeric 10) -> Bool =
LESS_EQ @(Numeric 10);
val less_eq_text: Text -> Text -> Bool =
LESS_EQ @Text;
val less_eq_timestamp: Timestamp -> Timestamp -> Bool =
LESS_EQ @Timestamp;
val less_eq_date: Date -> Date -> Bool =
LESS_EQ @Date;
val less_eq_party: Party -> Party -> Bool =
LESS_EQ @Party;
val less_int64: Int64 -> Int64 -> Bool =
LESS @Int64;
val less_decimal: (Numeric 10) -> (Numeric 10) -> Bool =
LESS @(Numeric 10);
val less_text: Text -> Text -> Bool =
LESS @Text;
val less_party: Party -> Party -> Bool =
LESS @Party;
val less_timestamp: Timestamp -> Timestamp -> Bool =
LESS @Timestamp;
val less_date: Date -> Date -> Bool =
LESS @Date;
val greater_eq_int64: Int64 -> Int64 -> Bool =
GREATER_EQ @Int64;
val greater_eq_decimal: (Numeric 10) -> (Numeric 10) -> Bool =
GREATER_EQ @(Numeric 10);
val greater_eq_text: Text -> Text -> Bool =
GREATER_EQ @Text;
val greater_eq_party: Party -> Party -> Bool =
GREATER_EQ @Party;
val greater_eq_timestamp: Timestamp -> Timestamp -> Bool =
GREATER_EQ @Timestamp;
val greater_eq_date: Date -> Date -> Bool =
GREATER_EQ @Date;
val greater_int64: Int64 -> Int64 -> Bool =
GREATER @Int64;
val greater_decimal: (Numeric 10) -> (Numeric 10) -> Bool =
GREATER @(Numeric 10);
val greater_text: Text -> Text -> Bool =
GREATER @Text;
val greater_party: Party -> Party -> Bool =
GREATER @Party;
val greater_timestamp: Timestamp -> Timestamp -> Bool =
GREATER @Timestamp;
val greater_date: Date -> Date -> Bool =
GREATER @Date;
}

View File

@ -1,67 +0,0 @@
// Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
module BuiltinMod {
val equal_int64: Int64 -> Int64 -> Bool =
EQUAL @Int64;
val equal_numeric: forall (n:nat). (Numeric n) -> (Numeric n) -> Bool =
EQUAL_NUMERIC;
val equal_text: Text -> Text -> Bool =
EQUAL @Text;
val equal_party: Party -> Party -> Bool =
EQUAL @Party;
val equal_timestamp: Timestamp -> Timestamp -> Bool =
EQUAL @Timestamp;
val equal_date: Date -> Date -> Bool =
EQUAL @Date;
val less_eq_int64: Int64 -> Int64 -> Bool =
LESS_EQ @Int64;
val less_eq_numeric: forall (n:nat). (Numeric n) -> (Numeric n) -> Bool =
LESS_EQ_NUMERIC;
val less_eq_text: Text -> Text -> Bool =
LESS_EQ @Text;
val less_eq_timestamp: Timestamp -> Timestamp -> Bool =
LESS_EQ @Timestamp;
val less_eq_date: Date -> Date -> Bool =
LESS_EQ @Date;
val less_eq_party: Party -> Party -> Bool =
LESS_EQ @Party;
val less_int64: Int64 -> Int64 -> Bool =
LESS @Int64;
val less_numeric: forall (n:nat). (Numeric n) -> (Numeric n) -> Bool =
LESS_NUMERIC;
val less_text: Text -> Text -> Bool =
LESS @Text;
val less_party: Party -> Party -> Bool =
LESS @Party;
val less_timestamp: Timestamp -> Timestamp -> Bool =
LESS @Timestamp;
val less_date: Date -> Date -> Bool =
LESS @Date;
val greater_eq_int64: Int64 -> Int64 -> Bool =
GREATER_EQ @Int64;
val greater_eq_numeric: forall (n:nat). (Numeric n) -> (Numeric n) -> Bool =
GREATER_EQ_NUMERIC;
val greater_eq_text: Text -> Text -> Bool =
GREATER_EQ @Text;
val greater_eq_party: Party -> Party -> Bool =
GREATER_EQ @Party;
val greater_eq_timestamp: Timestamp -> Timestamp -> Bool =
GREATER_EQ @Timestamp;
val greater_eq_date: Date -> Date -> Bool =
GREATER_EQ @Date;
val greater_int64: Int64 -> Int64 -> Bool =
GREATER @Int64;
val greater_numeric: forall (n:nat). (Numeric n) -> (Numeric n) -> Bool =
GREATER_NUMERIC;
val greater_text: Text -> Text -> Bool =
GREATER @Text;
val greater_party: Party -> Party -> Bool =
GREATER @Party;
val greater_timestamp: Timestamp -> Timestamp -> Bool =
GREATER @Timestamp;
val greater_date: Date -> Date -> Bool =
GREATER @Date;
}

View File

@ -9,14 +9,22 @@ module BuiltinMod {
SUB_NUMERIC;
val mulNumericLegacy: forall (a: nat) (b: nat) (g: nat). Numeric a -> Numeric b -> Numeric g =
MUL_NUMERIC_LEGACY;
val mulNumeric: forall (a: nat) (b: nat) (g: nat). Numeric g -> Numeric a -> Numeric b -> Numeric g =
MUL_NUMERIC;
val divNumericLegacy: forall (a: nat) (b: nat) (g: nat). Numeric a -> Numeric b -> Numeric g =
DIV_NUMERIC_LEGACY;
val divNumeric: forall (a: nat) (b: nat) (g: nat). Numeric g -> Numeric a -> Numeric b -> Numeric g =
DIV_NUMERIC;
val roundNumeric: forall (a: nat). Int64 -> Numeric a -> Numeric a =
ROUND_NUMERIC;
val castNumericLegacy: forall (a: nat) (b: nat). Numeric a -> Numeric b =
CAST_NUMERIC_LEGACY;
val castNumeric: forall (a: nat) (b: nat). Numeric b -> Numeric a -> Numeric b =
CAST_NUMERIC;
val shiftNumericLegacy: forall (a: nat) (b: nat). Numeric a -> Numeric b =
SHIFT_NUMERIC_LEGACY;
val shiftNumeric: forall (a: nat) (b: nat). Numeric b -> Numeric a -> Numeric b =
SHIFT_NUMERIC;
val addInt64: Int64 -> Int64 -> Int64 =
ADD_INT64;
val subInt64: Int64 -> Int64 -> Int64 =
@ -31,6 +39,8 @@ module BuiltinMod {
EXP_INT64;
val int64ToNumericLegacy: forall (a: nat). Int64 -> Numeric a =
INT64_TO_NUMERIC_LEGACY;
val int64ToNumeric: forall (a: nat). Numeric a -> Int64 -> Numeric a =
INT64_TO_NUMERIC;
val numericToInt64: forall (a: nat). Numeric a -> Int64 =
NUMERIC_TO_INT64;
val foldl: forall (a: *) (b: *). (b -> a -> b) -> b -> List a -> b =
@ -87,6 +97,8 @@ module BuiltinMod {
TEXT_TO_INT64;
val textToNumericLegacy: forall (a: nat). Text -> Option (Numeric a) =
TEXT_TO_NUMERIC_LEGACY;
val textToNumeric: forall (a: nat). Numeric a -> Text -> Option (Numeric a) =
TEXT_TO_NUMERIC;
val textToCodePoints: Text -> List Int64 =
TEXT_TO_CODE_POINTS;
val sha256Text: Text -> Text =
@ -137,11 +149,12 @@ module BuiltinMod {
SHIFT_RIGHT_BIGNUMERIC;
val bignumericToNumericLegacy: forall (a: nat). BigNumeric -> Numeric a =
BIGNUMERIC_TO_NUMERIC_LEGACY;
val bignumericToNumeric: forall (a: nat). Numeric a -> BigNumeric -> Numeric a =
BIGNUMERIC_TO_NUMERIC;
val numericToBignumeric: forall (a: nat). Numeric a -> BigNumeric =
NUMERIC_TO_BIGNUMERIC;
val bignumericToText: BigNumeric -> Text =
BIGNUMERIC_TO_TEXT;
val anyExceptionMessage: AnyException -> Text =
ANY_EXCEPTION_MESSAGE;
}

View File

@ -1,21 +0,0 @@
// Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
module TemplateMod {
record @serializable Person = { person: Party, name: Text } ;
template (this : Person) = {
precondition True;
signatories Cons @Party [TemplateMod:Person {person} this] (Nil @Party);
observers (Nil @Party);
choice Sleep (self) (u: Unit) : ContractId TemplateMod:Person
, controllers Cons @Party [TemplateMod:Person {person} this] (Nil @Party)
to upure @(ContractId TemplateMod:Person) self;
choice @nonConsuming Nap (self) (i : Int64) : Int64
, controllers Cons @Party [TemplateMod:Person {person} this] (Nil @Party)
to upure @Int64 i;
} ;
}

View File

@ -5,7 +5,7 @@ package com.daml.lf.testing.archive
import java.io.File
import com.daml.bazeltools.BazelRunfiles
import com.daml.daml_lf_dev.{DamlLf1, DamlLf2}
import com.daml.daml_lf_dev.DamlLf2
import com.daml.lf.archive.{
ArchivePayload,
Dar,
@ -61,9 +61,10 @@ class DamlLfEncoderTest
"ExceptionMod",
"InterfaceMod",
"InterfaceMod0",
"InterfaceExtMod",
)
val modules_2_dev = modules_2_1
val modules_2_dev = modules_2_1 ++ Set[DottedName](
"InterfaceExtMod"
)
val versions = Table(
"versions" -> "modules",
@ -93,35 +94,12 @@ class DamlLfEncoderTest
payload <- dar.all
ArchivePayload(_, pkg, version) = payload
name <- version match {
case LanguageVersion(Major.V1, _) => getNonEmptyModules(version, pkg.getDamlLf1)
case LanguageVersion(Major.V2, _) => getNonEmptyModules(pkg.getDamlLf2)
case _ => throw new RuntimeException(s"Unsupported language version: $version")
}
} yield name
}
private def getNonEmptyModules(
version: LanguageVersion,
pkg: DamlLf1.Package,
): Seq[ModuleName] = {
val internedStrings = pkg.getInternedStringsList.asScala.toArray
val dottedNames = pkg.getInternedDottedNamesList.asScala.map(
_.getSegmentsInternedStrList.asScala.map(internedStrings(_))
)
for {
segments <- pkg.getModulesList.asScala.toSeq.map {
case mod
if mod.getSynonymsCount != 0 ||
mod.getDataTypesCount != 0 ||
mod.getValuesCount != 0 ||
mod.getTemplatesCount != 0 =>
if (version < LanguageVersion.Features.internedStrings)
mod.getNameDname.getSegmentsList.asScala
else
dottedNames(mod.getNameInternedDname)
}
} yield DottedName.assertFromSegments(segments)
}
private def getNonEmptyModules(pkg: DamlLf2.Package): Seq[DottedName] = {
val internedStrings = pkg.getInternedStringsList.asScala.toArray
val dottedNames = pkg.getInternedDottedNamesList.asScala.map(
@ -145,7 +123,6 @@ class DamlLfEncoderTest
"contains all builtins " in {
forEvery(Table("version", LanguageVersion.All.filter(LanguageVersion.v2_1 <= _): _*)) {
// We do not check package older that 1.11 as they are used for stable packages only
version =>
val Right(dar) =
UniversalArchiveDecoder

View File

@ -15,30 +15,25 @@ class EngineInfoTest extends AnyWordSpec with Matchers {
engineInfoLegacy,
engineInfoStable,
engineEarlyAccess,
engineInfoV1Dev,
engineInfoV2,
) =
List(
LanguageVersion.LegacyVersions,
LanguageVersion.StableVersions,
LanguageVersion.EarlyAccessVersions,
LanguageVersion.AllVersions(LanguageMajorVersion.V1),
LanguageVersion.AllVersions(LanguageMajorVersion.V2),
).map(versions => new EngineInfo(EngineConfig(allowedLanguageVersions = versions)))
"show supported LF, Transaction and Value versions" in {
engineInfoLegacy.show shouldBe
"Daml-LF Engine supports LF versions: 1.6, 1.7, 1.8"
"Daml-LF Engine supports LF versions: 1.6, 1.7, 1.8, 1.11, 1.12, 1.13, 1.14, 1.15"
engineInfoStable.show shouldBe
"Daml-LF Engine supports LF versions: 1.6, 1.7, 1.8, 1.11, 1.12, 1.13, 1.14, 1.15"
"Daml-LF Engine supports LF versions: 2.1"
engineEarlyAccess.show shouldBe
"Daml-LF Engine supports LF versions: 1.6, 1.7, 1.8, 1.11, 1.12, 1.13, 1.14, 1.15"
engineInfoV1Dev.show shouldBe
"Daml-LF Engine supports LF versions: 1.6, 1.7, 1.8, 1.11, 1.12, 1.13, 1.14, 1.15, 1.dev"
"Daml-LF Engine supports LF versions: 2.1"
engineInfoV2.show shouldBe
"Daml-LF Engine supports LF versions: 2.1, 2.dev"

View File

@ -49,57 +49,52 @@ object LanguageVersion {
val List(v1_6, v1_7, v1_8, v1_11, v1_12, v1_13, v1_14, v1_15, v1_dev, v2_1, v2_dev) =
All: @nowarn("msg=match may not be exhaustive")
// TODO(#17366): Once LF2 deprecates some features, it will no longer be possible to represent
// them as a just a version number. Instead we'll need a richer specification of which versions
// support which feature. See PR #17334.
object Features {
val default = v1_6
val internedPackageId = v1_6
val internedStrings = v1_7
val internedDottedNames = v1_7
val numeric = v1_7
val anyType = v1_7
val typeRep = v1_7
val typeSynonyms = v1_8
val packageMetadata = v1_8
val genComparison = v1_11
val genMap = v1_11
val scenarioMustFailAtMsg = v1_11
val contractIdTextConversions = v1_11
val exerciseByKey = v1_11
val internedTypes = v1_11
val choiceObservers = v1_11
val bigNumeric = v1_13
val exceptions = v1_14
val basicInterfaces = v1_15
val choiceFuncs = v1_dev
val choiceAuthority = v1_dev
val natTypeErasure = v1_dev
val packageUpgrades = v1_dev
val dynamicExercise = v1_dev
val sharedKeys = v1_dev
val default = v2_1
val internedStrings = v2_1
val internedDottedNames = v2_1
val numeric = v2_1
val anyType = v2_1
val typeRep = v2_1
val typeSynonyms = v2_1
val packageMetadata = v2_1
val genComparison = v2_1
val genMap = v2_1
val contractIdTextConversions = v2_1
val exerciseByKey = v2_1
val internedTypes = v2_1
val choiceObservers = v2_1
val bigNumeric = v2_1
val exceptions = v2_1
val basicInterfaces = v2_1
val natTypeErasure = v2_1
val packageUpgrades = v2_1
val sharedKeys = v2_1
val choiceFuncs = v2_dev
val choiceAuthority = v2_dev
val dynamicExercise = v2_dev
/** TYPE_REP_TYCON_NAME builtin */
val templateTypeRepToText = v1_dev
val templateTypeRepToText = v2_dev
/** Guards in interfaces */
val extendedInterfaces = v1_dev
val extendedInterfaces = v2_dev
/** Unstable, experimental features. This should stay in x.dev forever.
* Features implemented with this flag should be moved to a separate
* feature flag once the decision to add them permanently has been made.
*/
val unstable = v1_dev
val unstable = v2_dev
}
// All the stable versions.
val StableVersions: VersionRange[LanguageVersion] =
VersionRange(min = v1_6, max = v1_15)
VersionRange(min = v2_1, max = v2_1)
// All versions compatible with legacy contract ID scheme.
// Versions of LF that are no longer supported.
val LegacyVersions: VersionRange[LanguageVersion] =
StableVersions.copy(max = v1_8)
VersionRange(min = v1_6, max = v1_15)
// All the stable and preview versions
// Equals `Stable` if no preview version is available
@ -109,23 +104,23 @@ object LanguageVersion {
// All the versions
def AllVersions(majorLanguageVersion: LanguageMajorVersion): VersionRange[LanguageVersion] = {
majorLanguageVersion match {
case Major.V1 => EarlyAccessVersions.copy(max = v1_dev)
case Major.V1 => throw new IllegalArgumentException("V1 is not supported")
case Major.V2 => VersionRange(v2_1, v2_dev)
}
}
// This refers to the default output LF version in the compiler
val default: LanguageVersion = v1_14
val default: LanguageVersion = v2_1
}
/** Operations on [[VersionRange]] that only make sense for ranges of [[LanguageVersion]]. */
object LanguageVersionRangeOps {
implicit class LanguageVersionRange(val range: VersionRange[LanguageVersion]) {
def majorVersion: LanguageMajorVersion = {
// TODO(#17366): uncomment once Canton stops using (1.14, 2.dev) as the version range for dev.
// require(
// range.min.major == range.max.major,
// s"version range ${range} spans over multiple version LF versions")
require(
range.min.major == range.max.major,
s"version range ${range} spans over multiple version LF versions",
)
range.max.major
}
}

View File

@ -670,7 +670,7 @@ object Repl {
private val seed = nextSeed()
val transactionVersions =
if (compilerConfig.allowedLanguageVersions.intersects(AllVersions(LanguageMajorVersion.V1))) {
if (compilerConfig.allowedLanguageVersions.intersects(AllVersions(LanguageMajorVersion.V2))) {
transaction.TransactionVersion.DevVersions
} else {
transaction.TransactionVersion.StableVersions

View File

@ -92,6 +92,6 @@ object TransactionVersion {
// TODO(#17366): parameterize by major language version once there's a transaction v2
private[lf] val DevVersions: VersionRange[TransactionVersion] =
LanguageVersion.AllVersions(LanguageMajorVersion.V1).map(assignNodeVersion)
LanguageVersion.AllVersions(LanguageMajorVersion.V2).map(assignNodeVersion)
}