nimbus-eth1/.github/workflows/ci.yml

261 lines
9.4 KiB
YAML
Raw Normal View History

2023-11-01 03:32:09 +00:00
# Nimbus
# Copyright (c) 2020-2024 Status Research & Development GmbH
2023-11-01 03:32:09 +00:00
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
# http://www.apache.org/licenses/LICENSE-2.0)
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or
# http://opensource.org/licenses/MIT)
# at your option. This file may not be copied, modified, or distributed except
# according to those terms.
name: Nimbus CI
on:
push:
paths-ignore:
- 'doc/**'
- 'docs/**'
- '**/*.md'
- 'hive_integration/**'
- 'fluffy/**'
- '.github/workflows/fluffy*.yml'
- 'nimbus_verified_proxy/**'
- '.github/workflows/nimbus_verified_proxy.yml'
# Disable `pull_request`. Experimenting with using only `push` for PRs.
#pull_request:
# paths-ignore: ['doc/**', 'docs/**', '**/*.md', 'hive_integration/**']
workflow_dispatch:
2021-01-06 07:40:07 +00:00
jobs:
build:
strategy:
fail-fast: false
max-parallel: 20
matrix:
target:
- os: linux
cpu: amd64
evmc: evmc
- os: macos
cpu: amd64
evmc: evmc
- os: windows
cpu: amd64
evmc: evmc
- os: linux
cpu: amd64
2023-06-27 00:40:01 +00:00
evmc: nimvm
- os: windows
cpu: amd64
2023-06-27 00:40:01 +00:00
evmc: nimvm
- os: macos
cpu: amd64
2023-06-27 00:40:01 +00:00
evmc: nimvm
2021-01-06 07:40:07 +00:00
include:
- target:
os: linux
builder: ubuntu-20.04
2021-01-06 07:40:07 +00:00
- target:
os: macos
builder: macos-13
2021-01-06 07:40:07 +00:00
- target:
os: windows
2021-04-08 15:46:00 +00:00
builder: windows-latest
2021-01-06 07:40:07 +00:00
2021-04-08 15:46:00 +00:00
defaults:
run:
shell: bash
2021-04-08 15:46:00 +00:00
name: '${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ matrix.target.evmc }}'
2021-01-06 07:40:07 +00:00
runs-on: ${{ matrix.builder }}
steps:
- name: Checkout nimbus-eth1
uses: actions/checkout@v4
2021-04-08 15:46:00 +00:00
- name: Derive environment variables
run: |
if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
PLATFORM=x64
GOARCH=amd64
USE_MIRACL=0
else
PLATFORM=x86
GOARCH=386
USE_MIRACL=1
fi
echo "PLATFORM=${PLATFORM}" >> $GITHUB_ENV
echo "GOARCH=${GOARCH}" >> $GITHUB_ENV
echo "USE_MIRACL=${USE_MIRACL}" >> $GITHUB_ENV
ncpu=''
case '${{ runner.os }}' in
'Linux')
ncpu=$(nproc)
echo "Number of cores: ${ncpu}"
echo "$(grep MemTotal /proc/meminfo)"
echo -e "Partition sizes:\n$(df -k -h .)"
2021-04-08 15:46:00 +00:00
;;
'macOS')
ncpu=$(sysctl -n hw.ncpu)
hwmemsize=$(sysctl -n hw.memsize)
ramsize=$(expr $hwmemsize / $((1024**3)))
echo "Number of cores: ${ncpu}"
echo "Physical memory: ${ramsize} GB"
echo -e "Partition sizes:\n$(df -k -h .)"
2021-04-08 15:46:00 +00:00
;;
'Windows')
ncpu=${NUMBER_OF_PROCESSORS}
CD=${PWD:1:1}
echo "Number of cores: ${NUMBER_OF_PROCESSORS}"
echo "Physical memory: $(wmic ComputerSystem get TotalPhysicalMemory)"
echo -e "Partition sizes:\n$(wmic logicaldisk get name,size,freespace | grep -e "${CD^}" -e "FreeSpace")"
2021-04-08 15:46:00 +00:00
;;
esac
[[ -z "$ncpu" || $ncpu -le 0 ]] && ncpu=1
echo "ncpu=${ncpu}" >> $GITHUB_ENV
if [[ '${{ matrix.target.evmc }}' == 'evmc' ]]; then
echo "ENABLE_EVMC=1" >> $GITHUB_ENV
else
echo "ENABLE_EVMC=0" >> $GITHUB_ENV
fi
- name: Install build dependencies (Macos)
# Some home brew modules were reported missing
if: runner.os == 'Macos'
run: |
HOMEBREW_NO_INSTALL_CLEANUP=1 brew install gnu-getopt
brew link --force gnu-getopt
- name: Restore llvm-mingw (Windows) from cache
if: runner.os == 'Windows'
id: windows-mingw-cache
uses: actions/cache@v4
2021-01-06 07:40:07 +00:00
with:
path: external/mingw-${{ matrix.target.cpu }}
key: 'mingw-llvm-17-${{ matrix.target.cpu }}'
2021-01-06 07:40:07 +00:00
- name: Restore Nim DLLs dependencies (Windows) from cache
if: runner.os == 'Windows'
id: windows-dlls-cache
uses: actions/cache@v4
2021-01-06 07:40:07 +00:00
with:
path: external/dlls-${{ matrix.target.cpu }}
Redesign of BaseVMState descriptor (#923) * Redesign of BaseVMState descriptor why: BaseVMState provides an environment for executing transactions. The current descriptor also provides data that cannot generally be known within the execution environment, e.g. the total gasUsed which is available not before after all transactions have finished. Also, the BaseVMState constructor has been replaced by a constructor that does not need pre-initialised input of the account database. also: Previous constructor and some fields are provided with a deprecated annotation (producing a lot of noise.) * Replace legacy directives in production sources * Replace legacy directives in unit test sources * fix CI (missing premix update) * Remove legacy directives * chase CI problem * rebased * Re-introduce 'AccountsCache' constructor optimisation for 'BaseVmState' re-initialisation why: Constructing a new 'AccountsCache' descriptor can be avoided sometimes when the current state root is properly positioned already. Such a feature existed already as the update function 'initStateDB()' for the 'BaseChanDB' where the accounts cache was linked into this desctiptor. The function 'initStateDB()' was removed and re-implemented into the 'BaseVmState' constructor without optimisation. The old version was of restricted use as a wrong accounts cache state would unconditionally throw an exception rather than conceptually ask for a remedy. The optimised 'BaseVmState' re-initialisation has been implemented for the 'persistBlocks()' function. also: moved some test helpers to 'test/replay' folder * Remove unused & undocumented fields from Chain descriptor why: Reduces attack surface in general & improves reading the code.
2022-01-18 16:19:32 +00:00
# according to docu, idle caches are kept for up to 7 days
# so change dlls# to force new cache contents (for some number #)
key: dlls1-${{ matrix.target.cpu }}
2021-01-06 07:40:07 +00:00
- name: Install llvm-mingw dependency (Windows)
if: >
steps.windows-mingw-cache.outputs.cache-hit != 'true' &&
runner.os == 'Windows'
run: |
mkdir -p external
MINGW_BASE="https://github.com/mstorsjo/llvm-mingw/releases/download/20230905"
if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
MINGW_URL="$MINGW_BASE/llvm-mingw-20230905-ucrt-x86_64.zip"
ARCH=64
else
MINGW_URL="$MINGW_BASE/llvm-mingw-20230905-ucrt-i686.zip"
ARCH=32
fi
curl -L "$MINGW_URL" -o "external/mingw-${{ matrix.target.cpu }}.zip"
7z x -y "external/mingw-${{ matrix.target.cpu }}.zip" -oexternal/mingw-${{ matrix.target.cpu }}/
mv external/mingw-${{ matrix.target.cpu }}/**/* ./external/mingw-${{ matrix.target.cpu }}
2021-01-06 07:40:07 +00:00
- name: Install DLLs dependencies (Windows)
if: >
steps.windows-dlls-cache.outputs.cache-hit != 'true' &&
runner.os == 'Windows'
run: |
DLLPATH=external/dlls-${{ matrix.target.cpu }}
mkdir -p external
curl -L "https://nim-lang.org/download/windeps.zip" -o external/windeps.zip
7z x -y external/windeps.zip -o"$DLLPATH"
- name: Path to cached dependencies (Windows)
if: >
runner.os == 'Windows'
run: |
echo '${{ github.workspace }}'"/external/mingw-${{ matrix.target.cpu }}/bin" >> $GITHUB_PATH
echo '${{ github.workspace }}'"/external/dlls-${{ matrix.target.cpu }}" >> $GITHUB_PATH
2021-01-06 07:40:07 +00:00
- name: Get latest nimbus-build-system commit hash
id: versions
run: |
getHash() {
git ls-remote "https://github.com/$1" "${2:-HEAD}" | cut -f 1
}
nbsHash=$(getHash status-im/nimbus-build-system)
echo "nimbus_build_system=$nbsHash" >> $GITHUB_OUTPUT
2021-01-06 07:40:07 +00:00
- name: Restore prebuilt Nim from cache
id: nim-cache
uses: actions/cache@v4
2021-01-06 07:40:07 +00:00
with:
2022-07-28 02:19:57 +00:00
path: NimBinCache
key: 'nim-${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ steps.versions.outputs.nimbus_build_system }}-${{ matrix.target.evmc }}'
2021-01-06 07:40:07 +00:00
2021-04-08 15:46:00 +00:00
- name: Build Nim and Nimbus-eth1 dependencies
run: |
make -j${ncpu} ARCH_OVERRIDE=${PLATFORM} CI_CACHE=NimBinCache update-from-ci
2021-01-06 07:40:07 +00:00
- name: Run nimbus-eth1 tests (Windows)
if: runner.os == 'Windows'
run: |
2021-04-08 15:46:00 +00:00
gcc --version
DEFAULT_MAKE_FLAGS="-j${ncpu} ENABLE_EVMC=${ENABLE_EVMC} ENABLE_VMLOWMEM=${ENABLE_VMLOWMEM}"
2024-06-05 19:56:43 +00:00
mingw32-make ${DEFAULT_MAKE_FLAGS} all test_import
2021-01-06 07:40:07 +00:00
build/nimbus.exe --help
2023-05-27 13:52:48 +00:00
# give us more space
# find . -type d -name ".git" -exec rm -rf {} +
2023-05-27 13:52:48 +00:00
find . -type d -name "nimcache" -exec rm -rf {} +
mingw32-make ${DEFAULT_MAKE_FLAGS} test t8n_test
2021-01-06 07:40:07 +00:00
if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
mingw32-make ${DEFAULT_MAKE_FLAGS}
2021-01-06 07:40:07 +00:00
fi
- name: Run nimbus-eth1 tests (Linux)
if: runner.os == 'Linux'
run: |
2021-04-08 15:46:00 +00:00
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/local/lib"
DEFAULT_MAKE_FLAGS="-j${ncpu} USE_MIRACL=${USE_MIRACL} ENABLE_EVMC=${ENABLE_EVMC}"
2024-06-05 19:56:43 +00:00
env CC=gcc make ${DEFAULT_MAKE_FLAGS} all test_import
2021-01-06 07:40:07 +00:00
build/nimbus --help
2021-01-16 11:26:55 +00:00
# CC, GOARCH, and CGO_ENABLED are needed to select correct compiler 32/64 bit
# pushd vendor/nimbus-eth2
# env NIMBUSEL_BINARY=../../build/nimbus NIMBUSEL_GENESIS=scripts/nimbusel_genesis.json \
# ./scripts/launch_local_testnet.sh --nodes=3 --stop-at-epoch=7 \
# --disable-htop --reuse-binaries --run-nimbus-el --dl-eth2 --verbose --kill-old-processes
# popd
env CC=gcc GOARCH=${GOARCH} CXX=g++ CGO_ENABLED=1 make ${DEFAULT_MAKE_FLAGS} test t8n_test
2021-01-06 07:40:07 +00:00
- name: Run nimbus-eth1 tests (Macos)
if: runner.os == 'Macos'
run: |
export ZERO_AR_DATE=1 # avoid timestamps in binaries
2021-04-08 15:46:00 +00:00
DEFAULT_MAKE_FLAGS="-j${ncpu} ENABLE_EVMC=${ENABLE_EVMC}"
2024-06-05 19:56:43 +00:00
make ${DEFAULT_MAKE_FLAGS} all test_import
2021-01-06 07:40:07 +00:00
build/nimbus --help
# "-static" option will not work for osx unless static system libraries are provided
# pushd vendor/nimbus-eth2
# env NIMBUSEL_BINARY=../../build/nimbus NIMBUSEL_GENESIS=scripts/nimbusel_genesis.json \
# ./scripts/launch_local_testnet.sh --nodes=3 --stop-at-epoch=7 \
# --disable-htop --reuse-binaries --run-nimbus-el --dl-eth2 --verbose --kill-old-processes
# popd
make ${DEFAULT_MAKE_FLAGS} test t8n_test
2021-04-08 15:46:00 +00:00
2023-11-01 03:32:09 +00:00
lint:
name: "Lint"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
2023-11-01 03:32:09 +00:00
with:
fetch-depth: 2 # In PR, has extra merge commit: ^1 = PR, ^2 = base
- name: Check copyright year
if: ${{ !cancelled() }} && github.event_name == 'pull_request'
run: |
bash scripts/check_copyright_year.sh