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

The hydra node can publish hydra scripts via blockfrost using --blockfrost #1907

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

v0d1ch
Copy link
Contributor

@v0d1ch v0d1ch commented Mar 20, 2025

✦ ➜  nix run .#hydra-node -- publish-scripts \
    --blockfrost "/home/v0d1ch/code/hydra/blockfrost.txt" \
    --cardano-signing-key hydra-cluster/config/credentials/alice.sk
evaluation warning: Explicitly set the ABI version of 'webkitgtk'
f5857bddd32b73d14fb6619f0f841050dc5a32ce80ba6644a9b71b3f5a15598d,2bab813d9de51311cb0f3797cc82d5a04126724d16d145768faf4a613341099c,5220d48789de0b105fb94788f5278628c04fcb1bdbbe02260a80d8fe064ada7c



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

@v0d1ch v0d1ch self-assigned this Mar 20, 2025
@v0d1ch v0d1ch force-pushed the handle-transaction-building-using-blockfrost-api branch from 61346f9 to 2df6034 Compare March 20, 2025 12:10
Copy link

github-actions bot commented Mar 20, 2025

Transaction cost differences

No cost or size differences found

Copy link

github-actions bot commented Mar 20, 2025

Transaction 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 2025-03-31 12:50:51.69778145 UTC
Max. memory units 14000000
Max. CPU units 10000000000
Max. tx size (kB) 16384

Script summary

Name Hash Size (Bytes)
νInitial c8a101a5c8ac4816b0dceb59ce31fc2258e387de828f02961d2f2045 2652
νCommit 61458bc2f297fff3cc5df6ac7ab57cefd87763b0b7bd722146a1035c 685
νHead 0e35115a2c7c13c68ecd8d74e4987c04d4539e337643be20bb3274bd 14756
μHead 57166715eadb8d3135964325c016eea546c21e1c0aae974ca67df9a5* 5541
νDeposit ae01dade3a9c346d5c93ae3ce339412b90a0b8f83f94ec6baa24e30c 1102
  • The minting policy hash is only usable for comparison. As the script is parameterized, the actual script is unique per head.

Init transaction costs

Parties Tx size % max Mem % max CPU Min fee ₳
1 6093 10.98 3.42 0.53
2 6292 13.47 4.19 0.57
3 6496 15.50 4.80 0.60
5 6895 20.19 6.25 0.66
10 7907 30.97 9.53 0.82
40 13935 98.39 30.22 1.78

Commit transaction costs

This uses ada-only outputs for better comparability.

UTxO Tx size % max Mem % max CPU Min fee ₳
1 559 2.44 1.16 0.20
2 741 3.38 1.73 0.22
3 919 4.36 2.33 0.24
5 1279 6.41 3.60 0.28
10 2180 12.13 7.25 0.40
54 10074 98.61 68.52 1.88

CollectCom transaction costs

Parties UTxO (bytes) Tx size % max Mem % max CPU Min fee ₳
1 57 525 26.44 7.58 0.44
2 114 636 35.86 10.21 0.54
3 170 747 45.83 12.98 0.65
4 228 858 50.75 14.59 0.70
5 282 969 65.05 18.37 0.85
6 341 1081 78.87 22.07 0.99
7 393 1192 78.47 22.41 1.00
8 450 1307 85.04 24.47 1.07
9 504 1414 97.18 27.79 1.20

Cost of Increment Transaction

Parties Tx size % max Mem % max CPU Min fee ₳
1 1818 25.03 8.22 0.49
2 1886 25.98 9.08 0.51
3 2149 29.83 11.08 0.57
5 2279 30.48 12.50 0.59
10 3161 44.25 20.39 0.79
38 7231 97.74 56.20 1.66

Cost of Decrement Transaction

Parties Tx size % max Mem % max CPU Min fee ₳
1 601 23.71 7.54 0.42
2 696 23.72 8.18 0.43
3 958 28.33 10.14 0.49
5 1150 29.79 11.85 0.53
10 2023 41.95 18.55 0.71
40 6393 98.84 54.24 1.62

Close transaction costs

Parties Tx size % max Mem % max CPU Min fee ₳
1 658 30.95 9.68 0.50
2 790 32.84 10.92 0.53
3 925 34.67 12.15 0.56
5 1267 37.10 14.40 0.61
10 2244 50.11 22.32 0.81
35 5824 98.78 54.49 1.60

Contest transaction costs

Parties Tx size % max Mem % max CPU Min fee ₳
1 704 35.95 11.01 0.55
2 888 38.77 12.63 0.59
3 954 40.28 13.63 0.62
5 1216 44.67 16.27 0.68
10 2121 58.96 24.38 0.90
26 4469 97.36 47.01 1.47

Abort transaction costs

There is some variation due to the random mixture of initial and already committed outputs.

Parties Tx size % max Mem % max CPU Min fee ₳
1 5985 28.29 9.32 0.71
2 6145 38.57 12.75 0.82
3 6334 49.12 16.25 0.94
4 6322 56.26 18.54 1.02
5 6516 66.45 21.94 1.13
6 6581 72.21 23.79 1.19
7 6792 80.44 26.57 1.29
8 6902 88.34 29.19 1.38

