Skip to content
Permalink
Browse files

Merge pull request #744 from input-output-hk/mrBliss/switch-to-ChainD…

…B-impl

Prepare to switch over to the ChainDB implementation
  • Loading branch information...
mrBliss committed Jul 12, 2019
2 parents 82322b9 + 1485b0f commit cb8c6624ea6947b78136b6bd3a9022fda258aa86

Some generated files are not rendered by default. Learn more.

@@ -29,13 +29,13 @@ source-repository-package
type: git
location: https://github.com/input-output-hk/iohk-monitoring-framework
subdir: iohk-monitoring
tag: 9cb21a3ebf0f45bfb94ece3e6d62e613eca8b17b
tag: 3ac2191fc4c68b46b7f6c08e2873f71949cc68e7

source-repository-package
type: git
location: https://github.com/input-output-hk/iohk-monitoring-framework
subdir: contra-tracer
tag: 9cb21a3ebf0f45bfb94ece3e6d62e613eca8b17b
tag: 3ac2191fc4c68b46b7f6c08e2873f71949cc68e7

source-repository-package
type: git
@@ -58,25 +58,25 @@ source-repository-package
source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-ledger
tag: ccb81fc69285c127c47ce622c4996317556aff42
tag: 5241971fe563c90ea82b20af344116d46d672835
subdir: cardano-ledger

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-ledger
tag: ccb81fc69285c127c47ce622c4996317556aff42
tag: 5241971fe563c90ea82b20af344116d46d672835
subdir: crypto

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-ledger
tag: ccb81fc69285c127c47ce622c4996317556aff42
tag: 5241971fe563c90ea82b20af344116d46d672835
subdir: cardano-ledger/test

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-ledger
tag: ccb81fc69285c127c47ce622c4996317556aff42
tag: 5241971fe563c90ea82b20af344116d46d672835
subdir: crypto/test

source-repository-package
@@ -99,7 +99,7 @@ source-repository-package
source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-shell
tag: d2ab3fdc2ad69d6b2b9ab8897010ee731a14b403
tag: 92e6b42167d1399971df788b691423222722c2f6

source-repository-package
type: git

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

@@ -112,7 +112,7 @@ protocolInfoByron (NumCoreNodes numCoreNodes) (CoreNodeId nid) params gc =

instance Condense Cardano.Block.HeaderHash where
condense = formatToString Cardano.Block.headerHashF

instance DemoHeaderHash Cardano.Block.HeaderHash where
demoEncodeHeaderHash = encodeByronHeaderHash
demoDecodeHeaderHash = decodeByronHeaderHash
@@ -121,10 +121,16 @@ instance ByronGiven => RunDemo (ByronBlock ByronDemoConfig) where
demoForgeBlock = forgeBlock
demoBlockMatchesHeader = \_hdr _blk -> True -- TODO #595
demoBlockFetchSize = const 2000 -- TODO #593
demoIsEBB = const False -- TODO #704
demoEpochSize = \_ _ -> return 21600 -- TODO #226
demoEncodeBlock = encodeByronBlock . pbftEpochSlots . encNodeConfigExt
demoEncodeHeader = encodeByronHeader . pbftEpochSlots . encNodeConfigExt
demoEncodeGenTx = encodeByronGenTx
demoEncodeLedgerState = const encodeByronLedgerState
demoEncodeChainState = const encodeByronChainState
demoDecodeBlock = decodeByronBlock . pbftEpochSlots . encNodeConfigExt
demoDecodeHeader = decodeByronHeader . pbftEpochSlots . encNodeConfigExt
demoDecodeGenTx = decodeByronGenTx
demoDecodeLedgerState = const decodeByronLedgerState
demoDecodeChainState = const decodeByronChainState
demoMockTx = elaborateTx
@@ -18,6 +18,7 @@ import Ouroboros.Consensus.Block
import Ouroboros.Consensus.Demo.Run
import Ouroboros.Consensus.Ledger.Abstract
import Ouroboros.Consensus.Ledger.Mock
import Ouroboros.Consensus.Protocol.Abstract (ChainState)
import Ouroboros.Consensus.Util.Condense

