Skip to content

Commit

Permalink
Merge #2818
Browse files Browse the repository at this point in the history
2818: Reduce reliance on Plutus API r=newhoggy a=newhoggy



Co-authored-by: John Ky <john.ky@iohk.io>
  • Loading branch information
iohk-bors[bot] and newhoggy authored Jun 14, 2021
2 parents 09b8522 + b785f9d commit 9de5e9c
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 30 deletions.
4 changes: 2 additions & 2 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ source-repository-package
source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-ledger-specs
tag: d6b3d6b8ed16b2c69684fa44218f4e7060f166d3
--sha256: 1afsvxv8a24rpd3inr4m323l1dx5xg6kmfnjkzb6jw72ykcgpsyz
tag: 810298f87d91a8ab6573d10710baedf35825a3b5
--sha256: 0msp9wm8vvz2yj5nzp3r48cf3b423w0qj8f10acamcyp6wfvlr61
subdir:
alonzo/impl
byron/chain/executable-spec
Expand Down
8 changes: 3 additions & 5 deletions cardano-api/src/Cardano/Api/Address.hs
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ import qualified Data.Text.Encoding as Text

import Control.Applicative

import Cardano.Ledger.Crypto (StandardCrypto)

import qualified Shelley.Spec.Ledger.Address as Shelley
import qualified Shelley.Spec.Ledger.Credential as Shelley

import Cardano.Api.Eras
import Cardano.Api.Hash
import Cardano.Api.HasTypeProxy
Expand All @@ -90,7 +85,10 @@ import Cardano.Api.SerialiseBech32
import Cardano.Api.SerialiseRaw
import qualified Cardano.Chain.Common as Byron
import qualified Cardano.Ledger.BaseTypes as Shelley
import Cardano.Ledger.Crypto (StandardCrypto)

import qualified Shelley.Spec.Ledger.Address as Shelley
import qualified Shelley.Spec.Ledger.Credential as Shelley

