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

Externally commit script utxo #903

Merged
merged 75 commits into from
Jun 27, 2023
Merged

Conversation

ffakenz
Copy link
Member

@ffakenz ffakenz commented Jun 2, 2023

This PR adds the option for our users to commit a script utxo to the Head externally, enabling script utxos to be made available in a Hydra head.

🌴 Extend the HTTP endpoint data types to accept utxo with an optional script witness (like datum, redeemer and script)

🌴 Generalize the Chain handler draftTx to build, balance and sign internally the drafted tx using utxos with script witnesses.

🌴 Reject commit transaction requests including UTxO addressed to the internal wallet.


  • CHANGELOG updated or not needed
  • Documentation updated or not needed
  • Haddocks updated or not needed
  • No new TODOs introduced or explained herafter

@ffakenz ffakenz changed the base branch from master to external-commits-regular-utxo June 2, 2023 10:34
@github-actions
Copy link

github-actions bot commented Jun 2, 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-06-27 10:26:19.614800836 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 4739 14.59 5.75 0.52
2 4951 16.11 6.29 0.54
3 5151 17.97 6.97 0.57
5 5561 22.49 8.67 0.64
10 6587 35.72 13.71 0.83
38 12329 99.31 37.59 1.77

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 972 24.75 9.88 0.46
5 1351 36.15 14.59 0.61
10 2287 71.73 28.85 1.04
13 2852 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.81 10.80 0.49
2 114 1136 43.24 16.93 0.67
3 171 1456 61.11 24.07 0.88
4 226 1783 82.12 32.49 1.13

Cost of Close Transaction

Parties Tx size % max Mem % max CPU Min fee ₳
1 572 16.77 6.99 0.36
2 804 19.97 9.56 0.42
3 970 21.37 10.82 0.44
5 1299 24.46 13.45 0.50
10 2124 31.12 19.62 0.64
50 8725 86.87 69.87 1.74

Cost of Contest Transaction

Parties Tx size % max Mem % max CPU Min fee ₳
1 710 24.84 10.83 0.46
2 842 26.06 11.84 0.48
3 1006 28.20 13.38 0.52
5 1336 31.63 16.12 0.58
10 2161 39.77 22.80 0.73
44 7780 98.46 69.53 1.79

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 4927 23.42 9.88 0.63
2 5175 36.59 15.53 0.79
3 5497 53.47 22.88 0.99
4 5816 73.48 31.59 1.23
5 5997 91.18 39.10 1.43

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 4761 8.66 3.57 0.46
5 1 57 4798 10.06 4.39 0.47
5 5 285 4945 15.64 7.69 0.55
5 10 570 5124 22.61 11.82 0.64
5 20 1138 5478 36.56 20.07 0.83
5 30 1707 5844 50.52 28.33 1.02
5 40 2277 6200 64.49 36.60 1.21
5 50 2848 6564 78.46 44.87 1.40
5 65 3700 7102 99.42 57.28 1.68

@ffakenz ffakenz force-pushed the external-commits-regular-utxo branch from c828a59 to 602d762 Compare June 5, 2023 09:14
@ffakenz ffakenz force-pushed the ensemble/external-commit-from-script branch from d387977 to 7d66857 Compare June 5, 2023 09:24
@ffakenz ffakenz marked this pull request as ready for review June 5, 2023 09:35
@github-actions
Copy link

github-actions bot commented Jun 5, 2023

Test Results

317 tests  +4   311 ✔️ +4   25m 18s ⏱️ + 5m 34s
107 suites +1       6 💤 ±0 
    5 files   ±0       0 ±0 

Results for commit cc4ab7d. ± Comparison against base commit 6a7c79a.

