Merge pull request #12562 from ethereum/brink-ext-test

External test for Brink
This commit is contained in:
Kamil Śliwak 2022-04-13 15:06:57 +02:00 committed by GitHub
commit 25923c1f08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 123 additions and 14 deletions

View File

@ -582,6 +582,12 @@ defaults:
binary_type: native
nodejs_version: '16'
resource_class: medium
- job_native_test_ext_brink: &job_native_test_ext_brink
<<: *workflow_ubuntu2004_static
name: t_native_test_ext_brink
project: brink
binary_type: native
nodejs_version: '16'
- job_ems_test_ext_colony: &job_ems_test_ext_colony
<<: *workflow_emscripten
name: t_ems_test_ext_colony
@ -1470,6 +1476,7 @@ workflows:
- t_ems_ext: *job_native_test_ext_uniswap
- t_ems_ext: *job_native_test_ext_prb_math
- t_ems_ext: *job_native_test_ext_elementfi
- t_ems_ext: *job_native_test_ext_brink
- c_ext_benchmarks:
<<: *workflow_trigger_on_tags
@ -1487,6 +1494,7 @@ workflows:
- t_native_test_ext_uniswap
- t_native_test_ext_prb_math
- t_native_test_ext_elementfi
- t_native_test_ext_brink
# Windows build and tests
- b_win: *workflow_trigger_on_tags

View File

@ -50,3 +50,4 @@ printTask "Running external tests..."
"${REPO_ROOT}/test/externalTests/uniswap.sh" "$@"
"${REPO_ROOT}/test/externalTests/prb-math.sh" "$@"
"${REPO_ROOT}/test/externalTests/elementfi.sh" "$@"
"${REPO_ROOT}/test/externalTests/brink.sh" "$@"

83
test/externalTests/brink.sh Executable file
View File

@ -0,0 +1,83 @@
#!/usr/bin/env bash
# ------------------------------------------------------------------------------
# This file is part of solidity.
#
# solidity is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# solidity is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with solidity. If not, see <http://www.gnu.org/licenses/>
#
# (c) 2022 solidity contributors.
#------------------------------------------------------------------------------
set -e
source scripts/common.sh
source test/externalTests/common.sh
REPO_ROOT=$(realpath "$(dirname "$0")/../..")
verify_input "$@"
BINARY_TYPE="$1"
BINARY_PATH="$2"
SELECTED_PRESETS="$3"
function compile_fn { yarn compile; }
function test_fn { SNAPSHOT_UPDATE=1 npx --no hardhat test; }
function brink_test
{
local repo="https://github.com/brinktrade/brink-core"
local ref_type=branch
local ref=master
local config_file="hardhat.config.js"
local config_var=""
local extra_settings="metadata: {bytecodeHash: 'none'}"
local extra_optimizer_settings="runs: 800"
local compile_only_presets=(
#ir-no-optimize # Compilation fails with "YulException: Variable var_signature_127_offset is 2 slot(s) too deep inside the stack."
#ir-optimize-evm-only # Compilation fails with "YulException: Variable var_signature_127_offset is 2 slot(s) too deep inside the stack."
ir-optimize-evm+yul # Lots of test failures. Tests depend on constants.js, which seems to be calculated specifically for 0.8.10.
legacy-optimize-evm+yul # Lots of test failures. Tests depend on constants.js, which seems to be calculated specifically for 0.8.10.
legacy-no-optimize # Lots of test failures. Tests depend on constants.js, which seems to be calculated specifically for 0.8.10.
legacy-optimize-evm-only # Lots of test failures. Tests depend on constants.js, which seems to be calculated specifically for 0.8.10.
)
local settings_presets=(
"${compile_only_presets[@]}"
)
[[ $SELECTED_PRESETS != "" ]] || SELECTED_PRESETS=$(circleci_select_steps_multiarg "${settings_presets[@]}")
print_presets_or_exit "$SELECTED_PRESETS"
setup_solc "$DIR" "$BINARY_TYPE" "$BINARY_PATH"
download_project "$repo" "$ref_type" "$ref" "$DIR"
neutralize_package_lock
neutralize_package_json_hooks
force_hardhat_compiler_binary "$config_file" "$BINARY_TYPE" "$BINARY_PATH"
force_hardhat_compiler_settings "$config_file" "$(first_word "$SELECTED_PRESETS")" "$config_var" "$CURRENT_EVM_VERSION" "$extra_settings" "$extra_optimizer_settings"
yarn install
yarn add hardhat-gas-reporter
# TODO: Remove when https://github.com/brinktrade/brink-core/issues/48 is fixed.
yarn add chai
replace_version_pragmas
for preset in $SELECTED_PRESETS; do
hardhat_run_test "$config_file" "$preset" "${compile_only_presets[*]}" compile_fn test_fn "$config_var" "$extra_settings" "$extra_optimizer_settings"
store_benchmark_report hardhat brink "$repo" "$preset"
done
}
external_test Brink brink_test

