Merge remote-tracking branch 'origin/develop' into breaking

This commit is contained in:
chriseth 2020-12-08 17:42:31 +01:00
commit b045195c1e
64 changed files with 863 additions and 215 deletions

View File

@ -7,10 +7,6 @@
# - ems: Emscripten
version: 2.1
parameters:
ubuntu-1804-docker-image:
type: string
# solbuildpackpusher/solidity-buildpack-deps:ubuntu1804-4
default: "solbuildpackpusher/solidity-buildpack-deps@sha256:79ccaf5a294a3c4f480b2cd69c6d845540c12435e64d732e8536f8f99ad35f03"
ubuntu-2004-docker-image:
type: string
# solbuildpackpusher/solidity-buildpack-deps:ubuntu2004-4
@ -478,19 +474,6 @@ jobs:
command: strip build/solc/solc
- store_artifacts: *artifacts_solc
b_ubu18: &build_ubuntu1804
docker:
- image: << pipeline.parameters.ubuntu-1804-docker-image >>
environment:
CMAKE_OPTIONS: -DCMAKE_CXX_FLAGS=-O2
CMAKE_BUILD_TYPE: RelWithDebugInfo
MAKEFLAGS: -j 3
steps:
- checkout
- run: *run_build
- store_artifacts: *artifacts_solc
- persist_to_workspace: *artifacts_executables
b_ubu_codecov:
<<: *build_ubuntu2004
environment:
@ -1164,7 +1147,6 @@ workflows:
# Ubuntu build and tests
- b_ubu: *workflow_trigger_on_tags
- b_ubu18: *workflow_trigger_on_tags
- t_ubu_cli: *workflow_ubuntu2004
- t_ubu_soltest: *workflow_ubuntu2004
- t_ubu_soltest_enforce_yul: *workflow_ubuntu2004

View File

@ -6,7 +6,6 @@ on:
paths:
- 'scripts/docker/buildpack-deps/Dockerfile.emscripten'
- 'scripts/docker/buildpack-deps/Dockerfile.ubuntu1604.clang.ossfuzz'
- 'scripts/docker/buildpack-deps/Dockerfile.ubuntu1804'
- 'scripts/docker/buildpack-deps/Dockerfile.ubuntu2004.clang'
- 'scripts/docker/buildpack-deps/Dockerfile.ubuntu2004'
@ -23,7 +22,7 @@ jobs:
strategy:
fail-fast: false
matrix:
image_variant: [emscripten, ubuntu1604.clang.ossfuzz, ubuntu1804, ubuntu2004.clang, ubuntu2004]
image_variant: [emscripten, ubuntu1604.clang.ossfuzz, ubuntu2004.clang, ubuntu2004]
steps:
- uses: actions/checkout@v2

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.9.0)
cmake_minimum_required(VERSION 3.13.0)
set(ETH_CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}/cmake" CACHE PATH "The the path to the cmake directory")
list(APPEND CMAKE_MODULE_PATH ${ETH_CMAKE_DIR})

View File

@ -49,12 +49,15 @@ Compiler Features:
* SMTChecker: Support named arguments in function calls.
* SMTChecker: Support struct constructor.
* SMTChecker: Support getters.
* SMTChecker: Support early returns in the CHC engine.
* Standard-Json: Properly filter the requested output artifacts.
Bugfixes:
* Code generator: Do not pad empty string literals with a single 32-byte zero field in the ABI coder v1.
* SMTChecker: Fix internal compiler error when doing bitwise compound assignment with string literals.
* SMTChecker: Fix internal error when trying to generate counterexamples with old z3.
* SMTChecker: Fix segmentation fault that could occur on certain SMT-enabled sources when no SMT solver was available.
* SMTChecker: Fix cast string literals to byte arrays.
* Type Checker: ``super`` is not available in libraries.
* Yul Optimizer: Fix a bug in NameSimplifier where a new name created by NameSimplifier could also be created by NameDispenser.
* Yul Optimizer: Removed NameSimplifier from optimization steps available to users.

View File

@ -52,7 +52,7 @@
### PPA
- [ ] Change ``scripts/release_ppa.sh`` to match your key's email and key id.
- [ ] Run ``scripts/release_ppa.sh v$VERSION`` to create the PPA release (you need the relevant openssl key).
- [ ] Wait for the ``~ethereum/ubuntu/ethereum-static`` PPA build to be finished and published for *all platforms*. SERIOUSLY: DO NOT PROCEED EARLIER!!! *After* the static builds are *published*, copy the static package to the ``~ethereum/ubuntu/ethereum`` PPA for the destination series ``Trusty`` and ``Xenial`` while selecting ``Copy existing binaries``.
- [ ] Wait for the ``~ethereum/ubuntu/ethereum-static`` PPA build to be finished and published for *all platforms*. SERIOUSLY: DO NOT PROCEED EARLIER!!! *After* the static builds are *published*, copy the static package to the ``~ethereum/ubuntu/ethereum`` PPA for the destination series ``Trusty``, ``Xenial`` and ``Bionic`` while selecting ``Copy existing binaries``.
### Documentation
- [ ] Build the new version on https://readthedocs.org/projects/solidity/ (select `latest` at the bottom of the page and click `BUILD`)

View File

