Skip to content

Commit

Permalink
8.8.0-pre integration
Browse files Browse the repository at this point in the history
  • Loading branch information
zliu41 committed Jan 25, 2024
1 parent 671afa2 commit 19d7288
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 106 deletions.
54 changes: 54 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,57 @@ package plutus-scripts-bench
-- temporary! Please read the section in CONTRIBUTING about updating dependencies.

-- `smtp-mail` should depend on `crypton-connection` rather than `connection`!

source-repository-package
type: git
location: https://github.com/IntersectMBO/cardano-ledger
tag: 33c0a26b753807bd683e109c73ecc8849de64a94
subdir:
eras/allegra/impl
eras/alonzo/impl
eras/alonzo/test-suite
eras/babbage/impl
eras/babbage/test-suite
eras/byron/ledger/impl
eras/conway/impl
eras/conway/test-suite
eras/mary/impl
eras/shelley/impl
eras/shelley/test-suite
eras/shelley-ma/test-suite
libs/cardano-data
libs/cardano-ledger-api
libs/cardano-ledger-binary
libs/cardano-ledger-core
libs/cardano-protocol-tpraos
libs/small-steps
libs/small-steps-test
libs/vector-map
--sha256: sha256-Ycdgk8c7X0Sbw1uixIxi9IwIb/2FB6hvzo+Mij6pnM8=

source-repository-package
type: git
location: https://github.com/IntersectMBO/ouroboros-consensus.git
tag: 6b125bea3a25a60f350ac0f1a228c5411f0182ef
subdir:
ouroboros-consensus
ouroboros-consensus-cardano
ouroboros-consensus-protocol
ouroboros-consensus-diffusion
sop-extras
strict-sop-core
--sha256: sha256-d/5Q/nE0De0TtvpCHHHDBVnGmi4Jbdrv2raCqELOGs8=

source-repository-package
type: git
location: https://github.com/IntersectMBO/cardano-api.git
tag: af785f9b057c8401b30c5cbd3be3780abe357613
subdir: cardano-api
--sha256: sha256-uje2F77Q3rSuBC4R6GmQt0jJdtusF0UK8HD9UpUxvCI=

source-repository-package
type: git
location: https://github.com/IntersectMBO/cardano-cli.git
tag: b5d94431000f645754667618b7164e8ac406eea6
subdir: cardano-cli
--sha256: sha256-UhSh7Kwk3jERTVzo+p87emSNb3BxqJrR2ZH3W1/gNA8=
3 changes: 2 additions & 1 deletion cardano-node/cardano-node.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ common project-config
-Wno-unticked-promoted-constructors
-Wpartial-fields
-Wredundant-constraints
-Wunused-packages
-- -Wunused-packages
common maybe-Win32
if os(windows)
build-depends: Win32
Expand Down Expand Up @@ -145,6 +145,7 @@ library
, base16-bytestring
, bytestring
, cardano-api ^>= 8.37.1.0
, cardano-api:internal
, cardano-crypto-class
, cardano-crypto-wrapper
, cardano-git-rev
Expand Down
44 changes: 23 additions & 21 deletions cardano-node/src/Cardano/Node/Protocol/Shelley.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -w #-}