-- ----------------------------------------------------------------------------
-- Address Serialisation
Expand Down
7 changes: 3 additions & 4 deletions cardano-api/src/Cardano/Api/Orphans.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import qualified Cardano.Ledger.Mary.Value as Mary
import qualified Cardano.Ledger.SafeHash as SafeHash
import qualified Cardano.Ledger.Shelley.Constraints as Shelley
import qualified Ouroboros.Consensus.Shelley.Eras as Consensus
import qualified Plutus.V1.Ledger.Api as Plutus
import qualified Shelley.Spec.Ledger.API as Shelley
import qualified Shelley.Spec.Ledger.Delegation.Certificates as Shelley
import qualified Shelley.Spec.Ledger.EpochBoundary as ShelleyEpoch
Expand Down Expand Up @@ -343,18 +342,18 @@ instance FromJSON Alonzo.AlonzoGenesis where
collateralPercentage <- o .: "collateralPercentage"
maxCollateralInputs <- o .: "maxCollateralInputs"
case cModels of
Nothing -> case Plutus.defaultCostModelParams of
Nothing -> case Alonzo.defaultCostModel of
Just m -> return Alonzo.AlonzoGenesis
{ Alonzo.coinsPerUTxOWord
, Alonzo.costmdls = Map.singleton Alonzo.PlutusV1 (Alonzo.CostModel m)
, Alonzo.costmdls = Map.singleton Alonzo.PlutusV1 m
, Alonzo.prices
, Alonzo.maxTxExUnits
, Alonzo.maxBlockExUnits
, Alonzo.maxValSize
, Alonzo.collateralPercentage
, Alonzo.maxCollateralInputs
}
Nothing -> fail "Failed to extract the cost model params from Plutus.defaultCostModel"
Nothing -> fail "Failed to extract the cost model params from defaultCostModel"
Just costmdls -> return Alonzo.AlonzoGenesis
{ Alonzo.coinsPerUTxOWord
, Alonzo.costmdls
Expand Down
8 changes: 2 additions & 6 deletions cardano-api/src/Cardano/Api/ProtocolParameters.hs
Original file line number Diff line number Diff line change
Expand Up @@ -748,10 +748,6 @@ validateCostModel :: PlutusScriptVersion lang
-> CostModel
-> Either InvalidCostModel ()
validateCostModel PlutusScriptV1 (CostModel m)
-- TODO alonzo: the ledger library should export something for this, e.g. like its
-- existing checkCostModel function. We should not need to depend on the
-- Plutus library directly. That makes too many assumptions about what the
-- ledger library is doing.
| Alonzo.validateCostModelParams m = Right ()
| otherwise = Left (InvalidCostModel (CostModel m))

Expand Down Expand Up @@ -976,7 +972,7 @@ toAlonzoPParamsUpdate
maybeToStrictMaybe protocolUpdateProtocolVersion
, Alonzo._minPoolCost = toShelleyLovelace <$>
maybeToStrictMaybe protocolUpdateMinPoolCost
, Alonzo._coinsPerUTxOWord= toShelleyLovelace <$>
, Alonzo._coinsPerUTxOWord = toShelleyLovelace <$>
maybeToStrictMaybe protocolUpdateUTxOCostPerWord
, Alonzo._costmdls = if Map.null protocolUpdateCostModels
then Ledger.SNothing
Expand Down Expand Up @@ -1270,7 +1266,7 @@ toAlonzoPParams ProtocolParameters {
protocolParamTreasuryCut

-- New params in Alonzo:
, Alonzo._coinsPerUTxOWord= toShelleyLovelace utxoCostPerWord
, Alonzo._coinsPerUTxOWord = toShelleyLovelace utxoCostPerWord
, Alonzo._costmdls = toAlonzoCostModels protocolParamCostModels
, Alonzo._prices = toAlonzoPrices prices
, Alonzo._maxTxExUnits = toAlonzoExUnits maxTxExUnits
Expand Down
4 changes: 2 additions & 2 deletions cardano-api/src/Cardano/Api/TxBody.hs
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,14 @@ import qualified Cardano.Chain.UTxO as Byron
import qualified Cardano.Crypto.Hashing as Byron

import qualified Cardano.Ledger.AuxiliaryData as Ledger (hashAuxiliaryData)
import Cardano.Ledger.BaseTypes (StrictMaybe (..), maybeToStrictMaybe)
import qualified Cardano.Ledger.Core as Core
import qualified Cardano.Ledger.Core as Ledger
import qualified Cardano.Ledger.Era as Ledger
import qualified Cardano.Ledger.Keys as Shelley
import qualified Cardano.Ledger.SafeHash as SafeHash
import qualified Cardano.Ledger.Shelley.Constraints as Ledger

import Cardano.Ledger.BaseTypes (StrictMaybe (..), maybeToStrictMaybe)
import qualified Cardano.Ledger.Keys as Shelley
import qualified Shelley.Spec.Ledger.Address as Shelley
import qualified Shelley.Spec.Ledger.Credential as Shelley
import qualified Shelley.Spec.Ledger.Genesis as Shelley
Expand Down
1 change: 0 additions & 1 deletion cardano-cli/cardano-cli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ library
, ouroboros-consensus-shelley
, ouroboros-network
, parsec
, plutus-core
, plutus-ledger-api
, shelley-spec-ledger
, small-steps
Expand Down
12 changes: 5 additions & 7 deletions cardano-cli/src/Cardano/CLI/Shelley/Run/Genesis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ import Ouroboros.Consensus.BlockchainTime (SystemStart (..))
import Ouroboros.Consensus.Shelley.Eras (StandardShelley)
import Ouroboros.Consensus.Shelley.Node (ShelleyGenesisStaking (..))

import qualified Plutus.V1.Ledger.Api as Plutus

import qualified Cardano.Ledger.Alonzo.Genesis as Alonzo
import qualified Cardano.Ledger.Alonzo.Language as Alonzo
import qualified Cardano.Ledger.Alonzo.Scripts as Alonzo
Expand Down Expand Up @@ -784,13 +782,13 @@ updateTemplate (SystemStart start)
, sgsStake = Ledger._poolId <$> poolSpecs
}
}
cModel = case Plutus.defaultCostModelParams of
Just m ->
cModel = case Alonzo.defaultCostModel of
Just (Alonzo.CostModel m) ->
if Alonzo.validateCostModelParams m
then Map.singleton Alonzo.PlutusV1 $ Alonzo.CostModel m
else panic "updateTemplate: Plutus.defaultCostModel is invalid"
then Map.singleton Alonzo.PlutusV1 (Alonzo.CostModel m)
else panic "updateTemplate: defaultCostModel is invalid"

Nothing -> panic "updateTemplate: Could not extract cost model params from Plutus.defaultCostModel"
Nothing -> panic "updateTemplate: Could not extract cost model params from defaultCostModel"
alonzoGenesis = Alonzo.AlonzoGenesis
{ Alonzo.coinsPerUTxOWord = toShelleyLovelace coinsPerUTxOWord
, Alonzo.costmdls = cModel
Expand Down
4 changes: 1 addition & 3 deletions cardano-cli/src/Cardano/CLI/Shelley/Run/Pool.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ import qualified Data.ByteString.Char8 as BS

import Cardano.Api
import Cardano.Api.Shelley

import qualified Shelley.Spec.Ledger.Slot as Shelley

import Cardano.CLI.Shelley.Commands
import Cardano.CLI.Shelley.Key (InputDecodeError, VerificationKeyOrFile,
readVerificationKeyOrFile)
import Cardano.CLI.Types (OutputFormat (..))

import qualified Shelley.Spec.Ledger.Slot as Shelley

data ShelleyPoolCmdError
= ShelleyPoolCmdReadFileError !(FileError TextEnvelopeError)
Expand Down

0 comments on commit 9de5e9c

Please sign in to comment.