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

cardano-api: 8.29.1.0 -> 8.37.0.0 #1232

Merged
merged 5 commits into from
Feb 4, 2024
Merged

Conversation

locallycompact
Copy link
Contributor

@locallycompact locallycompact commented Jan 3, 2024

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

Copy link

github-actions bot commented Jan 4, 2024

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 2024-02-02 13:30:56.459649302 UTC
Max. memory units 14000000
Max. CPU units 10000000000
Max. tx size (kB) 16384

Script summary

Name Hash Size (Bytes)
νInitial 985245919fcc6c0c5cd116023cd2c947c43e80dcbb5075fe12433fbb 4072
νCommit 7cb20fa71eb4c563ca283566ebe0aa65859d96c3f8cba35c52c181fd 2043
νHead 7a36661f5c15e9f1783aeaab890812c59b7286cbbc6de762d3110772 8816
μHead 8b111ac12274e46314769295a1c5dcab1d260096fc469fd698065463* 3851
  • 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 4374 10.25 3.95 0.45
2 4575 12.47 4.79 0.49
3 4774 14.79 5.67 0.52
5 5179 19.33 7.40 0.59
10 6185 30.30 11.55 0.75
41 12417 98.96 37.57 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 534 11.37 4.44 0.30
2 722 15.04 6.07 0.35
3 912 18.85 7.75 0.40
5 1288 26.90 11.27 0.51
10 2217 49.55 20.97 0.80
19 3891 99.43 41.75 1.43

Cost of CollectCom Transaction

Parties UTxO (bytes) Tx size % max Mem % max CPU Min fee ₳
1 57 480 21.78 8.51 0.41
2 114 594 33.21 13.10 0.54
3 169 700 48.27 19.14 0.71
4 226 810 64.17 25.59 0.89
5 282 920 77.72 31.29 1.04
6 336 1035 97.41 39.36 1.27

Cost of Close Transaction

Parties Tx size % max Mem % max CPU Min fee ₳
1 543 16.72 7.70 0.36
2 629 17.59 8.62 0.38
3 844 19.77 10.57 0.42
5 1084 22.13 12.85 0.47
10 1920 30.04 20.30 0.62
50 8120 90.63 77.66 1.80

Cost of Contest Transaction

Parties Tx size % max Mem % max CPU Min fee ₳
1 592 20.22 8.98 0.40
2 714 21.76 10.32 0.43
3 938 24.24 12.39 0.48
5 1090 26.44 14.39 0.52
10 1932 36.02 22.60 0.69
47 7676 99.50 78.23 1.86

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 4304 19.03 8.18 0.55
2 4501 31.77 13.87 0.71
3 4581 46.46 20.31 0.87
4 4629 53.95 23.30 0.96
5 4837 79.50 34.76 1.26

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 4206 7.84 3.28 0.42
5 1 57 4239 8.86 3.96 0.44
5 5 285 4375 13.77 7.00 0.50
5 10 569 4544 19.92 10.81 0.59
5 20 1139 4884 32.01 18.35 0.76
5 30 1708 5225 44.52 26.07 0.93
5 40 2275 5562 57.12 33.83 1.10
5 50 2844 5901 69.35 41.43 1.27
5 75 4261 6744 99.95 60.45 1.69

End-To-End Benchmark Results

This page is intended to collect the latest end-to-end benchmarks results produced by Hydra's Continuous Integration system from the latest master code.

Please take those results with a grain of salt as they are currently produced from very limited cloud VMs and not controlled hardware. Instead of focusing on the absolute results, the emphasis should be on relative results, eg. how the timings for a scenario evolve as the code changes.

Generated at 2024-02-02 13:33:01.039541148 UTC

Baseline Scenario

Number of nodes 3
Number of txs 9000
Avg. Confirmation Time (ms) 22.761068672
P99 53.093179420000176ms
P95 31.44388305ms
P50 20.339135ms
Number of Invalid txs 0

Baseline Scenario

Number of nodes 1
Number of txs 3000
Avg. Confirmation Time (ms) 4.904204899
P99 8.77058835999996ms
P95 6.453911049999996ms
P50 4.756533ms
Number of Invalid txs 0

@ch1bo
Copy link
Member

ch1bo commented Jan 5, 2024

