-
Notifications
You must be signed in to change notification settings - Fork 46
Daml: Add weight, kind to ValidatorLicense, and SV grant license support #2903
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
base: feature-cip-73
Are you sure you want to change the base?
Daml: Add weight, kind to ValidatorLicense, and SV grant license support #2903
Conversation
99fa074 to
373e496
Compare
373e496 to
01384d1
Compare
|
I'll review tomorrow morning my time. |
meiersi-da
left a comment
There was a problem hiding this 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
daml/splice-dso-governance-test/daml/Splice/Scripts/DsoTestUtils.daml
Outdated
Show resolved
Hide resolved
daml/splice-dso-governance-test/daml/Splice/Scripts/TestOnboarding.daml
Outdated
Show resolved
Hide resolved
| -- 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 |
There was a problem hiding this comment.
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:
- define a function
mergeValidatorLicenses : [ValidatorLicense] -> ValidatorLicenseinSplice.ValidatorLicense - create a unit test in
Splice.Scripts.UnitTests.ValidatorLicenseinsplice-amulet-test
Also consider testing a few of the constituent functions on their own to get a bit more succinct testing.
There was a problem hiding this comment.
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?)
There was a problem hiding this comment.
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.
daml/splice-dso-governance-test/daml/Splice/Scripts/TestOnboarding.daml
Outdated
Show resolved
Hide resolved
|
Making use of a |
Note that the branch is named 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). |
01384d1 to
1cab7be
Compare
|
@meiersi-da I updated the PR and addressed the comments. 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. |
meiersi-da
left a comment
There was a problem hiding this 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 |
There was a problem hiding this comment.
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:
splice/token-standard/splice-token-standard-test/daml/Splice/Testing/Registries/AmuletRegistry.daml
Lines 125 to 128 in 5689449
| 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.
There was a problem hiding this comment.
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.
daml/splice-dso-governance-test/daml/Splice/Scripts/TestValidatorLicense.daml
Outdated
Show resolved
Hide resolved
| faucetState = Some FaucetState with | ||
| firstReceivedFor = Round 0 | ||
| lastReceivedFor = Round 2 | ||
| numCouponsMissed = 0 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
7b810d0 to
020c441
Compare
meiersi-da
left a comment
There was a problem hiding this 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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing version bump
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice. thanks!
|
@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: ==> rename the test. we have a simple grep for fix the version; run pre-commit hooks before push |
|
I've fixed the simple actions here:
|
Signed-off-by: Divam <[email protected]>
Signed-off-by: Divam <[email protected]>
Signed-off-by: Divam <[email protected]>
Signed-off-by: Divam <[email protected]>
Signed-off-by: Divam <[email protected]>
Signed-off-by: Divam <[email protected]>
Signed-off-by: Divam <[email protected]>
Signed-off-by: Divam <[email protected]>
Signed-off-by: Divam <[email protected]>
Just to make the code compile Signed-off-by: Divam <[email protected]>
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]>
Signed-off-by: Divam <[email protected]>
Signed-off-by: Divam <[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]>
… code reuse. Signed-off-by: Divam <[email protected]>
Signed-off-by: Divam <[email protected]>
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]>
Signed-off-by: Divam <[email protected]>
eede310 to
af2cc92
Compare
Signed-off-by: Divam <[email protected]>
af2cc92 to
389dce7
Compare
|
I have rebased the branch over latest feature-cip-73, cherry-picked the af744e3 commit, and did the fix for test failure here 1274d07 |
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]>
|
The commits reviewed in this PR have been squashed and pushed here obsidiansystems@c9296bf |
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.