@@ -10,31 +10,31 @@ module Testnet.Blockfrost
10
10
, blockfrostToGenesis
11
11
) where
12
12
13
- import Cardano.Ledger.BaseTypes (EpochInterval , Nonce , NonNegativeInterval ,
14
- UnitInterval , ProtVer (.. ), Version )
13
+ import Cardano.Ledger.Alonzo.Genesis (AlonzoGenesis (.. ))
14
+ import Cardano.Ledger.Alonzo.PParams (CoinPerWord )
15
+ import Cardano.Ledger.BaseTypes (EpochInterval , NonNegativeInterval , Nonce , ProtVer (.. ),
16
+ UnitInterval , Version )
15
17
import Cardano.Ledger.Coin (Coin )
16
- import Cardano.Ledger.Core (PParams (.. ))
17
18
import Cardano.Ledger.Compactible (toCompactPartial )
18
- import Cardano.Ledger.Shelley.Genesis (ShelleyGenesis (.. ))
19
- import Cardano.Ledger.Shelley.PParams (ShelleyPParams (.. ))
20
- import Cardano.Ledger.Alonzo.Genesis (AlonzoGenesis (.. ))
21
- import Cardano.Ledger.Alonzo.PParams (CoinPerWord )
22
- import Cardano.Ledger.Conway.Genesis (ConwayGenesis (.. ))
23
- import Cardano.Ledger.Conway.PParams (UpgradeConwayPParams (.. ),
24
- PoolVotingThresholds (.. ), DRepVotingThresholds (.. ))
25
- import Cardano.Ledger.Plutus (CostModel , CostModels , ExUnits (.. ),
26
- Language (.. ), Prices (.. ))
19
+ import Cardano.Ledger.Conway.Genesis (ConwayGenesis (.. ))
20
+ import Cardano.Ledger.Conway.PParams (DRepVotingThresholds (.. ),
21
+ PoolVotingThresholds (.. ), UpgradeConwayPParams (.. ))
22
+ import Cardano.Ledger.Core (PParams (.. ))
23
+ import Cardano.Ledger.Plutus (CostModel , CostModels , ExUnits (.. ), Language (.. ),
24
+ Prices (.. ))
27
25
import qualified Cardano.Ledger.Plutus.CostModels as CostModels
26
+ import Cardano.Ledger.Shelley.Genesis (ShelleyGenesis (.. ))
27
+ import Cardano.Ledger.Shelley.PParams (ShelleyPParams (.. ))
28
28
29
29
import Control.Applicative ((<|>) )
30
+ import Data.Aeson (FromJSON (.. ), withObject , (.:) )
30
31
import qualified Data.Aeson as Aeson
31
- import Data.Aeson (FromJSON (.. ), (.:) , withObject )
32
32
import qualified Data.Aeson.Types as Aeson
33
33
import qualified Data.Map.Strict as Map
34
- import Text.Read (readMaybe )
35
34
import Data.Scientific (Scientific )
36
35
import Data.Word (Word16 , Word32 )
37
36
import Numeric.Natural (Natural )
37
+ import Text.Read (readMaybe )
38
38
39
39
data BlockfrostParams = BlockfrostParams
40
40
{ -- Alonzo parameters
@@ -206,7 +206,7 @@ blockfrostToGenesis (alonzoGenesis', conwayGenesis', shelleyGenesis') Blockfrost
206
206
{ prMem = bfgPriceMem
207
207
, prSteps = bfgPriceSteps
208
208
}
209
- , agCostModels = bfgAlonzoCostModels
209
+ , agCostModels = {- TODO trimCostModelToInitial PlutusV2 -} bfgAlonzoCostModels
210
210
}
211
211
212
212
-- Conway Params
@@ -237,7 +237,7 @@ blockfrostToGenesis (alonzoGenesis', conwayGenesis', shelleyGenesis') Blockfrost
237
237
, ucppDRepDeposit = bfgDRepDeposit
238
238
, ucppDRepActivity = bfgDRepActivity
239
239
, ucppMinFeeRefScriptCostPerByte = bfgMinFeeRevScriptCostPerByte
240
- , ucppPlutusV3CostModel = bfgConwayCostModel
240
+ , ucppPlutusV3CostModel = trimCostModelToInitial PlutusV3 bfgConwayCostModel
241
241
}
242
242
conwayGenesis = conwayGenesis'{cgUpgradePParams= conwayParams}
243
243
@@ -265,3 +265,14 @@ blockfrostToGenesis (alonzoGenesis', conwayGenesis', shelleyGenesis') Blockfrost
265
265
, sppMinPoolCost = bfgMinPoolCost
266
266
}
267
267
shelleyGenesis = shelleyGenesis'{sgProtocolParams= shelleyParams}
268
+
269
+ -- | Trims cost model to the initial number of parameters. The cost models in geneses can't
270
+ -- have more parameters than the initial number.
271
+ trimCostModelToInitial :: Language -> CostModel -> CostModel
272
+ trimCostModelToInitial lang cm = do
273
+ let paramsCount = CostModels. costModelInitParamCount lang
274
+ either (error . (" Testnet.Blockfrost: Cost model trimming failure: " <> ) . show ) id
275
+ . CostModels. mkCostModel lang
276
+ . take paramsCount
277
+ $ CostModels. getCostModelParams cm
278
+
0 commit comments