Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove legacy daml script #20646

Merged
merged 14 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion sdk/ci/build-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ if [ "$(uname)-$(uname -m)" = "Linux-x86_64" ]; then
extra_build_targets="//release:protobufs \
//daml-script/runner:daml-script-binary_distribute.jar \
//daml-script/daml:daml-script-dars \
//daml-script/daml3:daml3-script-dars \
//docs:sphinx-source-tree \
//docs:pdf-fonts-tar \
//docs:non-sphinx-html-docs \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ checkTypeCon isSerializable name = do
pkg <- inWorld (lookupExternalPackage pkgId)
let meta = packageMetadata pkg
PackageMetadata { packageName } = meta
let isNewDamlScript :: Bool
isNewDamlScript = packageName `elem` map PackageName ["daml3-script"]
when isNewDamlScript $ do
let isDamlScript :: Bool
isDamlScript = packageName `elem` map PackageName ["daml-script"]
when isDamlScript $ do
diagnosticWithContext $ WEDependsOnDatatypeFromNewDamlScript (pkgId, meta) (packageLfVersion pkg) name

-- | Check whether a data type definition satisfies all serializability constraints.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,7 @@ runScenariosScriptsPkg projRoot extPkg pkgs = do
concat
[ scriptsInModule mod
| mod <- NM.elems $ LF.packageModules pkg
, LF.moduleName mod /= LF.ModuleName ["Daml", "Script"]
, not $ ["Daml", "Script"] `isPrefixOf` LF.unModuleName (LF.moduleName mod)
]

toDiagnostics ::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,13 @@ import DA.Daml.LFConversion.Utils
import "ghc-lib" GhcPlugins as GHC hiding ((<>))
import "ghc-lib" TyCoRep

pattern Daml2ScriptPackage :: GHC.UnitId
pattern Daml2ScriptPackage <- (T.stripPrefix "daml-script-" . fsToText . unitIdFS -> Just _)
pattern Daml2ScriptModule :: GHC.Module
pattern Daml2ScriptModule <- ModuleIn Daml2ScriptPackage "Daml.Script"

pattern Daml3ScriptPackage :: GHC.UnitId
pattern Daml3ScriptPackage <- (T.stripPrefix "daml3-script-" . fsToText . unitIdFS -> Just _)
pattern Daml3ScriptInternalModule :: GHC.Module
pattern Daml3ScriptInternalModule <- ModuleIn Daml3ScriptPackage "Daml.Script.Internal.LowLevel"
pattern DamlScriptPackage :: GHC.UnitId
pattern DamlScriptPackage <- (T.stripPrefix "daml-script-" . fsToText . unitIdFS -> Just _)
pattern DamlScriptInternalModule :: GHC.Module
pattern DamlScriptInternalModule <- ModuleIn DamlScriptPackage "Daml.Script.Internal.LowLevel"

isDamlScriptType :: TyCon -> Bool
isDamlScriptType (NameIn Daml2ScriptModule "Script") = True
isDamlScriptType (NameIn Daml3ScriptInternalModule "Script") = True
isDamlScriptType (NameIn DamlScriptInternalModule "Script") = True
isDamlScriptType _ = False

topLevelWarnings :: (Var, Expr Var) -> ConvertM ()
Expand Down
18 changes: 8 additions & 10 deletions sdk/compiler/damlc/daml-opts/daml-opts/DA/Daml/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -557,23 +557,21 @@ expandSdkPackages logger lfVersion dars = do
mapM (expand mbSdkPath) (nubOrd dars)
where
isSdkPackage fp = takeExtension fp `notElem` [".dar", ".dalf"]
isInvalidDaml3Script = \case
"daml3-script" | LF.versionMajor lfVersion /= LF.V2 -> True
_ -> False
sdkSuffix = "-" <> LF.renderVersion lfVersion
expand mbSdkPath fp
| fp `elem` basePackages = pure fp
| isSdkPackage fp = case mbSdkPath of
Just _ | isInvalidDaml3Script fp -> fail "Daml3-script may only be used with LF v2, and is unstable."
Just sdkPath -> do
when (fp == "daml3-script")
$ Logger.logWarning logger
"You are using an unreleased and unstable version of daml-script intended for daml3. This will break without warning."
pure $ sdkPath </> "daml-libs" </> fp <> sdkSuffix <.> "dar"
Just sdkPath | fp == "daml3-script" -> do
Logger.logWarning logger "`daml3-script` is now the default `daml-script`, please replace `daml3-script` with `daml-script` in your daml.yaml"
pure $ sdkPath </> "daml-libs" </> "daml-script" <> sdkSuffix <.> "dar"
Just sdkPath | fp == "daml-script-lts" -> do
Logger.logWarning logger
"`daml-script-lts` is not available in daml 3, defaulting to daml-script. Please replace `daml-script-lts` with `daml-script` in your daml.yaml"
pure $ sdkPath </> "daml-libs" </> "daml-script" <> sdkSuffix <.> "dar"
Just sdkPath -> pure $ sdkPath </> "daml-libs" </> fp <> sdkSuffix <.> "dar"
Nothing -> fail $ "Cannot resolve SDK dependency '" ++ fp ++ "'. Use daml assistant."
| otherwise = pure fp


