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

Allow commit txs with multiple UTxO #774

Merged
merged 12 commits into from
May 26, 2023
Merged

Allow commit txs with multiple UTxO #774

merged 12 commits into from
May 26, 2023

Conversation

ch1bo
Copy link
Member

@ch1bo ch1bo commented Mar 15, 2023

🔢 Extends the specification and the on-chain protocol to record any number of outputs committed in a commit tx into a Hydra head.

🔢 Changes (and simplifies) multiple call sites from Maybe Commit to [Commit].

🔢 Adds a mutation test where a commit is tried to be left out.

🔢 This theoretically increases the likelihood that some party locks up too many UTxO and makes the head not even abortable (see #699). Practically, this issue already exists with reference scripts and big datums.

🔢 Removes the MoreThanOneUTxOCommitted error as it's not needed anymore.


TODO:

  • Update the spec / alternative version
  • Think about the fact that this makes the head not abortable more likely (see Always abortable Head #699)
    • While it's a bit simpler to shoot yourself in the foot, the risk is already there. Let's not worry and rather fix it with Always abortable Head #699 or so.
  • Add/update tests which leverage the fact that there are now more than one committed UTxO (new mutations?)
  • CHANGELOG updated
  • Documentation updated
  • Added and/or updated haddocks
  • No new TODOs introduced or explained herafter

@github-actions
Copy link

github-actions bot commented Mar 15, 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-05-26 10:49:57.567607076 UTC
Max. memory units 14000000
Max. CPU units 10000000000
Max. tx size (kB) 16384

Script summary

Name Hash Size (Bytes)
νInitial 2212a4ee618434b9b2f366d7c330dbdfb5c7072e793a850fd0de6ddd 4294
νCommit 69e1ccf9ad73dc6d37a5bc8de5aec86f3c4c1710fe5fd334e0e16b18 2124
νHead 8ae095dca4d14a1b8edffb37faa6c84ec60340fbf389a62f027e0b76 9355
μHead 33642a45c7fbb955ce1704ef09229bb211bf9af9980530db28c6aafe* 4148
  • The minting policy hash is only usable for comparison. As the script is parameterized, the actual script is unique per Head.

Cost of Init Transaction

Parties Tx size % max Mem % max CPU Min fee ₳
1 4742 14.66 5.78 0.52
2 4946 14.52 5.63 0.53
3 5149 17.99 6.98 0.57
5 5562 22.24 8.56 0.64
10 6587 35.05 13.43 0.82
37 12128 98.69 37.43 1.75

Cost of Commit Transaction

This is using ada-only outputs for better comparability.

UTxO Tx size % max Mem % max CPU Min fee ₳
1 599 14.98 5.74 0.34
2 787 19.66 7.73 0.40
3 974 24.75 9.88 0.46
5 1350 36.15 14.59 0.61
10 2287 71.73 28.85 1.04
13 2838 98.11 39.18 1.35

Cost of CollectCom Transaction

Parties UTxO (bytes) Tx size % max Mem % max CPU Min fee ₳
1 57 814 27.63 10.73 0.49
2 114 1136 43.67 17.09 0.68
3 171 1457 61.71 24.31 0.89
4 227 1775 82.19 32.54 1.13

Cost of Close Transaction

Parties Tx size % max Mem % max CPU Min fee ₳
1 639 18.58 8.31 0.39
2 805 19.97 9.56 0.42
3 977 21.37 10.82 0.44
5 1295 24.16 13.33 0.50
10 1471 25.68 11.14 0.50
50 8725 87.17 69.99 1.74

Cost of Contest Transaction

Parties Tx size % max Mem % max CPU Min fee ₳
1 668 24.77 10.63 0.46
2 841 26.49 12.01 0.49
3 999 28.20 13.38 0.52
5 1343 31.63 16.12 0.58
10 2153 40.20 22.97 0.74
44 7765 98.03 69.37 1.78

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 4713 19.19 7.79 0.57
2 5175 36.59 15.53 0.79
3 5355 49.09 20.77 0.93
4 5676 68.40 29.20 1.16
5 6136 95.88 41.39 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 4764 8.66 3.57 0.46
5 1 57 4800 10.06 4.39 0.47
5 5 285 4944 15.64 7.69 0.55
5 10 569 5127 22.61 11.82 0.64
5 20 1139 5484 36.56 20.07 0.83
5 30 1710 5846 50.52 28.33 1.02
5 40 2274 6204 64.49 36.60 1.21
5 50 2847 6563 78.46 44.87 1.40
5 65 3697 7099 99.42 57.28 1.68

@github-actions
Copy link

github-actions bot commented Mar 15, 2023

Test Results

307 tests   - 11   301 ✔️  - 11   19m 32s ⏱️ +33s
104 suites  -   4       6 💤 ±  0 
    5 files    -   1       0 ±  0 

Results for commit 3e4eb95. ± Comparison against base commit ed0c22d.

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
Contributor

@ffakenz ffakenz left a comment

Choose a reason for hiding this comment

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

This looks very good! 💯

What is left for me is:

  • a test to validate now multiple commits are allowed.
  • have a mutation to validate if any of the multiple commits is not healthy.
  • update api documentation to mention now we support multiple commits.
  • maybe explain and mention the limits around this.

Also what is not clear to me is how, from API can I commit multiple UTxO.
Seems the user must provide a big one instead of multiple, is that intended?

hydra-cluster/test/Test/DirectChainSpec.hs Show resolved Hide resolved
hydra-node/test/Hydra/Chain/Direct/TxSpec.hs Show resolved Hide resolved
hydra-plutus/src/Hydra/Contract/Initial.hs Outdated Show resolved Hide resolved
hydra-node/src/Hydra/Chain/Direct/Tx.hs Show resolved Hide resolved
hydra-node/test/Hydra/Chain/Direct/Contract/Commit.hs Outdated Show resolved Hide resolved
hydra-node/exe/tx-cost/TxCost.hs Outdated Show resolved Hide resolved
@ch1bo ch1bo force-pushed the master branch 6 times, most recently from 3d95dc4 to 270b957 Compare March 24, 2023 09:44
@ch1bo ch1bo force-pushed the ch1bo/multiple-commits branch 3 times, most recently from 82c032f to f903bc3 Compare April 25, 2023 14:38
@ch1bo ch1bo force-pushed the ch1bo/multiple-commits branch from 664d298 to f722d9a Compare May 16, 2023 08:56
@ch1bo ch1bo self-assigned this May 16, 2023
@ch1bo ch1bo marked this pull request as ready for review May 16, 2023 09:25
@GeorgeFlerovsky
Copy link

This PR works well for us at hydra-auction. Very helpful and no issues. 🙏

@ch1bo ch1bo requested review from ffakenz, pgrange, v0d1ch and a user May 17, 2023 06:54
@ch1bo ch1bo added this to the 0.11.0 milestone May 17, 2023
@ch1bo ch1bo force-pushed the ch1bo/multiple-commits branch 3 times, most recently from 168ab40 to 7814a8e Compare May 24, 2023 12:39
@ch1bo ch1bo force-pushed the ch1bo/multiple-commits branch from 2709d99 to 1e5032f Compare May 24, 2023 13:29
@ch1bo ch1bo removed their assignment May 24, 2023
ch1bo added 2 commits May 25, 2023 16:48
This changes the Redeemer and Datum types of commitTx to be [TxOutRef]
instead of Maybe TxOutRef and generalize the checks on- and off-chain to
work on a list of committed UTxO instead of an optional, single one.
Now that we allow multiple commits, we should improve the benchmark to
show the (sad) cost of this.
ch1bo added 9 commits May 25, 2023 16:48
This change is mostly fixing compilation issues. Not all tests are
testing the fact that there now may be more than one commit.
This also requires generating new golden files which had this error
included.
The picture for commitTx was not yet updated in this.
The limit of comitted UTxO is not in place anymore. Also, reorder two
bullets to group known issues related to commits.
Still ada-only (for better control of size), but within a range of 0-5
outputs are committed.

The scenario is static per compilation (constant seed, but depends on
generators), but currently UTxO with lengths of [0,2,4] is collected
from three parties.
Often we only modify a single one of them.
This is a bit artifical, but ensures we check for completeness of
recorded commits.
@ch1bo ch1bo force-pushed the ch1bo/multiple-commits branch from 116081f to 6b18f81 Compare May 25, 2023 14:48
@ch1bo ch1bo force-pushed the ch1bo/multiple-commits branch from 6b18f81 to 3e4eb95 Compare May 26, 2023 10:35
@ch1bo ch1bo merged commit 85e650c into master May 26, 2023
@ch1bo ch1bo deleted the ch1bo/multiple-commits branch May 26, 2023 11:47
@ch1bo ch1bo added the 💬 feature A feature on our roadmap label Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💬 feature A feature on our roadmap
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants