@@ -31,7 +31,9 @@ import qualified Cardano.Crypto.Hash.Class as CryptoClass
3131import Cardano.Crypto.Raw (Raw )
3232import qualified Cardano.Ledger.Api.Era as L
3333import qualified Cardano.Ledger.Api.Transition as SL
34+ import Cardano.Ledger.BaseTypes (boundRational , unsafeNonZero )
3435import Cardano.Ledger.Core (TxOut )
36+ import Cardano.Ledger.Dijkstra.PParams
3537import qualified Cardano.Ledger.Shelley.LedgerState as Shelley.LedgerState
3638import qualified Cardano.Ledger.Shelley.UTxO as Shelley.UTxO
3739import Cardano.Ledger.TxIn (TxIn )
@@ -47,7 +49,7 @@ import qualified Data.ByteString as BS
4749import qualified Data.Compact as Compact
4850import Data.Map.Strict (Map )
4951import qualified Data.Map.Strict as Map
50- import Data.Maybe (fromJust )
52+ import Data.Maybe (fromJust , fromMaybe )
5153import Data.SOP.BasicFunctors
5254import Data.SOP.Functors
5355import Data.SOP.Strict
@@ -157,9 +159,11 @@ instance HasProtocolInfo (CardanoBlock StandardCrypto) where
157159 genesisConway <-
158160 either (error . show ) return
159161 =<< Aeson. eitherDecodeFileStrict' (conwayGenesisPath cc)
160- genesisDijkstra <-
161- either (error . show ) return
162- =<< Aeson. eitherDecodeFileStrict' (dijkstraGenesisPath cc)
162+ genesisDijkstra <- case dijkstraGenesisPath cc of
163+ Nothing -> pure emptyDijkstraGenesis
164+ Just fp ->
165+ either (error . show ) return
166+ =<< Aeson. eitherDecodeFileStrict' fp
163167
164168 let transCfg =
165169 SL. mkLatestTransitionConfig genesisShelley genesisAlonzo genesisConway genesisDijkstra
@@ -182,6 +186,18 @@ instance HasProtocolInfo (CardanoBlock StandardCrypto) where
182186 initialNonce
183187 (cfgHardForkTriggers cc)
184188
189+ -- | An empty Dijkstra genesis to be provided when none is specified in the config.
190+ emptyDijkstraGenesis :: SL. DijkstraGenesis
191+ emptyDijkstraGenesis =
192+ let upgradePParamsDef =
193+ UpgradeDijkstraPParams
194+ { udppMaxRefScriptSizePerBlock = 1048576
195+ , udppMaxRefScriptSizePerTx = 204800
196+ , udppRefScriptCostStride = unsafeNonZero 25600
197+ , udppRefScriptCostMultiplier = fromMaybe (error " impossible" ) $ boundRational 1.2
198+ }
199+ in SL. DijkstraGenesis {SL. dgUpgradePParams = upgradePParamsDef}
200+
185201data CardanoConfig = CardanoConfig
186202 { requiresNetworkMagic :: RequiresNetworkMagic
187203 -- ^ @RequiresNetworkMagic@ field
@@ -197,7 +213,7 @@ data CardanoConfig = CardanoConfig
197213 -- ^ @AlonzoGenesisFile@ field
198214 , conwayGenesisPath :: FilePath
199215 -- ^ @ConwayGenesisFile@ field
200- , dijkstraGenesisPath :: FilePath
216+ , dijkstraGenesisPath :: Maybe FilePath
201217 -- ^ @DijkstraGenesisFile@ field
202218 , cfgHardForkTriggers :: CardanoHardForkTriggers
203219 -- ^ @Test*HardForkAtEpoch@ for each Shelley era
@@ -210,7 +226,7 @@ instance AdjustFilePaths CardanoConfig where
210226 , shelleyGenesisPath = f $ shelleyGenesisPath cc
211227 , alonzoGenesisPath = f $ alonzoGenesisPath cc
212228 , conwayGenesisPath = f $ conwayGenesisPath cc
213- , dijkstraGenesisPath = f $ dijkstraGenesisPath cc
229+ , dijkstraGenesisPath = f <$> dijkstraGenesisPath cc
214230 -- Byron, Shelley, Alonzo, and Conway are the only eras that have genesis
215231 -- data. The actual genesis block is a Byron block, therefore we needed a
216232 -- genesis file. To transition to Shelley, we needed to add some additional
@@ -241,7 +257,7 @@ instance Aeson.FromJSON CardanoConfig where
241257
242258 conwayGenesisPath <- v Aeson. .: " ConwayGenesisFile"
243259
244- dijkstraGenesisPath <- v Aeson. .: " DijkstraGenesisFile"
260+ dijkstraGenesisPath <- v Aeson. .:? " DijkstraGenesisFile"
245261
246262 triggers <- do
247263 let parseTrigger ::
0 commit comments