This pull request removes 4 and adds 8 tests. Note that renamed tests count towards both.
Hydra.API.RestServer/JSON encoding of (ReasonablySized (DraftCommitTxRequest (Tx BabbageEra))) ‑ allows to encode values with aeson and read them back
Hydra.API.RestServer/JSON encoding of (ReasonablySized (DraftCommitTxRequest (Tx BabbageEra))) ‑ produces the same JSON as is found in golden/ReasonablySized (DraftCommitTxRequest (Tx BabbageEra)).json
Hydra.API.RestServer/JSON encoding of (ReasonablySized (DraftCommitTxResponse (Tx BabbageEra))) ‑ allows to encode values with aeson and read them back
Hydra.API.RestServer/JSON encoding of (ReasonablySized (DraftCommitTxResponse (Tx BabbageEra))) ‑ produces the same JSON as is found in golden/ReasonablySized (DraftCommitTxResponse (Tx BabbageEra)).json
Hydra.API.RestServer ‑ Validate /commit publish api schema
Hydra.API.RestServer ‑ Validate /commit subscribe api schema
Hydra.API.RestServer/JSON encoding of (ReasonablySized DraftCommitTxRequest) ‑ allows to encode values with aeson and read them back
Hydra.API.RestServer/JSON encoding of (ReasonablySized DraftCommitTxRequest) ‑ produces the same JSON as is found in golden/ReasonablySized DraftCommitTxRequest.json
Hydra.API.RestServer/JSON encoding of (ReasonablySized DraftCommitTxResponse) ‑ allows to encode values with aeson and read them back
Hydra.API.RestServer/JSON encoding of (ReasonablySized DraftCommitTxResponse) ‑ produces the same JSON as is found in golden/ReasonablySized DraftCommitTxResponse.json
Test.EndToEnd/End-to-end on Cardano devnet/single party hydra head ‑ can't commit externally with internal wallet utxo
Test.EndToEnd/End-to-end on Cardano devnet/single party hydra head ‑ commits from external with script utxo

♻️ This comment has been updated with latest results.

@ffakenz ffakenz force-pushed the ensemble/external-commit-from-script branch from 7d66857 to dc70b10 Compare June 5, 2023 17:52
@v0d1ch v0d1ch force-pushed the external-commits-regular-utxo branch from f999ecb to 408bbb4 Compare June 6, 2023 07:18
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.

Leaving some comments to discuss together

hydra-cluster/src/Hydra/Cluster/Scenarios.hs Outdated Show resolved Hide resolved
hydra-cluster/src/Hydra/Cluster/Scenarios.hs Outdated Show resolved Hide resolved
hydra-cluster/src/Hydra/Cluster/Scenarios.hs Outdated Show resolved Hide resolved
hydra-cluster/src/Hydra/Cluster/Scenarios.hs Outdated Show resolved Hide resolved
hydra-node/src/Hydra/Chain.hs Outdated Show resolved Hide resolved
hydra-node/src/Hydra/API/RestServer.hs Outdated Show resolved Hide resolved
@v0d1ch v0d1ch force-pushed the external-commits-regular-utxo branch 2 times, most recently from 5a204be to 408bbb4 Compare June 6, 2023 07:50
@ffakenz ffakenz force-pushed the ensemble/external-commit-from-script branch from dc70b10 to dc1436d Compare June 6, 2023 17:52
@ch1bo ch1bo mentioned this pull request Jun 7, 2023
11 tasks
@v0d1ch v0d1ch force-pushed the external-commits-regular-utxo branch from 9a691df to f37c49a Compare June 7, 2023 07:47
@ch1bo ch1bo force-pushed the ensemble/external-commit-from-script branch from 44bbe6f to abe493c Compare June 7, 2023 08:13
@ch1bo ch1bo assigned v0d1ch and ch1bo Jun 7, 2023
@ch1bo ch1bo force-pushed the ensemble/external-commit-from-script branch 2 times, most recently from 5f97795 to 21658cb Compare June 7, 2023 09:32
@v0d1ch v0d1ch force-pushed the external-commits-regular-utxo branch from 0490cd3 to d8a1942 Compare June 7, 2023 09:56
@ch1bo ch1bo force-pushed the ensemble/external-commit-from-script branch from 21658cb to 9d98f9b Compare June 7, 2023 10:14
Base automatically changed from external-commits-regular-utxo to master June 7, 2023 10:19
@ffakenz ffakenz force-pushed the ensemble/external-commit-from-script branch 3 times, most recently from 572f5d3 to 22709ab Compare June 7, 2023 10:31
@v0d1ch v0d1ch force-pushed the ensemble/external-commit-from-script branch from 459c74e to 402f605 Compare June 8, 2023 09:48
@ffakenz ffakenz force-pushed the ensemble/external-commit-from-script branch 4 times, most recently from e39ac2c to 8726171 Compare June 8, 2023 11:50
v0d1ch and others added 13 commits June 27, 2023 12:07
Also remove tests that were not covering all cases properly
These expand the original UTxO argument to a UTxO including witnesses.
This way, we can pack the script UTxOs into the same value and the
commit transaction creation will just work™.
There is no point in mixing multiple utxo into such an integrated
scenario. Let's keep the test case on point for committing a script into
a head end-to-end. Should we desire more combinations, a "lower level"
test suite should be exercised.
Note that it's note safe to use unsafeHashableScriptData when the data
was already serialized (as in the FromJSON instance).
Seemingly the previously used prop_validateToJSON was not checking the
spec correctly (anymore) as there were at least two issues in the
logs.yaml specification.
- It caused one test to fail and from the error outcome I could not
see the actuall stack trace printed.
@pgrange pgrange force-pushed the ensemble/external-commit-from-script branch from 39b3e5c to cc4ab7d Compare June 27, 2023 10:07
abailly-iohk pushed a commit that referenced this pull request Jun 27, 2023
To prepare for #903 we want to be able to combine outcomes
of type `Wait` and `NewState`.

