Skip to content

Commit

Permalink
Merge #2641
Browse files Browse the repository at this point in the history
2641: ThreadNet: add ShelleyAllegra tests r=mrBliss a=nfrisby

Fixes #2633.

This follows up #2627 by adding tests that exercise the ability to hard from from a Shelley-based era to the next Shelley-based era (in this case, Shelley to Allegra).

This PR introduces the `TwoEras.hs` infrastructure. For every era we have, we should have a two-era test that has a primary interest of whether or not a proposal in that era can successfully induce a hard fork, especially in the presence of a short network partition. I suggest, as part of Issue #2472, we should continue to emphasize these "Will it fork?" tests.

As of this PR, `Cardano.hs` tests that we can hard fork out of Byron and `ShelleyAllegra.hs` tests that we can hard fork out of `Shelley`. At the moment, both have two eras, and so they can share the infrastructure that was factored out into `TwoEras.hs`

Eventually `Cardano.hs` will have 3-4 eras. At that time, I propose we introduce a `Byron______.hs` module that specifically tests leaving Byron. Maybe to Byron again, or still to Shelley, etc. To summarize: we should have a separate test dedicated to testing each adjacent pair of eras on mainnet and one more that tests a hard fork from the last mainnet era to another copy of itself.

Edit: Edsko and I have something along these lines in mind while working on Issue 2472, the rewrite. But we hope to have it be a tidy consolidated thing instead of as explicit as the above proposal.

Co-authored-by: Thomas Winant <thomas@well-typed.com>
Co-authored-by: Nicolas Frisby <nick.frisby@iohk.io>
  • Loading branch information
3 people committed Nov 23, 2020
2 parents 5ba22a3 + 55eb8b0 commit 4efe729
Show file tree
Hide file tree
Showing 21 changed files with 1,518 additions and 488 deletions.
45 changes: 28 additions & 17 deletions .buildkite/slow-ThreadNet-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ set -euo pipefail

# A table of words as a Bash array
#
# Each row is <number of invocations per physical core> <suite> <number of
# tests per invocation>.
# Each row is <number of invocations per physical core> <suite> <test group
# pattern> <number of tests per invocation>.
#
# INVARIANT: No whitespace in any word.
#
Expand All @@ -24,16 +24,16 @@ set -euo pipefail
# overhead and also more reliable percentages in their QuickCheck statistics.
rows=(
# From the slowest individual invocation ...
'1 Cardano 1500' # ~70 minutes per invocation
'2 Shelley 2000' # ~35 minutes per invocation
'8 Shelley 400' # ~13 minutes per invocation
'5 Cardano 200' # ~9 minutes per invocation
'1 Cardano Cardano 1500' # ~95 minutes per invocation
'2 Shelley Shelley 2000' # ~37 minutes per invocation
'2 Cardano ShelleyAllegra 400' # ~37 minutes per invocation
'5 Cardano Cardano 200' # ~12 minutes per invocation
# ... to fastest individual invocation
#
# And the number of invocations is non-decreasing.
)

# The test suite names as a string of words
# The test suite names as a string, one name per line
listSuiteNames () {
for row in "${rows[@]}"; do
cols=($row) # parse the row as another Bash array
Expand All @@ -42,6 +42,15 @@ listSuiteNames () {
}
suites=$(listSuiteNames | sort -u)

# The test suite-group name pairs as a string, one pair per line
listSuiteGroupNames () {
for row in "${rows[@]}"; do
cols=($row) # parse the row as another Bash array
echo ${cols[1]}-${cols[2]}
done
}
suitegroups=$(listSuiteGroupNames | sort -u)

#-------------------------------------------------------------------------------
# Script robustness
#-------------------------------------------------------------------------------
Expand Down Expand Up @@ -88,11 +97,11 @@ finish () {
# Don't abort during this exception handler
set +e

# Collect each suite's logs into one artifact file
for suite in $suites; do
forEachFile "$logAbsDir" "*-${suite}.log" \
# Collect each suite-group pairs's logs into one artifact file
for suitegroup in $suitegroups; do
forEachFile "$logAbsDir" "*-${suitegroup}.log" \
'echo "==> {} <=="; cat "{}"; echo;' \
1>"${logAbsDir}/${suite}-artifact.log"
1>"${logAbsDir}/${suitegroup}-artifact.log"
done

if [ "true" = "${BUILDKITE-}" ]
Expand Down Expand Up @@ -155,13 +164,14 @@ done
innerCommand () {
uniqueInvocationId="$(printf %03d $PARALLEL_SEQ)"
suite=$1
n=$2
group=$2
n=$3

logfile="${logAbsDir}/${uniqueInvocationId}-${suite}.log"
logfile="${logAbsDir}/${uniqueInvocationId}-${suite}-${group}.log"

# Run the specified tests with the nightly flag set
"${nixAbsDir}/${suite}/bin/test" \
--pattern "$suite ThreadNet" \
--pattern "$group ThreadNet" \
--quickcheck-tests=$n \
--iohk-enable-nightly-tests \
1>"$logfile" 2>&1
Expand All @@ -173,7 +183,7 @@ innerCommand () {
# Likely atomic, since it's almost surely less than PIPE_BUF.
#
# https://arto.s3.amazonaws.com/notes/posix#pipe-buf
echo Completed Invocation-${uniqueInvocationId}, $suite ${n}: \
echo Completed Invocation-${uniqueInvocationId}, $suite $group ${n}: \
$(tail -n1 "$logfile")

return $xc
Expand All @@ -192,10 +202,11 @@ genCommands () {
expandRow () {
numInvocations=$(expr $numCores "*" $1)
suite=$2
numTests=$3
group=$3
numTests=$4

for i in $(seq $numInvocations); do
echo innerCommand $suite $numTests
echo innerCommand $suite $group $numTests
done
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ library
Test.Consensus.Cardano.Generators
Test.Consensus.Cardano.MockCrypto

Test.ThreadNet.Infra.ShelleyBasedHardFork
Test.ThreadNet.Infra.TwoEras

Test.ThreadNet.TxGen.Allegra
Test.ThreadNet.TxGen.Cardano

build-depends: base
Expand Down Expand Up @@ -77,6 +81,7 @@ test-suite test
Test.Consensus.Cardano.Golden
Test.Consensus.Cardano.Serialisation
Test.ThreadNet.Cardano
Test.ThreadNet.ShelleyAllegra

build-depends: base
, bytestring
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import Ouroboros.Consensus.Util.Counting (Exactly (..))
import Ouroboros.Consensus.Util.SOP (Index (..))

import Ouroboros.Consensus.HardFork.Combinator
import Ouroboros.Consensus.HardFork.Combinator.Nary
import Ouroboros.Consensus.HardFork.Combinator.Embed.Nary
import qualified Ouroboros.Consensus.HardFork.Combinator.State as State

import Ouroboros.Consensus.Byron.Ledger (ByronBlock)
Expand Down
Loading

0 comments on commit 4efe729

Please sign in to comment.