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

Add missing explicit error expectation for transaction mutations #719

Merged
merged 30 commits into from
Mar 10, 2023

Conversation

ffakenz
Copy link
Contributor

@ffakenz ffakenz commented Feb 9, 2023

This contributes to moving #705 forward.

To check before merging:

  • CHANGELOG is up to date
  • Up to date with master

@ffakenz ffakenz self-assigned this Feb 9, 2023
@github-actions
Copy link

github-actions bot commented Feb 9, 2023

Transactions Costs

Sizes and execution budgets for Hydra protocol transactions. Note that unlisted parameters are currently using arbitrary values and results are not fully deterministic and comparable to previous runs.

Metadata
Generated at 2023-03-10 11:22:17.190960552 UTC
Max. memory units 14000000
Max. CPU units 10000000000
Max. tx size (kB) 16384

Script summary

Name Hash Size (Bytes)
μHead N/A 4458
νInitial 9492414f8f96e8483a0b8ee268fc06a954641cb2cbaa9a8b093c2c9b 4621
νCommit 5d3f107aaa56d06188cf231941cf8163e777236a9cfdc48fd4bbfa23 2422
νHead 82f16b51e2d81c6f4d42dd7398b4713a445464902f63dfd86ffe754e 8954

Cost of Init Transaction

Parties Tx size % max Mem % max CPU Min fee ₳
1 5058 13.57 5.35 0.52
2 5259 16.76 6.58 0.56
3 5465 20.43 8.01 0.61
5 5875 24.58 9.56 0.68
10 6903 37.83 14.61 0.87
36 12231 98.85 37.63 1.76

Cost of Commit Transaction

Currently only one UTxO per commit allowed (this is about to change soon)

UTxO Tx size % max Mem % max CPU Min fee ₳
1 603 15.75 6.19 0.35

Cost of CollectCom Transaction

Parties UTxO (bytes) Tx size % max Mem % max CPU Min fee ₳
1 57 816 24.80 10.07 0.46
2 114 1139 40.24 16.46 0.64
3 170 1467 59.09 24.31 0.87
4 225 1782 80.19 33.15 1.12

Cost of Close Transaction

Parties Tx size % max Mem % max CPU Min fee ₳
1 681 17.74 7.77 0.38
2 846 18.96 8.47 0.40
3 965 20.12 8.98 0.42
5 1299 22.87 10.50 0.47
10 2132 29.96 14.40 0.59
50 5424 64.63 29.40 1.12

Cost of Contest Transaction

Parties Tx size % max Mem % max CPU Min fee ₳
1 667 21.73 9.11 0.42
2 841 23.45 9.99 0.45
3 1007 25.21 10.89 0.48
5 1335 29.06 12.83 0.54
10 2161 37.72 17.28 0.67
46 8102 99.36 49.05 1.66

Cost of Abort Transaction

Some variation because of random mixture of still initial and already committed outputs.

Parties Tx size % max Mem % max CPU Min fee ₳
1 5243 30.33 13.03 0.72
2 5493 47.99 20.73 0.93
3 5816 70.07 30.46 1.19
4 6135 95.52 41.69 1.49

Cost of FanOut Transaction

Involves spending head output and burning head tokens. Uses ada-only UTxO for better comparability.

Parties UTxO UTxO (bytes) Tx size % max Mem % max CPU Min fee ₳
5 0 0 5075 10.59 4.43 0.49
5 1 57 5114 12.12 5.31 0.51
5 5 284 5253 18.22 8.83 0.59
5 10 570 5437 25.85 13.24 0.69
5 20 1140 5798 41.11 22.05 0.90
5 30 1711 6160 56.37 30.86 1.10
5 40 2276 6516 71.64 39.68 1.30
5 50 2848 6878 86.92 48.50 1.50
5 58 3301 7158 99.14 55.56 1.67

@ffakenz ffakenz changed the title ADD explicit error expectations for Init, Abort and Close ADD explicit error expectations for Init, Abort, Close and Contest Feb 10, 2023
@ffakenz ffakenz changed the title ADD explicit error expectations for Init, Abort, Close and Contest Add explicit error expectations for transaction mutations Feb 10, 2023
@ffakenz ffakenz changed the title Add explicit error expectations for transaction mutations Add missing explicit error expectations for transaction mutations Feb 10, 2023
@ffakenz ffakenz changed the title Add missing explicit error expectations for transaction mutations Add missing explicit error expectation for transaction mutations Feb 10, 2023
@github-actions
Copy link

github-actions bot commented Feb 10, 2023

Test Results

285 tests   - 11   279 ✔️  - 11   19m 45s ⏱️ -38s
  95 suites  -   4       6 💤 ±  0 
    4 files    -   1       0 ±  0 

Results for commit 29ac49e. ± Comparison against base commit 32d02fe.

This pull request removes 11 tests.
Hydra.TUI.Options ‑ parses --cardano-signing-key option
Hydra.TUI.Options ‑ parses --connect option
Hydra.TUI.Options ‑ parses --node-socket option
Hydra.TUI.Options ‑ parses --testnet-magic option
Hydra.TUI/end-to-end smoke tests ‑ display feedback long enough
Hydra.TUI/end-to-end smoke tests ‑ doesn't allow multiple initializations
Hydra.TUI/end-to-end smoke tests ‑ starts & renders
Hydra.TUI/end-to-end smoke tests ‑ supports the full Head life cycle
Hydra.TUI/end-to-end smoke tests ‑ supports the init & abort Head life cycle
Hydra.TUI/text rendering errors ‑ should show not enough fuel message and suggestion
…