This commit allows for that and provide a more cohesive
Outcome algebra.
@v0d1ch v0d1ch merged commit 55ccab1 into master Jun 27, 2023
36 of 38 checks passed
@v0d1ch v0d1ch deleted the ensemble/external-commit-from-script branch June 27, 2023 12:40
pgrange added a commit that referenced this pull request Jun 27, 2023
To prepare for #903 we want to be able to combine outcomes
of type `Wait` and `NewState`.

This commit allows for that and provide a more cohesive
Outcome algebra.
abailly-iohk pushed a commit that referenced this pull request Jun 30, 2023
To prepare for #903 we want to be able to combine outcomes
of type `Wait` and `NewState`.

This commit allows for that and provide a more cohesive
Outcome algebra.
abailly-iohk pushed a commit that referenced this pull request Jun 30, 2023
To prepare for #903 we want to be able to combine outcomes
of type `Wait` and `NewState`.

This commit allows for that and provide a more cohesive
Outcome algebra.
abailly-iohk pushed a commit that referenced this pull request Jul 3, 2023
To prepare for #903 we want to be able to combine outcomes
of type `Wait` and `NewState`.

This commit allows for that and provide a more cohesive
Outcome algebra.
abailly-iohk pushed a commit that referenced this pull request Jul 3, 2023
To prepare for #903 we want to be able to combine outcomes
of type `Wait` and `NewState`.

This commit allows for that and provide a more cohesive
Outcome algebra.
abailly-iohk pushed a commit that referenced this pull request Jul 4, 2023
To prepare for #903 we want to be able to combine outcomes
of type `Wait` and `NewState`.

This commit allows for that and provide a more cohesive
Outcome algebra.
abailly-iohk pushed a commit that referenced this pull request Jul 4, 2023
To prepare for #903 we want to be able to combine outcomes
of type `Wait` and `NewState`.

This commit allows for that and provide a more cohesive
Outcome algebra.
abailly-iohk pushed a commit that referenced this pull request Jul 5, 2023
To prepare for #903 we want to be able to combine outcomes
of type `Wait` and `NewState`.

This commit allows for that and provide a more cohesive
Outcome algebra.
abailly-iohk pushed a commit that referenced this pull request Jul 5, 2023
To prepare for #903 we want to be able to combine outcomes
of type `Wait` and `NewState`.

This commit allows for that and provide a more cohesive
Outcome algebra.
ffakenz pushed a commit that referenced this pull request Jul 5, 2023
To prepare for #903 we want to be able to combine outcomes
of type `Wait` and `NewState`.

This commit allows for that and provide a more cohesive
Outcome algebra.
abailly-iohk pushed a commit that referenced this pull request Jul 5, 2023
To prepare for #903 we want to be able to combine outcomes
of type `Wait` and `NewState`.

This commit allows for that and provide a more cohesive
Outcome algebra.
abailly-iohk pushed a commit that referenced this pull request Jul 7, 2023
To prepare for #903 we want to be able to combine outcomes
of type `Wait` and `NewState`.

This commit allows for that and provide a more cohesive
Outcome algebra.
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.

None yet

4 participants