Skip to content

Conversation

@dfordivam
Copy link
Contributor

@dfordivam dfordivam commented Oct 28, 2025

Fixes #2902

The daml version bump, and update of dars/package*.json is not in this PR to keep the changes easier to review. It would make sense to combine this PR with the one implementing governance of weight change, and then do the bump of the versions and update the release-notes.

@meiersi-da
Copy link
Contributor

I'll review tomorrow morning my time.

Copy link
Contributor

@meiersi-da meiersi-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 work @dfordivam !

Functionally we're almost there, but we need a few more tests.

Also: we should talk about how to land this and it's follow-up changes best.

We are just around the 0.5.0 release from main, and I'd like to avoid releasing the Daml changes too early. Given that we don't yet have support for Daml snapshots (#514), I'd suggest we land all of your changes on a cip-73 feature branch and merge them once they are done. If you agree with that, then I'll create the branch; and I'll take care of shepherding it ultimately into main.

What I do care about is that we have a decent commit history. So I'd like this PR to also include the work of the version bumps, so it passes CI and can ultimately be merged into the cip-73 feature branch.

FYI: @isegall-da

-- Test kind merging: Some OperatorLicense if any license has None or Some OperatorLicense
v3 <- allocateParty "v3"

-- Test case 1: mixing None and Some NonOperatorLicense -> should result in Some OperatorLicense
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest reorganizing the code so you can do this as a unit test:

  1. define a function mergeValidatorLicenses : [ValidatorLicense] -> ValidatorLicense in Splice.ValidatorLicense
  2. create a unit test in Splice.Scripts.UnitTests.ValidatorLicense in splice-amulet-test

Also consider testing a few of the constituent functions on their own to get a bit more succinct testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did a split here 4936052, though there seems to be no need for a unit test in this case. (Unless I move the logic out from the DsoRules_MergeValidatorLicense and test the API separately?)

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, as I just commented in my review, I found it challenging to check your tests as there's so much setup noise for what is essentially a three line assertion.

Introducing mergeValidatorLicenseWeights and its friends and testing them on their own would remediate that.

@dfordivam
Copy link
Contributor Author

Making use of a cip-73 feature branch sounds good. But in order to make each PR pass CI, I will have to include fixes elsewhere in code (not just Daml). These fixes should be trivial to review for the daml changes we plan to do.

@meiersi-da
Copy link
Contributor

Making use of a cip-73 feature branch sounds good. But in order to make each PR pass CI, I will have to include fixes elsewhere in code (not just Daml). These fixes should be trivial to review for the daml changes we plan to do.

Note that the branch is named feature-cip-73. You can find it here: https://github.com/hyperledger-labs/splice/tree/feature-cip-73

I do not mind the changes required to make a PR pass CI. Feel free to add them from the get-go.

What I care about is that we split the changes into: daml, backend, and frontend changes, as this limits the amount of change per PR. Each of these kinds of have their own tests, and can thus be validated on their own.

Where we do have separate pieces of functionality, then splitting them into separate sets of daml, backend, and frontend changes is also helpful to get more incremental progress and simplify reviewing (and often also development).

@dfordivam dfordivam force-pushed the dn/cip-0073-daml-weighted-validator-license branch from 01384d1 to 1cab7be Compare November 5, 2025 08:23
@dfordivam dfordivam changed the base branch from main to feature-cip-73 November 5, 2025 08:24
@dfordivam
Copy link
Contributor Author

@meiersi-da I updated the PR and addressed the comments.
I have kept the fixes to the scala code at a minimal 16bb8c4, and they are not correct, but I hope that this should atleast get the CI green for the daml changes.

I have tried to make the bigger changes to the test files in multiple commits for ease of review, so it may be better to go over the changes commit by commit.

Copy link
Contributor

@meiersi-da meiersi-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 work. Not yet approving as I'd like to see the CI run results first.

-- With weight 0.0, Bob should receive no rewards
test_ValidatorFaucetWithWeight0: Script ()
test_ValidatorFaucetWithWeight0 = do
-- bob actually loses balance when doing minting with 0 weight. So just confirm bobExpectedMax
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adjusting the test infra to setup the app with no fees to simplify these tests.

I've added this kind of infra to the token standard testing:

let amuletConfig
| config.noTransferFee = defaultAmuletConfig with
transferConfig = noTransferFeeConfig
| otherwise = defaultAmuletConfig

You could copy the same approach over to Splice.Scripts.Util.setupApp to make your tests more precise; and simplify later Daml changes.

I wouldn't recommend to switch all testing at once to using no-fees. Too onerous to do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added such a setup in 2cb34b6 and used it in these tests.

faucetState = Some FaucetState with
firstReceivedFor = Round 0
lastReceivedFor = Round 2
numCouponsMissed = 0
Copy link
Contributor

Choose a reason for hiding this comment

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

check that they are summed properly by setting them to a different non-zero amount

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This field (or rather any field in the FaucetState) is not modified in the existing merge logic. And I don't see any reason to add such a functionality in this PR.

DsoRules_MergeValidatorLicenseResult mergedKind2 <- submitMulti [sv1] [dso] $ exerciseCmd rulesCid (DsoRules_MergeValidatorLicense [validatorLicenseK3, validatorLicenseK4] (Some sv1))
[(_, mergedLicense2)] <- queryFilter @ValidatorLicense dso (\license -> license.validator == v4)
-- Should be OperatorLicense to prevent downgrading
mergedLicense2.kind === Some OperatorLicense
Copy link
Contributor

Choose a reason for hiding this comment

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

I still can't shake the feeling that these tests use a lot of code for testing that a particular pure function behaves as it should. Consider refactoring the code so you can use unit tests as proposed in my previous review. Your call though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, so I moved to code to pure function, in a separate file, and added unit-tests which are quite concise now.

@dfordivam dfordivam force-pushed the dn/cip-0073-daml-weighted-validator-license branch from 7b810d0 to 020c441 Compare November 6, 2025 08:32
Copy link
Contributor

@meiersi-da meiersi-da left a comment

Choose a reason for hiding this comment

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

Very nice! Thanks you very much for your cleanup contributions. Much appreciated to have your help on this 🙇

daml/dars.lock Outdated
splice-util-featured-app-proxies-test 1.0.3 827f48e333c24b96ca7b900f0ca4b903a2b3d1c71ea99d5bb5a5f1fa1d2ecb53
splice-util-token-standard-wallet 1.0.0 1da198cb7968fa478cfa12aba9fdf128a63a8af6ab284ea6be238cf92a3733ac
splice-util-token-standard-wallet-test 1.0.0 ee328d4744bce339f040078d7271a3d73c932d23589cfa1cfbd99aaf6408c3c2
splice-util-token-standard-wallet-test 1.0.0 90ddc14ec12a0e5b8bdfcf350fa9d2120b581c32c64caa23696cfe343c260c4c
Copy link
Contributor

Choose a reason for hiding this comment

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

missing version bump

daml/dars.lock Outdated
splice-util-featured-app-proxies 1.0.0 48e0c4fe4ea05e3b740404ebe37004ddd741efbdcd665c1c3199a5d6d9d944d7
splice-util-featured-app-proxies 1.1.0 81dd5a9e5c02d0de03208522a895fb85eeb12fbea4aca7c4ad0ad106f3b0bfce
splice-util-featured-app-proxies-test 1.0.3 115db68a3362e7e16754c147367c89f3a149bf8db199d4dcde91d416f9f894f4
splice-util-featured-app-proxies-test 1.0.3 827f48e333c24b96ca7b900f0ca4b903a2b3d1c71ea99d5bb5a5f1fa1d2ecb53
Copy link
Contributor

Choose a reason for hiding this comment

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

missing version bump

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

aliceExpectedMin = aliceExpectedMin
aliceExpectedMax = aliceExpectedMax
bobExpectedMin = aliceExpectedMin * bobWeight
bobExpectedMax = aliceExpectedMax * bobWeight
Copy link
Contributor

Choose a reason for hiding this comment

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

nice. Thanks you for this compactification!

return app

-- | Setup the DSO party and the contracts defining the Amulet app with no fees.
setupAppNoFees : Script AmuletApp
Copy link
Contributor

Choose a reason for hiding this comment

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

thanks a lot!

import Splice.ValidatorLicense
import Splice.Types (Round(..))

-- | Merges a list of `ValidatorLicense` contracts into a single license.
Copy link
Contributor

Choose a reason for hiding this comment

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

nice. thanks!

@meiersi-da
Copy link
Contributor

@dfordivam : there's a bug to with our runner for CI on contributor forks. I've thus created a copy that I pushed here:

Looking at the errors I see:

Found problems in the sbt output:
[info] daml/Splice/Scripts/UnitTests/MergeValidatorLicense.daml:test_ValidationError: ok, 0 active contracts, 0 transactions.
Total: 1 lines with problems.

==> rename the test. we have a simple grep for Error that is triggering this

Package (splice-util-featured-app-proxies-test,1.0.4) changed hash from 07a7177d917b3b405284d6433dfb81f6382d476bccf1380297dcd60f0edbf1b9 to ef633c6eff2d786cc571e58f572c5a0c72d31b7ffc1eeeedc420791c50b9a7f1

fix the version; run pre-commit hooks before push

@meiersi-da
Copy link
Contributor

I've fixed the simple actions here:

dfordivam and others added 24 commits November 7, 2025 06:17
Signed-off-by: Divam <[email protected]>
Just to make the code compile

Signed-off-by: Divam <[email protected]>
Signed-off-by: Divam <[email protected]>
Co-authored-by: Simon Meier <[email protected]>
Signed-off-by: Divam <[email protected]>
Co-authored-by: Simon Meier <[email protected]>
Signed-off-by: Divam <[email protected]>
Co-authored-by: Simon Meier <[email protected]>
Signed-off-by: Divam <[email protected]>
…alance change checks

This has no transferFee and holdingFee, and makes it easier to confirm the cases
where user's account balance change is not expected.

Signed-off-by: Divam <[email protected]>
Signed-off-by: Divam <[email protected]>
Signed-off-by: Divam <[email protected]>
[ci]

Signed-off-by: Simon Meier <[email protected]>
@dfordivam dfordivam force-pushed the dn/cip-0073-daml-weighted-validator-license branch from eede310 to af2cc92 Compare November 7, 2025 07:41
Signed-off-by: Divam <[email protected]>
@dfordivam dfordivam force-pushed the dn/cip-0073-daml-weighted-validator-license branch from af2cc92 to 389dce7 Compare November 7, 2025 07:43
@dfordivam
Copy link
Contributor Author

I have rebased the branch over latest feature-cip-73, cherry-picked the af744e3 commit, and did the fix for test failure here 1274d07

dfordivam added a commit to obsidiansystems/canton-splice that referenced this pull request Nov 12, 2025
PR reviewed in hyperledger-labs#2903
CI run hyperledger-labs#3093

Squash commit created by rebasing 5e8d90e7f over f47f017

Signed-off-by: Divam <[email protected]>
@dfordivam
Copy link
Contributor Author

The commits reviewed in this PR have been squashed and pushed here obsidiansystems@c9296bf

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Daml: ValidatorLicense weight and SV grant license

5 participants