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 7, 2021
1 parent 424a9d9 commit fa6f0cf
Show file tree
Hide file tree
Showing 15 changed files with 159 additions and 53 deletions.
4 changes: 2 additions & 2 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ source-repository-package
source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-ledger-specs
tag: 87fa50edc7c3a01c2f51073c0bd82ecff6fc6d03
--sha256: 197yfmp57hcnx6sxhm7jy589jzzcnhz7zm2zsld7vks5s63rp0jw
tag: e06ad6b73b2bc5dffd5e5212ddf32eaef938e653
subdir:
alonzo/impl
byron/chain/executable-spec
Expand Down Expand Up @@ -180,6 +179,7 @@ source-repository-package
type: git
location: https://github.com/input-output-hk/ouroboros-network
tag: aad909cfba4e23c623121457f5ef84e5c41a9b62
--sha256: 0d7bk9vzmhhb2z4ns2qw7f1vz6lr186m98sh8wvrnfpxk3z86dxb
subdir:
io-sim
io-sim-classes
Expand Down
18 changes: 7 additions & 11 deletions cardano-api/src/Cardano/Api/Fees.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,13 @@ transactionFee :: forall era.
-> Natural -- ^ The tx fee per byte
-> Tx era
-> Lovelace
transactionFee txFeeFixed txFeePerByte (ShelleyTx _ tx) =
Lovelace (a * x + b)
where
a = toInteger txFeePerByte
x = getField @"txsize" tx
b = toInteger txFeeFixed

--TODO: This can be made to work for Byron txs too. Do that: fill in this case
-- and remove the IsShelleyBasedEra constraint.
transactionFee _ _ (ByronTx _) =
case shelleyBasedEra :: ShelleyBasedEra era of {}
transactionFee txFeeFixed txFeePerByte tx =
let a = toInteger txFeePerByte
b = toInteger txFeeFixed
in case tx of
ShelleyTx _ tx' -> let x = getField @"txsize" tx'
in Lovelace (a * x + b)
ByronTx _ -> case shelleyBasedEra :: ShelleyBasedEra ByronEra of {}


--TODO: in the Byron case the per-byte is non-integral, would need different
Expand Down
3 changes: 1 addition & 2 deletions cardano-api/src/Cardano/Api/ProtocolParameters.hs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ import Cardano.Api.SerialiseTextEnvelope
import Cardano.Api.StakePoolMetadata
import Cardano.Api.TxMetadata
import Cardano.Api.Value
import Cardano.Binary


-- | The values of the set of /updateable/ protocol paramaters. At any
Expand Down Expand Up @@ -479,7 +478,7 @@ instance HasTextEnvelope UpdateProposal where
instance SerialiseAsCBOR UpdateProposal where
serialiseToCBOR = CBOR.serializeEncoding' . toCBOR . toShelleyUpdate @StandardShelley
deserialiseFromCBOR _ bs =
fromShelleyUpdate @StandardShelley <$> decodeFull (LBS.fromStrict bs)
fromShelleyUpdate @StandardShelley <$> CBOR.decodeFull (LBS.fromStrict bs)


makeShelleyUpdateProposal :: ProtocolParametersUpdate
Expand Down
2 changes: 1 addition & 1 deletion cardano-node/app/cardano-node.hs
Original file line number Diff line number Diff line change
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
2 changes: 1 addition & 1 deletion cardano-node/src/Cardano/Node/Orphans.hs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ deriving instance ToJSONKey Alonzo.Language
deriving instance ToJSON Alonzo.CostModel
deriving instance ToJSON (MemoBytes.MemoBytes (Map Text Integer))

deriving instance ToJSON (Alonzo.TxOut (Alonzo.AlonzoEra StandardCrypto))
--deriving instance ToJSON (Alonzo.TxOut (Alonzo.AlonzoEra StandardCrypto))

