Skip to content

Commit 126de8e

Browse files
authored
Release Consensus packages for Node 8.12.1 (#1166)
This PR technically violates the ReleaseProcess.md rules. But it's trivially so: the last commit of this PR is supposed to be isolated in a separate PR.
2 parents d2ecdfe + 49fc268 commit 126de8e

File tree

25 files changed

+207
-25
lines changed

25 files changed

+207
-25
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Ouroboros Consensus
22

3-
[![consensus](https://img.shields.io/badge/ouroboros--consensus-0.19.0.0-blue)](https://chap.intersectmbo.org/package/ouroboros-consensus-0.19.0.0/)
4-
[![diffusion](https://img.shields.io/badge/ouroboros--consensus--diffusion-0.17.0.0-blue)](https://chap.intersectmbo.org/package/ouroboros-consensus-diffusion-0.17.0.0/)
3+
[![consensus](https://img.shields.io/badge/ouroboros--consensus-0.19.1.0-blue)](https://chap.intersectmbo.org/package/ouroboros-consensus-0.19.1.0/)
4+
[![diffusion](https://img.shields.io/badge/ouroboros--consensus--diffusion-0.17.0.1-blue)](https://chap.intersectmbo.org/package/ouroboros-consensus-diffusion-0.17.0.1/)
55
[![protocol](https://img.shields.io/badge/ouroboros--consensus--protocol-0.9.0.1-blue)](https://chap.intersectmbo.org/package/ouroboros-consensus-protocol-0.9.0.1/)
6-
[![cardano](https://img.shields.io/badge/ouroboros--consensus--cardano-0.17.0.0-blue)](https://chap.intersectmbo.org/package/ouroboros-consensus-cardano-0.17.0.0/)
6+
[![cardano](https://img.shields.io/badge/ouroboros--consensus--cardano-0.17.1.0-blue)](https://chap.intersectmbo.org/package/ouroboros-consensus-cardano-0.17.1.0/)
77
[![sop-extras](https://img.shields.io/badge/sop--extras-0.2.0.0-blue)](https://chap.intersectmbo.org/package/sop-extras-0.2.0.0/)
88
[![strict-sop-core](https://img.shields.io/badge/strict--sop--core-0.1.1.0-blue)](https://chap.intersectmbo.org/package/strict-sop-core-0.1.1.0/)
99

cabal.project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ index-state:
1616
-- Bump this if you need newer packages from Hackage
1717
, hackage.haskell.org 2024-06-23T23:01:13Z
1818
-- Bump this if you need newer packages from CHaP
19-
, cardano-haskell-packages 2024-06-18T14:00:00Z
19+
, cardano-haskell-packages 2024-06-26T21:39:58Z
2020

2121
packages:
2222
ouroboros-consensus

flake.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ouroboros-consensus-cardano/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
# Changelog entries
44

5+
<a id='changelog-0.17.1.0'></a>
6+
## 0.17.1.0 — 2024-06-26
7+
8+
### Non-Breaking
9+
10+
- Enforce Conway minfees for ref scripts in the mempool, even in Babbage
11+
512
<a id='changelog-0.17.0.0'></a>
613
## 0.17.0.0 — 2024-06-19
714

ouroboros-consensus-cardano/ouroboros-consensus-cardano.cabal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 3.0
22
name: ouroboros-consensus-cardano
3-
version: 0.17.0.0
3+
version: 0.17.1.0
44
synopsis:
55
The instantation of the Ouroboros consensus layer used by Cardano
66

@@ -140,7 +140,7 @@ library
140140
cardano-ledger-babbage ^>=1.8.1,
141141
cardano-ledger-binary ^>=1.3.3,
142142
cardano-ledger-byron ^>=1.0.1,
143-
cardano-ledger-conway ^>=1.15,
143+
cardano-ledger-conway ^>=1.15.1,
144144
cardano-ledger-core ^>=1.13,
145145
cardano-ledger-mary ^>=1.6.1,
146146
cardano-ledger-shelley ^>=1.12,

ouroboros-consensus-cardano/src/byron/Ouroboros/Consensus/Byron/Ledger/Mempool.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ instance LedgerSupportsMempool ByronBlock where
143143

144144
txForgetValidated = forgetValidatedByronTx
145145

146+
txRefScriptSize _ _ _ = 0
147+
146148
data instance TxId (GenTx ByronBlock)
147149
= ByronTxId !Utxo.TxId
148150
| ByronDlgId !Delegation.CertificateId

ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Eras.hs

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
{-# LANGUAGE GADTs #-}
66
{-# LANGUAGE LambdaCase #-}
77
{-# LANGUAGE MultiParamTypeClasses #-}
8+
{-# LANGUAGE NumericUnderscores #-}
89
{-# LANGUAGE ScopedTypeVariables #-}
910
{-# LANGUAGE TypeApplications #-}
1011
{-# LANGUAGE TypeFamilies #-}
@@ -28,6 +29,7 @@ module Ouroboros.Consensus.Shelley.Eras (
2829
, StandardMary
2930
, StandardShelley
3031
-- * Shelley-based era
32+
, BabbageTxDict (..)
3133
, ConwayEraGovDict (..)
3234
, ShelleyBasedEra (..)
3335
, WrapTx (..)
@@ -45,6 +47,7 @@ import Cardano.Ledger.Alonzo (AlonzoEra)
4547
import qualified Cardano.Ledger.Alonzo.Rules as Alonzo
4648
import qualified Cardano.Ledger.Alonzo.Translation as Alonzo
4749
import qualified Cardano.Ledger.Alonzo.Tx as Alonzo
50+
import qualified Cardano.Ledger.Api as SL
4851
import qualified Cardano.Ledger.Api.Era as L
4952
import Cardano.Ledger.Babbage (BabbageEra)
5053
import qualified Cardano.Ledger.Babbage.Rules as Babbage
@@ -57,6 +60,8 @@ import qualified Cardano.Ledger.Conway.Rules as Conway
5760
import qualified Cardano.Ledger.Conway.Rules as SL
5861
(ConwayLedgerPredFailure (..))
5962
import qualified Cardano.Ledger.Conway.Translation as Conway
63+
import qualified Cardano.Ledger.Conway.Tx as SL
64+
import qualified Cardano.Ledger.Conway.UTxO as SL
6065
import Cardano.Ledger.Core as Core
6166
import Cardano.Ledger.Crypto (StandardCrypto)
6267
import Cardano.Ledger.Keys (DSignable, Hash)
@@ -68,11 +73,13 @@ import Cardano.Ledger.Shelley.Core as Core
6873
import qualified Cardano.Ledger.Shelley.LedgerState as SL
6974
import qualified Cardano.Ledger.Shelley.Rules as SL
7075
import qualified Cardano.Ledger.Shelley.Transition as SL
76+
import qualified Cardano.Ledger.Val as SL
7177
import qualified Cardano.Protocol.TPraos.API as SL
7278
import Control.Monad.Except
7379
import Control.State.Transition (PredicateFailure)
7480
import Data.Data (Proxy (Proxy))
7581
import Data.List.NonEmpty (NonEmpty ((:|)))
82+
import Lens.Micro ((^.))
7683
import NoThunks.Class (NoThunks)
7784
import Ouroboros.Consensus.Ledger.SupportsMempool
7885
(WhetherToIntervene (..))
@@ -162,6 +169,16 @@ class ( Core.EraSegWits era
162169
-- | Whether the era has an instance of 'CG.ConwayEraGov'
163170
getConwayEraGovDict :: proxy era -> Maybe (ConwayEraGovDict era)
164171

172+
getBabbageTxDict :: proxy era -> Maybe (BabbageTxDict era)
173+
174+
data BabbageTxDict era where
175+
BabbageTxDict ::
176+
SL.BabbageEraTxBody era
177+
=> (Integer -> Integer -> SL.ApplyTxError era)
178+
-- ^ Construct an arbitrary ledger error with two integers as its
179+
-- payload.
180+
-> BabbageTxDict era
181+
165182
data ConwayEraGovDict era where
166183
ConwayEraGovDict :: CG.ConwayEraGov era => ConwayEraGovDict era
167184

@@ -172,7 +189,7 @@ isBeforeConway _ =
172189
-- | The default implementation of 'applyShelleyBasedTx', a thin wrapper around
173190
-- 'SL.applyTx'
174191
defaultApplyShelleyBasedTx ::
175-
ShelleyBasedEra era
192+
forall era. ShelleyBasedEra era
176193
=> SL.Globals
177194
-> SL.LedgerEnv era
178195
-> SL.LedgerState era
@@ -183,12 +200,51 @@ defaultApplyShelleyBasedTx ::
183200
( SL.LedgerState era
184201
, SL.Validated (Core.Tx era)
185202
)
186-
defaultApplyShelleyBasedTx globals ledgerEnv mempoolState _wti tx =
203+
defaultApplyShelleyBasedTx globals ledgerEnv mempoolState _wti tx = do
204+
refScriptPredicate
187205
SL.applyTx
188206
globals
189207
ledgerEnv
190208
mempoolState
191209
tx
210+
where
211+
refScriptPredicate = case getBabbageTxDict (Proxy @era) of
212+
Nothing -> pure ()
213+
Just (BabbageTxDict mkError)
214+
-- Reject it if it has more than 100 kibibytes of ref script.
215+
| refScriptsSize > totalRefScriptsSizeLimit
216+
-> throwError $ mkError
217+
-- As we are reusing an existing error message, we add a large
218+
-- number to make users running into this are productively irritated
219+
-- and post this error message somewhere where they can receive
220+
-- help/context.
221+
(toInteger refScriptsSize + 1_000_000_000)
222+
(toInteger totalRefScriptsSizeLimit + 1_000_000_000)
223+
-- Reject it if it has more than 50 kibibytes of ref script and does not
224+
-- satisfy an additional fee as calculated in the table below.
225+
| refScriptsSize > freeOfChargeRefScriptsBytes
226+
, actualFee < expectedFee
227+
-> throwError $ mkError
228+
-- See above for why we add a large constant.
229+
(SL.unCoin actualFee + 100_000_000)
230+
(SL.unCoin expectedFee + 100_000_000)
231+
| otherwise -> pure ()
232+
where
233+
totalRefScriptsSizeLimit :: Int
234+
totalRefScriptsSizeLimit = 100 * 1024
235+
236+
freeOfChargeRefScriptsBytes :: Int
237+
freeOfChargeRefScriptsBytes = 50 * 1024
238+
239+
actualFee = tx ^. SL.bodyTxL . SL.feeTxBodyL
240+
expectedFee = minFee SL.<+> refScriptsFee
241+
where
242+
minFee = SL.getMinFeeTx (SL.ledgerPp ledgerEnv) tx 0
243+
refScriptsFee = SL.tierRefScriptFee 1.2 25600 15 refScriptsSize
244+
245+
refScriptsSize = SL.txNonDistinctRefScriptsSize utxo tx
246+
247+
utxo = SL.utxosUtxo . SL.lsUTxOState $ mempoolState
192248

193249
defaultGetConwayEraGovDict :: proxy era -> Maybe (ConwayEraGovDict era)
194250
defaultGetConwayEraGovDict _ = Nothing
@@ -199,34 +255,52 @@ instance (SL.PraosCrypto c, DSignable c (Hash c EraIndependentTxBody))
199255

200256
getConwayEraGovDict = defaultGetConwayEraGovDict
201257

258+
getBabbageTxDict _ = Nothing
259+
202260
instance (SL.PraosCrypto c, DSignable c (Hash c EraIndependentTxBody))
203261
=> ShelleyBasedEra (AllegraEra c) where
204262
applyShelleyBasedTx = defaultApplyShelleyBasedTx
205263

206264
getConwayEraGovDict = defaultGetConwayEraGovDict
207265

266+
getBabbageTxDict _ = Nothing
267+
208268
instance (SL.PraosCrypto c, DSignable c (Hash c EraIndependentTxBody))
209269
=> ShelleyBasedEra (MaryEra c) where
210270
applyShelleyBasedTx = defaultApplyShelleyBasedTx
211271

212272
getConwayEraGovDict = defaultGetConwayEraGovDict
213273

274+
getBabbageTxDict _ = Nothing
275+
214276
instance (SL.PraosCrypto c, DSignable c (Hash c EraIndependentTxBody))
215277
=> ShelleyBasedEra (AlonzoEra c) where
216278
applyShelleyBasedTx = applyAlonzoBasedTx
217279

218280
getConwayEraGovDict = defaultGetConwayEraGovDict
219281

282+
getBabbageTxDict _ = Nothing
283+
220284
instance (Praos.PraosCrypto c) => ShelleyBasedEra (BabbageEra c) where
221285
applyShelleyBasedTx = applyAlonzoBasedTx
222286

223287
getConwayEraGovDict = defaultGetConwayEraGovDict
224288

289+
getBabbageTxDict _ = Just $ BabbageTxDict $ \a b ->
290+
SL.ApplyTxError
291+
$ pure
292+
$ SL.UtxowFailure
293+
$ Babbage.UtxoFailure
294+
$ Babbage.AlonzoInBabbageUtxoPredFailure
295+
$ Alonzo.MaxTxSizeUTxO a b
296+
225297
instance (Praos.PraosCrypto c) => ShelleyBasedEra (ConwayEra c) where
226298
applyShelleyBasedTx = applyAlonzoBasedTx
227299

228300
getConwayEraGovDict _ = Just ConwayEraGovDict
229301

302+
getBabbageTxDict _ = Nothing
303+
230304
applyAlonzoBasedTx :: forall era.
231305
( ShelleyBasedEra era,
232306
SupportsTwoPhaseValidation era,

ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Mempool.hs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import Cardano.Ledger.Alonzo.Tx (totExUnits)
4242
import Cardano.Ledger.Binary (Annotator (..), DecCBOR (..),
4343
EncCBOR (..), FromCBOR (..), FullByteString (..),
4444
ToCBOR (..), toPlainDecoder)
45+
import qualified Cardano.Ledger.Conway.UTxO as SL
4546
import qualified Cardano.Ledger.Core as SL (txIdTxBody)
4647
import Cardano.Ledger.Crypto (Crypto)
4748
import qualified Cardano.Ledger.SafeHash as SL
@@ -147,6 +148,12 @@ instance ShelleyCompatible proto era
147148

148149
txForgetValidated (ShelleyValidatedTx txid vtx) = ShelleyTx txid (SL.extractTx vtx)
149150

151+
txRefScriptSize _cfg st (ShelleyTx _ tx) = case getBabbageTxDict (Proxy @era) of
152+
Nothing -> 0
153+
Just BabbageTxDict{} -> SL.txNonDistinctRefScriptsSize utxo tx
154+
where
155+
utxo = SL.getUTxO . tickedShelleyLedgerState $ st
156+
150157
mkShelleyTx :: forall era proto. ShelleyBasedEra era => Tx era -> GenTx (ShelleyBlock proto era)
151158
mkShelleyTx tx = ShelleyTx (SL.txIdTxBody @era (tx ^. bodyTxL)) tx
152159

ouroboros-consensus-cardano/src/unstable-byronspec/Ouroboros/Consensus/ByronSpec/Ledger/Mempool.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,5 @@ instance LedgerSupportsMempool ByronSpecBlock where
5656
txInBlockSize = const 0
5757

5858
txForgetValidated = forgetValidatedByronSpecGenTx
59+
60+
txRefScriptSize _cfg _tlst _tx = 0

ouroboros-consensus-diffusion/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
# Changelog entries
44

5+
<a id='changelog-0.17.0.1'></a>
6+
## 0.17.0.1 — 2024-06-26
7+
8+
### Patch
9+
10+
- Add trivial `txRefScriptSize` definitions
11+
512
<a id='changelog-0.17.0.0'></a>
613
## 0.17.0.0 — 2024-06-19
714

0 commit comments

Comments
 (0)