Skip to content

Commit

Permalink
Merge #2502
Browse files Browse the repository at this point in the history
2502: Extend Cardano ThreadNet tests so that Shelley era contains active stake pools r=nfrisby a=nfrisby

Fixes #2388.

The big commit could be decomposed a little, but the excess diff I'm thinking of is mostly minor (whitespace/renaming/adding one param to `testGenTxs` etc) and localized -- it's obvious when you see it. Please ping me if the decomposition would be worthwhile by making your review that much easier.

cc: @edsko FYI

Co-authored-by: Nicolas Frisby <nick.frisby@iohk.io>
  • Loading branch information
iohk-bors[bot] and nfrisby authored Aug 24, 2020
2 parents 50955c0 + 5f6e5ae commit 2988a23
Show file tree
Hide file tree
Showing 14 changed files with 593 additions and 112 deletions.
4 changes: 2 additions & 2 deletions .buildkite/slow-ThreadNet-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ set -euo pipefail
# overhead and also more reliable percentages in their QuickCheck statistics.
rows=(
# From the slowest individual invocation ...
'1 Cardano 5000' # ~45 minutes per invocation
'1 Cardano 2000' # ~35 minutes per invocation
'2 RealTPraos 200' # ~30 minutes per invocation (but high variance)
'4 RealTPraos 100' # ~15 minutes per invocation (but high variance)
'5 Cardano 500' # ~5 minutes per invocation
'5 Cardano 300' # ~5 minutes per invocation
# ... to fastest individual invocation
#
# And the number of invocations is non-decreasing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ import Test.ThreadNet.TxGen
instance TxGen ByronBlock where
-- We don't generate transactions for 'ByronBlock', but we do for
-- 'DualByronBlock'.
testGenTxs _ _ _ _ _ = return []
testGenTxs _ _ _ _ _ _ = return []
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ realPBftParams ByronSpecGenesis{..} =
-------------------------------------------------------------------------------}

instance TxGen DualByronBlock where
testGenTxs _numCoreNodes curSlotNo cfg () = \st -> do
testGenTxs _coreNodeId _numCoreNodes curSlotNo cfg () = \st -> do
n <- choose (0, 20)
go [] n $ applyChainTick (configLedger cfg) curSlotNo st
where
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ test-suite test
main-is: Main.hs
other-modules:
Test.Consensus.Cardano.ByronCompatibility
Test.Consensus.Cardano.Examples
Test.Consensus.Cardano.Generators
Test.Consensus.Cardano.Golden
Test.Consensus.Cardano.Examples
Test.Consensus.Cardano.MockCrypto
Test.Consensus.Cardano.Serialisation
Test.Consensus.Cardano.Translation
Test.ThreadNet.Cardano
Expand All @@ -87,6 +88,7 @@ test-suite test
, bytestring >=0.10 && <0.11
, cardano-binary
, cardano-crypto-class
, cardano-crypto-wrapper
, cardano-ledger
, cardano-ledger-test
, cardano-slotting
Expand All @@ -102,6 +104,7 @@ test-suite test
, time

, shelley-spec-ledger
, shelley-spec-ledger-test

, ouroboros-network
, ouroboros-consensus
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Test.Consensus.Cardano.MockCrypto (
BlockCompatByron
, TPraosMockCryptoCompatByron
) where

import Cardano.Crypto.DSIGN (Ed25519DSIGN)
import Cardano.Crypto.Hash (Blake2b_224, HashAlgorithm)
import Cardano.Crypto.KES (MockKES)

import Test.Cardano.Crypto.VRF.Fake (FakeVRF)

import Ouroboros.Consensus.Shelley.Ledger (ShelleyBlock)
import Ouroboros.Consensus.Shelley.Protocol.Crypto (TPraosCrypto)

import Shelley.Spec.Ledger.Crypto (Crypto (..))

-- | A mock replacement for 'TPraosStandardCrypto' that is compatible with
-- bootstrapping from Byron
--
-- This mocks more components than does
-- 'Test.Consensus.Shelley.MockCrypto.TPraosMockCrypto'. This prevents the
-- @cardano-ledger-specs@ generators from being re-used. Currently, this is not
-- an obstacle for example in the Cardano ThreadNet tests.
--
-- NOTE: The "Ouroboros.Consensus.Cardano.CanHardFork" translation currently
-- assumes that @ADDRHASH@ has the same bit size as Byron address hashes (ie
-- 224); that's why we use 'Blake2b_224' here.
--
-- NOTE: The @shelley-spec-ledger@ package currently requires that @'DSIGN' ~
-- 'Ed25519DSIGN' in order to use Byron bootstrap witnesses.
data TPraosMockCryptoCompatByron h

instance HashAlgorithm h => Crypto (TPraosMockCryptoCompatByron h) where
type ADDRHASH (TPraosMockCryptoCompatByron h) = Blake2b_224
type DSIGN (TPraosMockCryptoCompatByron h) = Ed25519DSIGN
type HASH (TPraosMockCryptoCompatByron h) = h
type KES (TPraosMockCryptoCompatByron h) = MockKES 10
type VRF (TPraosMockCryptoCompatByron h) = FakeVRF

instance HashAlgorithm h => TPraosCrypto (TPraosMockCryptoCompatByron h)

type BlockCompatByron h = ShelleyBlock (TPraosMockCryptoCompatByron h)
Loading

0 comments on commit 2988a23

Please sign in to comment.