Skip to content

Commit

Permalink
Merge #3818
Browse files Browse the repository at this point in the history
3818: Propagate protocol in block type r=disassembler a=Jimbo4350

This PR: 
- Propagates updated ShelleyBlock type (which is now also parameterized over the protocol)
- Re-enables the TestEnableDevelopmentHardForkEras flag so we can hardfork to Babbage without advertising we know about the Babbage era

Co-authored-by: Jordan Millar <[email protected]>
Co-authored-by: Nicolas Frisby <[email protected]>
Co-authored-by: Alexander Esgen <[email protected]>
  • Loading branch information
4 people authored May 21, 2022
2 parents 41afffd + b4308ef commit 88a4e71
Show file tree
Hide file tree
Showing 54 changed files with 2,035 additions and 665 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ import Ouroboros.Network.Protocol.BlockFetch.Client (BlockFetchClient
import Ouroboros.Network.Protocol.Handshake.Version (simpleSingletonVersions)
import Ouroboros.Network.Protocol.KeepAlive.Codec
import Ouroboros.Network.Protocol.KeepAlive.Client
import Ouroboros.Network.Protocol.TxSubmission.Client (TxSubmissionClient,
txSubmissionClientPeer)
import Ouroboros.Network.Protocol.Trans.Hello.Util (wrapClientPeer)
import Ouroboros.Network.Protocol.TxSubmission2.Client (TxSubmissionClient,
txSubmissionClientPeer)

import Ouroboros.Network.Snocket (socketSnocket)

Expand Down Expand Up @@ -95,7 +94,7 @@ benchmarkConnectTxSubmit ioManager handshakeTracer submissionTracer codecConfig
supportedVers :: Map.Map NodeToNodeVersion (BlockNodeToNodeVersion blk)
supportedVers = supportedNodeToNodeVersions (Proxy @blk)
myCodecs :: Codecs blk DeserialiseFailure IO
ByteString ByteString ByteString ByteString ByteString ByteString ByteString
ByteString ByteString ByteString ByteString ByteString ByteString
myCodecs = defaultCodecs codecConfig blkN2nVer n2nVer
peerMultiplex =
simpleSingletonVersions
Expand Down Expand Up @@ -124,7 +123,7 @@ benchmarkConnectTxSubmit ioManager handshakeTracer submissionTracer codecConfig
MuxPeer
submissionTracer
(cTxSubmission2Codec myCodecs)
(wrapClientPeer $ txSubmissionClientPeer myTxSubClient)
(txSubmissionClientPeer myTxSubClient)
} )
n2nVer
-- Stolen from: Ouroboros/Consensus/Network/NodeToNode.hs
Expand All @@ -134,27 +133,21 @@ benchmarkConnectTxSubmit ioManager handshakeTracer submissionTracer codecConfig
-> remotePeer
-> Channel IO ByteString
-> IO ((), Maybe ByteString)
kaClient version them channel = do
case version of
-- Version 1 doesn't support keep alive protocol but Blockfetch
-- still requires a PeerGSV per peer.
NodeToNodeV_1 -> forever (threadDelay 1000) >> return ((), Nothing)
NodeToNodeV_2 -> forever (threadDelay 1000) >> return ((), Nothing)
_ -> do
keepAliveRng <- newStdGen
peerGSVMap <- liftIO . newTVarIO $ Map.singleton them defaultGSV
runPeerWithLimits
kaClient _version them channel = do
keepAliveRng <- newStdGen
peerGSVMap <- liftIO . newTVarIO $ Map.singleton them defaultGSV
runPeerWithLimits
nullTracer
(cKeepAliveCodec myCodecs)
(byteLimitsKeepAlive (const 0)) -- TODO: Real Bytelimits, see #1727
timeLimitsKeepAlive
channel
$ keepAliveClientPeer
$ keepAliveClient
nullTracer
(cKeepAliveCodec myCodecs)
(byteLimitsKeepAlive (const 0)) -- TODO: Real Bytelimits, see #1727
timeLimitsKeepAlive
channel
$ keepAliveClientPeer
$ keepAliveClient
nullTracer
keepAliveRng
(continueForever (Proxy :: Proxy IO)) them peerGSVMap
(KeepAliveInterval 10)
keepAliveRng
(continueForever (Proxy :: Proxy IO)) them peerGSVMap
(KeepAliveInterval 10)

-- the null block fetch client
blockFetchClientNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import Cardano.Tracing.OrphanInstances.Consensus ()
import Cardano.Tracing.OrphanInstances.Network ()
import Cardano.Tracing.OrphanInstances.Shelley ()

import Ouroboros.Network.Protocol.TxSubmission.Type (TokBlockingStyle (..))
import Ouroboros.Network.Protocol.TxSubmission2.Type (TokBlockingStyle (..))