FanOut transaction costs

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 ₳
10 5 283 6259 30.97 10.82 0.75
10 10 569 6431 41.88 15.03 0.88
10 20 1137 6769 62.72 23.14 1.12
10 30 1707 7111 84.22 31.47 1.37
10 37 2107 7350 97.56 36.72 1.53

End-to-end benchmark results

This page is intended to collect the latest end-to-end benchmark results produced by Hydra's continuous integration (CI) system from the latest master code.

Please note that these results are approximate as they are currently produced from limited cloud VMs and not controlled hardware. Rather than focusing on the absolute results, the emphasis should be on relative results, such as how the timings for a scenario evolve as the code changes.

Generated at 2025-03-31 12:54:13.610174901 UTC

Baseline Scenario

Number of nodes 1
Number of txs 300
Avg. Confirmation Time (ms) 4.676077710
P99 7.373029939999992ms
P95 5.5698067ms
P50 4.391006000000001ms
Number of Invalid txs 0

Memory data

Time Used Free
2025-03-31 12:52:57.400434775 UTC 867M 6564M
2025-03-31 12:53:02.400420049 UTC 1005M 6367M
2025-03-31 12:53:07.400370056 UTC 1005M 6366M
2025-03-31 12:53:12.4003507 UTC 1017M 6353M
2025-03-31 12:53:17.400363058 UTC 1019M 6351M
2025-03-31 12:53:22.40033081 UTC 1019M 6351M

Three local nodes

Number of nodes 3
Number of txs 900
Avg. Confirmation Time (ms) 32.738731897
P99 70.66948986000001ms
P95 55.69975874999999ms
P50 29.281999ms
Number of Invalid txs 0

Memory data

Time Used Free
2025-03-31 12:53:35.602454826 UTC 933M 6447M
2025-03-31 12:53:40.602693724 UTC 1199M 6180M
2025-03-31 12:53:45.603705754 UTC 1249M 6073M
2025-03-31 12:53:50.602613631 UTC 1259M 6016M
2025-03-31 12:53:55.602588537 UTC 1260M 6007M
2025-03-31 12:54:00.60249345 UTC 1265M 6001M
2025-03-31 12:54:05.602669264 UTC 1267M 5999M
2025-03-31 12:54:10.602575873 UTC 1267M 5998M

@v0d1ch v0d1ch requested a review from a team March 20, 2025 15:55
@v0d1ch v0d1ch force-pushed the handle-transaction-building-using-blockfrost-api branch from 64da63c to e13dbf2 Compare March 24, 2025 07:43
@v0d1ch v0d1ch mentioned this pull request Mar 24, 2025
4 tasks
@v0d1ch v0d1ch changed the title Handle transaction building using blockfrost api The hydra node can publish hydra scripts via blockfrost using --blockfrost Mar 25, 2025
@v0d1ch v0d1ch force-pushed the handle-transaction-building-using-blockfrost-api branch from 6e05445 to 6d70b75 Compare March 25, 2025 08:51
@ch1bo
Copy link
Member

ch1bo commented Mar 25, 2025

Unfortunately I had to use a fork of the official library since I could not find a workaround for overlapping json instance https://github.com/blockfrost/blockfrost-haskell/blob/1a5360a51a1b61a14ffac4827f30c1ed525dedf3/blockfrost-api/src/Blockfrost/Types/Cardano/Pools.hs#L170

@v0d1ch What issue concretely did you encounter with the instance overlap? i.e. which of our instances would overlap with this one?

@v0d1ch
Copy link
Contributor Author

v0d1ch commented Mar 25, 2025

@ch1bo json instance for Message type https://github.com/cardano-scaling/hydra/blob/master/hydra-node/src/Hydra/Network/Message.hs#L48 specifically incrementUTxO field

@ch1bo
Copy link
Member

ch1bo commented Mar 25, 2025

@ch1bo json instance for Message type https://github.com/cardano-scaling/hydra/blob/master/hydra-node/src/Hydra/Network/Message.hs#L48 specifically incrementUTxO field

Okay. This works for me:

diff --git a/hydra-node/src/Hydra/Network/Message.hs b/hydra-node/src/Hydra/Network/Message.hs
index b7ea84b91d..14c4441a70 100644
--- a/hydra-node/src/Hydra/Network/Message.hs
+++ b/hydra-node/src/Hydra/Network/Message.hs
@@ -45,8 +45,8 @@ data Message tx
 
 deriving stock instance IsTx tx => Eq (Message tx)
 deriving stock instance IsTx tx => Show (Message tx)