deriving instance ToJSON (Shelley.CompactAddr StandardCrypto)
deriving instance Generic (Shelley.CompactAddr StandardCrypto)
Expand Down
8 changes: 4 additions & 4 deletions cardano-node/src/Cardano/Node/Protocol/Byron.hs
Original file line number Diff line number Diff line change
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
13 changes: 6 additions & 7 deletions cardano-node/src/Cardano/Node/Protocol/Cardano.hs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ mkSomeConsensusProtocolCardano NodeByronProtocolConfiguration {
npcShelleyGenesisFile,
npcShelleyGenesisFileHash
}
NodeAlonzoProtocolConfiguration {
npcAlonzoGenesisFile
}
(NodeAlonzoProtocolConfiguration _)
NodeHardForkProtocolConfiguration {
npcTestShelleyHardForkAtEpoch,
npcTestShelleyHardForkAtVersion,
Expand Down Expand Up @@ -145,7 +143,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 Down Expand Up @@ -175,10 +173,11 @@ mkSomeConsensusProtocolCardano NodeByronProtocolConfiguration {
-- 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 also the Alonzo protocol version.
alonzoProtVer =
ProtVer 4 0
-- 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
2 changes: 1 addition & 1 deletion cardano-node/src/Cardano/Node/Run.hs
Original file line number Diff line number Diff line change
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
13 changes: 12 additions & 1 deletion cardano-node/src/Cardano/Tracing/Constraints.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ import Cardano.BM.Tracing (ToObject)
import Cardano.Tracing.ConvertTxId (ConvertTxId)
import Cardano.Tracing.Queries (LedgerQueries)

import Cardano.Node.Orphans ()
import Cardano.Ledger.Alonzo (AlonzoEra)
import Cardano.Ledger.Alonzo.PParams (PParamsUpdate)
import Cardano.Ledger.Alonzo.Rules.Bbody (AlonzoBbodyPredFail)
import Cardano.Ledger.Alonzo.Rules.Utxo (UtxoPredicateFailure)
import Cardano.Ledger.Alonzo.Rules.Utxow (AlonzoPredFail)
import Cardano.Ledger.Alonzo.TxBody (TxOut)
import Ouroboros.Consensus.Block (BlockProtocol, CannotForge, ForgeStateUpdateError,
Header)
import Ouroboros.Consensus.HeaderValidation (OtherHeaderEnvelopeError)
Expand All @@ -22,6 +27,7 @@ import Ouroboros.Consensus.Ledger.Inspect (LedgerEvent)
import Ouroboros.Consensus.Ledger.SupportsMempool (ApplyTxErr, HasTxId, HasTxs (..))
import Ouroboros.Consensus.Protocol.Abstract (ValidationErr)
import Ouroboros.Consensus.Shelley.Ledger.Mempool (GenTx, TxId)
import Ouroboros.Consensus.Shelley.Protocol.Crypto (StandardCrypto)

-- | Tracing-related constraints for monitoring purposes.
type TraceConstraints blk =
Expand All @@ -30,6 +36,8 @@ type TraceConstraints blk =
, HasTxId (GenTx blk)
, LedgerQueries blk
, ToJSON (TxId (GenTx blk))
, ToJSON (TxOut (AlonzoEra StandardCrypto))
, ToJSON (PParamsUpdate (AlonzoEra StandardCrypto))
, ToObject (ApplyTxErr blk)
, ToObject (GenTx blk)
, ToObject (Header blk)
Expand All @@ -39,6 +47,9 @@ type TraceConstraints blk =
, ToObject (ValidationErr (BlockProtocol blk))
, ToObject (CannotForge blk)
, ToObject (ForgeStateUpdateError blk)
, ToObject (UtxoPredicateFailure (AlonzoEra StandardCrypto))
, ToObject (AlonzoBbodyPredFail (AlonzoEra StandardCrypto))
, ToObject (AlonzoPredFail (AlonzoEra StandardCrypto))
, Show blk
, Show (Header blk)
)
7 changes: 4 additions & 3 deletions cardano-node/src/Cardano/Tracing/OrphanInstances/Byron.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module Cardano.Tracing.OrphanInstances.Byron () where

import Cardano.Prelude

import Data.Aeson (Value (..))
import qualified Data.Set as Set
import qualified Data.Text as Text

Expand All @@ -22,14 +23,14 @@ import Ouroboros.Consensus.Block (Header)
import Ouroboros.Network.Block (blockHash, blockNo, blockSlot)

import Ouroboros.Consensus.Byron.Ledger (ByronBlock (..),
ByronOtherHeaderEnvelopeError (..), TxId (..), byronHeaderRaw)
ByronOtherHeaderEnvelopeError (..), TxId (..), byronHeaderRaw)
import Ouroboros.Consensus.Byron.Ledger.Inspect (ByronLedgerUpdate (..),
ProtocolUpdate (..), UpdateState (..))
ProtocolUpdate (..), UpdateState (..))
import Ouroboros.Consensus.Ledger.SupportsMempool (GenTx, txId)
import Ouroboros.Consensus.Util.Condense (condense)

import Cardano.Chain.Block (ABlockOrBoundaryHdr (..), AHeader (..),
ChainValidationError (..), delegationCertificate)
ChainValidationError (..), delegationCertificate)
import Cardano.Chain.Byron.API (ApplyMempoolPayloadErr (..))
import Cardano.Chain.Delegation (delegateVK)
import Cardano.Crypto.Signing (VerificationKey)
Expand Down
42 changes: 35 additions & 7 deletions cardano-node/src/Cardano/Tracing/OrphanInstances/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ module Cardano.Tracing.OrphanInstances.Common
, mkObject
, emptyObject
, ToJSON
, Value (..)
, toJSON
, (.=)