import Cardano.Api

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ import Ouroboros.Consensus.Shelley.Eras (StandardCrypto)
import Ouroboros.Consensus.Cardano.Block (GenTx (GenTxAllegra, GenTxAlonzo, GenTxShelley, GenTxMary))
import qualified Ouroboros.Consensus.Cardano.Block as Block (TxId(GenTxIdShelley, GenTxIdAllegra, GenTxIdAlonzo, GenTxIdMary))

import Ouroboros.Network.Protocol.TxSubmission.Client (ClientStIdle (..),
ClientStTxIds (..),
ClientStTxs (..),
TxSubmissionClient (..))
import Ouroboros.Network.Protocol.TxSubmission.Type (BlockingReplyList (..),
TokBlockingStyle (..), TxSizeInBytes)
import Ouroboros.Network.Protocol.TxSubmission2.Client (ClientStIdle (..),
ClientStTxIds (..),
ClientStTxs (..),
TxSubmissionClient (..))
import Ouroboros.Network.Protocol.TxSubmission2.Type (BlockingReplyList (..),
TokBlockingStyle (..), TxSizeInBytes)

import Cardano.Api
import Cardano.Api.Shelley (Tx(ShelleyTx), fromShelleyTxId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ getGenesis (SomeConsensusProtocol CardanoBlockType info) = shelleyBasedGenesis
(ProtocolInfoArgsCardano
_
Consensus.ProtocolParamsShelleyBased{Consensus.shelleyBasedGenesis}
_ _ _ _ _ _ _ _) = info
_ _ _ _ _ _ _ _ _ _) = info
getGenesis (SomeConsensusProtocol _ _ ) = error "getGenesis (SomeConsensusProtocol _ _ ) unknown protocol"

protocolToTopLevelConfig :: SomeConsensusProtocol -> TopLevelConfig CardanoBlock
Expand Down
39 changes: 27 additions & 12 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ package trace-resources
package byron-spec-ledger
tests: False

package compact-map
package vector-map
ghc-options: -Werror

package iohk-monitoring
Expand Down Expand Up @@ -168,8 +168,8 @@ source-repository-package
source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-base
tag: 394c4637c24d82325bd04ceb99c8e8df5617e663
--sha256: 02q8y69za5b0vsnj9qga1364vkmfc1kh35d0yshw1lf7nw9bls8m
tag: 631cb6cf1fa01ab346233b610a38b3b4cba6e6ab
--sha256: 0944wg2nqazmhlmsynwgdwxxj6ay0hb9qig9l128isb2cjia0hlp
subdir:
base-deriving-via
binary
Expand All @@ -191,12 +191,13 @@ source-repository-package
source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-ledger
tag: 1db68a3ec0a2dcb5751004beb22b906162474f23
--sha256: 03pv2jvskbi65dwaddp6a8bxbbcw674csjxhg8xbqd6q1kfpc41a
tag: c415253fff9a5ce9d7575230fc9098bcfee97653
--sha256: 1m4hq8yxcm7ny5vjzqkrl9qn9zmpr8c9xs0c98ix9hm9xd79fapc
subdir:
eras/alonzo/impl
eras/alonzo/test-suite
eras/babbage/impl
eras/babbage/test-suite
eras/byron/chain/executable-spec
eras/byron/crypto
eras/byron/crypto/test
Expand All @@ -211,7 +212,7 @@ source-repository-package
libs/cardano-ledger-pretty
libs/cardano-protocol-tpraos
libs/cardano-data
libs/compact-map
libs/vector-map
libs/set-algebra
libs/small-steps
libs/small-steps-test
Expand Down Expand Up @@ -256,11 +257,9 @@ source-repository-package
source-repository-package
type: git
location: https://github.com/input-output-hk/ouroboros-network
tag: ad47441e9e399495579d7dd05ccaf96b46a487b2
--sha256: 1a54yfc4m9n5j699cn8ln524h28043dyrlzn34wmnhsgqnxhavr4
tag: ea202b7b21983140d1944ccfde8750b891b59699
--sha256: 0bixx0b61sjzls7hzwjlgmvl0yk1ckd40cfazda8b3smqvxfrphq
subdir:
io-sim
io-classes
monoidal-synchronisation
network-mux
ouroboros-consensus
Expand All @@ -271,16 +270,32 @@ source-repository-package
ouroboros-network
ouroboros-network-framework
ouroboros-network-testing

source-repository-package
type: git
location: https://github.com/input-output-hk/io-sim
tag: 606de33fa2f467d108fb1efb86daeb3348bf34e3
--sha256: 048djqfdkzrbmdz670knbkjy12wddpvsmhm4x5yldg3w9lwqi1yx
subdir:
io-classes
io-sim
strict-stm

