Skip to content

Commit

Permalink
Point node deps at alonzo pre-release branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimbo4350 committed May 11, 2021
1 parent 3094f7b commit 56cdaba
Show file tree
Hide file tree
Showing 24 changed files with 245 additions and 94 deletions.
12 changes: 6 additions & 6 deletions cabal.project
Expand Up @@ -120,8 +120,8 @@ source-repository-package
source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-ledger-specs
tag: e8f19bcc9c8f405131cb95ca6ada26b2b4eac638
--sha256: 1v36d3lyhmadzj0abdfsppjna7n7llzqzp9ikx5yq28l2kda2f1p
tag: 46577026a5f3972258d675b193e0afc929d3905a
--sha256: 1daapjqkdmgmh0k61amim8k94vfca4z0pzbm1iv1y9ycyk0jbbxa
subdir:
alonzo/impl
byron/chain/executable-spec
Expand Down Expand Up @@ -179,8 +179,8 @@ source-repository-package
source-repository-package
type: git
location: https://github.com/input-output-hk/ouroboros-network
tag: 9b279c7548ee549e1ed755cd1acb69b6e69d0c7b
--sha256: 0d7bk9vzmhhb2z4ns2qw7f1vz6lr186m98sh8wvrnfpxk3z86dxb
tag: aad909cfba4e23c623121457f5ef84e5c41a9b62
--sha256: 0657a5wlszpkpql7yskw09gpwqwqvw3izx4an03l2yd608g169si
subdir:
io-sim
io-sim-classes
Expand All @@ -198,8 +198,8 @@ source-repository-package
source-repository-package
type: git
location: https://github.com/input-output-hk/plutus
tag: ffc1768f5be7af66d8d745a31c9c6a77c5c55104
--sha256: 0qwj0xnvkrxsmfw883w3idfnhj073d5swcxl54zs7ay4fgwrm4c2
tag: 1578ab92f9ac389c68aa915370bf38ad7b4a75e9
--sha256: 1fnpv2l7zs1in1hgdpb85zv8l37kjcclz0zjzqmll391gbdsb99f
subdir:
plutus-core
plutus-ledger-api
Expand Down
11 changes: 8 additions & 3 deletions cardano-api/src/Cardano/Api/Block.hs
Expand Up @@ -60,12 +60,15 @@ import qualified Ouroboros.Consensus.Cardano.Block as Consensus
import qualified Ouroboros.Consensus.Cardano.ByronHFC as Consensus
import qualified Ouroboros.Consensus.HardFork.Combinator as Consensus
import qualified Ouroboros.Consensus.HardFork.Combinator.Degenerate as Consensus
import qualified Ouroboros.Consensus.Shelley.ShelleyHFC as Consensus
import qualified Ouroboros.Consensus.Shelley.Ledger as Consensus
import qualified Ouroboros.Consensus.Shelley.ShelleyHFC as Consensus

import qualified Cardano.Chain.Block as Byron
import qualified Cardano.Chain.UTxO as Byron

import qualified Cardano.Ledger.Core as Core
import qualified Cardano.Ledger.Era as Ledger
import Cardano.Ledger.SafeHash (SafeToHash)
import qualified Shelley.Spec.Ledger.BlockChain as Shelley

