Skip to content

Support NUCK in daml-script#22830

Draft
samuel-williams-da wants to merge 13 commits intomainfrom
sw/nuck-daml-script-support
Draft

Support NUCK in daml-script#22830
samuel-williams-da wants to merge 13 commits intomainfrom
sw/nuck-daml-script-support

Conversation

@samuel-williams-da
Copy link
Copy Markdown
Contributor

@samuel-williams-da samuel-williams-da commented Mar 25, 2026

Needs canton with changes from this PR to pass
New script primitive awaiting naming discussion

Copy link
Copy Markdown
Contributor

@paulbrauner-da paulbrauner-da left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Shorter than I expected.

Comment on lines +251 to +253
-- If we get an error about --ide-ledger-protocol-version, forward it by itself, as we're depending
-- on the script service for parsing errors to avoid duplication of protocol versions
-- We clean up the error a bit to re-point it to script-service.protocol-version
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be simpler to validate the pv on the client side and thus assume that the script service will always parse it? This would remove this complex parsing logic and we could just printStderr as before. I realize that's some code duplication between the client and the server that could get out of sync, but we could maybe add a test to prevent this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is its one more place we need to update the latest protocol version as well, but this approach its a "one and done"

--
-- This is semantically equivalent to calling `query`
-- and filtering on the client side.
queryNContractKey : forall t k p. HasCallStack => (TemplateKey t k, IsParties p) => p -> k -> Int -> Script [(ContractId t, t)]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, we need to think about the naming. The name you've chosen doesn't clash with queryNByKey because there's no "by" (also I'm not sure the other one has N in the name). But it's pretty close. On the other hand, this is consistent with the queryContractKey name that we can't change because GS is using it already.

@remyhaemmerle-da, any opinion?

parties : [Party]
tplId : TemplateTypeRep
contractKey : AnyContractKey
limit : Int
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're anyway fetching everything and because this is only meant to be used for testing, I wonder if we need the limit. Let's discuss tomorrow.

v: ExtendedValue,
lookupContractKeyType: Identifier => Either[String, Type],
legacyAnyContractKey: Boolean,
legacyAnyContractKey: Boolean = false,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What introduces the need to assign it a default value?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parser for queryNContractKeys never needs legacyAnyContractKey, so I omit the argument.

@samuel-williams-da samuel-williams-da force-pushed the sw/nuck-daml-script-support branch from 562cb6d to a5249e1 Compare March 27, 2026 18:27
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the original test file, renamed to WithKeys.
The MultiTest is a copy of this with all key tests removed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the original test file, renamed to WithKeys.
The ScriptTest is a copy of this with all key tests removed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Single "Stable" is actually latest PV, which is currently PV34 (no key support)
I've added a test specifically for PV35

Comment on lines +61 to +64
-- TODO:
-- Exception semantics with keys have changed significantly, this test needs to be re-thought.
-- Consider cases like fetch/queryby keys in a rollback, as well as non-consuming exercise by key

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tested mustFail using duplicate keys. I've deleted it for now, perhaps we should add back a version that fails using a different error.

{-# OPTIONS_GHC -Wno-x-exceptions #-}

-- @IDE-PV V34

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want a version of this file for PV35, that avoids rollbacks

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All changes here are to allow different PVs in the IDE ledger per test.
We need a separate script service per PV, as we do for build options (which Jasper added some time back). I've extended his logic to also account for PV

-- Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0

-- TODO: This test is disabled as it requires PV34, refactoring the upgrade test suite to allow PV34 would be too much effort for now
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See here, unsure what we want to do. Do we want the suite to cover PV34?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Diff is being bad here, I didn't delete these tests, they're just in PV34 now.

Comment on lines +466 to +467
# Disabled as template uses keys and rollbacks, which is no longer permitted
# TODO: Remove/refactor this template and re-enable the test
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See here

jarPath: Path = CantonRunner.cantonPath,
authSecret: Option[String] = None,
devMode: Boolean = false,
protocolVersion: String = "latest",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe its worth changing the string to a trait, containing say "dev", "latest" and "explicit(ver: String)"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now every test in our security evidence is disabled 🙃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants