Browse Source

Merge branch 'develop' of github.com:ethereum/cpp-ethereum into develop

Conflicts:
	test/SolidityOptimizer.cpp
cl-refactor
Gav Wood 10 years ago
parent
commit
9acbab487b
  1. 20
      eth/main.cpp
  2. 17
      libsolidity/AST.cpp
  3. 5
      libsolidity/AST.h
  4. 1
      libsolidity/CMakeLists.txt
  5. 44
      libsolidity/Compiler.cpp
  6. 2
      libsolidity/CompilerUtils.cpp
  7. 4
      libsolidity/CompilerUtils.h
  8. 17
      libsolidity/ExpressionCompiler.cpp
  9. 25
      libsolidity/InterfaceHandler.cpp
  10. 18
      libsolidity/Types.cpp
  11. 2
      libsolidity/Types.h
  12. 4
      mix/AssemblyDebuggerControl.cpp
  13. 4
      mix/CodeHighlighter.cpp
  14. 2
      mix/CodeModel.cpp
  15. 10
      mix/QContractDefinition.cpp
  16. 272
      neth/main.cpp
  17. 28
      test/SolidityABIJSON.cpp
  18. 17
      test/SolidityCompiler.cpp
  19. 294
      test/SolidityEndToEndTest.cpp
  20. 26
      test/SolidityOptimizer.cpp
  21. 8
      test/TestHelper.cpp
  22. 1
      test/TestHelper.h
  23. 18
      test/solidityExecutionFramework.h
  24. 85
      test/stSystemOperationsTestFiller.json
  25. 10
      test/state.cpp
  26. 3
      test/vm.cpp
  27. 56
      test/vmArithmeticTestFiller.json
  28. 56
      test/vmBlockInfoTestFiller.json
  29. 1244
      test/vmIOandFlowOperationsTestFiller.json

20
eth/main.cpp

@ -30,6 +30,7 @@
#include <libdevcrypto/FileSystem.h> #include <libdevcrypto/FileSystem.h>
#include <libevmcore/Instruction.h> #include <libevmcore/Instruction.h>
#include <libevm/VM.h> #include <libevm/VM.h>
#include <libevm/VMFactory.h>
#include <libethereum/All.h> #include <libethereum/All.h>
#include <libwebthree/WebThree.h> #include <libwebthree/WebThree.h>
#if ETH_READLINE #if ETH_READLINE
@ -121,7 +122,11 @@ void help()
<< " -u,--public-ip <ip> Force public ip to given (default; auto)." << endl << " -u,--public-ip <ip> Force public ip to given (default; auto)." << endl
<< " -v,--verbosity <0 - 9> Set the log verbosity from 0 to 9 (Default: 8)." << endl << " -v,--verbosity <0 - 9> Set the log verbosity from 0 to 9 (Default: 8)." << endl
<< " -x,--peers <number> Attempt to connect to given number of peers (Default: 5)." << endl << " -x,--peers <number> Attempt to connect to given number of peers (Default: 5)." << endl
<< " -V,--version Show the version and exit." << endl; << " -V,--version Show the version and exit." << endl
#if ETH_EVMJIT
<< " --jit Use EVM JIT (default: off)." << endl
#endif
;
exit(0); exit(0);
} }
@ -193,6 +198,7 @@ int main(int argc, char** argv)
bool upnp = true; bool upnp = true;
bool useLocal = false; bool useLocal = false;
bool forceMining = false; bool forceMining = false;
bool jit = false;
string clientName; string clientName;
// Init defaults // Init defaults
@ -295,6 +301,15 @@ int main(int argc, char** argv)
return -1; return -1;
} }
} }
else if (arg == "--jit")
{
#if ETH_EVMJIT
jit = true;
#else
cerr << "EVM JIT not enabled" << endl;
return -1;
#endif
}
else if (arg == "-h" || arg == "--help") else if (arg == "-h" || arg == "--help")
help(); help();
else if (arg == "-V" || arg == "--version") else if (arg == "-V" || arg == "--version")
@ -308,9 +323,10 @@ int main(int argc, char** argv)
cout << credits(); cout << credits();
VMFactory::setKind(jit ? VMKind::JIT : VMKind::Interpreter);
NetworkPreferences netPrefs(listenPort, publicIP, upnp, useLocal); NetworkPreferences netPrefs(listenPort, publicIP, upnp, useLocal);
dev::WebThreeDirect web3( dev::WebThreeDirect web3(
"Ethereum(++)/" + clientName + "v" + dev::Version + "/" DEV_QUOTED(ETH_BUILD_TYPE) "/" DEV_QUOTED(ETH_BUILD_PLATFORM), "Ethereum(++)/" + clientName + "v" + dev::Version + "/" DEV_QUOTED(ETH_BUILD_TYPE) "/" DEV_QUOTED(ETH_BUILD_PLATFORM) + (jit ? "/JIT" : ""),
dbPath, dbPath,
false, false,
mode == NodeMode::Full ? set<string>{"eth", "shh"} : set<string>(), mode == NodeMode::Full ? set<string>{"eth", "shh"} : set<string>(),

17
libsolidity/AST.cpp

@ -27,6 +27,8 @@
#include <libsolidity/Exceptions.h> #include <libsolidity/Exceptions.h>
#include <libsolidity/AST_accept.h> #include <libsolidity/AST_accept.h>
#include <libdevcrypto/SHA3.h>
using namespace std; using namespace std;
namespace dev namespace dev
@ -50,18 +52,17 @@ void ContractDefinition::checkTypeRequirements()
function->checkTypeRequirements(); function->checkTypeRequirements();
} }
vector<FunctionDefinition const*> ContractDefinition::getInterfaceFunctions() const map<FixedHash<4>, FunctionDefinition const*> ContractDefinition::getInterfaceFunctions() const
{ {
vector<FunctionDefinition const*> exportedFunctions; map<FixedHash<4>, FunctionDefinition const*> exportedFunctions;
for (ASTPointer<FunctionDefinition> const& f: m_definedFunctions) for (ASTPointer<FunctionDefinition> const& f: m_definedFunctions)
if (f->isPublic() && f->getName() != getName()) if (f->isPublic() && f->getName() != getName())
exportedFunctions.push_back(f.get()); {
auto compareNames = [](FunctionDefinition const* _a, FunctionDefinition const* _b) FixedHash<4> hash(dev::sha3(f->getCanonicalSignature()));
{ auto res = exportedFunctions.insert(std::make_pair(hash,f.get()));
return _a->getName().compare(_b->getName()) < 0; solAssert(res.second, "Hash collision at Function Definition Hash calculation");
}; }
sort(exportedFunctions.begin(), exportedFunctions.end(), compareNames);
return exportedFunctions; return exportedFunctions;
} }

5
libsolidity/AST.h

@ -183,8 +183,9 @@ public:
/// Can contain a nullptr in which case indicates absence of documentation /// Can contain a nullptr in which case indicates absence of documentation
ASTPointer<ASTString> const& getDocumentation() const { return m_documentation; } ASTPointer<ASTString> const& getDocumentation() const { return m_documentation; }
/// Returns the functions that make up the calling interface in the intended order. /// @returns a map of canonical function signatures to FunctionDefinitions
std::vector<FunctionDefinition const*> getInterfaceFunctions() const; /// as intended for use by the ABI.
std::map<FixedHash<4>, FunctionDefinition const*> getInterfaceFunctions() const;
/// Returns the constructor or nullptr if no constructor was specified /// Returns the constructor or nullptr if no constructor was specified
FunctionDefinition const* getConstructor() const; FunctionDefinition const* getConstructor() const;

1
libsolidity/CMakeLists.txt

@ -28,6 +28,7 @@ endif()
target_link_libraries(${EXECUTABLE} ${JSONCPP_LIBRARIES}) target_link_libraries(${EXECUTABLE} ${JSONCPP_LIBRARIES})
target_link_libraries(${EXECUTABLE} evmcore) target_link_libraries(${EXECUTABLE} evmcore)
target_link_libraries(${EXECUTABLE} devcore) target_link_libraries(${EXECUTABLE} devcore)
target_link_libraries(${EXECUTABLE} devcrypto)
install( TARGETS ${EXECUTABLE} ARCHIVE DESTINATION lib LIBRARY DESTINATION lib ) install( TARGETS ${EXECUTABLE} ARCHIVE DESTINATION lib LIBRARY DESTINATION lib )
install( FILES ${HEADERS} DESTINATION include/${EXECUTABLE} ) install( FILES ${HEADERS} DESTINATION include/${EXECUTABLE} )

44
libsolidity/Compiler.cpp

@ -100,7 +100,7 @@ void Compiler::appendConstructorCall(FunctionDefinition const& _constructor)
{ {
m_context << u256(argumentSize); m_context << u256(argumentSize);
m_context.appendProgramSize(); m_context.appendProgramSize();
m_context << u256(1); // copy it to byte one as expected for ABI calls m_context << u256(CompilerUtils::dataStartOffset); // copy it to byte four as expected for ABI calls
m_context << eth::Instruction::CODECOPY; m_context << eth::Instruction::CODECOPY;
appendCalldataUnpacker(_constructor, true); appendCalldataUnpacker(_constructor, true);
} }
@ -118,35 +118,27 @@ set<FunctionDefinition const*> Compiler::getFunctionsNeededByConstructor(Functio
void Compiler::appendFunctionSelector(ContractDefinition const& _contract) void Compiler::appendFunctionSelector(ContractDefinition const& _contract)
{ {
vector<FunctionDefinition const*> interfaceFunctions = _contract.getInterfaceFunctions(); map<FixedHash<4>, FunctionDefinition const*> interfaceFunctions = _contract.getInterfaceFunctions();
vector<eth::AssemblyItem> callDataUnpackerEntryPoints; map<FixedHash<4>, const eth::AssemblyItem> callDataUnpackerEntryPoints;
if (interfaceFunctions.size() > 255) // retrieve the function signature hash from the calldata
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("More than 255 public functions for contract.")); m_context << u256(1) << u256(0);
CompilerUtils(m_context).loadFromMemory(0, 4, false, true);
// retrieve the first byte of the call data, which determines the called function
// @todo This code had a jump table in a previous version which was more efficient but also // stack now is: 1 0 <funhash>
// error prone (due to the optimizer and variable length tag addresses) // for (auto it = interfaceFunctions.cbegin(); it != interfaceFunctions.cend(); ++it)
m_context << u256(1) << u256(0) // some constants for (auto const& it: interfaceFunctions)
<< eth::dupInstruction(1) << eth::Instruction::CALLDATALOAD
<< eth::dupInstruction(2) << eth::Instruction::BYTE
<< eth::dupInstruction(2);
// stack here: 1 0 <funid> 0, stack top will be counted up until it matches funid
for (unsigned funid = 0; funid < interfaceFunctions.size(); ++funid)
{ {
callDataUnpackerEntryPoints.push_back(m_context.newTag()); callDataUnpackerEntryPoints.insert(std::make_pair(it.first, m_context.newTag()));
m_context << eth::dupInstruction(2) << eth::dupInstruction(2) << eth::Instruction::EQ; m_context << eth::dupInstruction(1) << u256(FixedHash<4>::Arith(it.first)) << eth::Instruction::EQ;
m_context.appendConditionalJumpTo(callDataUnpackerEntryPoints.back()); m_context.appendConditionalJumpTo(callDataUnpackerEntryPoints.at(it.first));
if (funid < interfaceFunctions.size() - 1)
m_context << eth::dupInstruction(4) << eth::Instruction::ADD;
} }
m_context << eth::Instruction::STOP; // function not found m_context << eth::Instruction::STOP; // function not found
for (unsigned funid = 0; funid < interfaceFunctions.size(); ++funid) for (auto const& it: interfaceFunctions)
{ {
FunctionDefinition const& function = *interfaceFunctions[funid]; FunctionDefinition const& function = *it.second;
m_context << callDataUnpackerEntryPoints[funid]; m_context << callDataUnpackerEntryPoints.at(it.first);
eth::AssemblyItem returnTag = m_context.pushNewTag(); eth::AssemblyItem returnTag = m_context.pushNewTag();
appendCalldataUnpacker(function); appendCalldataUnpacker(function);
m_context.appendJumpTo(m_context.getFunctionEntryLabel(function)); m_context.appendJumpTo(m_context.getFunctionEntryLabel(function));
@ -158,7 +150,7 @@ void Compiler::appendFunctionSelector(ContractDefinition const& _contract)
unsigned Compiler::appendCalldataUnpacker(FunctionDefinition const& _function, bool _fromMemory) unsigned Compiler::appendCalldataUnpacker(FunctionDefinition const& _function, bool _fromMemory)
{ {
// We do not check the calldata size, everything is zero-padded. // We do not check the calldata size, everything is zero-padded.
unsigned dataOffset = 1; unsigned dataOffset = CompilerUtils::dataStartOffset; // the 4 bytes of the function hash signature
//@todo this can be done more efficiently, saving some CALLDATALOAD calls //@todo this can be done more efficiently, saving some CALLDATALOAD calls
for (ASTPointer<VariableDeclaration> const& var: _function.getParameters()) for (ASTPointer<VariableDeclaration> const& var: _function.getParameters())
{ {

2
libsolidity/CompilerUtils.cpp

@ -31,6 +31,8 @@ namespace dev
namespace solidity namespace solidity
{ {
const unsigned int CompilerUtils::dataStartOffset = 4;
void CompilerUtils::loadFromMemory(unsigned _offset, unsigned _bytes, bool _leftAligned, bool _fromCalldata) void CompilerUtils::loadFromMemory(unsigned _offset, unsigned _bytes, bool _leftAligned, bool _fromCalldata)
{ {
if (_bytes == 0) if (_bytes == 0)

4
libsolidity/CompilerUtils.h

@ -58,10 +58,14 @@ public:
static unsigned getSizeOnStack(std::vector<T> const& _variables); static unsigned getSizeOnStack(std::vector<T> const& _variables);
static unsigned getSizeOnStack(std::vector<std::shared_ptr<Type const>> const& _variableTypes); static unsigned getSizeOnStack(std::vector<std::shared_ptr<Type const>> const& _variableTypes);
/// Bytes we need to the start of call data.
/// - The size in bytes of the function (hash) identifier.
static const unsigned int dataStartOffset;
private: private:
CompilerContext& m_context; CompilerContext& m_context;
}; };
template <class T> template <class T>
unsigned CompilerUtils::getSizeOnStack(std::vector<T> const& _variables) unsigned CompilerUtils::getSizeOnStack(std::vector<T> const& _variables)
{ {

17
libsolidity/ExpressionCompiler.cpp

@ -401,7 +401,7 @@ void ExpressionCompiler::endVisit(MemberAccess const& _memberAccess)
case Type::Category::CONTRACT: case Type::Category::CONTRACT:
{ {
ContractType const& type = dynamic_cast<ContractType const&>(*_memberAccess.getExpression().getType()); ContractType const& type = dynamic_cast<ContractType const&>(*_memberAccess.getExpression().getType());
m_context << type.getFunctionIndex(member); m_context << type.getFunctionIdentifier(member);
break; break;
} }
case Type::Category::MAGIC: case Type::Category::MAGIC:
@ -663,7 +663,11 @@ void ExpressionCompiler::appendExternalFunctionCall(FunctionType const& _functio
{ {
solAssert(_arguments.size() == _functionType.getParameterTypes().size(), ""); solAssert(_arguments.size() == _functionType.getParameterTypes().size(), "");
unsigned dataOffset = _options.bare ? 0 : 1; // reserve one byte for the function index _options.obtainAddress();
if (!_options.bare)
CompilerUtils(m_context).storeInMemory(0, CompilerUtils::dataStartOffset);
unsigned dataOffset = _options.bare ? 0 : CompilerUtils::dataStartOffset; // reserve 4 bytes for the function's hash identifier
for (unsigned i = 0; i < _arguments.size(); ++i) for (unsigned i = 0; i < _arguments.size(); ++i)
{ {
_arguments[i]->accept(*this); _arguments[i]->accept(*this);
@ -690,12 +694,13 @@ void ExpressionCompiler::appendExternalFunctionCall(FunctionType const& _functio
_options.obtainValue(); _options.obtainValue();
else else
m_context << u256(0); m_context << u256(0);
_options.obtainAddress(); m_context << eth::dupInstruction(6); //copy contract address
if (!_options.bare)
m_context << u256(0) << eth::Instruction::MSTORE8;
m_context << u256(25) << eth::Instruction::GAS << eth::Instruction::SUB m_context << u256(25) << eth::Instruction::GAS << eth::Instruction::SUB
<< eth::Instruction::CALL << eth::Instruction::CALL
<< eth::Instruction::POP; // @todo do not ignore failure indicator << eth::Instruction::POP // @todo do not ignore failure indicator
<< eth::Instruction::POP; // pop contract address
if (retSize > 0) if (retSize > 0)
{ {
bool const leftAligned = firstType->getCategory() == Type::Category::STRING; bool const leftAligned = firstType->getCategory() == Type::Category::STRING;

25
libsolidity/InterfaceHandler.cpp

@ -39,7 +39,7 @@ std::unique_ptr<std::string> InterfaceHandler::getABIInterface(ContractDefinitio
{ {
Json::Value methods(Json::arrayValue); Json::Value methods(Json::arrayValue);
for (FunctionDefinition const* f: _contractDef.getInterfaceFunctions()) for (auto const& it: _contractDef.getInterfaceFunctions())
{ {
Json::Value method; Json::Value method;
Json::Value inputs(Json::arrayValue); Json::Value inputs(Json::arrayValue);
@ -58,10 +58,10 @@ std::unique_ptr<std::string> InterfaceHandler::getABIInterface(ContractDefinitio
return params; return params;
}; };
method["name"] = f->getName(); method["name"] = it.second->getName();
method["constant"] = f->isDeclaredConst(); method["constant"] = it.second->isDeclaredConst();
method["inputs"] = populateParameters(f->getParameters()); method["inputs"] = populateParameters(it.second->getParameters());
method["outputs"] = populateParameters(f->getReturnParameters()); method["outputs"] = populateParameters(it.second->getReturnParameters());
methods.append(method); methods.append(method);
} }
return std::unique_ptr<std::string>(new std::string(m_writer.write(methods))); return std::unique_ptr<std::string>(new std::string(m_writer.write(methods)));
@ -70,8 +70,9 @@ std::unique_ptr<std::string> InterfaceHandler::getABIInterface(ContractDefinitio
unique_ptr<string> InterfaceHandler::getABISolidityInterface(ContractDefinition const& _contractDef) unique_ptr<string> InterfaceHandler::getABISolidityInterface(ContractDefinition const& _contractDef)
{ {
string ret = "contract " + _contractDef.getName() + "{"; string ret = "contract " + _contractDef.getName() + "{";
for (FunctionDefinition const* f: _contractDef.getInterfaceFunctions()) for (auto const& it: _contractDef.getInterfaceFunctions())
{ {
FunctionDefinition const* f = it.second;
auto populateParameters = [](vector<ASTPointer<VariableDeclaration>> const& _vars) auto populateParameters = [](vector<ASTPointer<VariableDeclaration>> const& _vars)
{ {
string r = ""; string r = "";
@ -94,10 +95,10 @@ std::unique_ptr<std::string> InterfaceHandler::getUserDocumentation(ContractDefi
Json::Value doc; Json::Value doc;
Json::Value methods(Json::objectValue); Json::Value methods(Json::objectValue);
for (FunctionDefinition const* f: _contractDef.getInterfaceFunctions()) for (auto const& it: _contractDef.getInterfaceFunctions())
{ {
Json::Value user; Json::Value user;
auto strPtr = f->getDocumentation(); auto strPtr = it.second->getDocumentation();
if (strPtr) if (strPtr)
{ {
resetUser(); resetUser();
@ -105,7 +106,7 @@ std::unique_ptr<std::string> InterfaceHandler::getUserDocumentation(ContractDefi
if (!m_notice.empty()) if (!m_notice.empty())
{// since @notice is the only user tag if missing function should not appear {// since @notice is the only user tag if missing function should not appear
user["notice"] = Json::Value(m_notice); user["notice"] = Json::Value(m_notice);
methods[f->getName()] = user; methods[it.second->getName()] = user;
} }
} }
} }
@ -135,10 +136,10 @@ std::unique_ptr<std::string> InterfaceHandler::getDevDocumentation(ContractDefin
doc["title"] = m_title; doc["title"] = m_title;
} }
for (FunctionDefinition const* f: _contractDef.getInterfaceFunctions()) for (auto const& it: _contractDef.getInterfaceFunctions())
{ {
Json::Value method; Json::Value method;
auto strPtr = f->getDocumentation(); auto strPtr = it.second->getDocumentation();
if (strPtr) if (strPtr)
{ {
resetDev(); resetDev();
@ -161,7 +162,7 @@ std::unique_ptr<std::string> InterfaceHandler::getDevDocumentation(ContractDefin
method["return"] = m_return; method["return"] = m_return;
if (!method.empty()) // add the function, only if we have any documentation to add if (!method.empty()) // add the function, only if we have any documentation to add
methods[f->getName()] = method; methods[it.second->getName()] = method;
} }
} }
doc["methods"] = methods; doc["methods"] = methods;

18
libsolidity/Types.cpp

@ -460,8 +460,8 @@ MemberList const& ContractType::getMembers() const
if (!m_members) if (!m_members)
{ {
map<string, shared_ptr<Type const>> members; map<string, shared_ptr<Type const>> members;
for (FunctionDefinition const* function: m_contract.getInterfaceFunctions()) for (auto const& it: m_contract.getInterfaceFunctions())
members[function->getName()] = make_shared<FunctionType>(*function, false); members[it.second->getName()] = make_shared<FunctionType>(*it.second, false);
m_members.reset(new MemberList(members)); m_members.reset(new MemberList(members));
} }
return *m_members; return *m_members;
@ -480,15 +480,13 @@ shared_ptr<FunctionType const> const& ContractType::getConstructorType() const
return m_constructorType; return m_constructorType;
} }
unsigned ContractType::getFunctionIndex(string const& _functionName) const u256 ContractType::getFunctionIdentifier(string const& _functionName) const
{ {
unsigned index = 0; auto interfaceFunctions = m_contract.getInterfaceFunctions();
for (FunctionDefinition const* function: m_contract.getInterfaceFunctions()) for (auto it = interfaceFunctions.cbegin(); it != interfaceFunctions.cend(); ++it)
{ if (it->second->getName() == _functionName)
if (function->getName() == _functionName) return FixedHash<4>::Arith(it->first);
return index;
++index;
}
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Index of non-existing contract function requested.")); BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Index of non-existing contract function requested."));
} }

2
libsolidity/Types.h

@ -291,7 +291,7 @@ public:
/// is not used, as this type cannot be the type of a variable or expression. /// is not used, as this type cannot be the type of a variable or expression.
std::shared_ptr<FunctionType const> const& getConstructorType() const; std::shared_ptr<FunctionType const> const& getConstructorType() const;
unsigned getFunctionIndex(std::string const& _functionName) const; u256 getFunctionIdentifier(std::string const& _functionName) const;
private: private:
ContractDefinition const& m_contract; ContractDefinition const& m_contract;

4
mix/AssemblyDebuggerControl.cpp

@ -50,7 +50,7 @@ QString toQString(dev::u256 _value)
return QString::fromStdString(s.str()); return QString::fromStdString(s.str());
} }
AssemblyDebuggerControl::AssemblyDebuggerControl(AppContext* _context): AssemblyDebuggerControl::AssemblyDebuggerControl(dev::mix::AppContext* _context):
Extension(_context, ExtensionDisplayBehavior::ModalDialog), m_running(false) Extension(_context, ExtensionDisplayBehavior::ModalDialog), m_running(false)
{ {
qRegisterMetaType<QVariableDefinition*>("QVariableDefinition*"); qRegisterMetaType<QVariableDefinition*>("QVariableDefinition*");
@ -111,7 +111,7 @@ void AssemblyDebuggerControl::debugState(QVariantMap _state)
executeSequence(transactionSequence, balance); executeSequence(transactionSequence, balance);
} }
void AssemblyDebuggerControl::executeSequence(std::vector<TransactionSettings> const& _sequence, u256 _balance) void AssemblyDebuggerControl::executeSequence(std::vector<TransactionSettings> const& _sequence, dev::u256 _balance)
{ {
if (m_running) if (m_running)
throw (std::logic_error("debugging already running")); throw (std::logic_error("debugging already running"));

4
mix/CodeHighlighter.cpp

@ -64,7 +64,7 @@ namespace
}; };
} }
CodeHighlighter::FormatRange::FormatRange(CodeHighlighterSettings::Token _t, solidity::Location const& _location): CodeHighlighter::FormatRange::FormatRange(CodeHighlighterSettings::Token _t, dev::solidity::Location const& _location):
token(_t), start(_location.start), length(_location.end - _location.start) token(_t), start(_location.start), length(_location.end - _location.start)
{} {}
@ -91,7 +91,7 @@ void CodeHighlighter::processSource(std::string const& _source)
std::sort(m_formats.begin(), m_formats.end()); std::sort(m_formats.begin(), m_formats.end());
} }
void CodeHighlighter::processAST(solidity::ASTNode const& _ast) void CodeHighlighter::processAST(dev::solidity::ASTNode const& _ast)
{ {
HighlightVisitor visitor(&m_formats); HighlightVisitor visitor(&m_formats);
_ast.accept(visitor); _ast.accept(visitor);

2
mix/CodeModel.cpp

@ -48,7 +48,7 @@ CompilationResult::CompilationResult():
m_codeHighlighter(new CodeHighlighter()) m_codeHighlighter(new CodeHighlighter())
{} {}
CompilationResult::CompilationResult(const solidity::CompilerStack& _compiler): CompilationResult::CompilationResult(const dev::solidity::CompilerStack& _compiler):
QObject(nullptr), QObject(nullptr),
m_successful(true), m_successful(true),
m_codeHash(qHash(QString())) m_codeHash(qHash(QString()))

10
mix/QContractDefinition.cpp

@ -33,11 +33,9 @@ using namespace dev::mix;
QContractDefinition::QContractDefinition(dev::solidity::ContractDefinition const* _contract): QBasicNodeDefinition(_contract) QContractDefinition::QContractDefinition(dev::solidity::ContractDefinition const* _contract): QBasicNodeDefinition(_contract)
{ {
std::vector<FunctionDefinition const*> functions = _contract->getInterfaceFunctions(); auto interfaceFunctions = _contract->getInterfaceFunctions();
for (unsigned i = 0; i < functions.size(); i++) unsigned i = 0;
{ for (auto it = interfaceFunctions.cbegin(); it != interfaceFunctions.cend(); ++it, ++i)
FunctionDefinition const* func = functions.at(i); m_functions.append(new QFunctionDefinition(it->second, i));
m_functions.append(new QFunctionDefinition(func, i));
}
} }

272
neth/main.cpp

@ -24,6 +24,7 @@
#include <chrono> #include <chrono>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <signal.h>
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/trim_all.hpp> #include <boost/algorithm/string/trim_all.hpp>
#include <libdevcrypto/FileSystem.h> #include <libdevcrypto/FileSystem.h>
@ -63,54 +64,54 @@ void help()
{ {
cout cout
<< "Usage neth [OPTIONS] <remote-host>" << endl << "Usage neth [OPTIONS] <remote-host>" << endl
<< "Options:" << endl << "Options:" << endl
<< " -a,--address <addr> Set the coinbase (mining payout) address to addr (default: auto)." << endl << " -a,--address <addr> Set the coinbase (mining payout) address to addr (default: auto)." << endl
<< " -c,--client-name <name> Add a name to your client's version string (default: blank)." << endl << " -c,--client-name <name> Add a name to your client's version string (default: blank)." << endl
<< " -d,--db-path <path> Load database from path (default: ~/.ethereum " << endl << " -d,--db-path <path> Load database from path (default: ~/.ethereum " << endl
<< " <APPDATA>/Etherum or Library/Application Support/Ethereum)." << endl << " <APPDATA>/Etherum or Library/Application Support/Ethereum)." << endl
<< " -h,--help Show this help message and exit." << endl << " -h,--help Show this help message and exit." << endl
#if ETH_JSONRPC #if ETH_JSONRPC
<< " -j,--json-rpc Enable JSON-RPC server (default: off)." << endl << " -j,--json-rpc Enable JSON-RPC server (default: off)." << endl
<< " --json-rpc-port Specify JSON-RPC server port (implies '-j', default: 8080)." << endl << " --json-rpc-port Specify JSON-RPC server port (implies '-j', default: 8080)." << endl
#endif #endif
<< " -l,--listen <port> Listen on the given port for incoming connected (default: 30303)." << endl << " -l,--listen <port> Listen on the given port for incoming connected (default: 30303)." << endl
<< " -m,--mining <on/off> Enable mining (default: off)" << endl << " -m,--mining <on/off> Enable mining (default: off)" << endl
<< " -n,--upnp <on/off> Use upnp for NAT (default: on)." << endl << " -n,--upnp <on/off> Use upnp for NAT (default: on)." << endl
<< " -o,--mode <full/peer> Start a full node or a peer node (Default: full)." << endl << " -o,--mode <full/peer> Start a full node or a peer node (Default: full)." << endl
<< " -p,--port <port> Connect to remote port (default: 30303)." << endl << " -p,--port <port> Connect to remote port (default: 30303)." << endl
<< " -r,--remote <host> Connect to remote host (default: none)." << endl << " -r,--remote <host> Connect to remote host (default: none)." << endl
<< " -s,--secret <secretkeyhex> Set the secret key for use with send command (default: auto)." << endl << " -s,--secret <secretkeyhex> Set the secret key for use with send command (default: auto)." << endl
<< " -u,--public-ip <ip> Force public ip to given (default; auto)." << endl << " -u,--public-ip <ip> Force public ip to given (default; auto)." << endl
<< " -v,--verbosity <0..9> Set the log verbosity from 0 to 9 (tmp forced to 1)." << endl << " -v,--verbosity <0..9> Set the log verbosity from 0 to 9 (tmp forced to 1)." << endl
<< " -x,--peers <number> Attempt to connect to given number of peers (default: 5)." << endl << " -x,--peers <number> Attempt to connect to given number of peers (default: 5)." << endl
<< " -V,--version Show the version and exit." << endl; << " -V,--version Show the version and exit." << endl;
exit(0); exit(0);
} }
void interactiveHelp() void interactiveHelp()
{ {
cout cout
<< "Commands:" << endl << "Commands:" << endl
<< " netstart <port> Starts the network sybsystem on a specific port." << endl << " netstart <port> Starts the network sybsystem on a specific port." << endl
<< " netstop Stops the network subsystem." << endl << " netstop Stops the network subsystem." << endl
#if ETH_JSONRPC #if ETH_JSONRPC
<< " jsonstart <port> Starts the JSON-RPC server." << endl << " jsonstart <port> Starts the JSON-RPC server." << endl
<< " jsonstop Stops the JSON-RPC server." << endl << " jsonstop Stops the JSON-RPC server." << endl
#endif #endif
<< " connect <addr> <port> Connects to a specific peer." << endl << " connect <addr> <port> Connects to a specific peer." << endl
<< " minestart Starts mining." << endl << " minestart Starts mining." << endl
<< " minestop Stops mining." << endl << " minestop Stops mining." << endl
<< " address Gives the current address." << endl << " address Gives the current address." << endl
<< " secret Gives the current secret" << endl << " secret Gives the current secret" << endl
<< " block Gives the current block height." << endl << " block Gives the current block height." << endl
<< " balance Gives the current balance." << endl << " balance Gives the current balance." << endl
<< " peers List the peers that are connected" << endl << " peers List the peers that are connected" << endl
<< " transact Execute a given transaction." << endl << " transact Execute a given transaction." << endl
<< " send Execute a given transaction with current secret." << endl << " send Execute a given transaction with current secret." << endl
<< " contract Create a new contract with current secret." << endl << " contract Create a new contract with current secret." << endl
<< " inspect <contract> Dumps a contract to <APPDATA>/<contract>.evm." << endl << " inspect <contract> Dumps a contract to <APPDATA>/<contract>.evm." << endl
<< " reset Resets ncurses windows" << endl << " reset Resets ncurses windows" << endl
<< " exit Exits the application." << endl; << " exit Exits the application." << endl;
} }
string credits() string credits()
@ -121,17 +122,8 @@ string credits()
<< " Code by Gav Wood & , (c) 2013, 2014." << endl << " Code by Gav Wood & , (c) 2013, 2014." << endl
<< " Based on a design by Vitalik Buterin." << endl << endl; << " Based on a design by Vitalik Buterin." << endl << endl;
string vs = toString(dev::Version);
vs = vs.substr(vs.find_first_of('.') + 1)[0];
int pocnumber = stoi(vs);
string m_servers;
if (pocnumber == 5)
m_servers = "54.72.69.180";
else
m_servers = "54.76.56.74";
ccout << "Type 'netstart 30303' to start networking" << endl; ccout << "Type 'netstart 30303' to start networking" << endl;
ccout << "Type 'connect " << m_servers << " 30303' to connect" << endl; ccout << "Type 'connect " << Host::pocHost() << " 30303' to connect" << endl;
ccout << "Type 'exit' to quit" << endl << endl; ccout << "Type 'exit' to quit" << endl << endl;
return ccout.str(); return ccout.str();
} }
@ -139,12 +131,13 @@ string credits()
void version() void version()
{ {
cout << "neth version " << dev::Version << endl; cout << "neth version " << dev::Version << endl;
cout << "Network protocol version: " << dev::eth::c_protocolVersion << endl;
cout << "Client database version: " << dev::eth::c_databaseVersion << endl;
cout << "Build: " << DEV_QUOTED(ETH_BUILD_PLATFORM) << "/" << DEV_QUOTED(ETH_BUILD_TYPE) << endl; cout << "Build: " << DEV_QUOTED(ETH_BUILD_PLATFORM) << "/" << DEV_QUOTED(ETH_BUILD_TYPE) << endl;
exit(0); exit(0);
} }
Address c_config = Address("661005d2720d855f1d9976f88bb10c1a3398c77f"); Address c_config = Address("661005d2720d855f1d9976f88bb10c1a3398c77f");
string pretty(h160 _a, dev::eth::State _st) string pretty(h160 _a, dev::eth::State _st)
{ {
string ns; string ns;
@ -161,6 +154,13 @@ string pretty(h160 _a, dev::eth::State _st)
return ns; return ns;
} }
bool g_exit = false;
void sighandler(int)
{
g_exit = true;
}
namespace nc namespace nc
{ {
@ -298,13 +298,17 @@ int main(int argc, char** argv)
string remoteHost; string remoteHost;
unsigned short remotePort = 30303; unsigned short remotePort = 30303;
string dbPath; string dbPath;
bool mining = false; unsigned mining = ~(unsigned)0;
NodeMode mode = NodeMode::Full;
unsigned peers = 5; unsigned peers = 5;
#if ETH_JSONRPC #if ETH_JSONRPC
int jsonrpc = 8080; int jsonrpc = 8080;
#endif #endif
string publicIP; string publicIP;
bool bootstrap = false;
bool upnp = true; bool upnp = true;
bool useLocal = false;
bool forceMining = false;
string clientName; string clientName;
// Init defaults // Init defaults
@ -365,14 +369,21 @@ int main(int argc, char** argv)
{ {
string m = argv[++i]; string m = argv[++i];
if (isTrue(m)) if (isTrue(m))
mining = true; mining = ~(unsigned)0;
else if (isFalse(m)) else if (isFalse(m))
mining = false; mining = 0;
else if (int i = stoi(m))
mining = i;
else else
{ {
cerr << "Unknown mining option: " << m << endl; cerr << "Unknown -m/--mining option: " << m << endl;
return -1;
} }
} }
else if (arg == "-b" || arg == "--bootstrap")
bootstrap = true;
else if (arg == "-f" || arg == "--force-mining")
forceMining = true;
#if ETH_JSONRPC #if ETH_JSONRPC
else if ((arg == "-j" || arg == "--json-rpc")) else if ((arg == "-j" || arg == "--json-rpc"))
jsonrpc = jsonrpc ? jsonrpc : 8080; jsonrpc = jsonrpc ? jsonrpc : 8080;
@ -394,12 +405,50 @@ int main(int argc, char** argv)
if (!clientName.empty()) if (!clientName.empty())
clientName += "/"; clientName += "/";
WebThreeDirect web3("NEthereum(++)/" + clientName + "v" + dev::Version + "/" DEV_QUOTED(ETH_BUILD_TYPE) "/" DEV_QUOTED(ETH_BUILD_PLATFORM), dbPath); cout << credits();
Client& c = *web3.ethereum();
NetworkPreferences netPrefs(listenPort, publicIP, upnp, useLocal);
dev::WebThreeDirect web3(
"NEthereum(++)/" + clientName + "v" + dev::Version + "/" DEV_QUOTED(ETH_BUILD_TYPE) "/" DEV_QUOTED(ETH_BUILD_PLATFORM),
dbPath,
false,
mode == NodeMode::Full ? set<string>{"eth", "shh"} : set<string>(),
netPrefs
);
web3.setIdealPeerCount(peers);
eth::Client* c = mode == NodeMode::Full ? web3.ethereum() : nullptr;
if (c)
{
c->setForceMining(forceMining);
c->setAddress(coinbase);
}
c.setForceMining(true); auto nodesState = contents((dbPath.size() ? dbPath : getDataDir()) + "/nodeState.rlp");
web3.restoreNodes(&nodesState);
cout << credits(); web3.startNetwork();
if (bootstrap)
web3.connect(Host::pocHost());
if (remoteHost.size())
web3.connect(remoteHost, remotePort);
#if ETH_JSONRPC
shared_ptr<WebThreeStubServer> jsonrpcServer;
unique_ptr<jsonrpc::AbstractServerConnector> jsonrpcConnector;
if (jsonrpc > -1)
{
jsonrpcConnector = unique_ptr<jsonrpc::AbstractServerConnector>(new jsonrpc::HttpServer(jsonrpc));
jsonrpcServer = shared_ptr<WebThreeStubServer>(new WebThreeStubServer(*jsonrpcConnector.get(), web3, vector<KeyPair>({us})));
jsonrpcServer->setIdentities({us});
jsonrpcServer->StartListening();
}
#endif
signal(SIGABRT, &sighandler);
signal(SIGTERM, &sighandler);
signal(SIGINT, &sighandler);
std::ostringstream ccout; std::ostringstream ccout;
@ -461,28 +510,6 @@ int main(int argc, char** argv)
wmove(mainwin, 1, 4); wmove(mainwin, 1, 4);
if (!remoteHost.empty())
{
web3.setIdealPeerCount(peers);
web3.setNetworkPreferences(NetworkPreferences(listenPort, publicIP, upnp));
web3.startNetwork();
web3.connect(remoteHost, remotePort);
}
if (mining)
c.startMining();
#if ETH_JSONRPC
shared_ptr<WebThreeStubServer> jsonrpcServer;
unique_ptr<jsonrpc::AbstractServerConnector> jsonrpcConnector;
if (jsonrpc > -1)
{
jsonrpcConnector = unique_ptr<jsonrpc::AbstractServerConnector>(new jsonrpc::HttpServer(jsonrpc));
jsonrpcServer = shared_ptr<WebThreeStubServer>(new WebThreeStubServer(*jsonrpcConnector.get(), web3, vector<KeyPair>({us})));
jsonrpcServer->setIdentities({us});
jsonrpcServer->StartListening();
}
#endif
while (true) while (true)
{ {
wclrtobot(consolewin); wclrtobot(consolewin);
@ -532,13 +559,25 @@ int main(int argc, char** argv)
{ {
web3.stopNetwork(); web3.stopNetwork();
} }
else if (cmd == "minestart") else if (c && cmd == "minestart")
{
c->startMining();
}
else if (c && cmd == "minestop")
{ {
c.startMining(); c->stopMining();
} }
else if (cmd == "minestop") else if (c && cmd == "mineforce")
{ {
c.stopMining(); string enable;
iss >> enable;
c->setForceMining(isTrue(enable));
}
else if (cmd == "verbosity")
{
if (iss.peek() != -1)
iss >> g_logVerbosity;
cout << "Verbosity: " << g_logVerbosity << endl;
} }
#if ETH_JSONRPC #if ETH_JSONRPC
else if (cmd == "jsonport") else if (cmd == "jsonport")
@ -575,7 +614,7 @@ int main(int argc, char** argv)
} }
else if (cmd == "block") else if (cmd == "block")
{ {
unsigned n = c.blockChain().details().number; unsigned n = c->blockChain().details().number;
ccout << "Current block # "; ccout << "Current block # ";
ccout << toString(n) << endl; ccout << toString(n) << endl;
} }
@ -588,13 +627,13 @@ int main(int argc, char** argv)
} }
else if (cmd == "balance") else if (cmd == "balance")
{ {
u256 balance = c.balanceAt(us.address()); u256 balance = c->balanceAt(us.address());
ccout << "Current balance:" << endl; ccout << "Current balance:" << endl;
ccout << toString(balance) << endl; ccout << toString(balance) << endl;
} }
else if (cmd == "transact") else if (cmd == "transact")
{ {
auto const& bc = c.blockChain(); auto const& bc = c->blockChain();
auto h = bc.currentHash(); auto h = bc.currentHash();
auto blockData = bc.block(h); auto blockData = bc.block(h);
BlockInfo info(blockData); BlockInfo info(blockData);
@ -663,7 +702,7 @@ int main(int argc, char** argv)
{ {
Secret secret = h256(fromHex(sechex)); Secret secret = h256(fromHex(sechex));
Address dest = h160(fromHex(fields[0])); Address dest = h160(fromHex(fields[0]));
c.transact(secret, amount, dest, data, gas, gasPrice); c->transact(secret, amount, dest, data, gas, gasPrice);
} }
} }
} }
@ -696,19 +735,19 @@ int main(int argc, char** argv)
} }
else else
{ {
auto const& bc = c.blockChain(); auto const& bc = c->blockChain();
auto h = bc.currentHash(); auto h = bc.currentHash();
auto blockData = bc.block(h); auto blockData = bc.block(h);
BlockInfo info(blockData); BlockInfo info(blockData);
u256 minGas = (u256)Client::txGas(bytes(), 0); u256 minGas = (u256)Client::txGas(bytes(), 0);
Address dest = h160(fromHex(fields[0])); Address dest = h160(fromHex(fields[0]));
c.transact(us.secret(), amount, dest, bytes(), minGas); c->transact(us.secret(), amount, dest, bytes(), minGas);
} }
} }
} }
else if (cmd == "contract") else if (cmd == "contract")
{ {
auto const& bc = c.blockChain(); auto const& bc = c->blockChain();
auto h = bc.currentHash(); auto h = bc.currentHash();
auto blockData = bc.block(h); auto blockData = bc.block(h);
BlockInfo info(blockData); BlockInfo info(blockData);
@ -768,7 +807,7 @@ int main(int argc, char** argv)
cwarn << "Minimum gas amount is" << minGas; cwarn << "Minimum gas amount is" << minGas;
else else
{ {
c.transact(us.secret(), endowment, init, gas); c->transact(us.secret(), endowment, init, gas);
} }
} }
} }
@ -786,10 +825,10 @@ int main(int argc, char** argv)
try try
{ {
auto storage = c.storageAt(address); auto storage = c->storageAt(address);
for (auto const& i: storage) for (auto const& i: storage)
s << "@" << showbase << hex << i.first << " " << showbase << hex << i.second << endl; s << "@" << showbase << hex << i.first << " " << showbase << hex << i.second << endl;
s << endl << disassemble(c.codeAt(address)) << endl; s << endl << disassemble(c->codeAt(address)) << endl;
string outFile = getDataDir() + "/" + rechex + ".evm"; string outFile = getDataDir() + "/" + rechex + ".evm";
ofstream ofs; ofstream ofs;
@ -824,7 +863,7 @@ int main(int argc, char** argv)
// Lock to prevent corrupt block-chain errors // Lock to prevent corrupt block-chain errors
auto const& bc = c.blockChain(); auto const& bc = c->blockChain();
ccout << "Genesis hash: " << bc.genesisHash() << endl; ccout << "Genesis hash: " << bc.genesisHash() << endl;
// Blocks // Blocks
@ -838,11 +877,11 @@ int main(int argc, char** argv)
auto b = bc.block(h); auto b = bc.block(h);
for (auto const& i: RLP(b)[1]) for (auto const& i: RLP(b)[1])
{ {
Transaction t(i[0].data()); Transaction t(i.data());
auto s = t.receiveAddress() ? auto s = t.receiveAddress() ?
boost::format(" %1% %2%> %3%: %4% [%5%]") % boost::format(" %1% %2%> %3%: %4% [%5%]") %
toString(t.safeSender()) % toString(t.safeSender()) %
(c.codeAt(t.receiveAddress(), 0).size() ? '*' : '-') % (c->codeAt(t.receiveAddress(), 0).size() ? '*' : '-') %
toString(t.receiveAddress()) % toString(t.receiveAddress()) %
toString(formatBalance(t.value())) % toString(formatBalance(t.value())) %
toString((unsigned)t.nonce()) : toString((unsigned)t.nonce()) :
@ -862,12 +901,12 @@ int main(int argc, char** argv)
// Pending // Pending
y = 1; y = 1;
for (Transaction const& t: c.pending()) for (Transaction const& t: c->pending())
{ {
auto s = t.receiveAddress() ? auto s = t.receiveAddress() ?
boost::format("%1% %2%> %3%: %4% [%5%]") % boost::format("%1% %2%> %3%: %4% [%5%]") %
toString(t.safeSender()) % toString(t.safeSender()) %
(c.codeAt(t.receiveAddress(), 0).size() ? '*' : '-') % (c->codeAt(t.receiveAddress(), 0).size() ? '*' : '-') %
toString(t.receiveAddress()) % toString(t.receiveAddress()) %
toString(formatBalance(t.value())) % toString(formatBalance(t.value())) %
toString((unsigned)t.nonce()) : toString((unsigned)t.nonce()) :
@ -877,7 +916,7 @@ int main(int argc, char** argv)
toString(formatBalance(t.value())) % toString(formatBalance(t.value())) %
toString((unsigned)t.nonce()); toString((unsigned)t.nonce());
mvwaddnstr(pendingwin, y++, x, s.str().c_str(), qwidth); mvwaddnstr(pendingwin, y++, x, s.str().c_str(), qwidth);
if (y > height * 1 / 5 - 4) if (y > height * 1 / 5 - 2)
break; break;
} }
@ -885,27 +924,27 @@ int main(int argc, char** argv)
// Contracts and addresses // Contracts and addresses
y = 1; y = 1;
int cc = 1; int cc = 1;
auto acs = c.addresses(); auto acs = c->addresses();
for (auto const& i: acs) for (auto const& i: acs)
if (c.codeAt(i, 0).size()) if (c->codeAt(i, 0).size())
{ {
auto s = boost::format("%1%%2% : %3% [%4%]") % auto s = boost::format("%1%%2% : %3% [%4%]") %
toString(i) % toString(i) %
pretty(i, c.postState()) % pretty(i, c->postState()) %
toString(formatBalance(c.balanceAt(i))) % toString(formatBalance(c->balanceAt(i))) %
toString((unsigned)c.countAt(i, 0)); toString((unsigned)c->countAt(i, 0));
mvwaddnstr(contractswin, cc++, x, s.str().c_str(), qwidth); mvwaddnstr(contractswin, cc++, x, s.str().c_str(), qwidth);
if (cc > qheight - 2) if (cc > qheight - 2)
break; break;
} }
for (auto const& i: acs) for (auto const& i: acs)
if (c.codeAt(i, 0).empty()) if (c->codeAt(i, 0).empty())
{ {
auto s = boost::format("%1%%2% : %3% [%4%]") % auto s = boost::format("%1%%2% : %3% [%4%]") %
toString(i) % toString(i) %
pretty(i, c.postState()) % pretty(i, c->postState()) %
toString(formatBalance(c.balanceAt(i))) % toString(formatBalance(c->balanceAt(i))) %
toString((unsigned)c.countAt(i, 0)); toString((unsigned)c->countAt(i, 0));
mvwaddnstr(addswin, y++, x, s.str().c_str(), width / 2 - 4); mvwaddnstr(addswin, y++, x, s.str().c_str(), width / 2 - 4);
if (y > height * 3 / 5 - 4) if (y > height * 3 / 5 - 4)
break; break;
@ -935,21 +974,18 @@ int main(int argc, char** argv)
// Balance // Balance
stringstream ssb; stringstream ssb;
u256 balance = c.balanceAt(us.address()); u256 balance = c->balanceAt(us.address());
Address coinsAddr = right160(c.stateAt(c_config, 1)); ssb << "Balance: " << formatBalance(balance);
Address gavCoin = right160(c.stateAt(coinsAddr, c.stateAt(coinsAddr, 1)));
u256 totalGavCoinBalance = c.stateAt(gavCoin, (u160)us.address());
ssb << "Balance: " << formatBalance(balance) << " | " << totalGavCoinBalance << " GAV";
mvwprintw(consolewin, 0, x, ssb.str().c_str()); mvwprintw(consolewin, 0, x, ssb.str().c_str());
// Block // Block
mvwprintw(blockswin, 0, x, "Block # "); mvwprintw(blockswin, 0, x, "Block # ");
unsigned n = c.blockChain().details().number; unsigned n = c->blockChain().details().number;
mvwprintw(blockswin, 0, 10, toString(n).c_str()); mvwprintw(blockswin, 0, 10, toString(n).c_str());
// Pending // Pending
string pc; string pc;
pc = "Pending: " + toString(c.pending().size()); pc = "Pending: " + toString(c->pending().size());
mvwprintw(pendingwin, 0, x, pc.c_str()); mvwprintw(pendingwin, 0, x, pc.c_str());
// Contracts // Contracts
@ -962,10 +998,10 @@ int main(int argc, char** argv)
mvwprintw(peerswin, 0, 9, toString(web3.peers().size()).c_str()); mvwprintw(peerswin, 0, 9, toString(web3.peers().size()).c_str());
// Mining flag // Mining flag
if (c.isMining()) if (c->isMining())
{ {
mvwprintw(consolewin, qheight - 1, width / 4 - 11, "Mining ON"); mvwprintw(consolewin, qheight - 1, width / 4 - 11, "Mining ON");
dev::eth::MineProgress p = c.miningProgress(); dev::eth::MineProgress p = c->miningProgress();
auto speed = boost::format("%2% kH/s @ %1%s") % (p.ms / 1000) % (p.ms ? p.hashes / p.ms : 0); auto speed = boost::format("%2% kH/s @ %1%s") % (p.ms / 1000) % (p.ms ? p.hashes / p.ms : 0);
mvwprintw(consolewin, qheight - 2, width / 4 - speed.str().length() - 2, speed.str().c_str()); mvwprintw(consolewin, qheight - 2, width / 4 - speed.str().length() - 2, speed.str().c_str());
} }

28
test/SolidityABIJSON.cpp

@ -236,20 +236,6 @@ BOOST_AUTO_TEST_CASE(const_function)
"}\n"; "}\n";
char const* interface = R"([ char const* interface = R"([
{
"name": "boo",
"constant": true,
"inputs": [{
"name": "a",
"type": "uint32"
}],
"outputs": [
{
"name": "b",
"type": "uint256"
}
]
},
{ {
"name": "foo", "name": "foo",
"constant": false, "constant": false,
@ -269,6 +255,20 @@ BOOST_AUTO_TEST_CASE(const_function)
"type": "uint256" "type": "uint256"
} }
] ]
},
{
"name": "boo",
"constant": true,
"inputs": [{
"name": "a",
"type": "uint32"
}],
"outputs": [
{
"name": "b",
"type": "uint256"
}
]
} }
])"; ])";

17
test/SolidityCompiler.cpp

@ -96,7 +96,7 @@ BOOST_AUTO_TEST_CASE(smoke_test)
"}\n"; "}\n";
bytes code = compileContract(sourceCode); bytes code = compileContract(sourceCode);
unsigned boilerplateSize = 40; unsigned boilerplateSize = 73;
bytes expectation({byte(Instruction::JUMPDEST), bytes expectation({byte(Instruction::JUMPDEST),
byte(Instruction::PUSH1), 0x0, // initialize local variable x byte(Instruction::PUSH1), 0x0, // initialize local variable x
byte(Instruction::PUSH1), 0x2, byte(Instruction::PUSH1), 0x2,
@ -115,9 +115,8 @@ BOOST_AUTO_TEST_CASE(different_argument_numbers)
" function g() returns (uint e, uint h) { h = f(1, 2, 3); }\n" " function g() returns (uint e, uint h) { h = f(1, 2, 3); }\n"
"}\n"; "}\n";
bytes code = compileContract(sourceCode); bytes code = compileContract(sourceCode);
unsigned shift = 103;
unsigned shift = 68; unsigned boilerplateSize = 116;
unsigned boilerplateSize = 81;
bytes expectation({byte(Instruction::JUMPDEST), bytes expectation({byte(Instruction::JUMPDEST),
byte(Instruction::PUSH1), 0x0, // initialize return variable d byte(Instruction::PUSH1), 0x0, // initialize return variable d
byte(Instruction::DUP3), byte(Instruction::DUP3),
@ -166,9 +165,8 @@ BOOST_AUTO_TEST_CASE(ifStatement)
" function f() { bool x; if (x) 77; else if (!x) 78; else 79; }" " function f() { bool x; if (x) 77; else if (!x) 78; else 79; }"
"}\n"; "}\n";
bytes code = compileContract(sourceCode); bytes code = compileContract(sourceCode);
unsigned shift = 60;
unsigned shift = 27; unsigned boilerplateSize = 73;
unsigned boilerplateSize = 40;
bytes expectation({byte(Instruction::JUMPDEST), bytes expectation({byte(Instruction::JUMPDEST),
byte(Instruction::PUSH1), 0x0, byte(Instruction::PUSH1), 0x0,
byte(Instruction::DUP1), byte(Instruction::DUP1),
@ -208,9 +206,8 @@ BOOST_AUTO_TEST_CASE(loops)
" function f() { while(true){1;break;2;continue;3;return;4;} }" " function f() { while(true){1;break;2;continue;3;return;4;} }"
"}\n"; "}\n";
bytes code = compileContract(sourceCode); bytes code = compileContract(sourceCode);
unsigned shift = 60;
unsigned shift = 27; unsigned boilerplateSize = 73;
unsigned boilerplateSize = 40;
bytes expectation({byte(Instruction::JUMPDEST), bytes expectation({byte(Instruction::JUMPDEST),
byte(Instruction::JUMPDEST), byte(Instruction::JUMPDEST),
byte(Instruction::PUSH1), 0x1, byte(Instruction::PUSH1), 0x1,

294
test/SolidityEndToEndTest.cpp

@ -45,7 +45,7 @@ BOOST_AUTO_TEST_CASE(smoke_test)
" function f(uint a) returns(uint d) { return a * 7; }\n" " function f(uint a) returns(uint d) { return a * 7; }\n"
"}\n"; "}\n";
compileAndRun(sourceCode); compileAndRun(sourceCode);
testSolidityAgainstCppOnRange(0, [](u256 const& a) -> u256 { return a * 7; }, 0, 100); testSolidityAgainstCppOnRange("f(uint256)", [](u256 const& a) -> u256 { return a * 7; }, 0, 100);
} }
BOOST_AUTO_TEST_CASE(empty_contract) BOOST_AUTO_TEST_CASE(empty_contract)
@ -53,7 +53,7 @@ BOOST_AUTO_TEST_CASE(empty_contract)
char const* sourceCode = "contract test {\n" char const* sourceCode = "contract test {\n"
"}\n"; "}\n";
compileAndRun(sourceCode); compileAndRun(sourceCode);
BOOST_CHECK(callContractFunction(0, bytes()).empty()); BOOST_CHECK(callContractFunction("i_am_not_there()", bytes()).empty());
} }
BOOST_AUTO_TEST_CASE(recursive_calls) BOOST_AUTO_TEST_CASE(recursive_calls)
@ -73,7 +73,7 @@ BOOST_AUTO_TEST_CASE(recursive_calls)
return n * recursive_calls_cpp(n - 1); return n * recursive_calls_cpp(n - 1);
}; };
testSolidityAgainstCppOnRange(0, recursive_calls_cpp, 0, 5); testSolidityAgainstCppOnRange("f(uint256)", recursive_calls_cpp, 0, 5);
} }
BOOST_AUTO_TEST_CASE(multiple_functions) BOOST_AUTO_TEST_CASE(multiple_functions)
@ -85,11 +85,11 @@ BOOST_AUTO_TEST_CASE(multiple_functions)
" function f() returns(uint n) { return 3; }\n" " function f() returns(uint n) { return 3; }\n"
"}\n"; "}\n";
compileAndRun(sourceCode); compileAndRun(sourceCode);
BOOST_CHECK(callContractFunction(0, bytes()) == toBigEndian(u256(0))); BOOST_CHECK(callContractFunction("a()", bytes()) == toBigEndian(u256(0)));
BOOST_CHECK(callContractFunction(1, bytes()) == toBigEndian(u256(1))); BOOST_CHECK(callContractFunction("b()", bytes()) == toBigEndian(u256(1)));
BOOST_CHECK(callContractFunction(2, bytes()) == toBigEndian(u256(2))); BOOST_CHECK(callContractFunction("c()", bytes()) == toBigEndian(u256(2)));
BOOST_CHECK(callContractFunction(3, bytes()) == toBigEndian(u256(3))); BOOST_CHECK(callContractFunction("f()", bytes()) == toBigEndian(u256(3)));
BOOST_CHECK(callContractFunction(4, bytes()) == bytes()); BOOST_CHECK(callContractFunction("i_am_not_there()", bytes()) == bytes());
} }
BOOST_AUTO_TEST_CASE(while_loop) BOOST_AUTO_TEST_CASE(while_loop)
@ -113,7 +113,7 @@ BOOST_AUTO_TEST_CASE(while_loop)
return nfac; return nfac;
}; };
testSolidityAgainstCppOnRange(0, while_loop_cpp, 0, 5); testSolidityAgainstCppOnRange("f(uint256)", while_loop_cpp, 0, 5);
} }
BOOST_AUTO_TEST_CASE(break_outside_loop) BOOST_AUTO_TEST_CASE(break_outside_loop)
@ -125,7 +125,7 @@ BOOST_AUTO_TEST_CASE(break_outside_loop)
" }\n" " }\n"
"}\n"; "}\n";
compileAndRun(sourceCode); compileAndRun(sourceCode);
testSolidityAgainstCpp(0, [](u256 const&) -> u256 { return 2; }, u256(0)); testSolidityAgainstCpp("f(uint256)", [](u256 const&) -> u256 { return 2; }, u256(0));
} }
BOOST_AUTO_TEST_CASE(nested_loops) BOOST_AUTO_TEST_CASE(nested_loops)
@ -174,7 +174,7 @@ BOOST_AUTO_TEST_CASE(nested_loops)
return n; return n;
}; };
testSolidityAgainstCppOnRange(0, nested_loops_cpp, 0, 12); testSolidityAgainstCppOnRange("f(uint256)", nested_loops_cpp, 0, 12);
} }
BOOST_AUTO_TEST_CASE(for_loop) BOOST_AUTO_TEST_CASE(for_loop)
@ -196,7 +196,7 @@ BOOST_AUTO_TEST_CASE(for_loop)
return nfac; return nfac;
}; };
testSolidityAgainstCppOnRange(0, for_loop_cpp, 0, 5); testSolidityAgainstCppOnRange("f(uint256)", for_loop_cpp, 0, 5);
} }
BOOST_AUTO_TEST_CASE(for_loop_empty) BOOST_AUTO_TEST_CASE(for_loop_empty)
@ -224,7 +224,7 @@ BOOST_AUTO_TEST_CASE(for_loop_empty)
return ret; return ret;
}; };
testSolidityAgainstCpp(0, for_loop_empty_cpp); testSolidityAgainstCpp("f()", for_loop_empty_cpp);
} }
BOOST_AUTO_TEST_CASE(for_loop_simple_init_expr) BOOST_AUTO_TEST_CASE(for_loop_simple_init_expr)
@ -248,7 +248,7 @@ BOOST_AUTO_TEST_CASE(for_loop_simple_init_expr)
return nfac; return nfac;
}; };
testSolidityAgainstCppOnRange(0, for_loop_simple_init_expr_cpp, 0, 5); testSolidityAgainstCppOnRange("f(uint256)", for_loop_simple_init_expr_cpp, 0, 5);
} }
BOOST_AUTO_TEST_CASE(calling_other_functions) BOOST_AUTO_TEST_CASE(calling_other_functions)
@ -293,11 +293,11 @@ BOOST_AUTO_TEST_CASE(calling_other_functions)
return y; return y;
}; };
testSolidityAgainstCpp(2, collatz_cpp, u256(0)); testSolidityAgainstCpp("run(uint256)", collatz_cpp, u256(0));
testSolidityAgainstCpp(2, collatz_cpp, u256(1)); testSolidityAgainstCpp("run(uint256)", collatz_cpp, u256(1));
testSolidityAgainstCpp(2, collatz_cpp, u256(2)); testSolidityAgainstCpp("run(uint256)", collatz_cpp, u256(2));
testSolidityAgainstCpp(2, collatz_cpp, u256(8)); testSolidityAgainstCpp("run(uint256)", collatz_cpp, u256(8));
testSolidityAgainstCpp(2, collatz_cpp, u256(127)); testSolidityAgainstCpp("run(uint256)", collatz_cpp, u256(127));
} }
BOOST_AUTO_TEST_CASE(many_local_variables) BOOST_AUTO_TEST_CASE(many_local_variables)
@ -318,7 +318,7 @@ BOOST_AUTO_TEST_CASE(many_local_variables)
u256 y = a + b + c + x1 + x2 + x3; u256 y = a + b + c + x1 + x2 + x3;
return y + b + x2; return y + b + x2;
}; };
testSolidityAgainstCpp(0, f, u256(0x1000), u256(0x10000), u256(0x100000)); testSolidityAgainstCpp("run(uint256,uint256,uint256)", f, u256(0x1000), u256(0x10000), u256(0x100000));
} }
BOOST_AUTO_TEST_CASE(packing_unpacking_types) BOOST_AUTO_TEST_CASE(packing_unpacking_types)
@ -331,7 +331,7 @@ BOOST_AUTO_TEST_CASE(packing_unpacking_types)
" }\n" " }\n"
"}\n"; "}\n";
compileAndRun(sourceCode); compileAndRun(sourceCode);
BOOST_CHECK(callContractFunction(0, fromHex("01""0f0f0f0f""f0f0f0f0f0f0f0f0")) BOOST_CHECK(callContractFunction("run(bool,uint32,uint64)", fromHex("01""0f0f0f0f""f0f0f0f0f0f0f0f0"))
== fromHex("00000000000000000000000000000000000000""01""f0f0f0f0""0f0f0f0f0f0f0f0f")); == fromHex("00000000000000000000000000000000000000""01""f0f0f0f0""0f0f0f0f0f0f0f0f"));
} }
@ -343,7 +343,7 @@ BOOST_AUTO_TEST_CASE(multiple_return_values)
" }\n" " }\n"
"}\n"; "}\n";
compileAndRun(sourceCode); compileAndRun(sourceCode);
BOOST_CHECK(callContractFunction(0, bytes(1, 1) + toBigEndian(u256(0xcd))) BOOST_CHECK(callContractFunction("run(bool,uint256)", bytes(1, 1) + toBigEndian(u256(0xcd)))
== toBigEndian(u256(0xcd)) + bytes(1, 1) + toBigEndian(u256(0))); == toBigEndian(u256(0xcd)) + bytes(1, 1) + toBigEndian(u256(0)));
} }
@ -363,7 +363,7 @@ BOOST_AUTO_TEST_CASE(short_circuiting)
return n; return n;
}; };
testSolidityAgainstCppOnRange(0, short_circuiting_cpp, 0, 2); testSolidityAgainstCppOnRange("run(uint256)", short_circuiting_cpp, 0, 2);
} }
BOOST_AUTO_TEST_CASE(high_bits_cleaning) BOOST_AUTO_TEST_CASE(high_bits_cleaning)
@ -383,7 +383,7 @@ BOOST_AUTO_TEST_CASE(high_bits_cleaning)
return 0; return 0;
return x; return x;
}; };
testSolidityAgainstCpp(0, high_bits_cleaning_cpp); testSolidityAgainstCpp("run()", high_bits_cleaning_cpp);
} }
BOOST_AUTO_TEST_CASE(sign_extension) BOOST_AUTO_TEST_CASE(sign_extension)
@ -403,7 +403,7 @@ BOOST_AUTO_TEST_CASE(sign_extension)
return 0; return 0;
return u256(x) * -1; return u256(x) * -1;
}; };
testSolidityAgainstCpp(0, sign_extension_cpp); testSolidityAgainstCpp("run()", sign_extension_cpp);
} }
BOOST_AUTO_TEST_CASE(small_unsigned_types) BOOST_AUTO_TEST_CASE(small_unsigned_types)
@ -420,7 +420,7 @@ BOOST_AUTO_TEST_CASE(small_unsigned_types)
uint32_t x = uint32_t(0xffffff) * 0xffffff; uint32_t x = uint32_t(0xffffff) * 0xffffff;
return x / 0x100; return x / 0x100;
}; };
testSolidityAgainstCpp(0, small_unsigned_types_cpp); testSolidityAgainstCpp("run()", small_unsigned_types_cpp);
} }
BOOST_AUTO_TEST_CASE(small_signed_types) BOOST_AUTO_TEST_CASE(small_signed_types)
@ -435,7 +435,7 @@ BOOST_AUTO_TEST_CASE(small_signed_types)
{ {
return -int32_t(10) * -int64_t(20); return -int32_t(10) * -int64_t(20);
}; };
testSolidityAgainstCpp(0, small_signed_types_cpp); testSolidityAgainstCpp("run()", small_signed_types_cpp);
} }
BOOST_AUTO_TEST_CASE(strings) BOOST_AUTO_TEST_CASE(strings)
@ -458,12 +458,12 @@ BOOST_AUTO_TEST_CASE(strings)
expectation[4] = byte(0xff); expectation[4] = byte(0xff);
expectation[5] = byte('_'); expectation[5] = byte('_');
expectation[6] = byte('_'); expectation[6] = byte('_');
BOOST_CHECK(callContractFunction(0, bytes()) == expectation); BOOST_CHECK(callContractFunction("fixed()", bytes()) == expectation);
expectation = bytes(17, 0); expectation = bytes(17, 0);
expectation[0] = 0; expectation[0] = 0;
expectation[1] = 2; expectation[1] = 2;
expectation[16] = 1; expectation[16] = 1;
BOOST_CHECK(callContractFunction(1, bytes({0x00, 0x02, 0x01})) == expectation); BOOST_CHECK(callContractFunction("pipeThrough(string2,bool)", bytes({0x00, 0x02, 0x01})) == expectation);
} }
BOOST_AUTO_TEST_CASE(empty_string_on_stack) BOOST_AUTO_TEST_CASE(empty_string_on_stack)
@ -477,7 +477,7 @@ BOOST_AUTO_TEST_CASE(empty_string_on_stack)
" }\n" " }\n"
"}\n"; "}\n";
compileAndRun(sourceCode); compileAndRun(sourceCode);
BOOST_CHECK(callContractFunction(0, bytes(1, 0x02)) == bytes({0x00, 0x02, 0x61/*'a'*/, 0x62/*'b'*/, 0x63/*'c'*/, 0x00})); BOOST_CHECK(callContractFunction("run(string0,uint8)", bytes(1, 0x02)) == bytes({0x00, 0x02, 0x61/*'a'*/, 0x62/*'b'*/, 0x63/*'c'*/, 0x00}));
} }
BOOST_AUTO_TEST_CASE(state_smoke_test) BOOST_AUTO_TEST_CASE(state_smoke_test)
@ -495,14 +495,14 @@ BOOST_AUTO_TEST_CASE(state_smoke_test)
" }\n" " }\n"
"}\n"; "}\n";
compileAndRun(sourceCode); compileAndRun(sourceCode);
BOOST_CHECK(callContractFunction(0, bytes(1, 0x00)) == toBigEndian(u256(0))); BOOST_CHECK(callContractFunction("get(uint8)", bytes(1, 0x00)) == toBigEndian(u256(0)));
BOOST_CHECK(callContractFunction(0, bytes(1, 0x01)) == toBigEndian(u256(0))); BOOST_CHECK(callContractFunction("get(uint8)", bytes(1, 0x01)) == toBigEndian(u256(0)));
BOOST_CHECK(callContractFunction(1, bytes(1, 0x00) + toBigEndian(u256(0x1234))) == bytes()); BOOST_CHECK(callContractFunction("set(uint8,uint256)", bytes(1, 0x00) + toBigEndian(u256(0x1234))) == bytes());
BOOST_CHECK(callContractFunction(1, bytes(1, 0x01) + toBigEndian(u256(0x8765))) == bytes()); BOOST_CHECK(callContractFunction("set(uint8,uint256)", bytes(1, 0x01) + toBigEndian(u256(0x8765))) == bytes());
BOOST_CHECK(callContractFunction(0, bytes(1, 0x00)) == toBigEndian(u256(0x1234))); BOOST_CHECK(callContractFunction("get(uint8)", bytes(1, 0x00)) == toBigEndian(u256(0x1234)));
BOOST_CHECK(callContractFunction(0, bytes(1, 0x01)) == toBigEndian(u256(0x8765))); BOOST_CHECK(callContractFunction("get(uint8)", bytes(1, 0x01)) == toBigEndian(u256(0x8765)));
BOOST_CHECK(callContractFunction(1, bytes(1, 0x00) + toBigEndian(u256(0x3))) == bytes()); BOOST_CHECK(callContractFunction("set(uint8,uint256)", bytes(1, 0x00) + toBigEndian(u256(0x3))) == bytes());
BOOST_CHECK(callContractFunction(0, bytes(1, 0x00)) == toBigEndian(u256(0x3))); BOOST_CHECK(callContractFunction("get(uint8)", bytes(1, 0x00)) == toBigEndian(u256(0x3)));
} }
BOOST_AUTO_TEST_CASE(compound_assign) BOOST_AUTO_TEST_CASE(compound_assign)
@ -530,14 +530,14 @@ BOOST_AUTO_TEST_CASE(compound_assign)
value2 *= value3 + value1; value2 *= value3 + value1;
return value2 += 7; return value2 += 7;
}; };
testSolidityAgainstCpp(0, f, u256(0), u256(6)); testSolidityAgainstCpp("f(uint256,uint256)", f, u256(0), u256(6));
testSolidityAgainstCpp(0, f, u256(1), u256(3)); testSolidityAgainstCpp("f(uint256,uint256)", f, u256(1), u256(3));
testSolidityAgainstCpp(0, f, u256(2), u256(25)); testSolidityAgainstCpp("f(uint256,uint256)", f, u256(2), u256(25));
testSolidityAgainstCpp(0, f, u256(3), u256(69)); testSolidityAgainstCpp("f(uint256,uint256)", f, u256(3), u256(69));
testSolidityAgainstCpp(0, f, u256(4), u256(84)); testSolidityAgainstCpp("f(uint256,uint256)", f, u256(4), u256(84));
testSolidityAgainstCpp(0, f, u256(5), u256(2)); testSolidityAgainstCpp("f(uint256,uint256)", f, u256(5), u256(2));
testSolidityAgainstCpp(0, f, u256(6), u256(51)); testSolidityAgainstCpp("f(uint256,uint256)", f, u256(6), u256(51));
testSolidityAgainstCpp(0, f, u256(7), u256(48)); testSolidityAgainstCpp("f(uint256,uint256)", f, u256(7), u256(48));
} }
BOOST_AUTO_TEST_CASE(simple_mapping) BOOST_AUTO_TEST_CASE(simple_mapping)
@ -554,21 +554,21 @@ BOOST_AUTO_TEST_CASE(simple_mapping)
compileAndRun(sourceCode); compileAndRun(sourceCode);
// msvc seems to have problems with initializer-list, when there is only 1 param in the list // msvc seems to have problems with initializer-list, when there is only 1 param in the list
BOOST_CHECK(callContractFunction(0, bytes(1, 0x00)) == bytes(1, 0x00)); BOOST_CHECK(callContractFunction("get(uint8)", bytes(1, 0x00)) == bytes(1, 0x00));
BOOST_CHECK(callContractFunction(0, bytes(1, 0x01)) == bytes(1, 0x00)); BOOST_CHECK(callContractFunction("get(uint8)", bytes(1, 0x01)) == bytes(1, 0x00));
BOOST_CHECK(callContractFunction(0, bytes(1, 0xa7)) == bytes(1, 0x00)); BOOST_CHECK(callContractFunction("get(uint8)", bytes(1, 0xa7)) == bytes(1, 0x00));
callContractFunction(1, bytes({0x01, 0xa1})); callContractFunction("set(uint8,uint8)", bytes({0x01, 0xa1}));
BOOST_CHECK(callContractFunction(0, bytes(1, 0x00)) == bytes(1, 0x00)); BOOST_CHECK(callContractFunction("get(uint8)", bytes(1, 0x00)) == bytes(1, 0x00));
BOOST_CHECK(callContractFunction(0, bytes(1, 0x01)) == bytes(1, 0xa1)); BOOST_CHECK(callContractFunction("get(uint8)", bytes(1, 0x01)) == bytes(1, 0xa1));
BOOST_CHECK(callContractFunction(0, bytes(1, 0xa7)) == bytes(1, 0x00)); BOOST_CHECK(callContractFunction("get(uint8)", bytes(1, 0xa7)) == bytes(1, 0x00));
callContractFunction(1, bytes({0x00, 0xef})); callContractFunction("set(uint8,uint8)", bytes({0x00, 0xef}));
BOOST_CHECK(callContractFunction(0, bytes(1, 0x00)) == bytes(1, 0xef)); BOOST_CHECK(callContractFunction("get(uint8)", bytes(1, 0x00)) == bytes(1, 0xef));
BOOST_CHECK(callContractFunction(0, bytes(1, 0x01)) == bytes(1, 0xa1)); BOOST_CHECK(callContractFunction("get(uint8)", bytes(1, 0x01)) == bytes(1, 0xa1));
BOOST_CHECK(callContractFunction(0, bytes(1, 0xa7)) == bytes(1, 0x00)); BOOST_CHECK(callContractFunction("get(uint8)", bytes(1, 0xa7)) == bytes(1, 0x00));
callContractFunction(1, bytes({0x01, 0x05})); callContractFunction("set(uint8,uint8)", bytes({0x01, 0x05}));
BOOST_CHECK(callContractFunction(0, bytes(1, 0x00)) == bytes(1, 0xef)); BOOST_CHECK(callContractFunction("get(uint8)", bytes(1, 0x00)) == bytes(1, 0xef));
BOOST_CHECK(callContractFunction(0, bytes(1, 0x01)) == bytes(1, 0x05)); BOOST_CHECK(callContractFunction("get(uint8)", bytes(1, 0x01)) == bytes(1, 0x05));
BOOST_CHECK(callContractFunction(0, bytes(1, 0xa7)) == bytes(1, 0x00)); BOOST_CHECK(callContractFunction("get(uint8)", bytes(1, 0xa7)) == bytes(1, 0x00));
} }
BOOST_AUTO_TEST_CASE(mapping_state) BOOST_AUTO_TEST_CASE(mapping_state)
@ -612,38 +612,38 @@ BOOST_AUTO_TEST_CASE(mapping_state)
auto getVoteCount = bind(&Ballot::getVoteCount, &ballot, _1); auto getVoteCount = bind(&Ballot::getVoteCount, &ballot, _1);
auto grantVoteRight = bind(&Ballot::grantVoteRight, &ballot, _1); auto grantVoteRight = bind(&Ballot::grantVoteRight, &ballot, _1);
auto vote = bind(&Ballot::vote, &ballot, _1, _2); auto vote = bind(&Ballot::vote, &ballot, _1, _2);
testSolidityAgainstCpp(0, getVoteCount, u160(0)); testSolidityAgainstCpp("getVoteCount(address)", getVoteCount, u160(0));
testSolidityAgainstCpp(0, getVoteCount, u160(1)); testSolidityAgainstCpp("getVoteCount(address)", getVoteCount, u160(1));
testSolidityAgainstCpp(0, getVoteCount, u160(2)); testSolidityAgainstCpp("getVoteCount(address)", getVoteCount, u160(2));
// voting without vote right shourd be rejected // voting without vote right shourd be rejected
testSolidityAgainstCpp(2, vote, u160(0), u160(2)); testSolidityAgainstCpp("vote(address,address)", vote, u160(0), u160(2));
testSolidityAgainstCpp(0, getVoteCount, u160(0)); testSolidityAgainstCpp("getVoteCount(address)", getVoteCount, u160(0));
testSolidityAgainstCpp(0, getVoteCount, u160(1)); testSolidityAgainstCpp("getVoteCount(address)", getVoteCount, u160(1));
testSolidityAgainstCpp(0, getVoteCount, u160(2)); testSolidityAgainstCpp("getVoteCount(address)", getVoteCount, u160(2));
// grant vote rights // grant vote rights
testSolidityAgainstCpp(1, grantVoteRight, u160(0)); testSolidityAgainstCpp("grantVoteRight(address)", grantVoteRight, u160(0));
testSolidityAgainstCpp(1, grantVoteRight, u160(1)); testSolidityAgainstCpp("grantVoteRight(address)", grantVoteRight, u160(1));
// vote, should increase 2's vote count // vote, should increase 2's vote count
testSolidityAgainstCpp(2, vote, u160(0), u160(2)); testSolidityAgainstCpp("vote(address,address)", vote, u160(0), u160(2));
testSolidityAgainstCpp(0, getVoteCount, u160(0)); testSolidityAgainstCpp("getVoteCount(address)", getVoteCount, u160(0));
testSolidityAgainstCpp(0, getVoteCount, u160(1)); testSolidityAgainstCpp("getVoteCount(address)", getVoteCount, u160(1));
testSolidityAgainstCpp(0, getVoteCount, u160(2)); testSolidityAgainstCpp("getVoteCount(address)", getVoteCount, u160(2));
// vote again, should be rejected // vote again, should be rejected
testSolidityAgainstCpp(2, vote, u160(0), u160(1)); testSolidityAgainstCpp("vote(address,address)", vote, u160(0), u160(1));
testSolidityAgainstCpp(0, getVoteCount, u160(0)); testSolidityAgainstCpp("getVoteCount(address)", getVoteCount, u160(0));
testSolidityAgainstCpp(0, getVoteCount, u160(1)); testSolidityAgainstCpp("getVoteCount(address)", getVoteCount, u160(1));
testSolidityAgainstCpp(0, getVoteCount, u160(2)); testSolidityAgainstCpp("getVoteCount(address)", getVoteCount, u160(2));
// vote without right to vote // vote without right to vote
testSolidityAgainstCpp(2, vote, u160(2), u160(1)); testSolidityAgainstCpp("vote(address,address)", vote, u160(2), u160(1));
testSolidityAgainstCpp(0, getVoteCount, u160(0)); testSolidityAgainstCpp("getVoteCount(address)", getVoteCount, u160(0));
testSolidityAgainstCpp(0, getVoteCount, u160(1)); testSolidityAgainstCpp("getVoteCount(address)", getVoteCount, u160(1));
testSolidityAgainstCpp(0, getVoteCount, u160(2)); testSolidityAgainstCpp("getVoteCount(address)", getVoteCount, u160(2));
// grant vote right and now vote again // grant vote right and now vote again
testSolidityAgainstCpp(1, grantVoteRight, u160(2)); testSolidityAgainstCpp("grantVoteRight(address)", grantVoteRight, u160(2));
testSolidityAgainstCpp(2, vote, u160(2), u160(1)); testSolidityAgainstCpp("vote(address,address)", vote, u160(2), u160(1));
testSolidityAgainstCpp(0, getVoteCount, u160(0)); testSolidityAgainstCpp("getVoteCount(address)", getVoteCount, u160(0));
testSolidityAgainstCpp(0, getVoteCount, u160(1)); testSolidityAgainstCpp("getVoteCount(address)", getVoteCount, u160(1));
testSolidityAgainstCpp(0, getVoteCount, u160(2)); testSolidityAgainstCpp("getVoteCount(address)", getVoteCount, u160(2));
} }
BOOST_AUTO_TEST_CASE(mapping_state_inc_dec) BOOST_AUTO_TEST_CASE(mapping_state_inc_dec)
@ -674,7 +674,7 @@ BOOST_AUTO_TEST_CASE(mapping_state_inc_dec)
table[value]++; table[value]++;
return --table[value++]; return --table[value++];
}; };
testSolidityAgainstCppOnRange(0, f, 0, 5); testSolidityAgainstCppOnRange("f(uint256)", f, 0, 5);
} }
BOOST_AUTO_TEST_CASE(multi_level_mapping) BOOST_AUTO_TEST_CASE(multi_level_mapping)
@ -694,14 +694,14 @@ BOOST_AUTO_TEST_CASE(multi_level_mapping)
if (_z == 0) return table[_x][_y]; if (_z == 0) return table[_x][_y];
else return table[_x][_y] = _z; else return table[_x][_y] = _z;
}; };
testSolidityAgainstCpp(0, f, u256(4), u256(5), u256(0)); testSolidityAgainstCpp("f(uint256,uint256,uint256)", f, u256(4), u256(5), u256(0));
testSolidityAgainstCpp(0, f, u256(5), u256(4), u256(0)); testSolidityAgainstCpp("f(uint256,uint256,uint256)", f, u256(5), u256(4), u256(0));
testSolidityAgainstCpp(0, f, u256(4), u256(5), u256(9)); testSolidityAgainstCpp("f(uint256,uint256,uint256)", f, u256(4), u256(5), u256(9));
testSolidityAgainstCpp(0, f, u256(4), u256(5), u256(0)); testSolidityAgainstCpp("f(uint256,uint256,uint256)", f, u256(4), u256(5), u256(0));
testSolidityAgainstCpp(0, f, u256(5), u256(4), u256(0)); testSolidityAgainstCpp("f(uint256,uint256,uint256)", f, u256(5), u256(4), u256(0));
testSolidityAgainstCpp(0, f, u256(5), u256(4), u256(7)); testSolidityAgainstCpp("f(uint256,uint256,uint256)", f, u256(5), u256(4), u256(7));
testSolidityAgainstCpp(0, f, u256(4), u256(5), u256(0)); testSolidityAgainstCpp("f(uint256,uint256,uint256)", f, u256(4), u256(5), u256(0));
testSolidityAgainstCpp(0, f, u256(5), u256(4), u256(0)); testSolidityAgainstCpp("f(uint256,uint256,uint256)", f, u256(5), u256(4), u256(0));
} }
BOOST_AUTO_TEST_CASE(structs) BOOST_AUTO_TEST_CASE(structs)
@ -736,9 +736,9 @@ BOOST_AUTO_TEST_CASE(structs)
" }\n" " }\n"
"}\n"; "}\n";
compileAndRun(sourceCode); compileAndRun(sourceCode);
BOOST_CHECK(callContractFunction(0) == bytes(1, 0x00)); BOOST_CHECK(callContractFunction("check()") == bytes(1, 0x00));
BOOST_CHECK(callContractFunction(1) == bytes()); BOOST_CHECK(callContractFunction("set()") == bytes());
BOOST_CHECK(callContractFunction(0) == bytes(1, 0x01)); BOOST_CHECK(callContractFunction("check()") == bytes(1, 0x01));
} }
BOOST_AUTO_TEST_CASE(struct_reference) BOOST_AUTO_TEST_CASE(struct_reference)
@ -764,9 +764,9 @@ BOOST_AUTO_TEST_CASE(struct_reference)
" }\n" " }\n"
"}\n"; "}\n";
compileAndRun(sourceCode); compileAndRun(sourceCode);
BOOST_CHECK(callContractFunction(0) == bytes(1, 0x00)); BOOST_CHECK(callContractFunction("check()") == bytes(1, 0x00));
BOOST_CHECK(callContractFunction(1) == bytes()); BOOST_CHECK(callContractFunction("set()") == bytes());
BOOST_CHECK(callContractFunction(0) == bytes(1, 0x01)); BOOST_CHECK(callContractFunction("check()") == bytes(1, 0x01));
} }
BOOST_AUTO_TEST_CASE(constructor) BOOST_AUTO_TEST_CASE(constructor)
@ -787,8 +787,8 @@ BOOST_AUTO_TEST_CASE(constructor)
{ {
return data[_x]; return data[_x];
}; };
testSolidityAgainstCpp(0, get, u256(6)); testSolidityAgainstCpp("get(uint256)", get, u256(6));
testSolidityAgainstCpp(0, get, u256(7)); testSolidityAgainstCpp("get(uint256)", get, u256(7));
} }
BOOST_AUTO_TEST_CASE(balance) BOOST_AUTO_TEST_CASE(balance)
@ -799,7 +799,7 @@ BOOST_AUTO_TEST_CASE(balance)
" }\n" " }\n"
"}\n"; "}\n";
compileAndRun(sourceCode, 23); compileAndRun(sourceCode, 23);
BOOST_CHECK(callContractFunction(0) == toBigEndian(u256(23))); BOOST_CHECK(callContractFunction("getBalance()") == toBigEndian(u256(23)));
} }
BOOST_AUTO_TEST_CASE(blockchain) BOOST_AUTO_TEST_CASE(blockchain)
@ -812,7 +812,7 @@ BOOST_AUTO_TEST_CASE(blockchain)
" }\n" " }\n"
"}\n"; "}\n";
compileAndRun(sourceCode, 27); compileAndRun(sourceCode, 27);
BOOST_CHECK(callContractFunction(0, bytes{0}, u256(28)) == toBigEndian(u256(28)) + bytes(20, 0) + toBigEndian(u256(1))); BOOST_CHECK(callContractFunction("someInfo()", bytes{0}, u256(28)) == toBigEndian(u256(28)) + bytes(20, 0) + toBigEndian(u256(1)));
} }
BOOST_AUTO_TEST_CASE(function_types) BOOST_AUTO_TEST_CASE(function_types)
@ -831,8 +831,8 @@ BOOST_AUTO_TEST_CASE(function_types)
" }\n" " }\n"
"}\n"; "}\n";
compileAndRun(sourceCode); compileAndRun(sourceCode);
BOOST_CHECK(callContractFunction(0, bytes{0}) == toBigEndian(u256(11))); BOOST_CHECK(callContractFunction("a(bool)", bytes{0}) == toBigEndian(u256(11)));
BOOST_CHECK(callContractFunction(0, bytes{1}) == toBigEndian(u256(12))); BOOST_CHECK(callContractFunction("a(bool)", bytes{1}) == toBigEndian(u256(12)));
} }
BOOST_AUTO_TEST_CASE(send_ether) BOOST_AUTO_TEST_CASE(send_ether)
@ -846,7 +846,7 @@ BOOST_AUTO_TEST_CASE(send_ether)
u256 amount(130); u256 amount(130);
compileAndRun(sourceCode, amount + 1); compileAndRun(sourceCode, amount + 1);
u160 address(23); u160 address(23);
BOOST_CHECK(callContractFunction(0, address, amount) == toBigEndian(u256(1))); BOOST_CHECK(callContractFunction("a(address,uint256)", address, amount) == toBigEndian(u256(1)));
BOOST_CHECK_EQUAL(m_state.balance(address), amount); BOOST_CHECK_EQUAL(m_state.balance(address), amount);
} }
@ -860,7 +860,7 @@ BOOST_AUTO_TEST_CASE(log0)
u256 amount(130); u256 amount(130);
compileAndRun(sourceCode, amount + 1); compileAndRun(sourceCode, amount + 1);
u160 address(23); u160 address(23);
callContractFunction(0, address, amount); callContractFunction("a()", address, amount);
BOOST_CHECK_EQUAL(m_logs.size(), 1); BOOST_CHECK_EQUAL(m_logs.size(), 1);
BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress); BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress);
BOOST_CHECK_EQUAL(h256(m_logs[0].data), h256(u256(1))); BOOST_CHECK_EQUAL(h256(m_logs[0].data), h256(u256(1)));
@ -877,7 +877,7 @@ BOOST_AUTO_TEST_CASE(log1)
u256 amount(130); u256 amount(130);
compileAndRun(sourceCode, amount + 1); compileAndRun(sourceCode, amount + 1);
u160 address(23); u160 address(23);
callContractFunction(0, address, amount); callContractFunction("a()", address, amount);
BOOST_CHECK_EQUAL(m_logs.size(), 1); BOOST_CHECK_EQUAL(m_logs.size(), 1);
BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress); BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress);
BOOST_CHECK_EQUAL(h256(m_logs[0].data), h256(u256(1))); BOOST_CHECK_EQUAL(h256(m_logs[0].data), h256(u256(1)));
@ -895,7 +895,7 @@ BOOST_AUTO_TEST_CASE(log2)
u256 amount(130); u256 amount(130);
compileAndRun(sourceCode, amount + 1); compileAndRun(sourceCode, amount + 1);
u160 address(23); u160 address(23);
callContractFunction(0, address, amount); callContractFunction("a()", address, amount);
BOOST_CHECK_EQUAL(m_logs.size(), 1); BOOST_CHECK_EQUAL(m_logs.size(), 1);
BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress); BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress);
BOOST_CHECK_EQUAL(h256(m_logs[0].data), h256(u256(1))); BOOST_CHECK_EQUAL(h256(m_logs[0].data), h256(u256(1)));
@ -914,7 +914,7 @@ BOOST_AUTO_TEST_CASE(log3)
u256 amount(130); u256 amount(130);
compileAndRun(sourceCode, amount + 1); compileAndRun(sourceCode, amount + 1);
u160 address(23); u160 address(23);
callContractFunction(0, address, amount); callContractFunction("a()", address, amount);
BOOST_CHECK_EQUAL(m_logs.size(), 1); BOOST_CHECK_EQUAL(m_logs.size(), 1);
BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress); BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress);
BOOST_CHECK_EQUAL(h256(m_logs[0].data), h256(u256(1))); BOOST_CHECK_EQUAL(h256(m_logs[0].data), h256(u256(1)));
@ -933,7 +933,7 @@ BOOST_AUTO_TEST_CASE(log4)
u256 amount(130); u256 amount(130);
compileAndRun(sourceCode, amount + 1); compileAndRun(sourceCode, amount + 1);
u160 address(23); u160 address(23);
callContractFunction(0, address, amount); callContractFunction("a()", address, amount);
BOOST_CHECK_EQUAL(m_logs.size(), 1); BOOST_CHECK_EQUAL(m_logs.size(), 1);
BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress); BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress);
BOOST_CHECK_EQUAL(h256(m_logs[0].data), h256(u256(1))); BOOST_CHECK_EQUAL(h256(m_logs[0].data), h256(u256(1)));
@ -953,7 +953,7 @@ BOOST_AUTO_TEST_CASE(suicide)
u256 amount(130); u256 amount(130);
compileAndRun(sourceCode, amount); compileAndRun(sourceCode, amount);
u160 address(23); u160 address(23);
BOOST_CHECK(callContractFunction(0, address) == bytes()); BOOST_CHECK(callContractFunction("a(address)", address) == bytes());
BOOST_CHECK(!m_state.addressHasCode(m_contractAddress)); BOOST_CHECK(!m_state.addressHasCode(m_contractAddress));
BOOST_CHECK_EQUAL(m_state.balance(address), amount); BOOST_CHECK_EQUAL(m_state.balance(address), amount);
} }
@ -970,9 +970,9 @@ BOOST_AUTO_TEST_CASE(sha3)
{ {
return dev::sha3(toBigEndian(_x)); return dev::sha3(toBigEndian(_x));
}; };
testSolidityAgainstCpp(0, f, u256(4)); testSolidityAgainstCpp("a(hash256)", f, u256(4));
testSolidityAgainstCpp(0, f, u256(5)); testSolidityAgainstCpp("a(hash256)", f, u256(5));
testSolidityAgainstCpp(0, f, u256(-1)); testSolidityAgainstCpp("a(hash256)", f, u256(-1));
} }
BOOST_AUTO_TEST_CASE(sha256) BOOST_AUTO_TEST_CASE(sha256)
@ -989,9 +989,9 @@ BOOST_AUTO_TEST_CASE(sha256)
dev::sha256(dev::ref(toBigEndian(_input)), bytesRef(&ret[0], 32)); dev::sha256(dev::ref(toBigEndian(_input)), bytesRef(&ret[0], 32));
return ret; return ret;
}; };
testSolidityAgainstCpp(0, f, u256(4)); testSolidityAgainstCpp("a(hash256)", f, u256(4));
testSolidityAgainstCpp(0, f, u256(5)); testSolidityAgainstCpp("a(hash256)", f, u256(5));
testSolidityAgainstCpp(0, f, u256(-1)); testSolidityAgainstCpp("a(hash256)", f, u256(-1));
} }
BOOST_AUTO_TEST_CASE(ripemd) BOOST_AUTO_TEST_CASE(ripemd)
@ -1008,9 +1008,9 @@ BOOST_AUTO_TEST_CASE(ripemd)
dev::ripemd160(dev::ref(toBigEndian(_input)), bytesRef(&ret[0], 32)); dev::ripemd160(dev::ref(toBigEndian(_input)), bytesRef(&ret[0], 32));
return u256(ret) >> (256 - 160); return u256(ret) >> (256 - 160);
}; };
testSolidityAgainstCpp(0, f, u256(4)); testSolidityAgainstCpp("a(hash256)", f, u256(4));
testSolidityAgainstCpp(0, f, u256(5)); testSolidityAgainstCpp("a(hash256)", f, u256(5));
testSolidityAgainstCpp(0, f, u256(-1)); testSolidityAgainstCpp("a(hash256)", f, u256(-1));
} }
BOOST_AUTO_TEST_CASE(ecrecover) BOOST_AUTO_TEST_CASE(ecrecover)
@ -1026,7 +1026,7 @@ BOOST_AUTO_TEST_CASE(ecrecover)
u256 r("0x73b1693892219d736caba55bdb67216e485557ea6b6af75f37096c9aa6a5a75f"); u256 r("0x73b1693892219d736caba55bdb67216e485557ea6b6af75f37096c9aa6a5a75f");
u256 s("0xeeb940b1d03b21e36b0e47e79769f095fe2ab855bd91e3a38756b7d75a9c4549"); u256 s("0xeeb940b1d03b21e36b0e47e79769f095fe2ab855bd91e3a38756b7d75a9c4549");
u160 addr("0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b"); u160 addr("0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b");
BOOST_CHECK(callContractFunction(0, h, v, r, s) == toBigEndian(addr)); BOOST_CHECK(callContractFunction("a(hash256,uint8,hash256,hash256)", h, v, r, s) == toBigEndian(addr));
} }
BOOST_AUTO_TEST_CASE(inter_contract_calls) BOOST_AUTO_TEST_CASE(inter_contract_calls)
@ -1052,11 +1052,11 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls)
compileAndRun(sourceCode, 0, "Helper"); compileAndRun(sourceCode, 0, "Helper");
u160 const helperAddress = m_contractAddress; u160 const helperAddress = m_contractAddress;
compileAndRun(sourceCode, 0, "Main"); compileAndRun(sourceCode, 0, "Main");
BOOST_REQUIRE(callContractFunction(2, helperAddress) == bytes()); BOOST_REQUIRE(callContractFunction("setHelper(address)", helperAddress) == bytes());
BOOST_REQUIRE(callContractFunction(1, helperAddress) == toBigEndian(helperAddress)); BOOST_REQUIRE(callContractFunction("getHelper()", helperAddress) == toBigEndian(helperAddress));
u256 a(3456789); u256 a(3456789);
u256 b("0x282837623374623234aa74"); u256 b("0x282837623374623234aa74");
BOOST_REQUIRE(callContractFunction(0, a, b) == toBigEndian(a * b)); BOOST_REQUIRE(callContractFunction("callHelper(uint256,uint256)", a, b) == toBigEndian(a * b));
} }
BOOST_AUTO_TEST_CASE(inter_contract_calls_with_complex_parameters) BOOST_AUTO_TEST_CASE(inter_contract_calls_with_complex_parameters)
@ -1082,12 +1082,12 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls_with_complex_parameters)
compileAndRun(sourceCode, 0, "Helper"); compileAndRun(sourceCode, 0, "Helper");
u160 const helperAddress = m_contractAddress; u160 const helperAddress = m_contractAddress;
compileAndRun(sourceCode, 0, "Main"); compileAndRun(sourceCode, 0, "Main");
BOOST_REQUIRE(callContractFunction(2, helperAddress) == bytes()); BOOST_REQUIRE(callContractFunction("setHelper(address)", helperAddress) == bytes());
BOOST_REQUIRE(callContractFunction(1, helperAddress) == toBigEndian(helperAddress)); BOOST_REQUIRE(callContractFunction("getHelper()", helperAddress) == toBigEndian(helperAddress));
u256 a(3456789); u256 a(3456789);
u256 b("0x282837623374623234aa74"); u256 b("0x282837623374623234aa74");
BOOST_REQUIRE(callContractFunction(0, a, true, b) == toBigEndian(a * 3)); BOOST_REQUIRE(callContractFunction("callHelper(uint256,bool,uint256)", a, true, b) == toBigEndian(a * 3));
BOOST_REQUIRE(callContractFunction(0, a, false, b) == toBigEndian(b * 3)); BOOST_REQUIRE(callContractFunction("callHelper(uint256,bool,uint256)", a, false, b) == toBigEndian(b * 3));
} }
BOOST_AUTO_TEST_CASE(inter_contract_calls_accessing_this) BOOST_AUTO_TEST_CASE(inter_contract_calls_accessing_this)
@ -1113,9 +1113,9 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls_accessing_this)
compileAndRun(sourceCode, 0, "Helper"); compileAndRun(sourceCode, 0, "Helper");
u160 const helperAddress = m_contractAddress; u160 const helperAddress = m_contractAddress;
compileAndRun(sourceCode, 0, "Main"); compileAndRun(sourceCode, 0, "Main");
BOOST_REQUIRE(callContractFunction(2, helperAddress) == bytes()); BOOST_REQUIRE(callContractFunction("setHelper(address)", helperAddress) == bytes());
BOOST_REQUIRE(callContractFunction(1, helperAddress) == toBigEndian(helperAddress)); BOOST_REQUIRE(callContractFunction("getHelper()", helperAddress) == toBigEndian(helperAddress));
BOOST_REQUIRE(callContractFunction(0) == toBigEndian(helperAddress)); BOOST_REQUIRE(callContractFunction("callHelper()") == toBigEndian(helperAddress));
} }
BOOST_AUTO_TEST_CASE(calls_to_this) BOOST_AUTO_TEST_CASE(calls_to_this)
@ -1144,11 +1144,11 @@ BOOST_AUTO_TEST_CASE(calls_to_this)
compileAndRun(sourceCode, 0, "Helper"); compileAndRun(sourceCode, 0, "Helper");
u160 const helperAddress = m_contractAddress; u160 const helperAddress = m_contractAddress;
compileAndRun(sourceCode, 0, "Main"); compileAndRun(sourceCode, 0, "Main");
BOOST_REQUIRE(callContractFunction(2, helperAddress) == bytes()); BOOST_REQUIRE(callContractFunction("setHelper(address)", helperAddress) == bytes());
BOOST_REQUIRE(callContractFunction(1, helperAddress) == toBigEndian(helperAddress)); BOOST_REQUIRE(callContractFunction("getHelper()", helperAddress) == toBigEndian(helperAddress));
u256 a(3456789); u256 a(3456789);
u256 b("0x282837623374623234aa74"); u256 b("0x282837623374623234aa74");
BOOST_REQUIRE(callContractFunction(0, a, b) == toBigEndian(a * b + 10)); BOOST_REQUIRE(callContractFunction("callHelper(uint256,uint256)", a, b) == toBigEndian(a * b + 10));
} }
BOOST_AUTO_TEST_CASE(inter_contract_calls_with_local_vars) BOOST_AUTO_TEST_CASE(inter_contract_calls_with_local_vars)
@ -1179,11 +1179,11 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls_with_local_vars)
compileAndRun(sourceCode, 0, "Helper"); compileAndRun(sourceCode, 0, "Helper");
u160 const helperAddress = m_contractAddress; u160 const helperAddress = m_contractAddress;
compileAndRun(sourceCode, 0, "Main"); compileAndRun(sourceCode, 0, "Main");
BOOST_REQUIRE(callContractFunction(2, helperAddress) == bytes()); BOOST_REQUIRE(callContractFunction("setHelper(address)", helperAddress) == bytes());
BOOST_REQUIRE(callContractFunction(1, helperAddress) == toBigEndian(helperAddress)); BOOST_REQUIRE(callContractFunction("getHelper()", helperAddress) == toBigEndian(helperAddress));
u256 a(3456789); u256 a(3456789);
u256 b("0x282837623374623234aa74"); u256 b("0x282837623374623234aa74");
BOOST_REQUIRE(callContractFunction(0, a, b) == toBigEndian(a * b + 9)); BOOST_REQUIRE(callContractFunction("callHelper(uint256,uint256)", a, b) == toBigEndian(a * b + 9));
} }
BOOST_AUTO_TEST_CASE(strings_in_calls) BOOST_AUTO_TEST_CASE(strings_in_calls)
@ -1209,9 +1209,9 @@ BOOST_AUTO_TEST_CASE(strings_in_calls)
compileAndRun(sourceCode, 0, "Helper"); compileAndRun(sourceCode, 0, "Helper");
u160 const helperAddress = m_contractAddress; u160 const helperAddress = m_contractAddress;
compileAndRun(sourceCode, 0, "Main"); compileAndRun(sourceCode, 0, "Main");
BOOST_REQUIRE(callContractFunction(2, helperAddress) == bytes()); BOOST_REQUIRE(callContractFunction("setHelper(address)", helperAddress) == bytes());
BOOST_REQUIRE(callContractFunction(1, helperAddress) == toBigEndian(helperAddress)); BOOST_REQUIRE(callContractFunction("getHelper()", helperAddress) == toBigEndian(helperAddress));
BOOST_CHECK(callContractFunction(0, bytes({0, 'a', 1})) == bytes({0, 'a', 0, 0, 0})); BOOST_CHECK(callContractFunction("callHelper(string2,bool)", bytes({0, 'a', 1})) == bytes({0, 'a', 0, 0, 0}));
} }
BOOST_AUTO_TEST_CASE(constructor_arguments) BOOST_AUTO_TEST_CASE(constructor_arguments)
@ -1236,8 +1236,8 @@ BOOST_AUTO_TEST_CASE(constructor_arguments)
function getName() returns (string3 ret) { return h.getName(); } function getName() returns (string3 ret) { return h.getName(); }
})"; })";
compileAndRun(sourceCode, 0, "Main"); compileAndRun(sourceCode, 0, "Main");
BOOST_REQUIRE(callContractFunction(0) == bytes({byte(0x01)})); BOOST_REQUIRE(callContractFunction("getFlag()") == bytes({byte(0x01)}));
BOOST_REQUIRE(callContractFunction(1) == bytes({'a', 'b', 'c'})); BOOST_REQUIRE(callContractFunction("getName()") == bytes({'a', 'b', 'c'}));
} }
BOOST_AUTO_TEST_CASE(functions_called_by_constructor) BOOST_AUTO_TEST_CASE(functions_called_by_constructor)
@ -1254,7 +1254,7 @@ BOOST_AUTO_TEST_CASE(functions_called_by_constructor)
function setName(string3 _name) { name = _name; } function setName(string3 _name) { name = _name; }
})"; })";
compileAndRun(sourceCode); compileAndRun(sourceCode);
BOOST_REQUIRE(callContractFunction(0) == bytes({'a', 'b', 'c'})); BOOST_REQUIRE(callContractFunction("getName()") == bytes({'a', 'b', 'c'}));
} }
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()

26
test/SolidityOptimizer.cpp

@ -55,12 +55,12 @@ public:
} }
template <class... Args> template <class... Args>
void compareVersions(byte _index, Args const&... _arguments) void compareVersions(std::string _sig, Args const&... _arguments)
{ {
m_contractAddress = m_nonOptimizedContract; m_contractAddress = m_nonOptimizedContract;
bytes nonOptimizedOutput = callContractFunction(_index, _arguments...); bytes nonOptimizedOutput = callContractFunction(_sig, _arguments...);
m_contractAddress = m_optimizedContract; m_contractAddress = m_optimizedContract;
bytes optimizedOutput = callContractFunction(_index, _arguments...); bytes optimizedOutput = callContractFunction(_sig, _arguments...);
BOOST_CHECK_MESSAGE(nonOptimizedOutput == optimizedOutput, "Computed values do not match." BOOST_CHECK_MESSAGE(nonOptimizedOutput == optimizedOutput, "Computed values do not match."
"\nNon-Optimized: " + toHex(nonOptimizedOutput) + "\nNon-Optimized: " + toHex(nonOptimizedOutput) +
"\nOptimized: " + toHex(optimizedOutput)); "\nOptimized: " + toHex(optimizedOutput));
@ -81,8 +81,8 @@ BOOST_AUTO_TEST_CASE(smoke_test)
return a; return a;
} }
})"; })";
compileBothVersions(4, sourceCode); compileBothVersions(29, sourceCode);
compareVersions(0, u256(7)); compareVersions("f(uint256)", u256(7));
} }
BOOST_AUTO_TEST_CASE(large_integers) BOOST_AUTO_TEST_CASE(large_integers)
@ -94,8 +94,8 @@ BOOST_AUTO_TEST_CASE(large_integers)
b = 0x10000000000000000000000002; b = 0x10000000000000000000000002;
} }
})"; })";
compileBothVersions(11, sourceCode); compileBothVersions(36, sourceCode);
compareVersions(0); compareVersions("f()");
} }
BOOST_AUTO_TEST_CASE(invariants) BOOST_AUTO_TEST_CASE(invariants)
@ -106,8 +106,8 @@ BOOST_AUTO_TEST_CASE(invariants)
return int(0) | (int(1) * (int(0) ^ (0 + a))); return int(0) | (int(1) * (int(0) ^ (0 + a)));
} }
})"; })";
compileBothVersions(16, sourceCode); compileBothVersions(41, sourceCode);
compareVersions(0, u256(0x12334664)); compareVersions("f(uint256)", u256(0x12334664));
} }
BOOST_AUTO_TEST_CASE(unused_expressions) BOOST_AUTO_TEST_CASE(unused_expressions)
@ -120,8 +120,8 @@ BOOST_AUTO_TEST_CASE(unused_expressions)
data; data;
} }
})"; })";
compileBothVersions(8, sourceCode); compileBothVersions(33, sourceCode);
compareVersions(0); compareVersions("f()");
} }
BOOST_AUTO_TEST_CASE(constant_folding_both_sides) BOOST_AUTO_TEST_CASE(constant_folding_both_sides)
@ -135,8 +135,8 @@ BOOST_AUTO_TEST_CASE(constant_folding_both_sides)
return 98 ^ (7 * ((1 | (x | 1000)) * 40) ^ 102); return 98 ^ (7 * ((1 | (x | 1000)) * 40) ^ 102);
} }
})"; })";
compileBothVersions(12, sourceCode); compileBothVersions(37, sourceCode);
compareVersions(0); compareVersions("f(uint256)");
} }
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()