mkPackageFlag :: UnitId -> PackageFlag
mkPackageFlag unitId = ExposePackage ("--package " <> unitIdString unitId) (UnitIdArg unitId) (ModRenaming True [])

Expand Down
94 changes: 30 additions & 64 deletions sdk/compiler/damlc/tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,13 @@ da_haskell_library(
args = [
"--daml-lf-version",
version,
"--daml-script-v2",
"false",
],
data = [
":bond-trading",
":cant-skip-preprocessor",
":daml-test-files",
":package-vetting-package-a-{}.dar".format(version),
":package-vetting-package-b-{}.dar".format(version),
":query-lf-lib",
"//compiler/damlc:ghcversion",
"//compiler/damlc:hpp-copy",
Expand All @@ -213,43 +213,6 @@ da_haskell_library(
for version in COMPILER_LF_VERSIONS
]

da_haskell_test(
name = "integration-v2dev-script2",
size = "large",
srcs = ["src/DA/Test/DamlcIntegrationMain.hs"],
args = [
"--daml-lf-version",
"2.dev", # script2 only supports 2.x
"--daml-script-v2",
"true",
],
data = [
":bond-trading",
":cant-skip-preprocessor",
":daml-test-files",
":package-vetting-package-a.dar",
":package-vetting-package-b.dar",
":query-lf-lib",
"//compiler/damlc:ghcversion",
"//compiler/damlc:hpp-copy",
"//compiler/damlc/pkg-db",
"//compiler/damlc/stable-packages",
"//compiler/scenario-service/server:scenario_service_jar",
"//daml-script/daml3:daml3-script-2.dev.dar",
"@jq_dev_env//:jq",
ghc_pkg,
],
hackage_deps = [
"base",
],
main_function = "DA.Test.DamlcIntegrationMain.main",
src_strip_prefix = "src",
visibility = ["//visibility:public"],
deps = [
":integration-lib",
],
)

# Tests for daml-doc
da_haskell_test(
name = "daml-doc",
Expand Down Expand Up @@ -356,7 +319,7 @@ da_haskell_test(
"//compiler/damlc/pkg-db",
"//compiler/damlc/stable-packages",
"//compiler/scenario-service/server:scenario_service_jar",
"//daml-script/daml3:daml3-script-2.1.dar",
"//daml-script/daml:daml-script-2.1.dar",
ghc_pkg,
],
hackage_deps = [
Expand Down Expand Up @@ -391,7 +354,6 @@ da_haskell_test(
data = [
"//compiler/damlc",
"//daml-script/daml:daml-script.dar",
"//daml-script/daml3:daml3-script.dar",
"//daml-script/runner:daml-script-binary",
],
hackage_deps = [
Expand Down Expand Up @@ -452,7 +414,7 @@ da_haskell_test(
data = [
"//compiler/damlc",
"//daml-script/daml:daml-script.dar",
"//daml-script/daml3:daml3-script-2.dev.dar",
"//daml-script/daml:daml-script-2.dev.dar",
"//daml-script/runner:daml-script-binary",

# Files for damlc tests
Expand Down Expand Up @@ -754,7 +716,7 @@ da_haskell_test(
"//compiler/damlc",
"@damlc_legacy",
"//compiler/damlc/tests:generate-simple-dalf",
"//daml-script/daml3:daml3-script-2.dev.dar",
"//daml-script/daml:daml-script-2.dev.dar",
# Feel free to update this to 0.13.55 once that is frozen.
":dars/old-proj-0.13.55-snapshot.20200309.3401.0.6f8c3ad8-1.8.dar",

Expand Down Expand Up @@ -992,8 +954,7 @@ da_haskell_test(
"//compiler/damlc/stable-packages",
"//compiler/scenario-service/server:scenario_service_jar",
"//daml-script/daml:daml-script.dar",
"//daml-script/daml3:daml3-script.dar",
"//daml-script/daml3:daml3-script-2.dev.dar",
"//daml-script/daml:daml-script-2.dev.dar",
ghc_pkg,
],
hackage_deps = [
Expand Down Expand Up @@ -1187,27 +1148,32 @@ da_haskell_test(
],
)

daml_compile(
name = "package-vetting-package-a",
srcs = ["daml-test-files/external-packages/package-vetting-test-files/PackageAModule.daml"],
project_name = "package-vetting-package-a",
target = "2.dev",
version = "1.0.0",
)
[
[
daml_compile(
name = "package-vetting-package-a-{}".format(lf_version),
srcs = ["daml-test-files/external-packages/package-vetting-test-files/PackageAModule.daml"],
project_name = "package-vetting-package-a",
target = lf_version,
version = "1.0.0",
),
daml_compile(
name = "package-vetting-package-b-{}".format(lf_version),
srcs = ["daml-test-files/external-packages/package-vetting-test-files/PackageBModule.daml"],
project_name = "package-vetting-package-b",
target = lf_version,
version = "1.0.0",
)
]
for lf_version in COMPILER_LF_VERSIONS
]

daml_compile(
name = "package-vetting-package-b",
srcs = ["daml-test-files/external-packages/package-vetting-test-files/PackageBModule.daml"],
project_name = "package-vetting-package-b",
target = "2.dev",
version = "1.0.0",
)

daml_compile(
name = "submit-test",
srcs = ["daml-test-files/Daml3ScriptSubmit.daml"],
srcs = ["daml-test-files/Submit.daml"],
dependencies = [
"//daml-script/daml3:daml3-script-2.dev.dar",
"//daml-script/daml:daml-script-2.dev.dar",
],
enable_interfaces = True,
project_name = "submit-test",
Expand All @@ -1217,9 +1183,9 @@ daml_compile(

daml_compile(
name = "try-submit-concurrently-test",
srcs = ["daml-test-files/Daml3ScriptTrySubmitConcurrently.daml"],
srcs = ["daml-test-files/TrySubmitConcurrently.daml"],
dependencies = [
"//daml-script/daml3:daml3-script-2.dev.dar",
"//daml-script/daml:daml-script-2.dev.dar",
],
project_name = "try-submit-concurrently-test",
target = "2.dev",
Expand All @@ -1230,7 +1196,7 @@ daml_compile(
name = "query-test",
srcs = ["daml-test-files/Query.daml"],
dependencies = [
"//daml-script/daml3:daml3-script-2.dev.dar",
"//daml-script/daml:daml-script-2.dev.dar",
],
target = "2.dev",
visibility = ["//visibility:public"],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
module Daml3ScriptCannotInspectContractNotFoundAdditionalInfo where

-- @ SCRIPT-V2
module CannotInspectContractNotFoundAdditionalInfo where

import Daml.Script

-- @ ERROR range=17:14-17:22; Not in scope: data constructor ‘NotFound’
-- @ ERROR range=18:14-18:23; Not in scope: data constructor ‘NotActive’
-- @ ERROR range=19:14-19:26; Not in scope: data constructor ‘NotEffective’
-- @ ERROR range=20:14-20:24; Not in scope: data constructor ‘NotVisible’
patternMatchShouldn'tCompile : ()
patternMatchShouldn'tCompile =
-- @ ERROR range=15:14-15:22; Not in scope: data constructor ‘NotFound’
-- @ ERROR range=16:14-16:23; Not in scope: data constructor ‘NotActive’
-- @ ERROR range=17:14-17:26; Not in scope: data constructor ‘NotEffective’
-- @ ERROR range=18:14-18:24; Not in scope: data constructor ‘NotVisible’
patternMatchShouldNotCompile : ()
patternMatchShouldNotCompile =
case error "placeholder error for typechecking, should not be evaluated" of
ContractNotFound { additionalDebuggingInfo } ->
case additionalDebuggingInfo of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"fct_type": {
"TypeApp": [
{
"referenceAnchor": "type-daml-script-script-90248",
"referenceAnchor": "type-daml-script-internal-lowlevel-script-4781",
"referencePackage": "daml-script-UNVERSIONED"
},
"Script",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
-- Copyright (c) 2023 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0

-- @ SCRIPT-V2

-- @ WARN range=11:1-11:31; Import of internal module Daml.Script.Internal of package daml3-script is discouraged, as this module will change without warning.
-- @ WARN range=9:1-9:31; Import of internal module Daml.Script.Internal of package daml3-script is discouraged, as this module will change without warning.

module DamlScriptInternalWarning where

Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
Transactions:
TX 0 1970-01-01T00:00:00Z (DivulgeFetchNodeActors:34:10)
TX 0 1970-01-01T00:00:00Z (Daml.Script.Internal.Questions.Submit:194:26)
#0:0
│ referenced by #2:1
│ disclosed to (since): 'alice' (0), 'bank' (0)
│ divulged to (since): 'divulgee' (2)
└─> 'bank' creates DivulgeFetchNodeActors:Iou
with
bank = 'bank'; owner = 'alice'
with
bank = 'bank'; owner = 'alice'

TX 1 1970-01-01T00:00:00Z (DivulgeFetchNodeActors:41:17)
TX 1 1970-01-01T00:00:00Z (Daml.Script.Internal.Questions.Submit:194:26)
#1:0
│ consumed by: #2:0
│ referenced by #2:0
│ disclosed to (since): 'alice' (1),
'divulgee' (1)
└─> 'divulgee' creates DivulgeFetchNodeActors:DivulgeFrom
with
stakeholder = 'alice'; divulgee = 'divulgee'
with
stakeholder = 'alice'; divulgee = 'divulgee'

TX 2 1970-01-01T00:00:00Z (DivulgeFetchNodeActors:44:3)
TX 2 1970-01-01T00:00:00Z (Daml.Script.Internal.Questions.Submit:194:26)
#2:0
│ disclosed to (since): 'alice' (2),
'divulgee' (2)
└─> 'alice' exercises ExeDivulgeFrom on #1:0 (DivulgeFetchNodeActors:DivulgeFrom)
with
cid = #0:0
with
cid = #0:0
children:
#2:1
│ disclosed to (since): 'alice' (2),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
Transactions:
TX 0 1970-01-01T00:00:00Z (DivulgeFetchNodeActors:34:10)
TX 0 1970-01-01T00:00:00Z (Daml.Script.Internal.Questions.Submit:194:26)
#0:0
│ referenced by #2:1
│ disclosed to (since): 'alice' (0), 'bank' (0)
│ divulged to (since): 'divulgee' (2)
└─> 'bank' creates DivulgeFetchNodeActors:Iou
with
bank = 'bank'; owner = 'alice'
with
bank = 'bank'; owner = 'alice'

TX 1 1970-01-01T00:00:00Z (DivulgeFetchNodeActors:41:17)
TX 1 1970-01-01T00:00:00Z (Daml.Script.Internal.Questions.Submit:194:26)
#1:0
│ consumed by: #2:0
│ referenced by #2:0
│ disclosed to (since): 'alice' (1),
'divulgee' (1)
└─> 'alice' creates DivulgeFetchNodeActors:DivulgeTo
with
stakeholder = 'alice'; divulgee = 'divulgee'
with
stakeholder = 'alice'; divulgee = 'divulgee'

TX 2 1970-01-01T00:00:00Z (DivulgeFetchNodeActors:44:3)
TX 2 1970-01-01T00:00:00Z (Daml.Script.Internal.Questions.Submit:194:26)
#2:0
│ disclosed to (since): 'alice' (2),
'divulgee' (2)
└─> 'alice' exercises ExeDivulgeTo on #1:0 (DivulgeFetchNodeActors:DivulgeTo)
with
cid = #0:0
with
cid = #0:0
children:
#2:1
│ disclosed to (since): 'alice' (2),
Expand Down
Loading
Loading