Nim-1.6 compatibility (#3434)

This commit is contained in:
Ștefan Talpalaru 2022-02-25 09:19:12 +01:00 committed by GitHub
parent 975b244c4a
commit ebba093362
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 122 additions and 203 deletions

View File

@ -2,81 +2,48 @@ name: CI
on: on:
push: push:
paths-ignore: ['media/**', 'docs/**', '**/*.md'] paths-ignore: ['media/**', 'docs/**', '**/*.md']
branches:
- stable
- testing
- unstable
pull_request: pull_request:
paths-ignore: ['media/**', 'docs/**', '**/*.md'] paths-ignore: ['media/**', 'docs/**', '**/*.md']
workflow_dispatch:
jobs: jobs:
build: build:
strategy: strategy:
fail-fast: false fail-fast: false
max-parallel: 20
matrix: matrix:
target: target:
# Unit tests
- os: linux - os: linux
cpu: amd64 cpu: amd64
TEST_KIND: unit-tests
- os: linux - os: linux
cpu: i386 cpu: i386
TEST_KIND: unit-tests
- os: macos - os: macos
cpu: amd64 cpu: amd64
TEST_KIND: unit-tests
- os: windows - os: windows
cpu: amd64 cpu: amd64
TEST_KIND: unit-tests branch: [version-1-2, version-1-6]
# Devel cache corrupted for mingw? missing propidl.h on PR but not push CI
# - os: windows
# cpu: i386
# TEST_KIND: unit-tests
# # Minimal integration tests
# - os: linux
# cpu: amd64
# TEST_KIND: finalization-minimal
# - os: linux
# cpu: i386
# TEST_KIND: finalization-minimal
# # Requires GNU getopt
# - os: macos
# cpu: amd64
# TEST_KIND: finalization-minimal
# - os: windows
# cpu: amd64
# TEST_KIND: finalization-minimal
# # TODO - Bootstrap issue: https://github.com/status-im/nimbus-eth2/issues/1725
# # - os: windows
# # cpu: i386
# # TEST_KIND: finalization-minimal
# Mainnet integration tests
# - os: linux
# cpu: amd64
# TEST_KIND: finalization-mainnet
# # - os: linux
# # cpu: i386
# # TEST_KIND: finalization-mainnet
# # - os: macos
# # cpu: amd64
# # TEST_KIND: finalization-mainnet
# - os: windows
# cpu: amd64
# TEST_KIND: finalization-mainnet
# # TODO - Bootstrap issue: https://github.com/status-im/nimbus-eth2/issues/1725
# # - os: windows
# # cpu: i386
# # TEST_KIND: finalization-mainnet
include: include:
- target: - target:
os: linux os: linux
builder: ubuntu-18.04 builder: ubuntu-18.04
shell: bash
- target: - target:
os: macos os: macos
builder: macos-10.15 builder: macos-10.15
shell: bash
- target: - target:
os: windows os: windows
builder: windows-2019 builder: windows-2019
name: '${{ matrix.target.os }}-${{ matrix.target.cpu }} (${{ matrix.target.TEST_KIND }})' shell: msys2 {0}
defaults:
run:
shell: ${{ matrix.shell }}
name: '${{ matrix.target.os }}-${{ matrix.target.cpu }} (Nim ${{ matrix.branch }})'
runs-on: ${{ matrix.builder }} runs-on: ${{ matrix.builder }}
steps: steps:
- name: Get branch name - name: Get branch name
@ -91,65 +58,17 @@ jobs:
fi fi
id: get_branch id: get_branch
- name: Cancel Previous Runs (except master/devel) - name: Cancel Previous Runs (except main branches)
if: > if: >
steps.get_branch.outputs.branch_name != 'master' &&
steps.get_branch.outputs.branch_name != 'devel' &&
steps.get_branch.outputs.branch_name != 'stable' && steps.get_branch.outputs.branch_name != 'stable' &&
steps.get_branch.outputs.branch_name != 'unstable' && steps.get_branch.outputs.branch_name != 'unstable' &&
steps.get_branch.outputs.branch_name != 'testing' steps.get_branch.outputs.branch_name != 'testing'
uses: styfle/cancel-workflow-action@0.5.0 uses: styfle/cancel-workflow-action@0.9.1
with: with:
access_token: ${{ github.token }} access_token: ${{ github.token }}
- name: Support longpaths (Windows) - name: Checkout
if: runner.os == 'Windows'
run: git config --system core.longpaths true
- name: Checkout nimbus-eth2
uses: actions/checkout@v2 uses: actions/checkout@v2
with:
path: nimbus-eth2
- name: Derive environment variables
shell: bash
run: |
if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
ARCH=64
PLATFORM=x64
else
ARCH=32
PLATFORM=x86
fi
echo "ARCH=$ARCH" >> $GITHUB_ENV
echo "PLATFORM=$PLATFORM" >> $GITHUB_ENV
# Stack usage test on recent enough gcc:
if [[ '${{ runner.os }}' == 'Linux' && '${{ matrix.target.cpu }}' == 'amd64' ]]; then
export NIMFLAGS="${NIMFLAGS} -d:limitStackUsage"
echo "NIMFLAGS=$NIMFLAGS" >> $GITHUB_ENV
fi
# libminiupnp / natpmp
if [[ '${{ runner.os }}' == 'Linux' && '${{ matrix.target.cpu }}' == 'i386' ]]; then
export CFLAGS="${CFLAGS} -m32 -mno-adx"
echo "CFLAGS=$CFLAGS" >> $GITHUB_ENV
fi
ncpu=
case '${{ runner.os }}' in
'Linux')
ncpu=$(nproc)
;;
'macOS')
ncpu=$(sysctl -n hw.ncpu)
;;
'Windows')
ncpu=$NUMBER_OF_PROCESSORS
;;
esac
[[ -z "$ncpu" || $ncpu -le 0 ]] && ncpu=1
echo "ncpu=$ncpu" >> $GITHUB_ENV
- name: Install build dependencies (Linux i386) - name: Install build dependencies (Linux i386)
if: runner.os == 'Linux' && matrix.target.cpu == 'i386' if: runner.os == 'Linux' && matrix.target.cpu == 'i386'
@ -170,154 +89,142 @@ jobs:
chmod 755 external/bin/gcc external/bin/g++ chmod 755 external/bin/gcc external/bin/g++
echo "${{ github.workspace }}/external/bin" >> $GITHUB_PATH echo "${{ github.workspace }}/external/bin" >> $GITHUB_PATH
- name: Restore MinGW-W64 (Windows) from cache - name: MSYS2 (Windows i386)
if: runner.os == 'Windows' if: runner.os == 'Windows' && matrix.target.cpu == 'i386'
id: windows-mingw-cache uses: msys2/setup-msys2@v2
uses: actions/cache@v2
with: with:
path: external/mingw-${{ matrix.target.cpu }} path-type: inherit
key: 'mingw-${{ matrix.target.cpu }}-cachekey_v2' msystem: MINGW32
install: >-
base-devel
git
mingw-w64-i686-toolchain
- name: MSYS2 (Windows amd64)
if: runner.os == 'Windows' && matrix.target.cpu == 'amd64'
uses: msys2/setup-msys2@v2
with:
path-type: inherit
install: >-
base-devel
git
mingw-w64-x86_64-toolchain
- name: Restore Nim DLLs dependencies (Windows) from cache - name: Restore Nim DLLs dependencies (Windows) from cache
if: runner.os == 'Windows' if: runner.os == 'Windows'
id: windows-dlls-cache id: windows-dlls-cache
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: external/dlls-${{ matrix.target.cpu }} path: external/dlls
key: 'dlls-${{ matrix.target.cpu }}' key: 'dlls-${{ matrix.target.cpu }}'
- name: Install MinGW64 dependency (Windows)
if: >
steps.windows-mingw-cache.outputs.cache-hit != 'true' &&
runner.os == 'Windows'
shell: bash
run: |
mkdir -p external
curl -L "https://nim-lang.org/download/mingw$ARCH.7z" -o "external/mingw-${{ matrix.target.cpu }}.7z"
7z x -y "external/mingw-${{ matrix.target.cpu }}.7z" -oexternal/
mv external/mingw$ARCH external/mingw-${{ matrix.target.cpu }}
- name: Install DLLs dependencies (Windows) - name: Install DLLs dependencies (Windows)
if: > if: >
steps.windows-dlls-cache.outputs.cache-hit != 'true' && steps.windows-dlls-cache.outputs.cache-hit != 'true' &&
runner.os == 'Windows' runner.os == 'Windows'
shell: bash
run: | run: |
mkdir -p external mkdir -p external
curl -L "https://nim-lang.org/download/windeps.zip" -o external/windeps.zip curl -L "https://nim-lang.org/download/windeps.zip" -o external/windeps.zip
7z x -y external/windeps.zip -oexternal/dlls-${{ matrix.target.cpu }} 7z x -y external/windeps.zip -oexternal/dlls
- name: Path to cached dependencies (Windows) - name: Path to cached dependencies (Windows)
if: > if: >
runner.os == 'Windows' runner.os == 'Windows'
shell: bash
run: | run: |
echo "${{ github.workspace }}/external/mingw-${{ matrix.target.cpu }}/bin" >> $GITHUB_PATH echo "${{ github.workspace }}/external/dlls" >> $GITHUB_PATH
echo "${{ github.workspace }}/external/dlls-${{ matrix.target.cpu }}" >> $GITHUB_PATH # for miniupnp that runs "wingenminiupnpcstrings.exe" from the current dir
echo "." >> $GITHUB_PATH
- name: Install build dependencies (MacOS) - name: Install build dependencies (macOS)
if: runner.os == 'macOS' if: runner.os == 'macOS'
shell: bash
run: | run: |
brew install gnu-getopt brew install gnu-getopt
brew link --force gnu-getopt brew link --force gnu-getopt
- name: Get latest nimbus-build-system commit hash - name: Derive environment variables
id: versions
shell: bash
run: | run: |
getHash() { if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
git ls-remote "https://github.com/$1" "${2:-HEAD}" | cut -f 1 PLATFORM=x64
} else
nbsHash=$(getHash status-im/nimbus-build-system) PLATFORM=x86
echo "::set-output name=nimbus_build_system::$nbsHash" fi
echo "PLATFORM=${PLATFORM}" >> $GITHUB_ENV
- name: Restore prebuilt Nim binaries from cache # Stack usage test on recent enough gcc:
id: nim-cache if [[ '${{ runner.os }}' == 'Linux' && '${{ matrix.target.cpu }}' == 'amd64' ]]; then
uses: actions/cache@v2 export NIMFLAGS="${NIMFLAGS} -d:limitStackUsage"
with: echo "NIMFLAGS=${NIMFLAGS}" >> $GITHUB_ENV
path: nimbus-eth2/NimBinaries fi
key: 'nim-${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ steps.versions.outputs.nimbus_build_system }}'
# libminiupnp / natpmp
if [[ '${{ runner.os }}' == 'Linux' && '${{ matrix.target.cpu }}' == 'i386' ]]; then
export CFLAGS="${CFLAGS} -m32 -mno-adx"
echo "CFLAGS=${CFLAGS}" >> $GITHUB_ENV
fi
ncpu=""
case '${{ runner.os }}' in
'Linux')
ncpu=$(nproc)
;;
'macOS')
ncpu=$(sysctl -n hw.ncpu)
;;
'Windows')
ncpu=${NUMBER_OF_PROCESSORS}
;;
esac
[[ -z "$ncpu" || $ncpu -le 0 ]] && ncpu=1
echo "ncpu=${ncpu}" >> $GITHUB_ENV
- name: Build Nim and Nimbus dependencies - name: Build Nim and Nimbus dependencies
shell: bash
working-directory: nimbus-eth2
run: | run: |
if [[ "${{ runner.os }}" == "macOS" ]]; then make -j ${ncpu} NIM_COMMIT=${{ matrix.branch }} ARCH_OVERRIDE=${PLATFORM} QUICK_AND_DIRTY_COMPILER=1 update
ulimit -n 1024 ./env.sh nim --version
fi
make -j$ncpu ARCH_OVERRIDE=$PLATFORM CI_CACHE=NimBinaries QUICK_AND_DIRTY_COMPILER=1 update
- name: Get latest fixtures commit hash - name: Get latest fixtures commit hash
if: matrix.target.TEST_KIND == 'unit-tests'
id: fixtures_version id: fixtures_version
shell: bash
run: | run: |
getHash() { getHash() {
git ls-remote "https://github.com/$1" "${2:-HEAD}" | cut -f 1 git ls-remote "https://github.com/$1" "${2:-HEAD}" | cut -f 1
} }
fixturesHash=$(getHash status-im/nim-eth2-scenarios) fixturesHash=$(getHash status-im/nim-eth2-scenarios)
echo "::set-output name=fixtures::$fixturesHash" echo "::set-output name=fixtures::${fixturesHash}"
- name: Restore Ethereum Foundation fixtures from cache - name: Restore Ethereum Foundation fixtures from cache
if: matrix.target.TEST_KIND == 'unit-tests'
id: fixtures-cache id: fixtures-cache
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: nimbus-eth2/fixturesCache path: fixturesCache
key: 'eth2-scenarios-${{ steps.fixtures_version.outputs.fixtures }}' key: 'eth2-scenarios-${{ steps.fixtures_version.outputs.fixtures }}'
# Important: even with a cache hit, this should be run # Important: even with a cache hit, this should be run
# as it symlinks the cached items in their proper place # as it symlinks the cached items in their proper place
- name: Get the Ethereum Foundation fixtures - name: Get the Ethereum Foundation fixtures
if: matrix.target.TEST_KIND == 'unit-tests'
shell: bash
working-directory: nimbus-eth2
run: | run: |
scripts/setup_scenarios.sh fixturesCache scripts/setup_scenarios.sh fixturesCache
- name: Smoke test the Beacon Node and Validator Client with all tracing enabled - name: Smoke test the Beacon Node and Validator Client with all tracing enabled
if: matrix.target.TEST_KIND == 'unit-tests'
shell: bash
working-directory: nimbus-eth2
run: | run: |
if [[ "${{ runner.os }}" == "macOS" ]]; then make -j ${ncpu} NIM_COMMIT=${{ matrix.branch }} LOG_LEVEL=TRACE nimbus_beacon_node nimbus_validator_client
ulimit -n 1024
fi
make -j$ncpu ARCH_OVERRIDE=$PLATFORM LOG_LEVEL=TRACE nimbus_beacon_node nimbus_validator_client
- name: Run nimbus-eth2 tests - name: Build all tools
if: matrix.target.TEST_KIND == 'unit-tests'
shell: bash
working-directory: nimbus-eth2
run: | run: |
if [[ "${{ runner.os }}" == "macOS" ]]; then make -j ${ncpu} NIM_COMMIT=${{ matrix.branch }}
ulimit -n 1024 # The Windows image runs out of disk space, so make some room
fi rm -rf nimcache
make -j$ncpu ARCH_OVERRIDE=$PLATFORM DISABLE_TEST_FIXTURES_SCRIPT=1 test
- name: Run tests
run: |
make -j ${ncpu} NIM_COMMIT=${{ matrix.branch }} DISABLE_TEST_FIXTURES_SCRIPT=1 test
# The upload creates a combined report that gets posted as a comment on the PR # The upload creates a combined report that gets posted as a comment on the PR
# https://github.com/EnricoMi/publish-unit-test-result-action # https://github.com/EnricoMi/publish-unit-test-result-action
- name: Upload combined results - name: Upload combined results
if: matrix.target.TEST_KIND == 'unit-tests'
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
with: with:
name: Unit Test Results ${{ matrix.target.os }}-${{ matrix.target.cpu }} name: Unit Test Results ${{ matrix.target.os }}-${{ matrix.target.cpu }}
path: nimbus-eth2/build/*.xml path: build/*.xml
- name: Run nimbus-eth2 testnet0 (minimal)
if: matrix.target.TEST_KIND == 'finalization-minimal'
shell: bash
working-directory: nimbus-eth2
run: |
./scripts/launch_local_testnet.sh --preset minimal --nodes 4 --stop-at-epoch 5 --log-level DEBUG --disable-htop --enable-logtrace --data-dir local_testnet0_data --base-port 9000 --base-rpc-port 7000 --base-metrics-port 8008 --timeout 600 -- --verify-finalization --discv5:no
- name: Run nimbus-eth2 testnet1 (mainnet)
if: matrix.target.TEST_KIND == 'finalization-mainnet'
shell: bash
working-directory: nimbus-eth2
run: |
./scripts/launch_local_testnet.sh --nodes 4 --stop-at-epoch 5 --log-level DEBUG --disable-htop --enable-logtrace --data-dir local_testnet0_data --base-port 9000 --base-rpc-port 7000 --base-metrics-port 8008 --timeout 2400 -- --verify-finalization --discv5:no
# https://github.com/EnricoMi/publish-unit-test-result-action # https://github.com/EnricoMi/publish-unit-test-result-action
event_file: event_file:

View File

@ -9,7 +9,6 @@ jobs:
build: build:
strategy: strategy:
fail-fast: false fail-fast: false
max-parallel: 20
matrix: matrix:
target: target:
- os: linux - os: linux
@ -45,13 +44,13 @@ jobs:
runs-on: ${{ matrix.builder }} runs-on: ${{ matrix.builder }}
continue-on-error: ${{ matrix.branch == 'version-1-6' || matrix.branch == 'devel' }} continue-on-error: ${{ matrix.branch == 'version-1-6' || matrix.branch == 'devel' }}
steps: steps:
- name: Checkout nimbus-eth2 - name: Checkout
if: ${{ github.event_name != 'pull_request' }} if: ${{ github.event_name != 'pull_request' }}
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
ref: unstable ref: unstable
- name: Checkout nimbus-eth2 (pull request) - name: Checkout (pull request)
if: ${{ github.event_name == 'pull_request' }} if: ${{ github.event_name == 'pull_request' }}
uses: actions/checkout@v2 uses: actions/checkout@v2
@ -100,7 +99,7 @@ jobs:
id: windows-dlls-cache id: windows-dlls-cache
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: external/dlls-${{ matrix.target.cpu }} path: external/dlls
key: 'dlls-${{ matrix.target.cpu }}' key: 'dlls-${{ matrix.target.cpu }}'
- name: Install DLLs dependencies (Windows) - name: Install DLLs dependencies (Windows)
@ -110,13 +109,13 @@ jobs:
run: | run: |
mkdir -p external mkdir -p external
curl -L "https://nim-lang.org/download/windeps.zip" -o external/windeps.zip curl -L "https://nim-lang.org/download/windeps.zip" -o external/windeps.zip
7z x -y external/windeps.zip -oexternal/dlls-${{ matrix.target.cpu }} 7z x -y external/windeps.zip -oexternal/dlls
- name: Path to cached dependencies (Windows) - name: Path to cached dependencies (Windows)
if: > if: >
runner.os == 'Windows' runner.os == 'Windows'
run: | run: |
echo "${{ github.workspace }}/external/dlls-${{ matrix.target.cpu }}" >> $GITHUB_PATH echo "${{ github.workspace }}/external/dlls" >> $GITHUB_PATH
# for miniupnp that runs "wingenminiupnpcstrings.exe" from the current dir # for miniupnp that runs "wingenminiupnpcstrings.exe" from the current dir
echo "." >> $GITHUB_PATH echo "." >> $GITHUB_PATH
@ -135,6 +134,12 @@ jobs:
fi fi
echo "PLATFORM=${PLATFORM}" >> $GITHUB_ENV echo "PLATFORM=${PLATFORM}" >> $GITHUB_ENV
# Stack usage test on recent enough gcc:
if [[ '${{ runner.os }}' == 'Linux' && '${{ matrix.target.cpu }}' == 'amd64' ]]; then
export NIMFLAGS="${NIMFLAGS} -d:limitStackUsage"
echo "NIMFLAGS=${NIMFLAGS}" >> $GITHUB_ENV
fi
# libminiupnp / natpmp # libminiupnp / natpmp
if [[ '${{ runner.os }}' == 'Linux' && '${{ matrix.target.cpu }}' == 'i386' ]]; then if [[ '${{ runner.os }}' == 'Linux' && '${{ matrix.target.cpu }}' == 'i386' ]]; then
export CFLAGS="${CFLAGS} -m32 -mno-adx" export CFLAGS="${CFLAGS} -m32 -mno-adx"
@ -187,7 +192,6 @@ jobs:
# The Windows image runs out of disk space, so make some room # The Windows image runs out of disk space, so make some room
rm -rf nimcache rm -rf nimcache
- name: Run nimbus-eth2 tests - name: Run tests
run: | run: |
make -j ${ncpu} V=1 NIM_COMMIT=${{ matrix.branch }} DISABLE_TEST_FIXTURES_SCRIPT=1 test make -j ${ncpu} V=1 NIM_COMMIT=${{ matrix.branch }} DISABLE_TEST_FIXTURES_SCRIPT=1 test

4
.gitmodules vendored
View File

@ -206,9 +206,13 @@
[submodule "vendor/eth2-networks"] [submodule "vendor/eth2-networks"]
path = vendor/eth2-networks path = vendor/eth2-networks
url = https://github.com/eth-clients/eth2-networks.git url = https://github.com/eth-clients/eth2-networks.git
ignore = untracked
branch = master
[submodule "vendor/nim-taskpools"] [submodule "vendor/nim-taskpools"]
path = vendor/nim-taskpools path = vendor/nim-taskpools
url = https://github.com/status-im/nim-taskpools url = https://github.com/status-im/nim-taskpools
ignore = untracked
branch = stable
[submodule "vendor/nim-ssz-serialization"] [submodule "vendor/nim-ssz-serialization"]
path = vendor/nim-ssz-serialization path = vendor/nim-ssz-serialization
url = https://github.com/status-im/nim-ssz-serialization.git url = https://github.com/status-im/nim-ssz-serialization.git

View File

@ -1333,19 +1333,15 @@ proc startEth1Syncing(m: Eth1Monitor, delayBeforeStart: Duration) {.async.} =
eth1SyncedTo = targetBlock eth1SyncedTo = targetBlock
eth1_synced_head.set eth1SyncedTo.toGaugeValue eth1_synced_head.set eth1SyncedTo.toGaugeValue
proc start(m: Eth1Monitor, delayBeforeStart: Duration) = proc start(m: Eth1Monitor, delayBeforeStart: Duration) {.gcsafe.} =
if m.runFut.isNil: if m.runFut.isNil:
let runFut = m.startEth1Syncing(delayBeforeStart) let runFut = m.startEth1Syncing(delayBeforeStart)
m.runFut = runFut m.runFut = runFut
runFut.addCallback do (p: pointer): runFut.addCallback do (p: pointer) {.gcsafe.}:
if runFut.failed: if runFut.failed:
if runFut.error[] of CatchableError: if runFut == m.runFut:
if runFut == m.runFut: warn "Eth1 chain monitoring failure, restarting", err = runFut.error.msg
warn "Eth1 chain monitoring failure, restarting", err = runFut.error.msg m.state = Failed
m.state = Failed
else:
fatal "Fatal exception reached", err = runFut.error.msg
quit 1
safeCancel m.runFut safeCancel m.runFut
m.start(5.seconds) m.start(5.seconds)

View File

@ -12,9 +12,17 @@ shift 2
# verbosity level # verbosity level
[[ -z "$V" ]] && V=0 [[ -z "$V" ]] && V=0
# According to the Nim compiler, the project name comes from the main source # Nim version (formatted as "{MAJOR}{MINOR}").
# file, not the output binary. # This weird "sed" invocation is because of macOS.
PROJECT_NAME="$(basename ${SOURCE%.nim})" NIM_VERSION=$(nim --version | head -n1 | sed -E 's/^.* ([0-9])\.([0-9]+).*$/\1\2/')
# According to old Nim compiler versions, the project name comes from the main
# source file, not the output binary.
if [[ "${NIM_VERSION}" -ge "16" ]]; then
PROJECT_NAME="$(basename ${BINARY%.nim})"
else
PROJECT_NAME="$(basename ${SOURCE%.nim})"
fi
# The default nimcache dir is "nimcache/release/${PROJECT_NAME}" which doesn't # The default nimcache dir is "nimcache/release/${PROJECT_NAME}" which doesn't
# allow building different binaries from the same main source file, in # allow building different binaries from the same main source file, in