source-repository-package
type: git
location: https://github.com/input-output-hk/typed-protocols
tag: 91c3fba44d68439df207796171cd6f867354b76b
--sha256: 1h1nh10859kd7j8bb55y577jfdp42aqpppx8fn0pm6fra5748a50
subdir:
typed-protocols
typed-protocols-cborg
typed-protocols-examples

source-repository-package
type: git
location: https://github.com/input-output-hk/plutus
tag: ccf5bcb99ffe054dc8cd5626723f64e02708dbae
--sha256: 18569bgywilibz7r5jyxj9bid8g4fwr80cc0hd9rcm3jhasbgq8i
tag: fec94223a985e34d3b270460c8f150002f41b85b
--sha256: 1mwknikvbpv9lj43c3ya24v7wpcbpcsrk0fnh6knpi7ds4rmj9j0
subdir:
plutus-core
plutus-ledger-api
Expand Down
2 changes: 1 addition & 1 deletion cardano-api/cardano-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ library
, cardano-protocol-tpraos
, cardano-slotting
, cborg
, compact-map
, vector-map
, contra-tracer
, containers
, cryptonite
Expand Down
5 changes: 3 additions & 2 deletions cardano-api/gen/Gen/Cardano/Api.hs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ genCostModels = do
genAlonzoGenesis :: Gen Alonzo.AlonzoGenesis
genAlonzoGenesis = do
coinsPerUTxOWord <- genCoin (Range.linear 0 5)
costmdls' <- genCostModels
-- TODO: Babbage: Figure out how to deal with the asymmetric cost model JSON
_costmdls' <- genCostModels
prices' <- genPrices
maxTxExUnits' <- genExUnits
maxBlockExUnits' <- genExUnits
Expand All @@ -113,7 +114,7 @@ genAlonzoGenesis = do

return Alonzo.AlonzoGenesis
{ Alonzo.coinsPerUTxOWord = coinsPerUTxOWord
, Alonzo.costmdls = costmdls'
, Alonzo.costmdls = Alonzo.CostModels mempty
, Alonzo.prices = prices'
, Alonzo.maxTxExUnits = maxTxExUnits'
, Alonzo.maxBlockExUnits = maxBlockExUnits'
Expand Down
12 changes: 8 additions & 4 deletions cardano-api/gen/Gen/Cardano/Api/Typed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,9 @@ genProtocolParameters =
<*> genRational
<*> genRational
<*> Gen.maybe genLovelace
<*> genCostModels
<*> return mempty
--TODO: Babbage figure out how to deal with
-- asymmetric cost model JSON instances
<*> Gen.maybe genExecutionUnitPrices
<*> Gen.maybe genExecutionUnits
<*> Gen.maybe genExecutionUnits
Expand Down Expand Up @@ -783,7 +785,9 @@ genProtocolParametersUpdate = do
protocolUpdateMonetaryExpansion <- Gen.maybe genRational
protocolUpdateTreasuryCut <- Gen.maybe genRational
protocolUpdateUTxOCostPerWord <- Gen.maybe genLovelace
protocolUpdateCostModels <- genCostModels
let protocolUpdateCostModels = mempty -- genCostModels
--TODO: Babbage figure out how to deal with
-- asymmetric cost model JSON instances
protocolUpdatePrices <- Gen.maybe genExecutionUnitPrices
protocolUpdateMaxTxExUnits <- Gen.maybe genExecutionUnits
protocolUpdateMaxBlockExUnits <- Gen.maybe genExecutionUnits
Expand Down Expand Up @@ -814,8 +818,8 @@ genCostModel = case Plutus.defaultCostModelParams of
genPlutusLanguage :: Gen Language
genPlutusLanguage = Gen.element [PlutusV1, PlutusV2]

genCostModels :: Gen (Map AnyPlutusScriptVersion CostModel)
genCostModels =
_genCostModels :: Gen (Map AnyPlutusScriptVersion CostModel)
_genCostModels =
Gen.map (Range.linear 0 (length plutusScriptVersions))
((,) <$> Gen.element plutusScriptVersions
<*> genCostModel)
Expand Down
3 changes: 3 additions & 0 deletions cardano-api/src/Cardano/Api.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module Cardano.Api (
AllegraEra,
MaryEra,
AlonzoEra,
BabbageEra,
CardanoEra(..),
IsCardanoEra(..),
AnyCardanoEra(..),
Expand Down Expand Up @@ -550,6 +551,8 @@ module Cardano.Api (
ConsensusModeIsMultiEra(..),
AnyConsensusModeParams(..),
ConsensusModeParams(..),
ConsensusProtocol,
ChainDepStateProtocol,
ConsensusBlockForMode,
ConsensusBlockForEra,
EraInMode(..),
Expand Down
Loading

0 comments on commit 88a4e71

Please sign in to comment.