@ -52,12 +52,9 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA
add_compile_options(-Wimplicit-fallthrough)
add_compile_options(-Wsign-conversion)
# While this should work on CMake 3.3+, it fails on Ubuntu 18
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.16)
eth_add_cxx_compiler_flag_if_supported(
$<$<COMPILE_LANGUAGE:CXX>:-Wextra-semi>
)
endif()
eth_add_cxx_compiler_flag_if_supported(
$<$<COMPILE_LANGUAGE:CXX>:-Wextra-semi>
)
# Configuration-specific compiler settings.
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3 -DETH_DEBUG")
@ -68,11 +65,11 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA
# Additional GCC-specific compiler settings.
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
# Check that we've got GCC 5.0 or newer.
# Check that we've got GCC 8.0 or newer.
execute_process(
COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
if (NOT (GCC_VERSION VERSION_GREATER 5.0 OR GCC_VERSION VERSION_EQUAL 5.0))
message(FATAL_ERROR "${PROJECT_NAME} requires g++ 5.0 or greater.")
if (NOT (GCC_VERSION VERSION_GREATER 8.0 OR GCC_VERSION VERSION_EQUAL 8.0))
message(FATAL_ERROR "${PROJECT_NAME} requires g++ 8.0 or greater.")
endif ()
# Use fancy colors in the compiler diagnostics

View File

@ -306,7 +306,7 @@ The following are dependencies for all builds of Solidity:
+-----------------------------------+-------------------------------------------------------+
| Software | Notes |
+===================================+=======================================================+
| `CMake`_ (version 3.9+) | Cross-platform build file generator. |
| `CMake`_ (version 3.13+) | Cross-platform build file generator. |
+-----------------------------------+-------------------------------------------------------+
| `Boost`_ (version 1.65+) | C++ libraries. |
+-----------------------------------+-------------------------------------------------------+
@ -335,8 +335,8 @@ Minimum compiler versions
The following C++ compilers and their minimum versions can build the Solidity codebase:
- `GCC <https://gcc.gnu.org>`_, version 5+
- `Clang <https://clang.llvm.org/>`_, version 3.4+
- `GCC <https://gcc.gnu.org>`_, version 8+
- `Clang <https://clang.llvm.org/>`_, version 7+
- `MSVC <https://visualstudio.microsoft.com/vs/>`_, version 2019+
Prerequisites - macOS

View File

@ -202,7 +202,7 @@ bool CHC::visit(FunctionDefinition const& _function)
initFunction(_function);
auto functionEntryBlock = createBlock(m_currentFunction, PredicateType::FunctionEntry);
auto functionEntryBlock = createBlock(m_currentFunction, PredicateType::FunctionBlock);
auto bodyBlock = createBlock(&m_currentFunction->body(), PredicateType::FunctionBlock);
auto functionPred = predicate(*functionEntryBlock);
@ -469,6 +469,8 @@ void CHC::endVisit(Break const& _break)
{
solAssert(m_breakDest, "");
connectBlocks(m_currentBlock, predicate(*m_breakDest));
// Add an unreachable ghost node to collect unreachable statements after a break.
auto breakGhost = createBlock(&_break, PredicateType::FunctionBlock, "break_ghost_");
m_currentBlock = predicate(*breakGhost);
}
@ -477,6 +479,8 @@ void CHC::endVisit(Continue const& _continue)
{
solAssert(m_continueDest, "");
connectBlocks(m_currentBlock, predicate(*m_continueDest));
// Add an unreachable ghost node to collect unreachable statements after a continue.
auto continueGhost = createBlock(&_continue, PredicateType::FunctionBlock, "continue_ghost_");
m_currentBlock = predicate(*continueGhost);
}
@ -511,6 +515,32 @@ void CHC::endVisit(IndexRangeAccess const& _range)
m_context.addAssertion(sliceArray->length() == end - start);
}
void CHC::endVisit(Return const& _return)
{
SMTEncoder::endVisit(_return);
connectBlocks(m_currentBlock, predicate(*m_returnDests.back()));
// Add an unreachable ghost node to collect unreachable statements after a return.
auto returnGhost = createBlock(&_return, PredicateType::FunctionBlock, "return_ghost_");
m_currentBlock = predicate(*returnGhost);
}
void CHC::pushInlineFrame(CallableDeclaration const& _callable)
{
m_returnDests.push_back(createBlock(&_callable, PredicateType::FunctionBlock, "return_"));
}
void CHC::popInlineFrame(CallableDeclaration const& _callable)
{
solAssert(!m_returnDests.empty(), "");
auto const& ret = *m_returnDests.back();
solAssert(ret.programNode() == &_callable, "");
connectBlocks(m_currentBlock, predicate(ret));
setCurrentBlock(ret);
m_returnDests.pop_back();
}
void CHC::visitAssert(FunctionCall const& _funCall)
{
auto const& args = _funCall.arguments();
@ -756,6 +786,7 @@ void CHC::resetContractAnalysis()
m_unknownFunctionCallSeen = false;
m_breakDest = nullptr;
m_continueDest = nullptr;
m_returnDests.clear();
errorFlag().resetIndex();
}
@ -806,7 +837,7 @@ set<unsigned> CHC::transactionVerificationTargetsIds(ASTNode const* _txRoot)
SortPointer CHC::sort(FunctionDefinition const& _function)
{
return functionSort(_function, m_currentContract, state());
return functionBodySort(_function, m_currentContract, state());
}
SortPointer CHC::sort(ASTNode const* _node)
@ -1079,7 +1110,6 @@ smtutil::Expression CHC::predicate(Predicate const& _block)
return ::interface(_block, *m_currentContract, m_context);
case PredicateType::ConstructorSummary:
return constructor(_block, m_context);
case PredicateType::FunctionEntry:
case PredicateType::FunctionSummary:
return smt::function(_block, m_currentContract, m_context);
case PredicateType::FunctionBlock:
@ -1228,7 +1258,7 @@ void CHC::verificationTargetEncountered(
connectBlocks(
m_currentBlock,
predicate(*m_errorDest),
currentPathConditions() && _errorCondition && errorFlag().currentValue() == errorId
_errorCondition && errorFlag().currentValue() == errorId
);
m_context.addAssertion(errorFlag().currentValue() == previousError);

View File

@ -83,6 +83,10 @@ private:
void endVisit(Break const& _node) override;
void endVisit(Continue const& _node) override;
void endVisit(IndexRangeAccess const& _node) override;
void endVisit(Return const& _node) override;
void pushInlineFrame(CallableDeclaration const& _callable) override;
void popInlineFrame(CallableDeclaration const& _callable) override;
void visitAssert(FunctionCall const& _funCall);
void visitAddMulMod(FunctionCall const& _funCall) override;
@ -333,6 +337,12 @@ private:
/// 2) Constructor summary, if error happens while evaluating base constructor arguments.
/// 3) Function summary, if error happens inside a function.
Predicate const* m_errorDest = nullptr;
/// Represents the stack of destinations where a `return` should go.
/// This is different from `m_errorDest` above:
/// - Constructor initializers and constructor summaries will never be `return` targets because they are artificial.
/// - Modifiers also have their own `return` target blocks, whereas they do not have their own error destination.
std::vector<Predicate const*> m_returnDests;
//@}
/// CHC solver.

View File

@ -35,7 +35,6 @@ enum class PredicateType
Interface,
NondetInterface,
ConstructorSummary,
FunctionEntry,
FunctionSummary,
FunctionBlock,
Error,

View File

@ -152,10 +152,12 @@ void SMTEncoder::visitFunctionOrModifier()
if (m_modifierDepthStack.back() == static_cast<int>(function.modifiers().size()))
{
pushPathCondition(currentPathConditions());
if (function.isImplemented())
{
pushInlineFrame(function);
function.body().accept(*this);
popPathCondition();
popInlineFrame(function);
}
}
else
{
@ -192,7 +194,7 @@ void SMTEncoder::inlineModifierInvocation(ModifierInvocation const* _invocation,
initializeFunctionCallParameters(*_definition, args);
pushCallStack({_definition, _invocation});
pushPathCondition(currentPathConditions());
pushInlineFrame(*_definition);
if (auto modifier = dynamic_cast<ModifierDefinition const*>(_definition))
{
if (modifier->isImplemented())
@ -205,7 +207,7 @@ void SMTEncoder::inlineModifierInvocation(ModifierInvocation const* _invocation,
function->accept(*this);
// Functions are popped from the callstack in endVisit(FunctionDefinition)
}
popPathCondition();
popInlineFrame(*_definition);
}
void SMTEncoder::inlineConstructorHierarchy(ContractDefinition const& _contract)
@ -289,6 +291,16 @@ bool SMTEncoder::visit(TryCatchClause const& _clause)
return false;
}
void SMTEncoder::pushInlineFrame(CallableDeclaration const&)
{
pushPathCondition(currentPathConditions());
}
void SMTEncoder::popInlineFrame(CallableDeclaration const&)
{
popPathCondition();
}
void SMTEncoder::endVisit(VariableDeclarationStatement const& _varDecl)
{
if (_varDecl.declarations().size() != 1)
@ -942,16 +954,21 @@ void SMTEncoder::visitTypeConversion(FunctionCall const& _funCall)
solAssert(_funCall.arguments().size() == 1, "");
auto argument = _funCall.arguments().front();
auto const& argType = argument->annotation().type;
auto const argType = argument->annotation().type;
auto const funCallType = _funCall.annotation().type;
unsigned argSize = argument->annotation().type->storageBytes();
unsigned castSize = _funCall.annotation().type->storageBytes();
auto symbArg = expr(*argument, funCallType);
auto const& funCallType = _funCall.annotation().type;
if (smt::isStringLiteral(*argType) && smt::isFixedBytes(*funCallType))
{
defineExpr(_funCall, symbArg);
return;
}
// TODO Simplify this whole thing for 0.8.0 where weird casts are disallowed.
auto symbArg = expr(*argument, funCallType);
unsigned argSize = argType->storageBytes();
unsigned castSize = funCallType->storageBytes();
bool castIsSigned = smt::isNumber(*funCallType) && smt::isSigned(funCallType);
bool argIsSigned = smt::isNumber(*argType) && smt::isSigned(argType);
optional<smtutil::Expression> symbMin;
@ -1095,7 +1112,7 @@ void SMTEncoder::endVisit(Literal const& _literal)
addArrayLiteralAssertions(
*symbArray,
applyMap(_literal.value(), [&](auto const& c) { return smtutil::Expression{size_t(c)}; })
applyMap(_literal.value(), [](unsigned char c) { return smtutil::Expression{size_t(c)}; })
);
}
else
@ -1953,12 +1970,6 @@ smtutil::Expression SMTEncoder::compoundAssignment(Assignment const& _assignment
auto decl = identifierToVariable(_assignment.leftHandSide());
TypePointer commonType = Type::commonType(
_assignment.leftHandSide().annotation().type,
_assignment.rightHandSide().annotation().type
);
solAssert(commonType == _assignment.annotation().type, "");
if (compoundToBitwise.count(op))
return bitwiseOperation(
compoundToBitwise.at(op),

View File

@ -118,6 +118,9 @@ protected:
void endVisit(Continue const&) override {}
bool visit(TryCatchClause const& _node) override;
virtual void pushInlineFrame(CallableDeclaration const&);
virtual void popInlineFrame(CallableDeclaration const&);
/// Do not visit subtree if node is a RationalNumber.
/// Symbolic _expr is the rational literal.
bool shortcutRationalNumber(Expression const& _expr);

View File

@ -566,11 +566,13 @@ optional<smtutil::Expression> symbolicTypeConversion(TypePointer _from, TypePoin
// but they can also be compared/assigned to fixed bytes, in which
// case they'd need to be encoded as numbers.
if (auto strType = dynamic_cast<StringLiteralType const*>(_from))
if (_to->category() == frontend::Type::Category::FixedBytes)
if (auto fixedBytesType = dynamic_cast<FixedBytesType const*>(_to))
{
if (strType->value().empty())
return smtutil::Expression(size_t(0));
return smtutil::Expression(u256(toHex(util::asBytes(strType->value()), util::HexPrefix::Add)));
auto bytesVec = util::asBytes(strType->value());
bytesVec.resize(fixedBytesType->numBytes(), 0);
return smtutil::Expression(u256(toHex(bytesVec, util::HexPrefix::Add)));
}
return std::nullopt;

View File

@ -172,16 +172,21 @@ bool hashMatchesContent(string const& _hash, string const& _content)
bool isArtifactRequested(Json::Value const& _outputSelection, string const& _artifact, bool _wildcardMatchesExperimental)
{
static set<string> experimental{"ir", "irOptimized", "wast", "ewasm", "ewasm.wast"};
for (auto const& artifact: _outputSelection)
/// @TODO support sub-matching, e.g "evm" matches "evm.assembly"
if (artifact == _artifact)
for (auto const& selectedArtifactJson: _outputSelection)
{
string const& selectedArtifact = selectedArtifactJson.asString();
if (
_artifact == selectedArtifact ||
boost::algorithm::starts_with(_artifact, selectedArtifact + ".")
)
return true;
else if (artifact == "*")
else if (selectedArtifact == "*")
{
// "ir", "irOptimized", "wast" and "ewasm.wast" can only be matched by "*" if activated.
if (experimental.count(_artifact) == 0 || _wildcardMatchesExperimental)
return true;
}
}
return false;
}
@ -371,17 +376,23 @@ Json::Value collectEVMObject(
evmasm::LinkerObject const& _object,
string const* _sourceMap,
Json::Value _generatedSources,
bool _runtimeObject
bool _runtimeObject,
function<bool(string)> const& _artifactRequested
)
{
Json::Value output = Json::objectValue;
output["object"] = _object.toHex();
output["opcodes"] = evmasm::disassemble(_object.bytecode);
output["sourceMap"] = _sourceMap ? *_sourceMap : "";
output["linkReferences"] = formatLinkReferences(_object.linkReferences);
if (_runtimeObject)
if (_artifactRequested("object"))
output["object"] = _object.toHex();
if (_artifactRequested("opcodes"))
output["opcodes"] = evmasm::disassemble(_object.bytecode);
if (_artifactRequested("sourceMap"))
output["sourceMap"] = _sourceMap ? *_sourceMap : "";
if (_artifactRequested("linkReferences"))
output["linkReferences"] = formatLinkReferences(_object.linkReferences);
if (_runtimeObject && _artifactRequested("immutableReferences"))
output["immutableReferences"] = formatImmutableReferences(_object.immutableReferences);
output["generatedSources"] = move(_generatedSources);
if (_artifactRequested("generatedSources"))
output["generatedSources"] = move(_generatedSources);
return output;
}
@ -1146,7 +1157,14 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting
compilerStack.object(contractName),
compilerStack.sourceMapping(contractName),
compilerStack.generatedSources(contractName),
false
false,
[&](string const& _element) { return isArtifactRequested(
_inputsAndSettings.outputSelection,
file,
name,
"evm.bytecode." + _element,
wildcardMatchesExperimental
); }
);
if (compilationSuccess && isArtifactRequested(
@ -1160,7 +1178,14 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting
compilerStack.runtimeObject(contractName),
compilerStack.runtimeSourceMapping(contractName),
compilerStack.generatedSources(contractName, true),
true
true,
[&](string const& _element) { return isArtifactRequested(
_inputsAndSettings.outputSelection,
file,
name,
"evm.deployedBytecode." + _element,
wildcardMatchesExperimental
); }
);
if (!evmData.empty())
@ -1257,7 +1282,19 @@ Json::Value StandardCompiler::compileYul(InputsAndSettings _inputsAndSettings)
MachineAssemblyObject const& o = objectKind == "bytecode" ? object : runtimeObject;
if (o.bytecode)
output["contracts"][sourceName][contractName]["evm"][objectKind] =
collectEVMObject(*o.bytecode, o.sourceMappings.get(), Json::arrayValue, false);
collectEVMObject(
*o.bytecode,
o.sourceMappings.get(),
Json::arrayValue,
false,
[&](string const& _element) { return isArtifactRequested(
_inputsAndSettings.outputSelection,
sourceName,
contractName,
"evm." + objectKind + "." + _element,
wildcardMatchesExperimental
); }
);
}
if (isArtifactRequested(_inputsAndSettings.outputSelection, sourceName, contractName, "irOptimized", wildcardMatchesExperimental))

View File

@ -27,7 +27,7 @@ email=builds@ethereum.org
packagename=libz3-static-dev
version=4.8.9
DISTRIBUTIONS="bionic focal groovy"
DISTRIBUTIONS="focal groovy"
for distribution in $DISTRIBUTIONS
do

View File

@ -1,108 +0,0 @@
# vim:syntax=dockerfile
#------------------------------------------------------------------------------
# Dockerfile for building and testing Solidity Compiler on CI
# Target: Ubuntu 18.04 (Bionic Beaver)
# URL: https://hub.docker.com/r/ethereum/solidity-buildpack-deps
#
# 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) 2016-2019 solidity contributors.
#------------------------------------------------------------------------------
FROM buildpack-deps:bionic AS base
LABEL version="4"
ARG DEBIAN_FRONTEND=noninteractive
RUN set -ex; \
dist=$(grep DISTRIB_CODENAME /etc/lsb-release | cut -d= -f2); \
echo "deb http://ppa.launchpad.net/ethereum/cpp-build-deps/ubuntu $dist main" >> /etc/apt/sources.list ; \
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1c52189c923f6ca9 ; \
apt-get update; \
apt-get install -qqy --no-install-recommends \
build-essential \
software-properties-common \
cmake ninja-build clang++-8 \
libboost-filesystem-dev libboost-test-dev libboost-system-dev \
libboost-program-options-dev \
libjsoncpp-dev \
llvm-8-dev libz3-static-dev \
; \
apt-get install -qy python-pip python-sphinx; \
update-alternatives --install /usr/bin/llvm-symbolizer llvm-symbolizer /usr/bin/llvm-symbolizer-8 1; \
pip install codecov; \
rm -rf /var/lib/apt/lists/*
FROM base AS libraries
# OSSFUZZ: libprotobuf-mutator
RUN set -ex; \
git clone https://github.com/google/libprotobuf-mutator.git \
/usr/src/libprotobuf-mutator; \
cd /usr/src/libprotobuf-mutator; \
git checkout d1fe8a7d8ae18f3d454f055eba5213c291986f21; \
mkdir build; \
cd build; \
cmake .. -GNinja -DLIB_PROTO_MUTATOR_DOWNLOAD_PROTOBUF=ON \
-DLIB_PROTO_MUTATOR_TESTING=OFF -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="/usr"; \
ninja; \
cp -vpr external.protobuf/bin/* /usr/bin/; \
cp -vpr external.protobuf/include/* /usr/include/; \
cp -vpr external.protobuf/lib/* /usr/lib/; \
ninja install/strip; \
rm -rf /usr/src/libprotobuf-mutator
# OSSFUZZ: libfuzzer
RUN set -ex; \
cd /var/tmp; \
svn co https://llvm.org/svn/llvm-project/compiler-rt/trunk/lib/fuzzer libfuzzer; \
mkdir -p build-libfuzzer; \
cd build-libfuzzer; \
clang++-8 -O1 -stdlib=libstdc++ -std=c++11 -O2 -fPIC -c ../libfuzzer/*.cpp -I../libfuzzer; \
ar r /usr/lib/libFuzzingEngine.a *.o; \
rm -rf /var/lib/libfuzzer
# EVMONE
ARG EVMONE_HASH="e9f8df89c52d9c60c9a38dd00687b1ec9e9ae9650b400a87c4c0cf7468e35307"
ARG EVMONE_MAJOR="0"
ARG EVMONE_MINOR="4"
ARG EVMONE_MICRO="0"
RUN set -ex; \
EVMONE_VERSION="$EVMONE_MAJOR.$EVMONE_MINOR.$EVMONE_MICRO"; \
TGZFILE="evmone-$EVMONE_VERSION-linux-x86_64.tar.gz"; \
wget https://github.com/ethereum/evmone/releases/download/v$EVMONE_VERSION/$TGZFILE; \
sha256sum $TGZFILE | grep ${EVMONE_HASH}; \
tar xzpf $TGZFILE -C /usr; \
rm -f $TGZFILE;
# HERA
ARG HERA_HASH="1a0b3cf626910c969f0ac86b7a731969a2e5b8254bc4e626b8f3a60471481f03"
ARG HERA_MAJOR="0"
ARG HERA_MINOR="3"
ARG HERA_MICRO="2"
RUN set -ex; \
HERA_VERSION="$HERA_MAJOR.$HERA_MINOR.$HERA_MICRO"; \
TGZFILE="hera-$HERA_VERSION-linux-x86_64.tar.gz"; \
wget https://github.com/ewasm/hera/releases/download/v$HERA_VERSION/$TGZFILE; \
sha256sum $TGZFILE | grep ${HERA_HASH}; \
tar xzpf $TGZFILE -C /usr; \
rm -f $TGZFILE;
FROM base
COPY --from=libraries /usr/lib /usr/lib
COPY --from=libraries /usr/bin /usr/bin
COPY --from=libraries /usr/include /usr/include

View File

@ -57,7 +57,7 @@ packagename=solc
static_build_distribution=focal
DISTRIBUTIONS="bionic focal groovy"
DISTRIBUTIONS="focal groovy"
if is_release
then

View File

@ -1 +1 @@
{"contracts":{"A":{"C":{"evm":{"bytecode":{"generatedSources":[],"linkReferences":{},"object":"<BYTECODE REMOVED>","opcodes":"<OPCODES REMOVED>","sourceMap":"<SOURCEMAP REMOVED>"}}}}},"sources":{"A":{"id":0}}}
{"contracts":{"A":{"C":{"evm":{"bytecode":{"linkReferences":{},"object":"<BYTECODE REMOVED>"}}}}},"sources":{"A":{"id":0}}}

View File

@ -1 +1 @@
{"contracts":{"A\"B":{"C":{"evm":{"bytecode":{"generatedSources":[],"linkReferences":{},"object":"<BYTECODE REMOVED>","opcodes":"<OPCODES REMOVED>","sourceMap":"<SOURCEMAP REMOVED>"}}}}},"sources":{"A\"B":{"id":0}}}
{"contracts":{"A\"B":{"C":{"evm":{"bytecode":{"linkReferences":{},"object":"<BYTECODE REMOVED>"}}}}},"sources":{"A\"B":{"id":0}}}

View File

@ -1 +1 @@
{"contracts":{"A":{"C":{"evm":{"bytecode":{"generatedSources":[],"linkReferences":{"A":{"L2":[{"length":20,"start":184},{"length":20,"start":368}]}},"object":"<BYTECODE REMOVED>__$622b2f540b6a16ff5db7bea656ad8fcf4f$__<BYTECODE REMOVED>__$622b2f540b6a16ff5db7bea656ad8fcf4f$__<BYTECODE REMOVED>","opcodes":"<OPCODES REMOVED>","sourceMap":"<SOURCEMAP REMOVED>"}}}}},"sources":{"A":{"id":0}}}
{"contracts":{"A":{"C":{"evm":{"bytecode":{"linkReferences":{"A":{"L2":[{"length":20,"start":184},{"length":20,"start":368}]}},"object":"<BYTECODE REMOVED>__$622b2f540b6a16ff5db7bea656ad8fcf4f$__<BYTECODE REMOVED>__$622b2f540b6a16ff5db7bea656ad8fcf4f$__<BYTECODE REMOVED>"}}}}},"sources":{"A":{"id":0}}}

View File

@ -1 +1 @@
{"contracts":{"A":{"a":{"evm":{"bytecode":{"generatedSources":[],"linkReferences":{},"object":"<BYTECODE REMOVED>","opcodes":"<OPCODES REMOVED>","sourceMap":"<SOURCEMAP REMOVED>"}}}}},"errors":[{"component":"general","formattedMessage":"Yul is still experimental. Please use the output with care.","message":"Yul is still experimental. Please use the output with care.","severity":"warning","type":"Warning"}]}
{"contracts":{"A":{"a":{"evm":{"bytecode":{"linkReferences":{},"object":"<BYTECODE REMOVED>"}}}}},"errors":[{"component":"general","formattedMessage":"Yul is still experimental. Please use the output with care.","message":"Yul is still experimental. Please use the output with care.","severity":"warning","type":"Warning"}]}

View File

@ -1 +1 @@
{"contracts":{"A":{"a":{"evm":{"bytecode":{"generatedSources":[],"linkReferences":{},"object":"<BYTECODE REMOVED>","opcodes":"<OPCODES REMOVED>","sourceMap":"<SOURCEMAP REMOVED>"}}}}},"errors":[{"component":"general","formattedMessage":"Yul is still experimental. Please use the output with care.","message":"Yul is still experimental. Please use the output with care.","severity":"warning","type":"Warning"}]}
{"contracts":{"A":{"a":{"evm":{"bytecode":{"linkReferences":{},"object":"<BYTECODE REMOVED>"}}}}},"errors":[{"component":"general","formattedMessage":"Yul is still experimental. Please use the output with care.","message":"Yul is still experimental. Please use the output with care.","severity":"warning","type":"Warning"}]}

View File

@ -1 +1 @@
{"contracts":{"A":{"a":{"evm":{"bytecode":{"generatedSources":[],"linkReferences":{"contract/test.sol":{"L2":[{"length":20,"start":22}]}},"object":"<BYTECODE REMOVED>__$fb58009a6b1ecea3b9d99bedd645df4ec3$__<BYTECODE REMOVED>","opcodes":"<OPCODES REMOVED>","sourceMap":"<SOURCEMAP REMOVED>"}}}}},"errors":[{"component":"general","formattedMessage":"Yul is still experimental. Please use the output with care.","message":"Yul is still experimental. Please use the output with care.","severity":"warning","type":"Warning"}]}
{"contracts":{"A":{"a":{"evm":{"bytecode":{"linkReferences":{"contract/test.sol":{"L2":[{"length":20,"start":22}]}},"object":"<BYTECODE REMOVED>__$fb58009a6b1ecea3b9d99bedd645df4ec3$__<BYTECODE REMOVED>"}}}}},"errors":[{"component":"general","formattedMessage":"Yul is still experimental. Please use the output with care.","message":"Yul is still experimental. Please use the output with care.","severity":"warning","type":"Warning"}]}

View File

@ -1 +1 @@
{"contracts":{"a.sol":{"A1":{"evm":{"bytecode":{"generatedSources":[],"linkReferences":{},"object":"<BYTECODE REMOVED>","opcodes":"<OPCODES REMOVED>","sourceMap":"<SOURCEMAP REMOVED>"}}}},"b.sol":{"A1":{"evm":{"bytecode":{"generatedSources":[],"linkReferences":{},"object":"<BYTECODE REMOVED>","opcodes":"<OPCODES REMOVED>","sourceMap":"<SOURCEMAP REMOVED>"}}}}},"sources":{"a.sol":{"id":0},"b.sol":{"id":1}}}
{"contracts":{"a.sol":{"A1":{"evm":{"bytecode":{"object":"<BYTECODE REMOVED>"}}}},"b.sol":{"A1":{"evm":{"bytecode":{"object":"<BYTECODE REMOVED>"}}}}},"sources":{"a.sol":{"id":0},"b.sol":{"id":1}}}

View File

@ -1 +1 @@
{"contracts":{"a.sol":{"A2":{"evm":{"bytecode":{"generatedSources":[],"linkReferences":{},"object":"<BYTECODE REMOVED>","opcodes":"<OPCODES REMOVED>","sourceMap":"<SOURCEMAP REMOVED>"}}}}},"sources":{"a.sol":{"id":0},"b.sol":{"id":1}}}
{"contracts":{"a.sol":{"A2":{"evm":{"bytecode":{"object":"<BYTECODE REMOVED>"}}}}},"sources":{"a.sol":{"id":0},"b.sol":{"id":1}}}

View File

@ -1 +1 @@
{"contracts":{"a.sol":{"A1":{"evm":{"bytecode":{"generatedSources":[],"linkReferences":{},"object":"<BYTECODE REMOVED>","opcodes":"<OPCODES REMOVED>","sourceMap":"<SOURCEMAP REMOVED>"}}},"A2":{"evm":{"bytecode":{"generatedSources":[],"linkReferences":{},"object":"<BYTECODE REMOVED>","opcodes":"<OPCODES REMOVED>","sourceMap":"<SOURCEMAP REMOVED>"}}}},"b.sol":{"A1":{"evm":{"bytecode":{"generatedSources":[],"linkReferences":{},"object":"<BYTECODE REMOVED>","opcodes":"<OPCODES REMOVED>","sourceMap":"<SOURCEMAP REMOVED>"}}},"B2":{"evm":{"bytecode":{"generatedSources":[],"linkReferences":{},"object":"<BYTECODE REMOVED>","opcodes":"<OPCODES REMOVED>","sourceMap":"<SOURCEMAP REMOVED>"}}}}},"sources":{"a.sol":{"id":0},"b.sol":{"id":1}}}
{"contracts":{"a.sol":{"A1":{"evm":{"bytecode":{"object":"<BYTECODE REMOVED>"}}},"A2":{"evm":{"bytecode":{"object":"<BYTECODE REMOVED>"}}}},"b.sol":{"A1":{"evm":{"bytecode":{"object":"<BYTECODE REMOVED>"}}},"B2":{"evm":{"bytecode":{"object":"<BYTECODE REMOVED>"}}}}},"sources":{"a.sol":{"id":0},"b.sol":{"id":1}}}

View File

@ -1 +1 @@
{"contracts":{"a.sol":{"A1":{"evm":{"bytecode":{"generatedSources":[],"linkReferences":{},"object":"<BYTECODE REMOVED>","opcodes":"<OPCODES REMOVED>","sourceMap":"<SOURCEMAP REMOVED>"}}}}},"sources":{"a.sol":{"id":0},"b.sol":{"id":1}}}
{"contracts":{"a.sol":{"A1":{"evm":{"bytecode":{"object":"<BYTECODE REMOVED>"}}}}},"sources":{"a.sol":{"id":0},"b.sol":{"id":1}}}

View File

@ -1 +1 @@
{"contracts":{"b.sol":{"B2":{"evm":{"bytecode":{"generatedSources":[],"linkReferences":{},"object":"<BYTECODE REMOVED>","opcodes":"<OPCODES REMOVED>","sourceMap":"<SOURCEMAP REMOVED>"}}}}},"sources":{"a.sol":{"id":0},"b.sol":{"id":1}}}
{"contracts":{"b.sol":{"B2":{"evm":{"bytecode":{"object":"<BYTECODE REMOVED>"}}}}},"sources":{"a.sol":{"id":0},"b.sol":{"id":1}}}

View File

@ -1 +1 @@
{"contracts":{"a.sol":{"A1":{"evm":{"bytecode":{"generatedSources":[],"linkReferences":{},"object":"<BYTECODE REMOVED>","opcodes":"<OPCODES REMOVED>","sourceMap":"<SOURCEMAP REMOVED>"}}},"A2":{"evm":{"bytecode":{"generatedSources":[],"linkReferences":{},"object":"<BYTECODE REMOVED>","opcodes":"<OPCODES REMOVED>","sourceMap":"<SOURCEMAP REMOVED>"}}}}},"sources":{"a.sol":{"id":0},"b.sol":{"id":1}}}
{"contracts":{"a.sol":{"A1":{"evm":{"bytecode":{"object":"<BYTECODE REMOVED>"}}},"A2":{"evm":{"bytecode":{"object":"<BYTECODE REMOVED>"}}}}},"sources":{"a.sol":{"id":0},"b.sol":{"id":1}}}

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
{"contracts":{"a.sol":{"A":{"evm":{"deployedBytecode":{"generatedSources":[],"immutableReferences":{"6":[{"length":32,"start":77}]},"linkReferences":{},"object":"<BYTECODE REMOVED>","opcodes":"<OPCODES REMOVED>","sourceMap":"59:100:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;101:56;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;135:7;153:1;146:8;;101:56;:::o"}}}}},"sources":{"a.sol":{"id":0}}}
{"contracts":{"a.sol":{"A":{"evm":{"deployedBytecode":{"immutableReferences":{"6":[{"length":32,"start":77}]}}}}}},"sources":{"a.sol":{"id":0}}}

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
{"contracts":{"A":{"C":{"evm":{"bytecode":{"generatedSources":[],"linkReferences":{},"object":"<BYTECODE REMOVED>","opcodes":"<OPCODES REMOVED>","sourceMap":""},"deployedBytecode":{"generatedSources":[],"immutableReferences":{},"linkReferences":{},"object":"","opcodes":"","sourceMap":""}},"ir":"/*******************************************************
{"contracts":{"A":{"C":{"evm":{"bytecode":{"generatedSources":[],"object":"<BYTECODE REMOVED>"},"deployedBytecode":{"object":""}},"ir":"/*******************************************************
* WARNING *
* Solidity to Yul compilation is still EXPERIMENTAL *
* It can result in LOSS OF FUNDS or worse *
@ -49,7 +49,7 @@ object \"C_2\" {
}
"},"D":{"evm":{"bytecode":{"generatedSources":[],"linkReferences":{},"object":"<BYTECODE REMOVED>","opcodes":"<OPCODES REMOVED>","sourceMap":""},"deployedBytecode":{"generatedSources":[],"immutableReferences":{},"linkReferences":{},"object":"","opcodes":"","sourceMap":""}},"ir":"/*******************************************************
"},"D":{"evm":{"bytecode":{"generatedSources":[],"object":"<BYTECODE REMOVED>"},"deployedBytecode":{"object":""}},"ir":"/*******************************************************
* WARNING *
* Solidity to Yul compilation is still EXPERIMENTAL *
* It can result in LOSS OF FUNDS or worse *

View File

@ -0,0 +1,26 @@
pragma experimental SMTChecker;
contract C {
uint x;
modifier check() {
require(x == 0);
_;
assert(x == 1); // should fail;
assert(x == 0); // should hold;
}
modifier inc() {
if (x == 0) {
return;
}
x = x + 1;
_;
}
function test() check inc public {
}
}
// ----
// Warning 6328: (103-117): CHC: Assertion violation happens here.

View File

@ -0,0 +1,47 @@
pragma experimental SMTChecker;
contract C {
uint x;
function reset_if_overflow() internal postinc {
if (x < 10)
return;
x = 0;
}
modifier postinc() {
if (x == 0) {
return;
}
_;
x = x + 1;
}
function test() public {
if (x == 0) {
reset_if_overflow();
assert(x == 1); // should fail;
assert(x == 0); // should hold;
return;
}
if (x < 10) {
uint oldx = x;
reset_if_overflow();
assert(oldx + 1 == x); // should hold;
assert(oldx == x); // should fail;
return;
}
reset_if_overflow();
assert(x == 1); // should hold;
assert(x == 0); // should fail;
}
function set(uint _x) public {
x = _x;
}
}
// ----
// Warning 6328: (384-398): CHC: Assertion violation happens here.
// Warning 6328: (635-652): CHC: Assertion violation happens here.
// Warning 6328: (781-795): CHC: Assertion violation happens here.

View File

@ -0,0 +1,41 @@
pragma experimental SMTChecker;
contract A {
int x;
constructor (int a) { x = a;}
}
contract B is A {
int y;
constructor(int a) A(-a) {
if (a > 0) {
y = 2;
return;
}
else {
y = 3;
}
y = 4; // overwrites the else branch
}
}
contract C is B {
constructor(int a) B(a) {
assert(y != 3); // should hold
assert(y == 4); // should fail
if (a > 0) {
assert(x < 0 && y == 2); // should hold
assert(x < 0 && y == 4); // should fail
}
else {
assert(x >= 0 && y == 4); // should hold
assert(x >= 0 && y == 2); // should fail
assert(x > 0); // should fail
}
}
}
// ----
// Warning 6328: (330-344): CHC: Assertion violation happens here.
// Warning 6328: (422-445): CHC: Assertion violation happens here.
// Warning 6328: (522-546): CHC: Assertion violation happens here.
// Warning 6328: (566-579): CHC: Assertion violation happens here.

View File

@ -0,0 +1,28 @@
pragma experimental SMTChecker;
contract A {
uint x = 1;
}
contract B is A {
constructor(int a) {
if (a > 0) {
x = 2;
return;
}
x = 3;
}
}
abstract contract C is B {
}
contract D is C {
constructor(int a) B(a) {
assert(a > 0 || x == 3); // should hold
assert(a <= 0 || x == 2); // should hold
assert(x == 1); // should fail
}
}
// ----
// Warning 6328: (319-333): CHC: Assertion violation happens here.

View File

@ -0,0 +1,70 @@
pragma experimental SMTChecker;
contract A {
int x;
}
contract B is A {
int y;
constructor (int a) {
if (a >= 0) {
y = 1;
return;
}
x = 1;
y = 2;
}
}
contract C is A {
int z;
constructor (int a) {
if (a >= 0) {
z = 1;
return;
}
x = -1;
z = 2;
}
}
contract D1 is B, C {
constructor() B(1) C(1) {
assert(x == 0); // should hold
assert(x == 1); // should fail
assert(x == -1); // should fail
}
}
contract D2 is B, C {
constructor() B(1) C(-1) {
assert(x == 0); // should fail
assert(x == 1); // should fail
assert(x == -1); // should hold (constructor of C is executed AFTER constructor of B)
}
}
contract D3 is B, C {
constructor() B(-1) C(1) {
assert(x == 0); // should fail
assert(x == 1); // should hold
assert(x == -1); // should fail
}
}
contract D4 is B, C {
constructor() B(-1) C(-1) {
assert(x == 0); // should fail
assert(x == 1); // should fail
assert(x == -1); // should hold (constructor of C is executed AFTER constructor of B)
}
}
// ----
// Warning 6328: (370-384): CHC: Assertion violation happens here.
// Warning 6328: (403-418): CHC: Assertion violation happens here.
// Warning 6328: (493-507): CHC: Assertion violation happens here.
// Warning 6328: (526-540): CHC: Assertion violation happens here.
// Warning 6328: (703-717): CHC: Assertion violation happens here.
// Warning 6328: (769-784): CHC: Assertion violation happens here.
// Warning 6328: (860-874): CHC: Assertion violation happens here.
// Warning 6328: (893-907): CHC: Assertion violation happens here.

View File

@ -0,0 +1,31 @@
pragma experimental SMTChecker;
contract B {
int x;
constructor(int b) {
if (b > 0) {
x = 1;
return;
}
else {
x = 2;
return;
}
x = 3; // dead code
}
}
contract C is B {
constructor(int a) B(a) {
assert(a > 0 || x == 2); // should hold
assert(a <= 0 || x == 1); // should hold
assert(x == 3); // should fail
assert(x == 2); // should fail
assert(x == 1); // should fail
}
}
// ----
// Warning 5740: (152-157): Unreachable code.
// Warning 6328: (310-324): CHC: Assertion violation happens here.
// Warning 6328: (343-357): CHC: Assertion violation happens here.
// Warning 6328: (376-390): CHC: Assertion violation happens here.

View File

@ -0,0 +1,26 @@
pragma experimental SMTChecker;
contract C {
function test(uint256 a, uint256 b) public pure {
assert(nested_if(a,b) != 42); // should hold
assert(nested_if(a,b) == 1); // should fail
}
function nested_if(uint256 a, uint256 b) internal pure returns (uint256) {
if (a < 5) {
if (b > 1) {
return 0;
}
}
if (a == 2 && b == 2) {
return 42; // unreachable
}
else {
return 1;
}
}
}
// ----
// Warning 6328: (147-174): CHC: Assertion violation happens here.
// Warning 6838: (332-348): BMC: Condition is always false.

View File

@ -0,0 +1,21 @@
pragma experimental SMTChecker;
contract C {
function test() public pure {
assert(branches(0) == 0);
assert(branches(1) == 42);
}
function branches(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
else {
return 42;
}
return 1; // dead code
}
}
// ----
// Warning 5740: (265-273): Unreachable code.

View File

@ -0,0 +1,10 @@
pragma experimental SMTChecker;
contract C {
function test(uint256 a, uint256 b) public pure returns (uint256) {
if (a == 0) {
return 0;
}
return b / a; // This division is safe because of the early return in if-block.
}
}

View File

@ -0,0 +1,17 @@
pragma experimental SMTChecker;
contract C {
function test(uint256 a) public pure {
assert(simple_if(a) == 1); // should fail for a == 0
}
function simple_if(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
return 1;
}
}
// ----
// Warning 6328: (89-114): CHC: Assertion violation happens here.

View File

@ -0,0 +1,28 @@
pragma experimental SMTChecker;
contract C {
uint[] a;
constructor () {
a.push();
a.push();
}
function check() public {
require(a.length >= 2);
require(a[1] == 0);
conditional_store();
assert(a[1] == 1); // should fail;
assert(a[1] == 0); // should hold;
}
function conditional_store() internal {
if (a[1] == 0) {
return;
}
a[1] = 1;
}
}
// ----
// Warning 6328: (205-222): CHC: Assertion violation happens here.

View File

@ -0,0 +1,22 @@
pragma experimental SMTChecker;
contract C {
uint x;
function check() public {
require(x == 0);
conditional_increment();
assert(x == 1); // should fail;
assert(x == 0); // should hold;
}
function conditional_increment() internal {
if (x == 0) {
return;
}
x = 1;
}
}
// ----
// Warning 6328: (132-146): CHC: Assertion violation happens here.

View File

@ -0,0 +1,25 @@
pragma experimental SMTChecker;
contract C {
struct S {
uint x;
}
S s;
function check() public {
require(s.x == 0);
conditional_increment();
assert(s.x == 1); // should fail;
assert(s.x == 0); // should hold;
}
function conditional_increment() internal {
if (s.x == 0) {
return;
}
s.x = 1;
}
}
// ----
// Warning 6328: (156-172): CHC: Assertion violation happens here.

View File

@ -0,0 +1,25 @@
pragma experimental SMTChecker;
contract C {
struct S {
uint x;
}
S s;
function check() public {
require(s.x == 0);
conditional_increment();
assert(s.x == 1); // should fail;
assert(s.x == 0); // should hold;
}
function conditional_increment() internal {
if (s.x == 0) {
return;
}
s = S(1);
}
}
// ----
// Warning 6328: (156-172): CHC: Assertion violation happens here.

View File

@ -0,0 +1,27 @@
pragma experimental SMTChecker;
contract C {
uint x;
uint y;
function check() public {
require(x == 0);
require(y == 0);
conditional_increment();
assert(x == 0); // should fail;
assert(x == 1); // should fail;
assert(x == 2); // should hold;
}
function conditional_increment() internal {
if (x == 0) {
(x,y) = (2,2);
return;
}
(x,y) = (1,1);
}
}
// ----
// Warning 6328: (160-174): CHC: Assertion violation happens here.
// Warning 6328: (194-208): CHC: Assertion violation happens here.

View File

@ -0,0 +1,19 @@
pragma experimental SMTChecker;
contract C {
uint a;
uint b;
uint c;
function test() public view {
if (a == 0) {
if (b == 0) {
if (c == 0) {
return;
}
}
}
assert(a != 0 || b != 0 || c != 0);
}
}

View File

@ -0,0 +1,22 @@
pragma experimental SMTChecker;
contract C {
function add(uint x, uint y) internal pure returns (uint) {
if (y == 0)
return x;
if (y == 1)
return ++x;
if (y == 2)
return x + 2;
return x + y;
}
function f() public pure {
assert(add(100, 0) == 100);
assert(add(100, 1) == 101);
assert(add(100, 2) == 102);
assert(add(100, 100) == 200);
}
}
// ----
// Warning 2661: (158-161): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.

View File

@ -0,0 +1,26 @@
pragma experimental SMTChecker;
contract C {
function add(uint x, uint y) internal pure returns (uint) {
if (y == 0)
return x;
if (y == 1)
return ++x;
if (y == 2)
return x + 2;
return x + y;
}
function f() public pure {
assert(add(100, 0) != 100);
assert(add(100, 1) != 101);
assert(add(100, 2) != 102);
assert(add(100, 100) != 200);
}
}
// ----
// Warning 6328: (244-270): CHC: Assertion violation happens here.
// Warning 6328: (274-300): CHC: Assertion violation happens here.
// Warning 6328: (304-330): CHC: Assertion violation happens here.
// Warning 6328: (334-362): CHC: Assertion violation happens here.
// Warning 2661: (158-161): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.

View File

@ -0,0 +1,31 @@
pragma experimental SMTChecker;
contract C {
uint c;
function add(uint x, uint y) internal returns (uint) {
c = 0xff;
if (y == 0)
return x;
c = 0xffff;
if (y == 1)
return ++x;
c = 0xffffff;
if (y == 2)
return x + 2;
c = 0xffffffff;
return x + y;
}
function f() public {
assert(add(100, 0) == 100);
assert(c == 0xff);
assert(add(100, 1) == 101);
assert(c == 0xffff);
assert(add(100, 2) == 102);
assert(c == 0xffffff);
assert(add(100, 100) == 200);
assert(c == 0xffffffff);
}
}
// ----
// Warning 2661: (188-191): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.

View File

@ -0,0 +1,39 @@
pragma experimental SMTChecker;
contract C {
uint c;
function add(uint x, uint y) internal returns (uint) {
c = 0xff;
if (y == 0)
return x;
c = 0xffff;
if (y == 1)
return ++x;
c = 0xffffff;
if (y == 2)
return x + 2;
c = 0xffffffff;
return x + y;
}
function f() public {
assert(add(100, 0) != 100);
assert(c != 0xff);
assert(add(100, 1) != 101);
assert(c != 0xffff);
assert(add(100, 2) != 102);
assert(c != 0xffffff);
assert(add(100, 100) != 200);
assert(c != 0xffffffff);
}
}
// ----
// Warning 6328: (303-329): CHC: Assertion violation happens here.
// Warning 6328: (333-350): CHC: Assertion violation happens here.
// Warning 6328: (354-380): CHC: Assertion violation happens here.
// Warning 6328: (384-403): CHC: Assertion violation happens here.
// Warning 6328: (407-433): CHC: Assertion violation happens here.
// Warning 6328: (437-458): CHC: Assertion violation happens here.
// Warning 6328: (462-490): CHC: Assertion violation happens here.
// Warning 6328: (494-517): CHC: Assertion violation happens here.
// Warning 2661: (188-191): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.

View File

@ -1,7 +1,11 @@
pragma experimental SMTChecker;
contract C {
function f() public pure returns (byte) {
return (byte("") & (""));
}
function f() public pure {
assert(byte("") & ("") == byte(0)); // should hold
assert(byte(0xAA) & byte(0x55) == byte(0)); // should hold
assert(byte(0xFF) & byte(0xAA) == byte(0xAA)); // should hold
assert(byte(0xFF) & byte(0xAA) == byte(0)); // should fail
}
}
// ----
// Warning 6328: (253-295): CHC: Assertion violation happens here.

View File

@ -9,4 +9,4 @@ contract C {
}
}
// ----
// Warning 6328: (175-198): CHC: Assertion violation happens here.
// Warning 6328: (133-156): CHC: Assertion violation happens here.

View File

@ -1,7 +1,11 @@
pragma experimental SMTChecker;
contract C {
function f() public pure returns (byte) {
return (byte(0x0F) | (byte(0xF0)));
}
function f() public pure returns (byte) {
byte b = (byte(0x0F) | (byte(0xF0)));
assert(b == byte(0xFF)); // should hold
assert(b == byte(0x00)); // should fail
return b;
}
}
// ----
// Warning 6328: (172-195): CHC: Assertion violation happens here.

View File

@ -1,8 +1,11 @@
pragma experimental SMTChecker;
contract Simp {
function f3() public pure returns (byte) {
bytes memory y = "def";
return y[0] ^ "e";
}
function f3() public pure returns (byte) {
bytes memory y = "def";
assert(y[0] ^ "e" != byte(0)); // should hold
assert(y[1] ^ "e" != byte(0)); // should fail
return y[0];
}
}
// ----
// Warning 6328: (168-197): CHC: Assertion violation happens here.

View File

@ -0,0 +1,11 @@
pragma experimental SMTChecker;
contract C {
function f(int a, uint b) public view {
a >>= tx.gasprice;
require(a == 16 && b == 2);
a >>= b;
assert(a == 4); // should hold
}
}
// ----

View File

@ -11,4 +11,3 @@ contract C {
}
// ----
// Warning 4984: (160-165): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.
// Warning 4281: (177-182): CHC: Division by zero happens here.

View File

@ -5,8 +5,8 @@ contract C {
require(b[10] == 0xff);
assert(bytes(b[10:20]).length == 10);
assert(bytes(b[10:20])[0] == 0xff);
assert(bytes(b[10:20])[5] == 0xff);
// Disabled because of Spacer nondeterminism
//assert(bytes(b[10:20])[5] == 0xff);
}
}
// ----
// Warning 6328: (198-232): CHC: Assertion violation happens here.

View File

@ -0,0 +1,12 @@
pragma experimental SMTChecker;
contract C {
function f() public pure {
bytes memory b = bytes(hex"ffff");
assert(b.length == 2); // should hold
assert(b[0] == byte(uint8(255))); // should hold
assert(b[1] == byte(uint8(100))); // should fail
}
}
// ----
// Warning 6328: (204-236): CHC: Assertion violation happens here.

View File

@ -0,0 +1,10 @@
pragma experimental SMTChecker;
contract C {
function f() public pure {
assert(bytes4(hex"0000ffff") == bytes4(hex"ffff")); // should fail
assert(bytes4(hex"ffff0000") == bytes4(hex"ffff")); // should hold
}
}
// ----
// Warning 6328: (76-126): CHC: Assertion violation happens here.

View File

@ -0,0 +1,37 @@
/*
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/>.
*/
#include <test/tools/ossfuzz/abiV2FuzzerCommon.h>
#include <test/tools/ossfuzz/protoToAbiV2.h>
#include <src/libfuzzer/libfuzzer_macro.h>
#include <abicoder.hpp>
using namespace solidity::test::abiv2fuzzer;
using namespace solidity::test;
using namespace std;
static constexpr size_t abiCoderHeapSize = 1024 * 512;
DEFINE_PROTO_FUZZER(Contract const&)
{
abicoder::ABICoder coder(abiCoderHeapSize);
auto [encodeStatus, encodedData] = coder.encode("bool", "true");
solAssert(encodeStatus, "Isabelle abicoder fuzzer: Encoding failed");
return;
}

View File

@ -21,7 +21,7 @@ if (OSSFUZZ)
)
add_custom_target(ossfuzz_abiv2)
add_dependencies(ossfuzz_abiv2 abiv2_proto_ossfuzz)
add_dependencies(ossfuzz_abiv2 abiv2_proto_ossfuzz abiv2_isabelle_ossfuzz)
endif()
if (OSSFUZZ)
@ -135,6 +135,28 @@ if (OSSFUZZ)
set_target_properties(abiv2_proto_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE})
target_compile_options(abiv2_proto_ossfuzz PUBLIC ${COMPILE_OPTIONS} -Wno-sign-conversion)
add_executable(abiv2_isabelle_ossfuzz
../../EVMHost.cpp
AbiV2IsabelleFuzzer.cpp
abiV2FuzzerCommon.cpp
protoToAbiV2.cpp
abiV2Proto.pb.cc
)
target_include_directories(abiv2_isabelle_ossfuzz PRIVATE
/usr/include/libprotobuf-mutator
)
target_link_libraries(abiv2_isabelle_ossfuzz PRIVATE solidity
evmc
evmone-standalone
protobuf-mutator-libfuzzer.a
protobuf-mutator.a
protobuf.a
abicoder
gmp
)
set_target_properties(abiv2_isabelle_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE})
target_compile_options(abiv2_isabelle_ossfuzz PUBLIC ${COMPILE_OPTIONS} -Wno-sign-conversion)
add_executable(sol_proto_ossfuzz
solProtoFuzzer.cpp
protoToSol.cpp