8
test/TestHelper.cpp

@ -489,4 +489,12 @@ void processCommandLineOptions()
} }
} }
LastHashes lastHashes(u256 _currentBlockNumber)
{
LastHashes ret;
for (u256 i = 1; i <= 256 && i <= _currentBlockNumber; ++i)
ret.push_back(sha3(toString(_currentBlockNumber - i)));
return ret;
}
} } // namespaces } } // namespaces

1
test/TestHelper.h

@ -77,6 +77,7 @@ void executeTests(const std::string& _name, const std::string& _testPathAppendix
std::string getTestPath(); std::string getTestPath();
void userDefinedTest(std::string testTypeFlag, std::function<void(json_spirit::mValue&, bool)> doTests); void userDefinedTest(std::string testTypeFlag, std::function<void(json_spirit::mValue&, bool)> doTests);
void processCommandLineOptions(); void processCommandLineOptions();
eth::LastHashes lastHashes(u256 _currentBlockNumber);
template<typename mapType> template<typename mapType>
void checkAddresses(mapType& _expectedAddrs, mapType& _resultAddrs) void checkAddresses(mapType& _expectedAddrs, mapType& _resultAddrs)

18
test/solidityExecutionFramework.h

@ -56,34 +56,36 @@ public:
return m_output; return m_output;
} }
bytes const& callContractFunction(byte _index, bytes const& _data = bytes(), u256 const& _value = 0) bytes const& callContractFunction(std::string _sig, bytes const& _data = bytes(),
u256 const& _value = 0)
{ {
sendMessage(bytes(1, _index) + _data, false, _value); FixedHash<4> hash(dev::sha3(_sig));
sendMessage(hash.asBytes() + _data, false, _value);
return m_output; return m_output;
} }
template <class... Args> template <class... Args>
bytes const& callContractFunction(byte _index, Args const&... _arguments) bytes const& callContractFunction(std::string _sig, Args const&... _arguments)
{ {
return callContractFunction(_index, argsToBigEndian(_arguments...)); return callContractFunction(_sig, argsToBigEndian(_arguments...));
} }
template <class CppFunction, class... Args> template <class CppFunction, class... Args>
void testSolidityAgainstCpp(byte _index, CppFunction const& _cppFunction, Args const&... _arguments) void testSolidityAgainstCpp(std::string _sig, CppFunction const& _cppFunction, Args const&... _arguments)
{ {
bytes solidityResult = callContractFunction(_index, _arguments...); bytes solidityResult = callContractFunction(_sig, _arguments...);
bytes cppResult = callCppAndEncodeResult(_cppFunction, _arguments...); bytes cppResult = callCppAndEncodeResult(_cppFunction, _arguments...);
BOOST_CHECK_MESSAGE(solidityResult == cppResult, "Computed values do not match." BOOST_CHECK_MESSAGE(solidityResult == cppResult, "Computed values do not match."
"\nSolidity: " + toHex(solidityResult) + "\nC++: " + toHex(cppResult)); "\nSolidity: " + toHex(solidityResult) + "\nC++: " + toHex(cppResult));
} }
template <class CppFunction, class... Args> template <class CppFunction, class... Args>
void testSolidityAgainstCppOnRange(byte _index, CppFunction const& _cppFunction, void testSolidityAgainstCppOnRange(std::string _sig, CppFunction const& _cppFunction,
u256 const& _rangeStart, u256 const& _rangeEnd) u256 const& _rangeStart, u256 const& _rangeEnd)
{ {
for (u256 argument = _rangeStart; argument < _rangeEnd; ++argument) for (u256 argument = _rangeStart; argument < _rangeEnd; ++argument)
{ {
bytes solidityResult = callContractFunction(_index, argument); bytes solidityResult = callContractFunction(_sig, argument);
bytes cppResult = callCppAndEncodeResult(_cppFunction, argument); bytes cppResult = callCppAndEncodeResult(_cppFunction, argument);
BOOST_CHECK_MESSAGE(solidityResult == cppResult, "Computed values do not match." BOOST_CHECK_MESSAGE(solidityResult == cppResult, "Computed values do not match."
"\nSolidity: " + toHex(solidityResult) + "\nC++: " + toHex(cppResult) + "\nSolidity: " + toHex(solidityResult) + "\nC++: " + toHex(cppResult) +

85
test/stSystemOperationsTestFiller.json

@ -529,12 +529,53 @@
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : { "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000", "balance" : "1000000000000000000",
"nonce" : 0, "nonce" : 0,
"code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALL 1000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 0 2) }", "code" : "{ [[ 0 ]] (CALL 1000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 0 31 1) [[ 1 ]] @0 }",
"storage": {} "storage": {}
}, },
"945304eb96065b2a98b57a48a06ae28d285a71b5" : { "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
"balance" : "23", "balance" : "23",
"code" : "0x6001600155603760005360026000f3", "code" : "0x6001600155602a601f536001601ff3",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "",
"storage": {}
}
},
"transaction" : {
"nonce" : "0",
"gasPrice" : "1",
"gasLimit" : "10000",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "100000",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"data" : ""
}
},
"CallToReturn1ForDynamicJump0": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "10000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "0x6001601f60006000601773945304eb96065b2a98b57a48a06ae28d285a71b56103e8f1600055600051565b6023602355",
"storage": {}
},
"945304eb96065b2a98b57a48a06ae28d285a71b5" : {
"balance" : "23",
"code" : "0x6001600155602a601f536001601ff3",
"nonce" : "0", "nonce" : "0",
"storage" : { "storage" : {
} }
@ -545,7 +586,47 @@
"code" : "", "code" : "",
"storage": {} "storage": {}
} }
},
"transaction" : {
"nonce" : "0",
"gasPrice" : "1",
"gasLimit" : "10000",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "100000",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"data" : ""
}
},
"CallToReturn1ForDynamicJump1": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "10000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "0x6001601f60006000601773945304eb96065b2a98b57a48a06ae28d285a71b56103e8f160005560005156605b6023602355",
"storage": {}
},
"945304eb96065b2a98b57a48a06ae28d285a71b5" : {
"balance" : "23",
"code" : "0x6001600155602b601f536001601ff3",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "",
"storage": {}
}
}, },
"transaction" : { "transaction" : {
"nonce" : "0", "nonce" : "0",

10
test/state.cpp

@ -39,16 +39,6 @@ using namespace dev::eth;
namespace dev { namespace test { namespace dev { namespace test {
LastHashes lastHashes(u256 _currentBlockNumber)
{
LastHashes ret;
for (u256 i = 1; i <= 256 && i <= _currentBlockNumber; ++i)
ret.push_back(sha3(toString(_currentBlockNumber - i)));
return ret;
}
void doStateTests(json_spirit::mValue& v, bool _fillin) void doStateTests(json_spirit::mValue& v, bool _fillin)
{ {
processCommandLineOptions(); processCommandLineOptions();

3
test/vm.cpp

@ -33,7 +33,7 @@ using namespace dev::eth;
using namespace dev::test; using namespace dev::test;
FakeExtVM::FakeExtVM(eth::BlockInfo const& _previousBlock, eth::BlockInfo const& _currentBlock, unsigned _depth): /// TODO: XXX: remove the default argument & fix. FakeExtVM::FakeExtVM(eth::BlockInfo const& _previousBlock, eth::BlockInfo const& _currentBlock, unsigned _depth): /// TODO: XXX: remove the default argument & fix.
ExtVMFace(Address(), Address(), Address(), 0, 1, bytesConstRef(), bytes(), _previousBlock, _currentBlock, LastHashes(), _depth) {} ExtVMFace(Address(), Address(), Address(), 0, 1, bytesConstRef(), bytes(), _previousBlock, _currentBlock, test::lastHashes(_currentBlock.number), _depth) {}
h160 FakeExtVM::create(u256 _endowment, u256& io_gas, bytesConstRef _init, OnOpFunc const&) h160 FakeExtVM::create(u256 _endowment, u256& io_gas, bytesConstRef _init, OnOpFunc const&)
{ {
@ -117,6 +117,7 @@ void FakeExtVM::importEnv(mObject& _o)
previousBlock.hash = h256(_o["previousHash"].get_str()); previousBlock.hash = h256(_o["previousHash"].get_str());
currentBlock.number = toInt(_o["currentNumber"]); currentBlock.number = toInt(_o["currentNumber"]);
lastHashes = test::lastHashes(currentBlock.number);
currentBlock.gasLimit = toInt(_o["currentGasLimit"]); currentBlock.gasLimit = toInt(_o["currentGasLimit"]);
currentBlock.difficulty = toInt(_o["currentDifficulty"]); currentBlock.difficulty = toInt(_o["currentDifficulty"]);
currentBlock.timestamp = toInt(_o["currentTimestamp"]); currentBlock.timestamp = toInt(_o["currentTimestamp"]);

56
test/vmArithmeticTestFiller.json

@ -814,6 +814,62 @@
} }
}, },
"sdiv4": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "1000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ [[ 0 ]] (SDIV 5 (- 0 4) ) }",
"storage": {}
}
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"origin" : "cd1722f2947def4cf144679da39c4c32bdc35681",
"caller" : "cd1722f2947def4cf144679da39c4c32bdc35681",
"value" : "1000000000000000000",
"data" : "",
"gasPrice" : "100000000000000",
"gas" : "10000"
}
},
"sdiv5": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "1000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ [[ 0 ]] (SDIV (- 0 57896044618658097711785492504343953926634992332820282019728792003956564819967) (- 0 1) ) }",
"storage": {}
}
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"origin" : "cd1722f2947def4cf144679da39c4c32bdc35681",
"caller" : "cd1722f2947def4cf144679da39c4c32bdc35681",
"value" : "1000000000000000000",
"data" : "",
"gasPrice" : "100000000000000",
"gas" : "10000"
}
},
"mod0": { "mod0": {
"env" : { "env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",

56
test/vmBlockInfoTestFiller.json

@ -111,6 +111,62 @@
} }
}, },
"blockhashInRange": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "257",
"currentGasLimit" : "1000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ [[ 0 ]] (BLOCKHASH 1) [[ 1 ]] (BLOCKHASH 2) [[ 2 ]] (BLOCKHASH 256) }",
"storage": {}
}
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "1000000000000000000",
"data" : "",
"gasPrice" : "100000000000000",
"gas" : "10000"
}
},
"blockhashOutOfRange": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "257",
"currentGasLimit" : "1000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ [[ 0 ]] (BLOCKHASH 0) [[ 1 ]] (BLOCKHASH 257) [[ 2 ]] (BLOCKHASH 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) }",
"storage": {}
}
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "1000000000000000000",
"data" : "",
"gasPrice" : "100000000000000",
"gas" : "10000"
}
},
"coinbase": { "coinbase": {
"env" : { "env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",

1244
test/vmIOandFlowOperationsTestFiller.json

File diff suppressed because it is too large
Loading…
Cancel
Save