-deriving anyclass instance IsTx tx => ToJSON (Message tx)
-deriving anyclass instance IsTx tx => FromJSON (Message tx)
+deriving anyclass instance {-# OVERLAPPABLE #-} IsTx tx => ToJSON (Message tx)
+deriving anyclass instance {-# OVERLAPPABLE #-} IsTx tx => FromJSON (Message tx)
 
 instance ArbitraryIsTx tx => Arbitrary (Message tx) where
   arbitrary = genericArbitrary

We should add an explanation though and ideally we would have more fine-grained constraints in the future as that would make it more clear that Maybe (UTxOType tx) is the issue here (it depends on how UTxoType tx is instantiated and as soon as one concrete Maybe Type is in scope this can overlap).

@v0d1ch
Copy link
Contributor Author

v0d1ch commented Mar 25, 2025

Hmm... I already tried using OVERLAPPABLE but it didn't do the trick. I'll report back when I get to it.

@v0d1ch
Copy link
Contributor Author

v0d1ch commented Mar 25, 2025

Yup, this is what I used to get too:

src/Hydra/Network/Message.hs:48:1: error: [GHC-43085]
    • Overlapping instances for ToJSON (Maybe (UTxOType tx))
        arising from a use of ‘aeson-2.2.3.0:Data.Aeson.Types.ToJSON.$dmtoJSON’
      Matching instance:
        instance ToJSON a => ToJSON (Maybe a)
          -- Defined in ‘aeson-2.2.3.0:Data.Aeson.Types.ToJSON’
        ...plus one instance involving out-of-scope types
          Potentially matching instance:
            instance [overlap ok] ToJSON
                                    (Maybe
                                       blockfrost-api-0.12.1.0:Blockfrost.Types.Cardano.Pools.PoolMetadata)
      (The choice depends on the instantiation of ‘tx’
       and the result of evaluating ‘UTxOType’
       To pick the first instance above, use IncoherentInstances
       when compiling the other instance declarations)
    • In the expression:
        aeson-2.2.3.0:Data.Aeson.Types.ToJSON.$dmtoJSON @(Message tx)
      In an equation for ‘toJSON’:
          toJSON
            = aeson-2.2.3.0:Data.Aeson.Types.ToJSON.$dmtoJSON @(Message tx)
      When typechecking the code for ‘toJSON’
        in a derived instance for ‘ToJSON (Message tx)’:
        To see the code I am typechecking, use -ddump-deriv
      In the instance declaration for ‘ToJSON (Message tx)’
   |
48 | deriving anyclass instance {-# OVERLAPPABLE #-} IsTx tx => ToJSON (Message tx)
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Hydra/Network/Message.hs:49:1: error: [GHC-43085]
    • Overlapping instances for FromJSON (Maybe (UTxOType tx))
        arising from a use of ‘aeson-2.2.3.0:Data.Aeson.Types.FromJSON.$dmparseJSON’
      Matching instance:
        instance FromJSON a => FromJSON (Maybe a)
          -- Defined in ‘aeson-2.2.3.0:Data.Aeson.Types.FromJSON’
        ...plus one instance involving out-of-scope types
          Potentially matching instance:
            instance [overlap ok] FromJSON
                                    (Maybe
                                       blockfrost-api-0.12.1.0:Blockfrost.Types.Cardano.Pools.PoolMetadata)
      (The choice depends on the instantiation of ‘tx’
       and the result of evaluating ‘UTxOType’
       To pick the first instance above, use IncoherentInstances
       when compiling the other instance declarations)
    • In the expression:
        aeson-2.2.3.0:Data.Aeson.Types.FromJSON.$dmparseJSON @(Message tx)
      In an equation for ‘parseJSON’:
          parseJSON
            = aeson-2.2.3.0:Data.Aeson.Types.FromJSON.$dmparseJSON
                @(Message tx)
      When typechecking the code for ‘parseJSON’
        in a derived instance for ‘FromJSON (Message tx)’:
        To see the code I am typechecking, use -ddump-deriv
      In the instance declaration for ‘FromJSON (Message tx)’
   |
49 | deriving anyclass instance {-# OVERLAPPABLE #-} IsTx tx => FromJSON (Message tx)

@v0d1ch v0d1ch force-pushed the handle-transaction-building-using-blockfrost-api branch 2 times, most recently from 95a1748 to d59b491 Compare March 25, 2025 14:41
@v0d1ch v0d1ch linked an issue Mar 25, 2025 that may be closed by this pull request
2 tasks
@v0d1ch v0d1ch force-pushed the handle-transaction-building-using-blockfrost-api branch 2 times, most recently from e09c820 to f58c56b Compare March 27, 2025 17:26
ffakenz and others added 10 commits March 31, 2025 14:46
Signed-off-by: Sasha Bogicevic <[email protected]>
Signed-off-by: Sasha Bogicevic <[email protected]>
We submit a tx and wait to see it returned from blockfrost. Then
we get the tx output utxo and use that for the next tx.

Signed-off-by: Sasha Bogicevic <[email protected]>
There is an json instance for (Maybe PoolMetadata) which
overlaps with our instances for Maybe types. This is a ugly
workaround but I couldn't find anything else that works.

Signed-off-by: Sasha Bogicevic <[email protected]>
Remove extra diff and pragma

Signed-off-by: Sasha Bogicevic <[email protected]>
Introduce a function to re-map from blockfrost to ledger GenesisParameters

Signed-off-by: Sasha Bogicevic <[email protected]>
@v0d1ch v0d1ch force-pushed the handle-transaction-building-using-blockfrost-api branch from f58c56b to f5b5a55 Compare March 31, 2025 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In review 👀
3 participants