Expand All @@ -43,7 +42,8 @@ module Cardano.Tracing.OrphanInstances.Common
import Cardano.Prelude
import Prelude (fail)

import Data.Aeson
import Data.Aeson hiding (Value)
import qualified Data.Aeson as Aeson
import qualified Data.ByteString.Base16 as B16
import qualified Data.ByteString.Short as SBS
import Data.Scientific (coefficient)
Expand All @@ -52,19 +52,28 @@ import qualified Data.Text.Encoding as Text
import Network.Socket (PortNumber)

import Cardano.BM.Data.LogItem (LOContent (..), LogObject (..), PrivacyAnnotation (..),
mkLOMeta)
mkLOMeta)
import Cardano.BM.Data.Tracer (HasTextFormatter (..), emptyObject, mkObject, trStructured,
trStructuredText)
trStructuredText)
import Cardano.BM.Stats
import Cardano.BM.Tracing (HasPrivacyAnnotation (..), HasSeverityAnnotation (..),
Severity (..), ToObject (..), Tracer (..), TracingVerbosity (..),
Transformable (..))
Severity (..), ToObject (..), Tracer (..), TracingVerbosity (..),
Transformable (..))
import qualified Cardano.Chain.Update as Update
import qualified Cardano.Crypto.Hash.Class as Crypto
import Cardano.Ledger.Alonzo as Alonzo
import Cardano.Ledger.Alonzo.Rules.Bbody (AlonzoBbodyPredFail)
import Cardano.Ledger.Alonzo.Rules.Utxo (UtxoPredicateFailure)
import qualified Cardano.Ledger.Alonzo.TxBody as Alonzo
import qualified Cardano.Ledger.Core as Ledger
import qualified Cardano.Ledger.Era as Ledger
import qualified Cardano.Ledger.SafeHash as SafeHash
import Cardano.Slotting.Block (BlockNo (..))
import Ouroboros.Consensus.Byron.Ledger.Block (ByronHash (..))
import Ouroboros.Consensus.HardFork.Combinator (OneEraHash (..))
import Ouroboros.Consensus.Shelley.Protocol.Crypto (StandardCrypto)
import Ouroboros.Network.Block (HeaderHash, Tip (..))

import Shelley.Spec.Ledger.BaseTypes (strictMaybeToMaybe)

-- | A bit of a weird one, but needed because some of the very general
-- consensus interfaces are sometimes instantiated to 'Void', when there are
Expand Down Expand Up @@ -125,3 +134,22 @@ instance ToObject ResourceStats where
case toJSON stats of
Object x -> x
_ -> mempty

instance (Ledger.Era era, Show (Ledger.Value era), ToJSON (Ledger.Value era))
=> ToJSON (TxOut era) where
toJSON (Alonzo.TxOut addr v dataHash) =
object [ "address" .= toJSON addr
, "value" .= toJSON v
, "datahash" .= case strictMaybeToMaybe dataHash of
Nothing -> Aeson.Null
Just dHash ->
Aeson.String . Crypto.hashToTextAsHex
$ SafeHash.extractHash dHash
]


instance ToObject (UtxoPredicateFailure (Alonzo.AlonzoEra StandardCrypto)) where
toObject _ _ = panic "ToJSON: UtxoPredicateFailure not implemented yet"

instance ToObject (AlonzoBbodyPredFail (Alonzo.AlonzoEra StandardCrypto)) where
toObject _ _ = panic "ToJSON: AlonzoBbodyPredFail not implemented yet"
2 changes: 2 additions & 0 deletions cardano-node/src/Cardano/Tracing/OrphanInstances/Consensus.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module Cardano.Tracing.OrphanInstances.Consensus () where
import Cardano.Prelude hiding (show)
import Prelude (show)

import Data.Aeson (Value (..))
import Data.Text (pack)
import qualified Data.Text as Text
import qualified Data.Text.Encoding as Text
Expand Down Expand Up @@ -263,6 +264,7 @@ instance ( tx ~ GenTx blk
, ConvertRawHash blk
, HasTxId tx
, LedgerSupportsProtocol blk
, LedgerSupportsMempool blk
, Show (TxId tx)
, Show (ForgeStateUpdateError blk)
, Show (CannotForge blk)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Cardano.Prelude hiding (show)
import Prelude (String, show)

import Control.Monad.Class.MonadTime (DiffTime, Time (..))
import Data.Aeson (Value (..))
import Data.Text (pack)

import Network.Mux (MuxTrace (..), WithMuxBearer (..))
Expand Down
Loading

0 comments on commit fa6f0cf

Please sign in to comment.