{-------------------------------------------------------------------------------
@@ -40,14 +41,21 @@ instance ( ProtocolLedgerView (SimpleBlock SimpleMockCrypto ext)
, ForgeExt (BlockProtocol (SimpleBlock SimpleMockCrypto ext))
SimpleMockCrypto
ext
, Serialise (ChainState (BlockProtocol (SimpleBlock SimpleMockCrypto ext)))
) => RunDemo (SimpleBlock SimpleMockCrypto ext) where
demoForgeBlock = forgeSimple
demoBlockMatchesHeader = matchesSimpleHeader
demoBlockFetchSize = fromIntegral . simpleBlockSize . simpleHeaderStd
demoIsEBB = const False
demoEpochSize = \_ _ -> return 21600
demoEncodeBlock = const Serialise.encode
demoEncodeHeader = const Serialise.encode
demoEncodeGenTx = Serialise.encode
demoEncodeLedgerState = const Serialise.encode
demoEncodeChainState = const Serialise.encode
demoDecodeBlock = const Serialise.decode
demoDecodeHeader = const Serialise.decode
demoDecodeGenTx = Serialise.decode
demoDecodeLedgerState = const Serialise.decode
demoDecodeChainState = const Serialise.decode
demoMockTx = \_ -> SimpleGenTx
@@ -1,7 +1,11 @@
{-# LANGUAGE FlexibleInstances #-}

{-# OPTIONS_GHC -Wno-orphans #-}
module Ouroboros.Consensus.Demo.Ledger.Mock.PBFT (
protocolInfoMockPBFT
) where

import Codec.Serialise (Serialise (..))
import qualified Data.Bimap as Bimap
import qualified Data.Sequence as Seq

@@ -42,3 +46,7 @@ protocolInfoMockPBFT (NumCoreNodes numCoreNodes) (CoreNodeId nid) params =
where
addrDist :: AddrDist
addrDist = mkAddrDist numCoreNodes

instance Serialise (VerKeyDSIGN MockDSIGN) where
encode = encodeVerKeyDSIGN
decode = decodeVerKeyDSIGN
@@ -1,10 +1,18 @@
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE RecordWildCards #-}

{-# OPTIONS_GHC -Wno-orphans #-}
module Ouroboros.Consensus.Demo.Ledger.Mock.Praos (
protocolInfoPraos
) where

import Codec.CBOR.Decoding (decodeListLenOf)
import Codec.CBOR.Encoding (encodeListLen)
import Codec.Serialise (Serialise (..))
import Data.IntMap (IntMap)
import qualified Data.IntMap as IntMap

import Cardano.Binary (fromCBOR, toCBOR)
import Cardano.Crypto.KES
import Cardano.Crypto.VRF

@@ -51,3 +59,17 @@ protocolInfoPraos (NumCoreNodes numCoreNodes) (CoreNodeId nid) params =
verKeys = IntMap.fromList [ (nd, (VerKeyMockKES nd, VerKeyMockVRF nd))
| nd <- [0 .. numCoreNodes - 1]
]

instance Serialise (BlockInfo PraosMockCrypto) where
encode BlockInfo {..} = mconcat
[ encodeListLen 3
, encode biSlot
, toCBOR biRho
, encode biStake
]
decode = do
decodeListLenOf 3
biSlot <- decode
biRho <- fromCBOR
biStake <- decode
return BlockInfo {..}
@@ -20,6 +20,7 @@ module Ouroboros.Consensus.Demo.Run (
import Codec.CBOR.Decoding (Decoder)
import Codec.CBOR.Encoding (Encoding)
import Crypto.Random (MonadRandom)
import Data.Proxy (Proxy)

import Ouroboros.Network.Block (BlockNo, ChainHash (..), HeaderHash,
SlotNo)
@@ -34,6 +35,8 @@ import Ouroboros.Consensus.Mempool
import Ouroboros.Consensus.Protocol.Abstract
import Ouroboros.Consensus.Util.Condense

import Ouroboros.Storage.Common (EpochNo, EpochSize)

{-------------------------------------------------------------------------------
ProtocolInfo
-------------------------------------------------------------------------------}
@@ -75,6 +78,7 @@ class ( ProtocolLedgerView blk
, Show (ApplyTxErr blk)
, Condense (GenTx blk)
, Show (GenTx blk)
, Show (Header blk)
) => RunDemo blk where
demoForgeBlock :: (HasNodeState (BlockProtocol blk) m, MonadRandom m)
=> NodeConfig (BlockProtocol blk)
@@ -86,16 +90,23 @@ class ( ProtocolLedgerView blk
-> m blk
demoBlockMatchesHeader :: Header blk -> blk -> Bool
demoBlockFetchSize :: Header blk -> SizeInBytes
demoIsEBB :: blk -> Bool
demoEpochSize :: Monad m
=> Proxy blk -> EpochNo -> m EpochSize

-- Encoders
demoEncodeBlock :: NodeConfig (BlockProtocol blk) -> blk -> Encoding
demoEncodeHeader :: NodeConfig (BlockProtocol blk) -> Header blk -> Encoding
demoEncodeGenTx :: GenTx blk -> Encoding
demoEncodeBlock :: NodeConfig (BlockProtocol blk) -> blk -> Encoding
demoEncodeHeader :: NodeConfig (BlockProtocol blk) -> Header blk -> Encoding
demoEncodeGenTx :: GenTx blk -> Encoding
demoEncodeLedgerState :: NodeConfig (BlockProtocol blk) -> LedgerState blk -> Encoding
demoEncodeChainState :: Proxy blk -> ChainState (BlockProtocol blk) -> Encoding

-- Decoders
demoDecodeHeader :: forall s. NodeConfig (BlockProtocol blk) -> Decoder s (Header blk)
demoDecodeBlock :: forall s. NodeConfig (BlockProtocol blk) -> Decoder s blk
demoDecodeGenTx :: forall s. Decoder s (GenTx blk)
demoDecodeHeader :: forall s. NodeConfig (BlockProtocol blk) -> Decoder s (Header blk)
demoDecodeBlock :: forall s. NodeConfig (BlockProtocol blk) -> Decoder s blk
demoDecodeGenTx :: forall s. Decoder s (GenTx blk)
demoDecodeLedgerState :: forall s. NodeConfig (BlockProtocol blk) -> Decoder s (LedgerState blk)
demoDecodeChainState :: forall s. Proxy blk -> Decoder s (ChainState (BlockProtocol blk))

-- | Construct transaction from mock transaction
--

0 comments on commit cb8c662

Please sign in to comment.
You can’t perform that action at this time.