import Cardano.Api.Eras
Expand Down Expand Up @@ -145,7 +148,9 @@ getBlockTxs (ShelleyBlock shelleyEra Consensus.ShelleyBlock{Consensus.shelleyBlo
ShelleyBasedEraAllegra -> go
ShelleyBasedEraMary -> go
where
go :: Consensus.ShelleyBasedEra (ShelleyLedgerEra era) => [Tx era]
go :: Ledger.TxSeq (ShelleyLedgerEra era) ~ Shelley.TxSeq (ShelleyLedgerEra era)
=> SafeToHash (Core.Witnesses (ShelleyLedgerEra era))
=> Consensus.ShelleyBasedEra (ShelleyLedgerEra era) => [Tx era]
go = case shelleyBlockRaw of Shelley.Block _header (Shelley.TxSeq txs) -> [ShelleyTx shelleyEra x | x <- toList txs]

-- ----------------------------------------------------------------------------
Expand Down Expand Up @@ -192,7 +197,7 @@ fromConsensusBlock CardanoMode =
Consensus.BlockMary b' ->
BlockInMode (ShelleyBlock ShelleyBasedEraMary b')
MaryEraInCardanoMode

Consensus.BlockAlonzo _ -> error "fromConsensusBlock: Alonzo not implemented yet"

-- ----------------------------------------------------------------------------
-- Block headers
Expand Down
11 changes: 1 addition & 10 deletions cardano-api/src/Cardano/Api/Fees.hs
Expand Up @@ -20,8 +20,6 @@ import Numeric.Natural
import qualified Cardano.Binary as CBOR
import qualified Cardano.Chain.Common as Byron

import qualified Shelley.Spec.Ledger.LedgerState as Shelley
import qualified Shelley.Spec.Ledger.Tx as Shelley

import Cardano.Api.Eras
import Cardano.Api.NetworkId
Expand Down Expand Up @@ -50,19 +48,12 @@ transactionFee sbe txFeeFixed txFeePerByte tx =
getFee :: Lovelace
getFee =
case tx of
ShelleyTx _ tx' -> let x = getTxSize sbe tx'
ShelleyTx _ tx' -> let x = getField @"txsize" tx'
in Lovelace (a * x + b)
ByronTx _ -> case sbe :: ShelleyBasedEra ByronEra of {}

getTxSize :: ShelleyBasedEra era -> Shelley.Tx (ShelleyLedgerEra era) -> Integer
getTxSize ShelleyBasedEraShelley = Shelley.txsize
getTxSize ShelleyBasedEraAllegra = Shelley.txsize
getTxSize ShelleyBasedEraMary = Shelley.txsize
-- TODO: Change Shelley.Tx to Tx type family
-- getTxSize ShelleyBasedEraAlonzo = getField @"txsize"

a = toInteger txFeePerByte
x = getField @"txsize" tx
b = toInteger txFeeFixed

--TODO: in the Byron case the per-byte is non-integral, would need different
Expand Down
5 changes: 5 additions & 0 deletions cardano-api/src/Cardano/Api/LedgerState.hs
Expand Up @@ -619,9 +619,14 @@ mkProtocolInfoCardano (GenesisCardano dnc byronGenesis shelleyGenesis)
Consensus.ProtocolParamsMary
{ Consensus.maryProtVer = shelleyProtVer dnc
}
Consensus.ProtocolParamsAlonzo
{ Consensus.alonzoGenesis = error "mkProtocolInfoCardano: Alonzo era not implemented yet"
, Consensus.alonzoProtVer = error "mkProtocolInfoCardano: Alonzo era not implemented yet"
}
(ncByronToShelley dnc)
(ncShelleyToAllegra dnc)
(ncAllegraToMary dnc)
(error "mkProtocolInfoCardano: Alonzo era not implemented yet")

shelleyPraosNonce :: ShelleyConfig -> Shelley.Spec.Nonce
shelleyPraosNonce sCfg = Shelley.Spec.Nonce (Cardano.Crypto.Hash.Class.castHash . unGenesisHashShelley $ scGenesisHash sCfg)
Expand Down
5 changes: 4 additions & 1 deletion cardano-api/src/Cardano/Api/Modes.hs
Expand Up @@ -46,9 +46,9 @@ import qualified Ouroboros.Consensus.Cardano.ByronHFC as Consensus (ByronBlockHF
import Ouroboros.Consensus.HardFork.Combinator as Consensus (EraIndex (..), eraIndexSucc,
eraIndexZero)
import Ouroboros.Consensus.Shelley.Eras (StandardAllegra, StandardMary, StandardShelley)
import qualified Ouroboros.Consensus.Shelley.ShelleyHFC as Consensus (ShelleyBlockHFC)
import qualified Ouroboros.Consensus.Shelley.Ledger as Consensus
import Ouroboros.Consensus.Shelley.Protocol (StandardCrypto)
import qualified Ouroboros.Consensus.Shelley.ShelleyHFC as Consensus (ShelleyBlockHFC)

import qualified Cardano.Chain.Slotting as Byron (EpochSlots (..))

Expand Down Expand Up @@ -279,4 +279,7 @@ fromConsensusEraIndex CardanoMode = fromShelleyEraIndex

fromShelleyEraIndex (Consensus.EraIndex (S (S (S (Z (K ())))))) =
AnyEraInMode MaryEraInCardanoMode
fromShelleyEraIndex (Consensus.EraIndex (S (S (S (S (Z (K ()))))))) =
error "fromShelleyEraIndex: Alonzo not implemented yet"


12 changes: 9 additions & 3 deletions cardano-api/src/Cardano/Api/Protocol/Types.hs
Expand Up @@ -22,11 +22,11 @@ import Cardano.Chain.Slotting (EpochSlots)

import Ouroboros.Consensus.Byron.Ledger (ByronBlock)
import Ouroboros.Consensus.Cardano
import Ouroboros.Consensus.Cardano.Node
import Ouroboros.Consensus.Cardano.Block
import Ouroboros.Consensus.Cardano.ByronHFC (ByronBlockHFC)
import Ouroboros.Consensus.Cardano.Node
import Ouroboros.Consensus.HardFork.Combinator.Embed.Unary
import Ouroboros.Consensus.Node.ProtocolInfo (ProtocolClientInfo(..), ProtocolInfo(..))
import Ouroboros.Consensus.Node.ProtocolInfo (ProtocolClientInfo (..), ProtocolInfo (..))
import Ouroboros.Consensus.Node.Run (RunNode)
import Ouroboros.Consensus.Shelley.Ledger (ShelleyBlock)
import Ouroboros.Consensus.Shelley.ShelleyHFC (ShelleyBlockHFC)
Expand Down Expand Up @@ -58,27 +58,33 @@ instance IOLike m => Protocol m (CardanoBlock StandardCrypto) where
ProtocolParamsShelley
ProtocolParamsAllegra
ProtocolParamsMary
ProtocolParamsAlonzo
(ProtocolParamsTransition ByronBlock (ShelleyBlock StandardShelley))
(ProtocolParamsTransition (ShelleyBlock StandardShelley) (ShelleyBlock StandardAllegra))
(ProtocolParamsTransition (ShelleyBlock StandardAllegra) (ShelleyBlock StandardMary))
(ProtocolParamsTransition (ShelleyBlock StandardMary) (ShelleyBlock StandardAlonzo))
protocolInfo (ProtocolInfoArgsCardano
paramsByron
paramsShelleyBased
paramsShelley
paramsAllegra
paramsMary
paramsAlonzo
paramsByronShelley
paramsShelleyAllegra
paramsAllegraMary) =
paramsAllegraMary
paramsMaryAlonzo) =
protocolInfoCardano
paramsByron
paramsShelleyBased
paramsShelley
paramsAllegra
paramsMary
paramsAlonzo
paramsByronShelley
paramsShelleyAllegra
paramsAllegraMary
paramsMaryAlonzo

instance ProtocolClient ByronBlockHFC where
data ProtocolClientInfoArgs ByronBlockHFC =
Expand Down
4 changes: 1 addition & 3 deletions cardano-api/src/Cardano/Api/ProtocolParameters.hs
Expand Up @@ -70,12 +70,11 @@ import Cardano.Api.Script
import Cardano.Api.StakePoolMetadata
import Cardano.Api.TxMetadata
import Cardano.Api.Value
import Cardano.Binary

import qualified Cardano.Ledger.Alonzo.Language as Alonzo
import qualified Cardano.Ledger.Alonzo.Scripts as Alonzo
import qualified Cardano.Ledger.Core as Core
import qualified Language.PlutusCore.Evaluation.Machine.ExBudgeting as Plutus
import qualified PlutusCore.Evaluation.Machine.ExBudgeting as Plutus
import qualified Shelley.Spec.Ledger.BaseTypes as Shelley
import qualified Shelley.Spec.Ledger.Genesis as Shelley
import qualified Shelley.Spec.Ledger.Keys as Shelley
Expand Down Expand Up @@ -492,7 +491,6 @@ _fromCostModel aCostMap = Map.fromList . mapMaybe conv $ Map.toList aCostMap
conv :: (Alonzo.Language, Alonzo.CostModel) -> Maybe (AnyScriptLanguage, CostModel)
conv (Alonzo.PlutusV1, Alonzo.CostModel _aCostModel) =
Just (undefined, CostModel $ error "Need to bump ledger spec dependency")
conv (Alonzo.PlutusV1, _) = Nothing

_toCostModel :: Map AnyScriptLanguage CostModel -> Map Alonzo.Language Alonzo.CostModel
_toCostModel cMap = Map.fromList . mapMaybe conv $ Map.toList cMap
Expand Down
5 changes: 2 additions & 3 deletions cardano-api/src/Cardano/Api/ProtocolParametersUpdate.hs
Expand Up @@ -69,7 +69,7 @@ import Cardano.Api.Value

import qualified Cardano.Ledger.Alonzo.Language as Alonzo
import qualified Cardano.Ledger.Alonzo.Scripts as Alonzo
import qualified Language.PlutusCore.Evaluation.Machine.ExBudgeting as Plutus
import qualified PlutusCore.Evaluation.Machine.ExBudgeting as Plutus
import Shelley.Spec.Ledger.BaseTypes (maybeToStrictMaybe, strictMaybeToMaybe)
import qualified Shelley.Spec.Ledger.BaseTypes as Shelley
import qualified Shelley.Spec.Ledger.PParams as Shelley
Expand Down Expand Up @@ -307,7 +307,7 @@ instance SerialiseAsCBOR UpdateProposal where
serialiseToCBOR = CBOR.serializeEncoding' . toCBOR . toShelleyUpdate @StandardShelley
deserialiseFromCBOR _ bs =
fromShelleyUpdate @StandardShelley <$>
CBOR.decodeAnnotator "UpdateProposal" fromCBOR (LBS.fromStrict bs)
CBOR.decodeFull (LBS.fromStrict bs)


makeShelleyUpdateProposal :: ProtocolParametersUpdate
Expand All @@ -330,7 +330,6 @@ _fromCostModel aCostMap = Map.fromList . mapMaybe conv $ Map.toList aCostMap
conv :: (Alonzo.Language, Alonzo.CostModel) -> Maybe (AnyScriptLanguage, CostModel)
conv (Alonzo.PlutusV1, Alonzo.CostModel _aCostModel) =
Just (undefined, CostModel $ error "Need to bump ledger spec dependency")
conv (Alonzo.PlutusV1, _) = Nothing

_toCostModel :: Map AnyScriptLanguage CostModel -> Map Alonzo.Language Alonzo.CostModel
_toCostModel cMap = Map.fromList . mapMaybe conv $ Map.toList cMap
Expand Down
3 changes: 3 additions & 0 deletions cardano-api/src/Cardano/Api/TxInMode.hs
Expand Up @@ -198,6 +198,9 @@ fromConsensusApplyTxErr CardanoMode (Consensus.ApplyTxErrMary err) =
(ShelleyTxValidationError ShelleyBasedEraMary err)
MaryEraInCardanoMode

fromConsensusApplyTxErr CardanoMode (Consensus.ApplyTxErrAlonzo _) =
error "fromConsensusApplyTxErr: Alonzo era not implemented yet"

fromConsensusApplyTxErr CardanoMode (Consensus.ApplyTxErrWrongEra err) =
TxValidationEraMismatch err

2 changes: 1 addition & 1 deletion cardano-node/app/cardano-node.hs
Expand Up @@ -18,7 +18,7 @@ import System.Info (arch, compilerName, compilerVersion, os)
import Cardano.Node.Configuration.POM (PartialNodeConfiguration)
import Cardano.Node.Handlers.TopLevel
import Cardano.Node.Parsers (nodeCLIParser, parserHelpHeader, parserHelpOptions,
renderHelpDoc)
renderHelpDoc)
import Cardano.Node.Run (runNode)

main :: IO ()
Expand Down
1 change: 1 addition & 0 deletions cardano-node/cardano-node.cabal
Expand Up @@ -103,6 +103,7 @@ library
, cardano-config
, cardano-crypto-class
, cardano-crypto-wrapper
, cardano-ledger-alonzo
, cardano-ledger-byron
, cardano-ledger-core
, cardano-ledger-shelley-ma
Expand Down
9 changes: 5 additions & 4 deletions cardano-node/src/Cardano/Node/Configuration/Logging.hs
Expand Up @@ -33,10 +33,10 @@ import qualified Data.Map as Map
import Data.Text (pack)
import Data.Time.Clock (UTCTime, getCurrentTime)
import Data.Version (showVersion)
import qualified System.Remote.Monitoring as EKG
import System.Metrics.Counter (Counter)
import System.Metrics.Gauge (Gauge)
import System.Metrics.Label (Label)
import System.Metrics.Counter (Counter)
import qualified System.Remote.Monitoring as EKG

import Cardano.BM.Backend.Aggregation (plugin)
import Cardano.BM.Backend.EKGView (plugin)
Expand Down Expand Up @@ -78,8 +78,8 @@ import qualified Shelley.Spec.Ledger.API as SL
import Cardano.Api.Protocol.Types (BlockType (..), protocolInfo)
import Cardano.Config.Git.Rev (gitRev)
import Cardano.Node.Configuration.POM (NodeConfiguration (..), ncProtocol)
import Cardano.Node.Types
import Cardano.Node.Protocol.Types (SomeConsensusProtocol (..))
import Cardano.Node.Types
import Cardano.Tracing.OrphanInstances.Common ()
import Paths_cardano_node (version)

Expand Down Expand Up @@ -321,11 +321,12 @@ nodeBasicInfo nc (SomeConsensusProtocol whichP pForInfo) nodeStartTime' = do
let DegenLedgerConfig cfgShelley = Consensus.configLedger cfg
in getGenesisValues "Shelley" cfgShelley
CardanoBlockType ->
let CardanoLedgerConfig cfgByron cfgShelley cfgAllegra cfgMary = Consensus.configLedger cfg
let CardanoLedgerConfig cfgByron cfgShelley cfgAllegra cfgMary cfgAlonzo = Consensus.configLedger cfg
in getGenesisValuesByron cfg cfgByron
++ getGenesisValues "Shelley" cfgShelley
++ getGenesisValues "Allegra" cfgAllegra
++ getGenesisValues "Mary" cfgMary
++ getGenesisValues "Alonzo" cfgAlonzo
items = nub $
[ ("protocol", pack . protocolName $ ncProtocol nc)
, ("version", pack . showVersion $ version)
Expand Down
8 changes: 7 additions & 1 deletion cardano-node/src/Cardano/Node/Configuration/POM.hs
Expand Up @@ -255,6 +255,9 @@ instance FromJSON PartialNodeConfiguration where
npcTestMaryHardForkAtEpoch <- v .:? "TestMaryHardForkAtEpoch"
npcTestMaryHardForkAtVersion <- v .:? "TestMaryHardForkAtVersion"

npcTestAlonzoHardForkAtEpoch <- v .:? "TestAlonzoHardForkAtEpoch"
npcTestAlonzoHardForkAtVersion <- v .:? "TestAlonzoHardForkAtVersion"

pure NodeHardForkProtocolConfiguration {
npcTestShelleyHardForkAtEpoch,
npcTestShelleyHardForkAtVersion,
Expand All @@ -263,7 +266,10 @@ instance FromJSON PartialNodeConfiguration where
npcTestAllegraHardForkAtVersion,

npcTestMaryHardForkAtEpoch,
npcTestMaryHardForkAtVersion
npcTestMaryHardForkAtVersion,

npcTestAlonzoHardForkAtEpoch,
npcTestAlonzoHardForkAtVersion
}

-- | Default configuration is mainnet
Expand Down
8 changes: 4 additions & 4 deletions cardano-node/src/Cardano/Node/Protocol/Byron.hs
Expand Up @@ -14,7 +14,7 @@ module Cardano.Node.Protocol.Byron

import Cardano.Prelude
import Control.Monad.Trans.Except.Extra (bimapExceptT, firstExceptT, hoistEither,
hoistMaybe, left)
hoistMaybe, left)
import qualified Data.ByteString.Lazy as LB
import qualified Data.Text as Text

Expand All @@ -26,19 +26,19 @@ import qualified Cardano.Crypto.Hash as Crypto
import qualified Cardano.Crypto.Hashing as Byron.Crypto

import qualified Cardano.Chain.Genesis as Genesis
import qualified Cardano.Chain.Update as Update
import qualified Cardano.Chain.UTxO as UTxO
import qualified Cardano.Chain.Update as Update
import Cardano.Crypto.ProtocolMagic (RequiresNetworkMagic)

import Ouroboros.Consensus.Cardano
import qualified Ouroboros.Consensus.Cardano as Consensus

import Cardano.Node.Types

import Cardano.Node.Protocol.Types
import Cardano.Tracing.OrphanInstances.Byron ()
import Cardano.Tracing.OrphanInstances.HardFork ()

import Cardano.Node.Protocol.Types
import Cardano.Tracing.OrphanInstances.Shelley ()


------------------------------------------------------------------------------
Expand Down
14 changes: 13 additions & 1 deletion cardano-node/src/Cardano/Node/Protocol/Cardano.hs
Expand Up @@ -140,7 +140,7 @@ mkSomeConsensusProtocolCardano NodeByronProtocolConfiguration {
shelleyBasedGenesis = shelleyGenesis,
shelleyBasedInitialNonce =
Shelley.genesisHashToPraosNonce shelleyGenesisHash,
shelleyBasedLeaderCredentials = shelleyLeaderCredentials
shelleyBasedLeaderCredentials = shelleyLeaderCredentials
}
Consensus.ProtocolParamsShelley {
-- This is /not/ the Shelley protocol version. It is the protocol
Expand All @@ -166,6 +166,15 @@ mkSomeConsensusProtocolCardano NodeByronProtocolConfiguration {
maryProtVer =
ProtVer 4 0
}
Consensus.ProtocolParamsAlonzo {
-- This is /not/ the Alonzo protocol version. It is the protocol
-- version that this node will declare that it understands, when it
-- is in the Alonzo era. Since Alonzo is currently the last known
-- protocol version then this is a Consensus.ProtocolParamsTransition {
alonzoGenesis = error "mkSomeConsensusProtocolCardano: Alonzo not implemented yet",
alonzoProtVer = error "mkSomeConsensusProtocolCardano: Alonzo not implemented yet"
}

-- ProtocolParamsTransition specifies the parameters needed to transition between two eras
-- The comments below also apply for the Shelley -> Allegra and Allegra -> Mary hard forks.
-- Byron to Shelley hard fork parameters
Expand Down Expand Up @@ -209,6 +218,9 @@ mkSomeConsensusProtocolCardano NodeByronProtocolConfiguration {
(maybe 4 fromIntegral npcTestMaryHardForkAtVersion)
Just epochNo -> Consensus.TriggerHardForkAtEpoch epochNo
}
Consensus.ProtocolParamsTransition {
transitionTrigger = error "mkSomeConsensusProtocolCardano: Alonzo era not implemented yet"
}

------------------------------------------------------------------------------
-- Errors
Expand Down
2 changes: 1 addition & 1 deletion cardano-node/src/Cardano/Node/Run.hs
Expand Up @@ -54,7 +54,7 @@ import Cardano.Node.Configuration.POM (NodeConfiguration (..),
import Cardano.Node.Types
import Cardano.Tracing.Config (TraceOptions (..), TraceSelection (..))
import Cardano.Tracing.Constraints (TraceConstraints)
import Cardano.Tracing.Metrics (HasKESMetricsData (..), HasKESInfo (..))
import Cardano.Tracing.Metrics (HasKESInfo (..), HasKESMetricsData (..))

import qualified Ouroboros.Consensus.Config as Consensus
import Ouroboros.Consensus.Config.SupportsNode (getNetworkMagic)
Expand Down

0 comments on commit 56cdaba

Please sign in to comment.