diff --git a/Jenkinsfile b/Jenkinsfile index 84f10c44f..ac7c86877 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,9 +11,12 @@ def runStages() { [$class: "ArbitraryFileCache", excludes: "", includes: "**/*", path: "${WORKSPACE}/jsonTestsCache"] ]) { stage("Build") { - sh "make -j${env.NPROC} update" /* to allow a newer Nim version to be detected */ - sh "make -j${env.NPROC} deps" /* to allow the following parallel stages */ - sh "V=1 ./scripts/setup_official_tests.sh jsonTestsCache" + sh """#!/bin/bash + set -e + make -j${env.NPROC} update # to allow a newer Nim version to be detected + make -j${env.NPROC} deps # to allow the following parallel stages + V=1 ./scripts/setup_official_tests.sh jsonTestsCache + """ } } @@ -21,8 +24,11 @@ def runStages() { parallel( "tools": { stage("Tools") { - sh "make -j${env.NPROC}" - sh "make -j${env.NPROC} LOG_LEVEL=TRACE NIMFLAGS='-d:testnet_servers_image'" + sh """#!/bin/bash + set -e + make -j${env.NPROC} + make -j${env.NPROC} LOG_LEVEL=TRACE NIMFLAGS='-d:testnet_servers_image' + """ } }, "test suite": { @@ -32,8 +38,11 @@ def runStages() { if ("${NODE_NAME}" ==~ /linux.*/) { stage("testnet finalization") { // EXECUTOR_NUMBER will be 0 or 1, since we have 2 executors per Jenkins node - sh "timeout -k 20s 10m ./scripts/launch_local_testnet.sh --testnet 0 --nodes 4 --log-level INFO --disable-htop --base-port \$(( 9000 + EXECUTOR_NUMBER * 100 )) --base-metrics-port \$(( 8008 + EXECUTOR_NUMBER * 100 )) -- --verify-finalization --stop-at-epoch=5" - sh "timeout -k 20s 40m ./scripts/launch_local_testnet.sh --testnet 1 --nodes 4 --log-level INFO --disable-htop --base-port \$(( 9000 + EXECUTOR_NUMBER * 100 )) --base-metrics-port \$(( 8008 + EXECUTOR_NUMBER * 100 )) -- --verify-finalization --stop-at-epoch=5" + sh """#!/bin/bash + set -e + timeout -k 20s 10m ./scripts/launch_local_testnet.sh --testnet 0 --nodes 4 --log-level INFO --disable-htop --base-port \$(( 9000 + EXECUTOR_NUMBER * 100 )) --base-metrics-port \$(( 8008 + EXECUTOR_NUMBER * 100 )) -- --verify-finalization --stop-at-epoch=5 + timeout -k 20s 40m ./scripts/launch_local_testnet.sh --testnet 1 --nodes 4 --log-level INFO --disable-htop --base-port \$(( 9000 + EXECUTOR_NUMBER * 100 )) --base-metrics-port \$(( 8008 + EXECUTOR_NUMBER * 100 )) -- --verify-finalization --stop-at-epoch=5 + """ } } } diff --git a/beacon_chain/eth2_network.nim b/beacon_chain/eth2_network.nim index 90f8e6e5e..c2516d712 100644 --- a/beacon_chain/eth2_network.nim +++ b/beacon_chain/eth2_network.nim @@ -4,8 +4,9 @@ import options as stdOptions, net as stdNet, # Status libs - stew/[varints, base58, bitseqs, results], stew/shims/[macros, tables], - stint, faststreams/[inputs, outputs, buffers], snappy, snappy/framing, + stew/[varints, base58, bitseqs, endians2, results], + stew/shims/[macros, tables], + faststreams/[inputs, outputs, buffers], snappy, snappy/framing, json_serialization, json_serialization/std/[net, options], chronos, chronicles, metrics, # TODO: create simpler to use libp2p modules that use re-exports @@ -719,11 +720,14 @@ proc start*(node: Eth2Node) {.async.} = traceAsyncErrors node.discoveryLoop proc stop*(node: Eth2Node) {.async.} = - # ignore errors in futures, since we're shutting down - await allFutures(@[ - node.discovery.closeWait(), - node.switch.stop(), - ]) + # Ignore errors in futures, since we're shutting down. + # Use a timer to avoid hangups. + discard await one(sleepAsync(5.seconds), + allFutures(@[ + node.discovery.closeWait(), + node.switch.stop(), + ]) + ) proc init*(T: type Peer, network: Eth2Node, info: PeerInfo): Peer = new result diff --git a/beacon_chain/ssz.nim b/beacon_chain/ssz.nim index 1a48e0481..46f3e8e4d 100644 --- a/beacon_chain/ssz.nim +++ b/beacon_chain/ssz.nim @@ -14,7 +14,7 @@ import options, algorithm, options, strformat, typetraits, - stint, stew/[bitops2, bitseqs, objects, varints, ptrops], + stew/[bitops2, bitseqs, endians2, objects, varints, ptrops], stew/ranges/[ptr_arith, stackarrays], stew/shims/macros, faststreams/[inputs, outputs, buffers], serialization, serialization/testing/tracing, @@ -44,7 +44,7 @@ type SszWriter* = object stream: OutputStream - BasicType = byte|char|bool|SomeUnsignedInt|StUint + BasicType = byte|char|bool|SomeUnsignedInt SszChunksMerkleizer = object combinedChunks: StackArray[Eth2Digest] @@ -105,7 +105,7 @@ proc writeFixedSized(s: var (OutputStream|WriteCursor), x: auto) {.raises: [Defe s.write x elif x is bool|char: s.write byte(ord(x)) - elif x is SomeUnsignedInt|StUint: + elif x is SomeUnsignedInt: when cpuEndian == bigEndian: s.write toBytesLE(x) else: @@ -418,7 +418,7 @@ template merkleizeFields(totalElements: int, body: untyped): Eth2Digest = getFinalHash(merkleizer) template writeBytesLE(chunk: var array[bytesPerChunk, byte], atParam: int, - val: SomeUnsignedInt|StUint) = + val: SomeUnsignedInt) = let at = atParam chunk[at ..< at + sizeof(val)] = toBytesLE(val) @@ -448,7 +448,7 @@ func chunkedHashTreeRootForBasicTypes[T](merkleizer: var SszChunksMerkleizer, else: static: - assert T is SomeUnsignedInt|StUInt + assert T is SomeUnsignedInt assert bytesPerChunk mod sizeof(Т) == 0 const valuesPerChunk = bytesPerChunk div sizeof(Т) @@ -539,7 +539,7 @@ func hashTreeRootAux[T](x: T): Eth2Digest = unsupported T # Blocks are identified by htr(BeaconBlock) so we avoid these elif T is bool|char: result.data[0] = byte(x) - elif T is SomeUnsignedInt|StUint: + elif T is SomeUnsignedInt: when cpuEndian == bigEndian: result.data[0..