We consider this blocked by #1213 as this would make us not need to work around a changed ToJSON ShelleyTxCert upstream.

@ch1bo ch1bo force-pushed the master branch 8 times, most recently from 0a69b7e to 55a9077 Compare January 18, 2024 18:00
Copy link
Contributor

@v0d1ch v0d1ch left a comment

Choose a reason for hiding this comment

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

Had some questions, overall looks good 👍

--
-- NOTE: this function is partial and throws if given a Byron transaction for
-- which fees are necessarily implicit.
txFee' :: HasCallStack => Tx era -> Lovelace
Copy link
Contributor

Choose a reason for hiding this comment

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

Why don't we keep the HasCallStack here?

Copy link
Member

Choose a reason for hiding this comment

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

Because this function seemingly can be made total now

@@ -7,8 +7,9 @@ import Hydra.Cardano.Api.MaryEraOnwards (IsMaryEraOnwards (..))
-- | Inject some 'Value' into a 'TxOutValue'
mkTxOutValue ::
forall era.
IsShelleyBasedEra era =>
IsMaryEraOnwards era =>
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to keep both constraints here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Neither implies the other

@@ -331,8 +337,16 @@ queryUTxOByTxIn ::
queryUTxOByTxIn networkId socket queryPoint inputs =
runQueryExpr networkId socket queryPoint $ do
(AnyCardanoEra era) <- queryCurrentEraExpr
eraUTxO <- queryInEraExpr era $ QueryUTxO (QueryUTxOByTxIn (Set.fromList inputs))
pure $ UTxO.fromApi eraUTxO
(sbe :: ShelleyBasedEra e) <- liftIO $ assumeShelleyBasedEraOrThrow era
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this type annotation needed?

Copy link
Member

Choose a reason for hiding this comment

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

It should work without it.

@locallycompact locallycompact force-pushed the lc/cardano-api-8.37 branch 5 times, most recently from 6fa48f3 to 8404d4d Compare January 29, 2024 21:02
@ch1bo ch1bo self-requested a review January 30, 2024 10:39
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.

Overall fine changes, but we should avoid adding a witness to fromApi when we have type classes and also adding always 10ADA to genValue is dangerous IMO.

--
-- NOTE: this function is partial and throws if given a Byron transaction for
-- which fees are necessarily implicit.
txFee' :: HasCallStack => Tx era -> Lovelace
Copy link
Member

Choose a reason for hiding this comment

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

Because this function seemingly can be made total now

(IsMaryEraOnwards era, IsAlonzoEraOnwards era, IsBabbageEraOnwards era, IsShelleyBasedEra era) =>
Network ->
Plutus.TxOut ->
Maybe (TxOut CtxUTxO era)
fromPlutusTxOut network out = do
value <- TxOutValue maryEraOnwards <$> fromPlutusValue plutusValue
value <- shelleyBasedEraConstraints (shelleyBasedEra @era) $ TxOutValueShelleyBased (shelleyBasedEra @era) <$> (toLedgerValue (maryEraOnwards @era) <$> fromPlutusValue plutusValue)
Copy link
Member

Choose a reason for hiding this comment

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

Should: use mkTxOutValue

This seemingly has become a lot more complicated now (too complicated? smell?) and hence we should keep the complexity in one function only.

@@ -46,7 +46,7 @@ mkTxOutAutoBalance ::
ReferenceScript Era ->
TxOut CtxTx Era
mkTxOutAutoBalance pparams addr val dat ref =
let out = TxOut addr (TxOutValue maryEraOnwards val) dat ref
let out = TxOut addr (TxOutValueShelleyBased (shelleyBasedEra @Era) (toLedgerValue (maryEraOnwards @Era) val)) dat ref
Copy link
Member

Choose a reason for hiding this comment

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

Should: use mkTxOutValue

This seemingly has become a lot more complicated now (too complicated? smell?) and hence we should keep the complexity in one function only.

@@ -1,14 +1,13 @@
module Hydra.Cardano.Api.Value where

import Hydra.Cardano.Api.Prelude
import Hydra.Cardano.Api.Prelude hiding (toLedgerValue)
Copy link
Member

Choose a reason for hiding this comment

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

Should: use the upstream toLedgerValue if it exists now

