From bbe3557a2fda2f4a09b63b1f3e501d4c8625bfe1 Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 22 Mar 2017 20:19:57 +0100 Subject: Create bytecode for all tests and push to remote repo. --- scripts/bytecodecompare/deploy_key.enc | Bin 0 -> 1680 bytes scripts/bytecodecompare/prepare_report.py | 20 ++++++ scripts/bytecodecompare/storebytecode.bat | 41 +++++++++++++ scripts/bytecodecompare/storebytecode.sh | 98 ++++++++++++++++++++++++++++++ 4 files changed, 159 insertions(+) create mode 100644 scripts/bytecodecompare/deploy_key.enc create mode 100755 scripts/bytecodecompare/prepare_report.py create mode 100644 scripts/bytecodecompare/storebytecode.bat create mode 100755 scripts/bytecodecompare/storebytecode.sh (limited to 'scripts/bytecodecompare') diff --git a/scripts/bytecodecompare/deploy_key.enc b/scripts/bytecodecompare/deploy_key.enc new file mode 100644 index 00000000..acab2a27 Binary files /dev/null and b/scripts/bytecodecompare/deploy_key.enc differ diff --git a/scripts/bytecodecompare/prepare_report.py b/scripts/bytecodecompare/prepare_report.py new file mode 100755 index 00000000..68793927 --- /dev/null +++ b/scripts/bytecodecompare/prepare_report.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python + +import sys +import glob +import subprocess +import json + +solc = sys.argv[1] +report = open("report.txt", "w") + +for f in sorted(glob.glob("*.sol")): + proc = subprocess.Popen([solc, '--combined-json', 'bin,metadata', f], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + (out, err) = proc.communicate() + try: + result = json.loads(out.strip()) + for contractName in sorted(result['contracts'].keys()): + report.write(contractName + ' ' + result['contracts'][contractName]['bin'] + '\n') + report.write(contractName + ' ' + result['contracts'][contractName]['metadata'] + '\n') + except: + report.write(f + ": ERROR\n") diff --git a/scripts/bytecodecompare/storebytecode.bat b/scripts/bytecodecompare/storebytecode.bat new file mode 100644 index 00000000..969a42a4 --- /dev/null +++ b/scripts/bytecodecompare/storebytecode.bat @@ -0,0 +1,41 @@ +@ECHO OFF + +REM --------------------------------------------------------------------------- +REM This file is part of solidity. +REM +REM solidity is free software: you can redistribute it and/or modify +REM it under the terms of the GNU General Public License as published by +REM the Free Software Foundation, either version 3 of the License, or +REM (at your option) any later version. +REM +REM solidity is distributed in the hope that it will be useful, +REM but WITHOUT ANY WARRANTY; without even the implied warranty of +REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +REM GNU General Public License for more details. +REM +REM You should have received a copy of the GNU General Public License +REM along with solidity. If not, see +REM +REM Copyright (c) 2017 solidity contributors. +REM --------------------------------------------------------------------------- + +set CONFIGURATION=%1 +set COMMIT=%2 + +mkdir bytecode +cd bytecode +..\scripts\isolate_tests.py ..\test\ +..\scripts\bytecodecompare\prepare_report.py ..\build\solc\%CONFIGURATION%\solc.exe + +git clone --depth 2 git@github.com:ethereum/solidity-test-bytecode.git +cd solidity-test-bytecode +git config user.name "travis" +git config user.email "chris@ethereum.org" +git clean -f -d -x + +mkdir %COMMIT% +set REPORT=%COMMIT%/windows.txt +cp ../report.txt %REPORT% +git add %REPORT% +git commit -a -m "Added report." +git push origin diff --git a/scripts/bytecodecompare/storebytecode.sh b/scripts/bytecodecompare/storebytecode.sh new file mode 100755 index 00000000..8a3953c3 --- /dev/null +++ b/scripts/bytecodecompare/storebytecode.sh @@ -0,0 +1,98 @@ +#!/usr/bin/env bash + +#------------------------------------------------------------------------------ +# Script used for cross-platform comparison as part of the travis automation. +# Splits all test source code into multiple files, generates bytecode and +# uploads the bytecode into github.com/ethereum/solidity-test-bytecode where +# another travis job is triggered to do the actual comparison. +# +# ------------------------------------------------------------------------------ +# 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 +# +# (c) 2017 solidity contributors. +#------------------------------------------------------------------------------ + +set -e + +REPO_ROOT="$(dirname "$0")"/../.. + +echo "Compiling all test contracts into bytecode..." +TMPDIR=$(mktemp -d) +( + cd "$REPO_ROOT" + REPO_ROOT=$(pwd) # make it absolute + cd "$TMPDIR" + + "$REPO_ROOT"/scripts/isolate_tests.py "$REPO_ROOT"/test/ + + if [[ "$SOLC_EMSCRIPTEN" = "On" ]] + then + cp "$REPO_ROOT/build/solc/soljson.js" . + npm install solc + cat > solc < report.txt + else + $REPO_ROOT/scripts/bytecodecompare/prepare_report.py $REPO_ROOT/build/solc/solc + fi + + openssl aes-256-cbc -K $encrypted_60701c962b9c_key -iv $encrypted_60701c962b9c_iv -in "$REPO_ROOT"/scripts/bytecodecompare/deploy_key.enc -out deploy_key -d + chmod 600 deploy_key + eval `ssh-agent -s` + ssh-add deploy_key + + git clone --depth 2 git@github.com:ethereum/solidity-test-bytecode.git + cd solidity-test-bytecode + git config user.name "travis" + git config user.email "chris@ethereum.org" + git clean -f -d -x + + mkdir -p "$TRAVIS_COMMIT" + REPORT="$TRAVIS_COMMIT/$ZIP_SUFFIX.txt" + cp ../report.txt "$REPORT" + git add "$REPORT" + git commit -a -m "Added report $REPORT" + git push origin +) +rm -rf "$TMPDIR" \ No newline at end of file -- cgit