♻️ This comment has been updated with latest results.

Copy link
Member

@ch1bo ch1bo left a comment

Choose a reason for hiding this comment

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

Let's clarify some of the failures further.

hydra-node/test/Hydra/Chain/Direct/Contract/Abort.hs Outdated Show resolved Hide resolved
hydra-node/test/Hydra/Chain/Direct/Contract/Close.hs Outdated Show resolved Hide resolved
hydra-node/test/Hydra/Chain/Direct/Contract/Contest.hs Outdated Show resolved Hide resolved
hydra-node/test/Hydra/Chain/Direct/Contract/Contest.hs Outdated Show resolved Hide resolved
@ffakenz ffakenz force-pushed the mutations/explicit_expected_errors_2 branch from b731115 to 2a1128c Compare February 20, 2023 10:39
@ffakenz ffakenz force-pushed the mutations/explicit_expected_errors_2 branch from 2a1128c to e0c85ee Compare February 27, 2023 21:19
@ch1bo ch1bo mentioned this pull request Feb 28, 2023
4 tasks
@ch1bo ch1bo force-pushed the mutations/explicit_expected_errors_2 branch from e0c85ee to fd9c157 Compare February 28, 2023 09:47
@ffakenz ffakenz force-pushed the mutations/explicit_expected_errors_2 branch from fd9c157 to 447c4e0 Compare February 28, 2023 10:41
@ch1bo ch1bo changed the base branch from master to task/refactor_script_error_messages_into_error_codes February 28, 2023 10:50
Base automatically changed from task/refactor_script_error_messages_into_error_codes to master February 28, 2023 11:17
@ffakenz ffakenz force-pushed the mutations/explicit_expected_errors_2 branch 3 times, most recently from b08a808 to 2e15138 Compare March 2, 2023 16:07
hydra-plutus/src/Hydra/Contract/Head.hs Outdated Show resolved Hide resolved
hydra-plutus/src/Hydra/Contract/Head.hs Show resolved Hide resolved
hydra-plutus/src/Hydra/Contract/Head.hs Outdated Show resolved Hide resolved
@ch1bo ch1bo linked an issue Mar 3, 2023 that may be closed by this pull request
@ffakenz ffakenz force-pushed the mutations/explicit_expected_errors_2 branch 5 times, most recently from e83bcfe to 2f9aef7 Compare March 7, 2023 18:47
@ffakenz ffakenz marked this pull request as ready for review March 7, 2023 19:50
@ch1bo ch1bo requested review from pgrange and v0d1ch March 8, 2023 09:32
Copy link
Contributor

@pgrange pgrange left a comment

Choose a reason for hiding this comment

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

Ask for clarifications if my comments are not clear.
If you disagree with my comments, just ignore them and don’t answer or explain.
Hence I, in advance, approve the P.R.

What I like about this P.R.:

  • The effort made to explain the intent of the existing mutations
  • Some of the simplifications introduced

For me to find it perfect you would have to:

  • reduce the size of the P.R. so that we have a simple and clear commit history to walk through (I can't pretend I've reviewed everything)
  • see inline comments

Copy link
Contributor

@pgrange pgrange left a comment

Choose a reason for hiding this comment

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

Last round of inline comments

ffakenz and others added 26 commits March 10, 2023 08:11
By using 'const $ healthyClosedState' we are producing an output datum state with snapshotNumber = 3,
and because the input datum snapshotNumber = 3, then it fails for the wrong reason TooOldSnapshot,
as it needs to be greater to verify: closedSnapshotNumber' > closedSnapshotNumber.
This is redundant because is enough to check that the value is preserved,
as we are comming from a valid Closed state having already checked that the ST is present.

This is a breaking change so we upgrade hydra-plutus to 0.10.0.

Update changelog.
We were changing input using the closed state as script data instad of a contest redeemer.
To be explicit about the transactions being involved.
We were changing input using the open state as script data instad of a close redeemer.
Notes added to apply them in another PR.
We want to enforce the why for a mutation to relevant and not the what is doing.

So here we are removing details about the 'what' is failing about the tx.

We think that is better to follow a white box approach on mutations,
thus labels and error codes should be enough to describe the what.
Break haddock lines on 80 characters makes it easier to read on small or
split screens.
On each success, quickcheck increases the size parameter and this will
make generators create bigger values (if they honor the size).

The genValue generator was creating too big values to pass evaluation
within the budget, so we scale them down by a factor of 2.
On each success, quickcheck increases the size parameter and this will
make generators create bigger values (if they honor the size).

The genValue generator was creating too big values to pass evaluation
within the budget, so we scale them down by a factor of 2.
Chances to have this test produce a verification key equal to the
healthy one is very unlikely.
Anyhow, the changes make the mutation more readable and explicit,
thus the reason for this change.
This mutation also exists in Close so this also brings consistency
to the table between the two.
@ffakenz ffakenz force-pushed the mutations/explicit_expected_errors_2 branch from 12e94e8 to 29ac49e Compare March 10, 2023 11:11
@ffakenz ffakenz merged commit 9bed804 into master Mar 10, 2023
@ffakenz ffakenz deleted the mutations/explicit_expected_errors_2 branch March 10, 2023 12:31
@pgrange pgrange added this to the 0.10.0 milestone May 11, 2023
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.

Mutation test should be explicit about the expected error
4 participants