View File

@ -198,6 +198,8 @@ function force_truffle_compiler_settings
local solc_path="$3"
local preset="$4"
local evm_version="${5:-"$CURRENT_EVM_VERSION"}"
local extra_settings="$6"
local extra_optimizer_settings="$7"
[[ $binary_type == native || $binary_type == solcjs ]] || assertFail
@ -209,14 +211,14 @@ function force_truffle_compiler_settings
echo "Binary type: $binary_type"
echo "Compiler path: $solc_path"
echo "Settings preset: ${preset}"
echo "Settings: $(settings_from_preset "$preset" "$evm_version")"
echo "Settings: $(settings_from_preset "$preset" "$evm_version" "$extra_settings" "$extra_optimizer_settings")"
echo "EVM version: $evm_version"
echo "Compiler version: ${SOLCVERSION_SHORT}"
echo "Compiler version (full): ${SOLCVERSION}"
echo "-------------------------------------"
local compiler_settings gas_reporter_settings
compiler_settings=$(truffle_compiler_settings "$solc_path" "$preset" "$evm_version")
compiler_settings=$(truffle_compiler_settings "$solc_path" "$preset" "$evm_version" "$extra_settings" "$extra_optimizer_settings")
gas_reporter_settings=$(eth_gas_reporter_settings "$preset")
{
@ -307,19 +309,21 @@ function force_hardhat_compiler_settings
local preset="$2"
local config_var_name="$3"
local evm_version="${4:-"$CURRENT_EVM_VERSION"}"
local extra_settings="$5"
local extra_optimizer_settings="$6"
printLog "Configuring Hardhat..."
echo "-------------------------------------"
echo "Config file: ${config_file}"
echo "Settings preset: ${preset}"
echo "Settings: $(settings_from_preset "$preset" "$evm_version")"
echo "Settings: $(settings_from_preset "$preset" "$evm_version" "$extra_settings" "$extra_optimizer_settings")"
echo "EVM version: ${evm_version}"
echo "Compiler version: ${SOLCVERSION_SHORT}"
echo "Compiler version (full): ${SOLCVERSION}"
echo "-------------------------------------"
local compiler_settings gas_reporter_settings
compiler_settings=$(hardhat_compiler_settings "$SOLCVERSION_SHORT" "$preset" "$evm_version")
compiler_settings=$(hardhat_compiler_settings "$SOLCVERSION_SHORT" "$preset" "$evm_version" "$extra_settings" "$extra_optimizer_settings")
gas_reporter_settings=$(eth_gas_reporter_settings "$preset")
if [[ $config_file == *\.js ]]; then
[[ $config_var_name == "" ]] || assertFail
@ -372,17 +376,22 @@ function settings_from_preset
{
local preset="$1"
local evm_version="$2"
local extra_settings="$3"
local extra_optimizer_settings="$4"
[[ " ${AVAILABLE_PRESETS[*]} " == *" $preset "* ]] || assertFail
[[ $extra_settings == "" ]] || extra_settings="${extra_settings}, "
[[ $extra_optimizer_settings == "" ]] || extra_optimizer_settings="${extra_optimizer_settings}, "
case "$preset" in
# NOTE: Remember to update `parallelism` of `t_ems_ext` job in CI config if you add/remove presets
legacy-no-optimize) echo "{evmVersion: '${evm_version}', viaIR: false, optimizer: {enabled: false}}" ;;
ir-no-optimize) echo "{evmVersion: '${evm_version}', viaIR: true, optimizer: {enabled: false}}" ;;
legacy-optimize-evm-only) echo "{evmVersion: '${evm_version}', viaIR: false, optimizer: {enabled: true, details: {yul: false}}}" ;;
ir-optimize-evm-only) echo "{evmVersion: '${evm_version}', viaIR: true, optimizer: {enabled: true, details: {yul: false}}}" ;;
legacy-optimize-evm+yul) echo "{evmVersion: '${evm_version}', viaIR: false, optimizer: {enabled: true, details: {yul: true}}}" ;;
ir-optimize-evm+yul) echo "{evmVersion: '${evm_version}', viaIR: true, optimizer: {enabled: true, details: {yul: true}}}" ;;
legacy-no-optimize) echo "{${extra_settings}evmVersion: '${evm_version}', viaIR: false, optimizer: {${extra_optimizer_settings}enabled: false}}" ;;
ir-no-optimize) echo "{${extra_settings}evmVersion: '${evm_version}', viaIR: true, optimizer: {${extra_optimizer_settings}enabled: false}}" ;;
legacy-optimize-evm-only) echo "{${extra_settings}evmVersion: '${evm_version}', viaIR: false, optimizer: {${extra_optimizer_settings}enabled: true, details: {yul: false}}}" ;;
ir-optimize-evm-only) echo "{${extra_settings}evmVersion: '${evm_version}', viaIR: true, optimizer: {${extra_optimizer_settings}enabled: true, details: {yul: false}}}" ;;
legacy-optimize-evm+yul) echo "{${extra_settings}evmVersion: '${evm_version}', viaIR: false, optimizer: {${extra_optimizer_settings}enabled: true, details: {yul: true}}}" ;;
ir-optimize-evm+yul) echo "{${extra_settings}evmVersion: '${evm_version}', viaIR: true, optimizer: {${extra_optimizer_settings}enabled: true, details: {yul: true}}}" ;;
*)
fail "Unknown settings preset: '${preset}'."
;;
@ -419,11 +428,13 @@ function truffle_compiler_settings
local solc_path="$1"
local preset="$2"
local evm_version="$3"
local extra_settings="$4"
local extra_optimizer_settings="$5"
echo "{"
echo " solc: {"
echo " version: \"${solc_path}\","
echo " settings: $(settings_from_preset "$preset" "$evm_version")"
echo " settings: $(settings_from_preset "$preset" "$evm_version" "$extra_settings" "$extra_optimizer_settings")"
echo " }"
echo "}"
}
@ -468,10 +479,12 @@ function hardhat_compiler_settings {
local solc_version="$1"
local preset="$2"
local evm_version="$3"
local extra_settings="$4"
local extra_optimizer_settings="$5"
echo "{"
echo " version: '${solc_version}',"
echo " settings: $(settings_from_preset "$preset" "$evm_version")"
echo " settings: $(settings_from_preset "$preset" "$evm_version" "$extra_settings" "$extra_optimizer_settings")"
echo "}"
}
@ -506,9 +519,11 @@ function truffle_run_test
local compile_only_presets="$5"
local compile_fn="$6"
local test_fn="$7"
local extra_settings="$8"
local extra_optimizer_settings="$9"
truffle_clean
force_truffle_compiler_settings "$config_file" "$binary_type" "$solc_path" "$preset"
force_truffle_compiler_settings "$config_file" "$binary_type" "$solc_path" "$preset" "$CURRENT_EVM_VERSION" "$extra_settings" "$extra_optimizer_settings"
compile_and_run_test compile_fn test_fn truffle_verify_compiler_version "$preset" "$compile_only_presets"
}
@ -520,9 +535,11 @@ function hardhat_run_test
local compile_fn="$4"
local test_fn="$5"
local config_var_name="$6"
local extra_settings="$7"
local extra_optimizer_settings="$8"
hardhat_clean
force_hardhat_compiler_settings "$config_file" "$preset" "$config_var_name"
force_hardhat_compiler_settings "$config_file" "$preset" "$config_var_name" "$CURRENT_EVM_VERSION" "$extra_settings" "$extra_optimizer_settings"
compile_and_run_test compile_fn test_fn hardhat_verify_compiler_version "$preset" "$compile_only_presets"
}