module Cardano.Node.Protocol.Shelley
( mkSomeConsensusProtocolShelley
Expand Down Expand Up @@ -79,27 +80,28 @@ mkSomeConsensusProtocolShelley NodeShelleyProtocolConfiguration {
npcShelleyGenesisFile,
npcShelleyGenesisFileHash
}
files = do
(genesis, genesisHash) <- firstExceptT GenesisReadError $
readGenesis npcShelleyGenesisFile
npcShelleyGenesisFileHash
firstExceptT GenesisValidationError $ validateGenesis genesis
leaderCredentials <- firstExceptT PraosLeaderCredentialsError $
readLeaderCredentials files

return $ SomeConsensusProtocol Api.ShelleyBlockType $ Api.ProtocolInfoArgsShelley
genesis
Consensus.ProtocolParamsShelleyBased {
shelleyBasedInitialNonce = genesisHashToPraosNonce genesisHash,
shelleyBasedLeaderCredentials =
leaderCredentials
}
Consensus.ProtocolParamsShelley {
shelleyProtVer =
ProtVer (natVersion @2) 0,
shelleyMaxTxCapacityOverrides =
TxLimits.mkOverrides TxLimits.noOverridesMeasure
}
files = undefined
-- do
-- (genesis, genesisHash) <- firstExceptT GenesisReadError $
-- readGenesis npcShelleyGenesisFile
-- npcShelleyGenesisFileHash
-- firstExceptT GenesisValidationError $ validateGenesis genesis
-- leaderCredentials <- firstExceptT PraosLeaderCredentialsError $
-- readLeaderCredentials files

-- return $ SomeConsensusProtocol Api.ShelleyBlockType $ Api.ProtocolInfoArgsShelley
-- genesis
-- Consensus.ProtocolParamsShelleyBased {
-- shelleyBasedInitialNonce = genesisHashToPraosNonce genesisHash,
-- shelleyBasedLeaderCredentials =
-- leaderCredentials
-- }
-- Consensus.ProtocolParamsShelley {
-- shelleyProtVer =
-- ProtVer (natVersion @2) 0,
-- shelleyMaxTxCapacityOverrides =
-- TxLimits.mkOverrides TxLimits.noOverridesMeasure
-- }

genesisHashToPraosNonce :: GenesisHash -> Nonce
genesisHashToPraosNonce (GenesisHash h) = Nonce (Crypto.castHash h)
Expand Down
28 changes: 15 additions & 13 deletions cardano-node/src/Cardano/Node/Tracing/Era/Shelley.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,20 @@
{-# LANGUAGE UndecidableInstances #-}

{-# OPTIONS_GHC -Wno-orphans #-}
{-# OPTIONS_GHC -w #-}

module Cardano.Node.Tracing.Era.Shelley () where

import Cardano.Api (textShow)
import qualified Cardano.Api.Shelley as Api
import Cardano.Api.Tx.Body (toScriptIndex)

import qualified Cardano.Crypto.Hash.Class as Crypto
import qualified Cardano.Crypto.VRF.Class as Crypto
import Cardano.Ledger.Allegra.Rules (AllegraUtxoPredFailure)
import qualified Cardano.Ledger.Allegra.Rules as Allegra
import qualified Cardano.Ledger.Allegra.Scripts as Allegra
import qualified Cardano.Ledger.Alonzo.PlutusScriptApi as Alonzo
import qualified Cardano.Ledger.Alonzo.Plutus.Evaluate as Alonzo
import Cardano.Ledger.Alonzo.Rules (AlonzoBbodyPredFailure, AlonzoUtxoPredFailure,
AlonzoUtxosPredFailure, AlonzoUtxowPredFailure (..))
import qualified Cardano.Ledger.Alonzo.Rules as Alonzo
Expand Down Expand Up @@ -348,10 +350,10 @@ instance
) => LogFormatting (AlonzoUtxowPredFailure era) where
forMachine dtal (ShelleyInAlonzoUtxowPredFailure utxoPredFail) =
forMachine dtal utxoPredFail
forMachine _ (MissingRedeemers scripts) =
mconcat [ "kind" .= String "MissingRedeemers"
, "scripts" .= renderMissingRedeemers scripts
]
forMachine _ (MissingRedeemers scripts) = undefined
-- mconcat [ "kind" .= String "MissingRedeemers"
-- , "scripts" .= renderMissingRedeemers scripts
-- ]
forMachine _ (MissingRequiredDatums required received) =
mconcat [ "kind" .= String "MissingRequiredDatums"
, "required" .= map (Crypto.hashToTextAsHex . SafeHash.extractHash)
Expand All @@ -377,11 +379,11 @@ instance
, "disallowed" .= Set.toList disallowed
, "acceptable" .= Set.toList acceptable
]
forMachine _ (ExtraRedeemers rdmrs) =
mconcat
[ "kind" .= String "ExtraRedeemers"
, "rdmrs" .= map Api.fromAlonzoRdmrPtr rdmrs
]
forMachine _ (ExtraRedeemers rdmrs) = undefined
-- mconcat
-- [ "kind" .= String "ExtraRedeemers"
-- , "rdmrs" .= map (toScriptIndex undefined) rdmrs
-- ]

instance
( Consensus.ShelleyBasedEra era
Expand Down Expand Up @@ -1135,9 +1137,9 @@ instance
mconcat [ "kind" .= String "ExpirationEpochTooSmall"
, "credentialsToEpoch" .= credsToEpoch
]
forMachine _ (Conway.InvalidPrevGovActionIdsInProposals proposals) =
mconcat [ "kind" .= String "InvalidPrevGovActionIdsInProposals"
, "proposals" .= proposals
forMachine _ (Conway.InvalidPrevGovActionId proposalProcedure) =
mconcat [ "kind" .= String "InvalidPrevGovActionId"
, "proposalProcedure" .= proposalProcedure
]
forMachine _ (Conway.VotingOnExpiredGovAction actions) =
mconcat [ "kind" .= String "VotingOnExpiredGovAction"
Expand Down
23 changes: 13 additions & 10 deletions cardano-node/src/Cardano/Node/Tracing/Render.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ import Data.Text (Text)
import qualified Data.Text as Text
import qualified Data.Text.Encoding as Text

import qualified Cardano.Ledger.Alonzo as Alonzo
import Cardano.Ledger.Alonzo.Scripts
(AlonzoPlutusPurpose (..), AsItem (..), PlutusPurpose)
import qualified Cardano.Ledger.Alonzo.Tx as Alonzo
import qualified Cardano.Ledger.Core as Ledger
import Cardano.Ledger.Crypto (StandardCrypto)
Expand Down Expand Up @@ -180,14 +183,14 @@ renderScriptIntegrityHash Nothing = Aeson.Null


renderMissingRedeemers :: ()
=> Ledger.EraCrypto ledgerera ~ StandardCrypto
=> [(Alonzo.ScriptPurpose ledgerera, Ledger.ScriptHash StandardCrypto)]
=> Ledger.EraCrypto (Alonzo.AlonzoEra c) ~ StandardCrypto
=> [(PlutusPurpose AsItem (Alonzo.AlonzoEra c), Ledger.ScriptHash StandardCrypto)]
-> Aeson.Value
renderMissingRedeemers scripts = Aeson.object $ map renderTuple scripts
where
renderTuple :: ()
=> Ledger.EraCrypto ledgerera ~ StandardCrypto
=> (Alonzo.ScriptPurpose ledgerera, Ledger.ScriptHash StandardCrypto)
=> Ledger.EraCrypto (Alonzo.AlonzoEra c) ~ StandardCrypto
=> (PlutusPurpose AsItem (Alonzo.AlonzoEra c), Ledger.ScriptHash StandardCrypto)
-> Aeson.Pair
renderTuple (scriptPurpose, sHash) =
Aeson.fromText (renderScriptHash sHash) .= renderScriptPurpose scriptPurpose
Expand All @@ -196,17 +199,17 @@ renderScriptHash :: Ledger.ScriptHash StandardCrypto -> Text
renderScriptHash = Api.serialiseToRawBytesHexText . Api.fromShelleyScriptHash

renderScriptPurpose :: ()
=> Ledger.EraCrypto ledgerera ~ StandardCrypto
=> Alonzo.ScriptPurpose ledgerera
=> Ledger.EraCrypto (Alonzo.AlonzoEra c) ~ StandardCrypto
=> PlutusPurpose AsItem (Alonzo.AlonzoEra c)
-> Aeson.Value
renderScriptPurpose = \case
Alonzo.Minting pid ->
AlonzoMinting pid ->
Aeson.object [ "minting" .= Aeson.toJSON pid]
Alonzo.Spending txin ->
AlonzoSpending (AsItem txin) ->
Aeson.object [ "spending" .= Api.fromShelleyTxIn txin]
Alonzo.Rewarding rwdAcct ->
AlonzoRewarding (AsItem rwdAcct) ->
Aeson.object [ "rewarding" .= Aeson.String (Api.serialiseAddress $ Api.fromShelleyStakeAddr rwdAcct)]
Alonzo.Certifying _cert ->
AlonzoCertifying _cert ->
Aeson.object
[ "certifying" .= Aeson.toJSON @String "TODO CIP-1694 unimplemented" -- toJSON (Api.textEnvelopeDefaultDescr $ Api.fromShelleyCertificate sbe cert)
]
5 changes: 3 additions & 2 deletions cardano-node/src/Cardano/Node/Tracing/Tracers/Peer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import qualified Data.Text as Text
import Text.Printf (printf)

import Ouroboros.Consensus.Block (Header)
import Ouroboros.Consensus.Util.NormalForm.StrictTVar (StrictTVar, readTVar)
import Ouroboros.Consensus.Util.Orphans ()
import Ouroboros.Network.ConnectionId (remoteAddress)

Expand Down Expand Up @@ -105,9 +106,9 @@ getCurrentPeers nkd = mapNodeKernelDataIO extractPeers nkd
tuple3pop (a, b, _) = (a, b)

getCandidates
:: STM.StrictTVar IO (Map peer (STM.StrictTVar IO (Net.AnchoredFragment (Header blk))))
:: StrictTVar IO (Map peer (StrictTVar IO (Net.AnchoredFragment (Header blk))))
-> STM.STM IO (Map peer (Net.AnchoredFragment (Header blk)))
getCandidates var = STM.readTVar var >>= traverse STM.readTVar
getCandidates var = readTVar var >>= traverse readTVar

extractPeers :: NodeKernel IO RemoteAddress LocalConnectionId blk
-> IO [PeerT blk]
Expand Down
Loading

0 comments on commit 19d7288

Please sign in to comment.