@@ -159,7 +158,7 @@ chainSyncClient tracer networkId startingPoint observerHandler =
ClientStNext
{ recvMsgRollForward = \blockInMode tip -> ChainSyncClient $ do
case blockInMode of
BlockInMode _ (Block _header txs) BabbageEraInCardanoMode -> do
BlockInMode BabbageEra (Block _header txs) -> do
Copy link
Member

Choose a reason for hiding this comment

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

Nice.. they removed some redundancy witnessing.

@@ -87,35 +87,35 @@ min = UTxO . uncurry Map.singleton . Map.findMin . toMap
-- * Type Conversions

-- | Transforms a UTxO containing tx outs from any era into Babbage era.
fromApi :: Cardano.Api.UTxO era -> UTxO
fromApi (Cardano.Api.UTxO eraUTxO) =
fromApi :: forall era. ShelleyBasedEra era -> Cardano.Api.UTxO era -> UTxO
Copy link
Member

Choose a reason for hiding this comment

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

Must: not introduce witness values if we can avoid it

We do not need this witness value and we try hard to stick to a constraint based interface in hydra-cardano-api.

Suggested change
fromApi :: forall era. ShelleyBasedEra era -> Cardano.Api.UTxO era -> UTxO
fromApi :: IsShelleyBasedEra era => Cardano.Api.UTxO era -> UTxO

should be possible here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see how to do this. We are querying AnyCardanoEra at runtime. How do you prove this constraint holds?


assumeShelleyBasedEraOrThrow :: MonadThrow m => CardanoEra era -> m (ShelleyBasedEra era)
assumeShelleyBasedEraOrThrow era = do
x <- requireShelleyBasedEra era
Copy link
Member

Choose a reason for hiding this comment

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

Could: name this requireShelleyBasedEraOrThrow to indicate it's a thin wrapper around requireShelleyBasedEra

Copy link
Member

Choose a reason for hiding this comment

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

Could: follow the module style and use an Maybe discharging function like throwOnUnsupportedNtcVersion for Either

i.e. throwOnNonShelleyBasedEra :: MonadThrow m => Maybe (ShelleyBasedEra a) -> m (ShelleyBasedEra a)

@@ -331,8 +337,16 @@ queryUTxOByTxIn ::
queryUTxOByTxIn networkId socket queryPoint inputs =
runQueryExpr networkId socket queryPoint $ do
(AnyCardanoEra era) <- queryCurrentEraExpr
eraUTxO <- queryInEraExpr era $ QueryUTxO (QueryUTxOByTxIn (Set.fromList inputs))
pure $ UTxO.fromApi eraUTxO
(sbe :: ShelleyBasedEra e) <- liftIO $ assumeShelleyBasedEraOrThrow era
Copy link
Member

Choose a reason for hiding this comment

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

It should work without it.

hydra-node/src/Hydra/Ledger/Cardano.hs Show resolved Hide resolved
@ch1bo ch1bo force-pushed the lc/cardano-api-8.37 branch 2 times, most recently from c7c1321 to 2fe512a Compare January 31, 2024 11:43
locallycompact and others added 3 commits February 2, 2024 10:34
This works as long as all shelley based eras use the 'MaryValue era'
type from the cardano-ledger.
@locallycompact locallycompact force-pushed the lc/cardano-api-8.37 branch 2 times, most recently from 9054b74 to 288d5db Compare February 2, 2024 12:14
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.

Still some "Should"-haves, but in principle I do approve now (as we explored the situation with genValue and know why things are one way or the other now)

@@ -428,7 +429,7 @@ genAddressInEra networkId =
mkVkAddress networkId <$> genVerificationKey

genValue :: Gen Value
genValue = scale (`div` 10) $ fromLedgerValue <$> arbitrary
genValue = liftA2 (<>) (pure $ lovelaceToValue $ Lovelace 10_000_000) (scale (`div` 10) $ fromLedgerValue <$> arbitrary)
Copy link
Member

Choose a reason for hiding this comment

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

Should: not need to divide by 10 anymore and use a bit smaller value, 10ADA is a bit much and I think 1-2 ADA is "more realistic" (I know it was millions of ADA before)

@locallycompact locallycompact merged commit 2074ee5 into master Feb 4, 2024
19 of 20 checks passed
@locallycompact locallycompact deleted the lc/cardano-api-8.37 branch February 4, 2024 15:59
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

3 participants