From 777fcbd12ef01f3a63b0a27317ad402aff6d611b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Tue, 21 Apr 2015 13:13:49 +0200 Subject: [PATCH 01/20] Port to LLVM 3.7 --- evmjit/libevmjit/Array.cpp | 20 ++++++++++---------- evmjit/libevmjit/Cache.cpp | 17 +++++++---------- evmjit/libevmjit/Cache.h | 4 ++-- evmjit/libevmjit/ExecutionEngine.cpp | 13 ++++++------- evmjit/libevmjit/Optimizer.cpp | 4 ++-- evmjit/libevmjit/RuntimeManager.cpp | 12 ++++++------ evmjit/libevmjit/Type.h | 5 +++-- 7 files changed, 36 insertions(+), 39 deletions(-) diff --git a/evmjit/libevmjit/Array.cpp b/evmjit/libevmjit/Array.cpp index 3266038db..b3d3cc0bb 100644 --- a/evmjit/libevmjit/Array.cpp +++ b/evmjit/libevmjit/Array.cpp @@ -47,9 +47,9 @@ llvm::Function* Array::createArrayPushFunc() auto pushBB = llvm::BasicBlock::Create(m_builder.getContext(), "Push", func); m_builder.SetInsertPoint(entryBB); - auto dataPtr = m_builder.CreateStructGEP(arrayPtr, 0, "dataPtr"); - auto sizePtr = m_builder.CreateStructGEP(arrayPtr, 1, "sizePtr"); - auto capPtr = m_builder.CreateStructGEP(arrayPtr, 2, "capPtr"); + auto dataPtr = m_builder.CreateStructGEP(getType(), arrayPtr, 0, "dataPtr"); + auto sizePtr = m_builder.CreateStructGEP(getType(), arrayPtr, 1, "sizePtr"); + auto capPtr = m_builder.CreateStructGEP(getType(), arrayPtr, 2, "capPtr"); auto data = m_builder.CreateLoad(dataPtr, "data"); auto size = m_builder.CreateLoad(sizePtr, "size"); auto cap = m_builder.CreateLoad(capPtr, "cap"); @@ -96,7 +96,7 @@ llvm::Function* Array::createArraySetFunc() InsertPointGuard guard{m_builder}; m_builder.SetInsertPoint(llvm::BasicBlock::Create(m_builder.getContext(), {}, func)); - auto dataPtr = m_builder.CreateStructGEP(arrayPtr, 0, "dataPtr"); + auto dataPtr = m_builder.CreateStructGEP(getType(), arrayPtr, 0, "dataPtr"); auto data = m_builder.CreateLoad(dataPtr, "data"); auto valuePtr = m_builder.CreateGEP(data, index, "valuePtr"); m_builder.CreateStore(value, valuePtr); @@ -118,7 +118,7 @@ llvm::Function* Array::createArrayGetFunc() InsertPointGuard guard{m_builder}; m_builder.SetInsertPoint(llvm::BasicBlock::Create(m_builder.getContext(), {}, func)); - auto dataPtr = m_builder.CreateStructGEP(arrayPtr, 0, "dataPtr"); + auto dataPtr = m_builder.CreateStructGEP(getType(), arrayPtr, 0, "dataPtr"); auto data = m_builder.CreateLoad(dataPtr, "data"); auto valuePtr = m_builder.CreateGEP(data, index, "valuePtr"); auto value = m_builder.CreateLoad(valuePtr, "value"); @@ -163,7 +163,7 @@ llvm::Function* Array::createFreeFunc() InsertPointGuard guard{m_builder}; m_builder.SetInsertPoint(llvm::BasicBlock::Create(m_builder.getContext(), {}, func)); - auto dataPtr = m_builder.CreateStructGEP(arrayPtr, 0, "dataPtr"); + auto dataPtr = m_builder.CreateStructGEP(getType(), arrayPtr, 0, "dataPtr"); auto data = m_builder.CreateLoad(dataPtr, "data"); auto mem = m_builder.CreateBitCast(data, Type::BytePtr, "mem"); m_builder.CreateCall(freeFunc, mem); @@ -199,8 +199,8 @@ llvm::Function* Array::createExtendFunc() InsertPointGuard guard{m_builder}; m_builder.SetInsertPoint(llvm::BasicBlock::Create(m_builder.getContext(), {}, func)); auto dataPtr = m_builder.CreateBitCast(arrayPtr, Type::BytePtr->getPointerTo(), "dataPtr");// TODO: Use byte* in Array - auto sizePtr = m_builder.CreateStructGEP(arrayPtr, 1, "sizePtr"); - auto capPtr = m_builder.CreateStructGEP(arrayPtr, 2, "capPtr"); + auto sizePtr = m_builder.CreateStructGEP(getType(), arrayPtr, 1, "sizePtr"); + auto capPtr = m_builder.CreateStructGEP(getType(), arrayPtr, 2, "capPtr"); auto data = m_builder.CreateLoad(dataPtr, "data"); auto size = m_builder.CreateLoad(sizePtr, "size"); auto extSize = m_builder.CreateNUWSub(newSize, size, "extSize"); @@ -246,7 +246,7 @@ Array::Array(llvm::IRBuilder<>& _builder, llvm::Value* _array) : void Array::pop(llvm::Value* _count) { - auto sizePtr = m_builder.CreateStructGEP(m_array, 1, "sizePtr"); + auto sizePtr = m_builder.CreateStructGEP(getType(), m_array, 1, "sizePtr"); auto size = m_builder.CreateLoad(sizePtr, "size"); auto newSize = m_builder.CreateNUWSub(size, _count, "newSize"); m_builder.CreateStore(newSize, sizePtr); @@ -254,7 +254,7 @@ void Array::pop(llvm::Value* _count) llvm::Value* Array::size(llvm::Value* _array) { - auto sizePtr = m_builder.CreateStructGEP(_array ? _array : m_array, 1, "sizePtr"); + auto sizePtr = m_builder.CreateStructGEP(getType(), _array ? _array : m_array, 1, "sizePtr"); return m_builder.CreateLoad(sizePtr, "array.size"); } diff --git a/evmjit/libevmjit/Cache.cpp b/evmjit/libevmjit/Cache.cpp index 47a6386e9..aa316d51d 100644 --- a/evmjit/libevmjit/Cache.cpp +++ b/evmjit/libevmjit/Cache.cpp @@ -24,7 +24,7 @@ namespace jit namespace { CacheMode g_mode; - llvm::MemoryBuffer* g_lastObject; + std::unique_ptr g_lastObject; ExecutionEngineListener* g_listener; static const size_t c_versionStampLength = 32; @@ -79,8 +79,7 @@ void Cache::preload(llvm::ExecutionEngine& _ee, std::unordered_map Cache::getObject(std::string const& id) } -void ObjectCache::notifyObjectCompiled(llvm::Module const* _module, llvm::MemoryBuffer const* _object) +void ObjectCache::notifyObjectCompiled(llvm::Module const* _module, llvm::MemoryBufferRef _object) { // Only in "on" and "write" mode if (g_mode != CacheMode::on && g_mode != CacheMode::write) @@ -154,17 +153,15 @@ void ObjectCache::notifyObjectCompiled(llvm::Module const* _module, llvm::Memory llvm::sys::path::append(cachePath, id); DLOG(cache) << id << ": write\n"; - std::string error; + std::error_code error; llvm::raw_fd_ostream cacheFile(cachePath.c_str(), error, llvm::sys::fs::F_None); - cacheFile << _object->getBuffer() << getLibVersionStamp(); + cacheFile << _object.getBuffer() << getLibVersionStamp(); } -llvm::MemoryBuffer* ObjectCache::getObject(llvm::Module const* _module) +std::unique_ptr ObjectCache::getObject(llvm::Module const* _module) { DLOG(cache) << _module->getModuleIdentifier() << ": use\n"; - auto o = g_lastObject; - g_lastObject = nullptr; - return o; + return std::move(g_lastObject); } } diff --git a/evmjit/libevmjit/Cache.h b/evmjit/libevmjit/Cache.h index f6a0a3400..6b8457f4b 100644 --- a/evmjit/libevmjit/Cache.h +++ b/evmjit/libevmjit/Cache.h @@ -32,13 +32,13 @@ class ObjectCache : public llvm::ObjectCache { public: /// notifyObjectCompiled - Provides a pointer to compiled code for Module M. - virtual void notifyObjectCompiled(llvm::Module const* _module, llvm::MemoryBuffer const* _object) final override; + virtual void notifyObjectCompiled(llvm::Module const* _module, llvm::MemoryBufferRef _object) final override; /// getObjectCopy - Returns a pointer to a newly allocated MemoryBuffer that /// contains the object which corresponds with Module M, or 0 if an object is /// not available. The caller owns both the MemoryBuffer returned by this /// and the memory it references. - virtual llvm::MemoryBuffer* getObject(llvm::Module const* _module) final override; + virtual std::unique_ptr getObject(llvm::Module const* _module) final override; }; diff --git a/evmjit/libevmjit/ExecutionEngine.cpp b/evmjit/libevmjit/ExecutionEngine.cpp index e15dad969..9bd767158 100644 --- a/evmjit/libevmjit/ExecutionEngine.cpp +++ b/evmjit/libevmjit/ExecutionEngine.cpp @@ -131,20 +131,20 @@ ReturnCode ExecutionEngine::run(RuntimeData* _data, Env* _env) llvm::InitializeNativeTargetAsmPrinter(); auto module = std::unique_ptr(new llvm::Module({}, llvm::getGlobalContext())); - llvm::EngineBuilder builder(module.get()); - builder.setEngineKind(llvm::EngineKind::JIT); - builder.setUseMCJIT(true); - builder.setOptLevel(g_optimize ? llvm::CodeGenOpt::Default : llvm::CodeGenOpt::None); + // FIXME: LLVM 3.7: test on Windows auto triple = llvm::Triple(llvm::sys::getProcessTriple()); if (triple.getOS() == llvm::Triple::OSType::Win32) triple.setObjectFormat(llvm::Triple::ObjectFormatType::ELF); // MCJIT does not support COFF format module->setTargetTriple(triple.str()); + llvm::EngineBuilder builder(std::move(module)); + builder.setEngineKind(llvm::EngineKind::JIT); + builder.setOptLevel(g_optimize ? llvm::CodeGenOpt::Default : llvm::CodeGenOpt::None); + ee.reset(builder.create()); if (!CHECK(ee)) return ReturnCode::LLVMConfigError; - module.release(); // Successfully created llvm::ExecutionEngine takes ownership of the module ee->setObjectCache(objectCache); if (preloadCache) @@ -179,8 +179,7 @@ ReturnCode ExecutionEngine::run(RuntimeData* _data, Env* _env) if (g_dump) module->dump(); - ee->addModule(module.get()); - module.release(); + ee->addModule(std::move(module)); listener->stateChanged(ExecState::CodeGen); entryFuncPtr = (EntryFuncPtr)ee->getFunctionAddress(mainFuncName); } diff --git a/evmjit/libevmjit/Optimizer.cpp b/evmjit/libevmjit/Optimizer.cpp index 84a7c3a6a..731fda5c6 100644 --- a/evmjit/libevmjit/Optimizer.cpp +++ b/evmjit/libevmjit/Optimizer.cpp @@ -1,7 +1,7 @@ #include "Optimizer.h" #include "preprocessor/llvm_includes_start.h" -#include +#include #include #include #include "preprocessor/llvm_includes_end.h" @@ -15,7 +15,7 @@ namespace jit bool optimize(llvm::Module& _module) { - auto pm = llvm::PassManager{}; + auto pm = llvm::legacy::PassManager{}; //pm.add(llvm::createFunctionInliningPass(2, 2)); // Produces invalid IR pm.add(llvm::createCFGSimplificationPass()); //pm.add(llvm::createInstructionCombiningPass()); // Produces invalid runtime results diff --git a/evmjit/libevmjit/RuntimeManager.cpp b/evmjit/libevmjit/RuntimeManager.cpp index dc7bc24a3..5c66a5a21 100644 --- a/evmjit/libevmjit/RuntimeManager.cpp +++ b/evmjit/libevmjit/RuntimeManager.cpp @@ -93,13 +93,13 @@ RuntimeManager::RuntimeManager(llvm::IRBuilder<>& _builder, code_iterator _codeB // Unpack data auto rtPtr = getRuntimePtr(); - m_dataPtr = m_builder.CreateLoad(m_builder.CreateStructGEP(rtPtr, 0), "data"); + m_dataPtr = m_builder.CreateLoad(m_builder.CreateStructGEP(getRuntimeType(), rtPtr, 0), "data"); assert(m_dataPtr->getType() == Type::RuntimeDataPtr); - m_gasPtr = m_builder.CreateStructGEP(m_dataPtr, 0, "gas"); + m_gasPtr = m_builder.CreateStructGEP(getRuntimeDataType(), m_dataPtr, 0, "gas"); assert(m_gasPtr->getType() == Type::Gas->getPointerTo()); - m_memPtr = m_builder.CreateStructGEP(rtPtr, 2, "mem"); + m_memPtr = m_builder.CreateStructGEP(getRuntimeType(), rtPtr, 2, "mem"); assert(m_memPtr->getType() == Array::getType()->getPointerTo()); - m_envPtr = m_builder.CreateLoad(m_builder.CreateStructGEP(rtPtr, 1), "env"); + m_envPtr = m_builder.CreateLoad(m_builder.CreateStructGEP(getRuntimeType(), rtPtr, 1), "env"); assert(m_envPtr->getType() == Type::EnvPtr); m_stackSize = m_builder.CreateAlloca(Type::Size, nullptr, "stackSize"); @@ -160,7 +160,7 @@ llvm::Value* RuntimeManager::getDataPtr() return m_dataPtr; auto rtPtr = getRuntimePtr(); - auto dataPtr = m_builder.CreateLoad(m_builder.CreateStructGEP(rtPtr, 0), "data"); + auto dataPtr = m_builder.CreateLoad(m_builder.CreateStructGEP(getRuntimeType(), rtPtr, 0), "data"); assert(dataPtr->getType() == getRuntimeDataType()->getPointerTo()); return dataPtr; } @@ -173,7 +173,7 @@ llvm::Value* RuntimeManager::getEnvPtr() llvm::Value* RuntimeManager::getPtr(RuntimeData::Index _index) { - auto ptr = getBuilder().CreateStructGEP(getDataPtr(), _index); + auto ptr = getBuilder().CreateStructGEP(getRuntimeDataType(), getDataPtr(), _index); assert(getRuntimeDataType()->getElementType(_index)->getPointerTo() == ptr->getType()); return ptr; } diff --git a/evmjit/libevmjit/Type.h b/evmjit/libevmjit/Type.h index ffacc5407..fcca98d74 100644 --- a/evmjit/libevmjit/Type.h +++ b/evmjit/libevmjit/Type.h @@ -2,8 +2,9 @@ #include "preprocessor/llvm_includes_start.h" #include -#include -#include "preprocessor/llvm_includes_end.h" +#include +#include +#include "preprocessor/llvm_includes_end.h" // FIXME: LLVM 3.7: check if needed #include "Common.h" From 56c3d1858201a3956ce669b03875ebac060e9b3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Tue, 21 Apr 2015 16:23:01 +0200 Subject: [PATCH 02/20] Remove some LLVM 3.5 bugs workarounds --- evmjit/libevmjit/Arith256.cpp | 11 ---------- evmjit/libevmjit/Compiler.cpp | 8 ++----- evmjit/libevmjit/Endianness.cpp | 5 ++--- evmjit/libevmjit/ExecutionEngine.cpp | 15 +------------ evmjit/libevmjit/GasMeter.cpp | 22 +++++-------------- evmjit/libevmjit/Optimizer.cpp | 4 ++-- .../preprocessor/llvm_includes_end.h | 4 ---- .../preprocessor/llvm_includes_start.h | 8 ------- 8 files changed, 13 insertions(+), 64 deletions(-) diff --git a/evmjit/libevmjit/Arith256.cpp b/evmjit/libevmjit/Arith256.cpp index e88fda432..029eb9370 100644 --- a/evmjit/libevmjit/Arith256.cpp +++ b/evmjit/libevmjit/Arith256.cpp @@ -170,18 +170,7 @@ llvm::Function* Arith256::getDivFunc(llvm::Type* _type) auto yLz = m_builder.CreateCall2(ctlzIntr, yArg, m_builder.getInt1(true), "y.lz"); auto rLz = m_builder.CreateCall2(ctlzIntr, r0, m_builder.getInt1(true), "r.lz"); auto i0 = m_builder.CreateNUWSub(yLz, rLz, "i0"); - auto shlBy0 = m_builder.CreateICmpEQ(i0, zero); auto y0 = m_builder.CreateShl(yArg, i0); - if (_type == m_builder.getIntNTy(512)) // Workaround for shl bug for long shifts - { - const auto treshold = m_builder.getIntN(512, 128); - auto highShift = m_builder.CreateICmpUGT(i0, treshold); - auto s = m_builder.CreateNUWSub(i0, treshold); - auto yhs = m_builder.CreateShl(yArg, treshold); - yhs = m_builder.CreateShl(yhs, s); - y0 = m_builder.CreateSelect(highShift, yhs, y0); - } - y0 = m_builder.CreateSelect(shlBy0, yArg, y0, "y0"); // Workaround for LLVM bug: shl by 0 produces wrong result m_builder.CreateBr(loopBB); m_builder.SetInsertPoint(loopBB); diff --git a/evmjit/libevmjit/Compiler.cpp b/evmjit/libevmjit/Compiler.cpp index 1e1f8fe93..d5cb493ab 100644 --- a/evmjit/libevmjit/Compiler.cpp +++ b/evmjit/libevmjit/Compiler.cpp @@ -464,12 +464,8 @@ void Compiler::compileBasicBlock(BasicBlock& _basicBlock, RuntimeManager& _runti // test for word >> (k * 8 + 7) auto bitpos = m_builder.CreateAdd(k32x8, m_builder.getInt64(7), "bitpos"); auto bitposEx = m_builder.CreateZExt(bitpos, Type::Word); - auto bittester = m_builder.CreateShl(Constant::get(1), bitposEx); - auto bitresult = m_builder.CreateAnd(word, bittester); - auto bittest = m_builder.CreateICmpUGT(bitresult, Constant::get(0)); - // FIXME: The following does not work - LLVM bug, report! - //auto bitval = m_builder.CreateLShr(word, bitpos, "bitval"); - //auto bittest = m_builder.CreateTrunc(bitval, Type::Bool, "bittest"); + auto bitval = m_builder.CreateLShr(word, bitposEx, "bitval"); + auto bittest = m_builder.CreateTrunc(bitval, Type::Bool, "bittest"); auto mask_ = m_builder.CreateShl(Constant::get(1), bitposEx); auto mask = m_builder.CreateSub(mask_, Constant::get(1), "mask"); diff --git a/evmjit/libevmjit/Endianness.cpp b/evmjit/libevmjit/Endianness.cpp index d36f4b7fa..25b66c0d5 100644 --- a/evmjit/libevmjit/Endianness.cpp +++ b/evmjit/libevmjit/Endianness.cpp @@ -18,9 +18,8 @@ llvm::Value* Endianness::bswapIfLE(llvm::IRBuilder<>& _builder, llvm::Value* _wo { if (llvm::sys::IsLittleEndianHost) { - // FIXME: Disabled because of problems with BYTE - //if (auto constant = llvm::dyn_cast(_word)) - // return _builder.getInt(constant->getValue().byteSwap()); + if (auto constant = llvm::dyn_cast(_word)) + return _builder.getInt(constant->getValue().byteSwap()); // OPT: Cache func declaration? auto bswapFunc = llvm::Intrinsic::getDeclaration(_builder.GetInsertBlock()->getParent()->getParent(), llvm::Intrinsic::bswap, Type::Word); diff --git a/evmjit/libevmjit/ExecutionEngine.cpp b/evmjit/libevmjit/ExecutionEngine.cpp index 9bd767158..fba9cfd96 100644 --- a/evmjit/libevmjit/ExecutionEngine.cpp +++ b/evmjit/libevmjit/ExecutionEngine.cpp @@ -85,20 +85,7 @@ void parseOptions() { static llvm::llvm_shutdown_obj shutdownObj{}; cl::AddExtraVersionPrinter(printVersion); - //cl::ParseEnvironmentOptions("evmjit", "EVMJIT", "Ethereum EVM JIT Compiler"); - - // FIXME: LLVM workaround: - // Manually select instruction scheduler. Confirmed bad schedulers: source, list-burr, list-hybrid. - // "source" scheduler has a bug: http://llvm.org/bugs/show_bug.cgi?id=22304 - auto envLine = std::getenv("EVMJIT"); - auto commandLine = std::string{"evmjit "} + (envLine ? envLine : "") + " -pre-RA-sched=list-ilp\0"; - static const auto c_maxArgs = 20; - char const* argv[c_maxArgs] = {nullptr, }; - auto arg = std::strtok(&*commandLine.begin(), " "); - auto i = 0; - for (; i < c_maxArgs && arg; ++i, arg = std::strtok(nullptr, " ")) - argv[i] = arg; - cl::ParseCommandLineOptions(i, argv, "Ethereum EVM JIT Compiler"); + cl::ParseEnvironmentOptions("evmjit", "EVMJIT", "Ethereum EVM JIT Compiler"); } } diff --git a/evmjit/libevmjit/GasMeter.cpp b/evmjit/libevmjit/GasMeter.cpp index ffbd654e6..c0a2ed287 100644 --- a/evmjit/libevmjit/GasMeter.cpp +++ b/evmjit/libevmjit/GasMeter.cpp @@ -216,22 +216,12 @@ void GasMeter::countExp(llvm::Value* _exponent) // cost = ((256 - lz) + 7) / 8 // OPT: Can gas update be done in exp algorithm? - - auto t = llvm::APInt{256, 1}; - auto c = m_builder.CreateSelect(m_builder.CreateICmpUGE(_exponent, Constant::get(t)), m_builder.getInt64(1), m_builder.getInt64(0)); - for (auto i = 2; i <= 32; ++i) - { - t <<= 8; - c = m_builder.CreateSelect(m_builder.CreateICmpUGE(_exponent, Constant::get(t)), m_builder.getInt64(i), c); - } - - // FIXME: Does not work because of LLVM bug: https://llvm.org/bugs/show_bug.cgi?id=22304 -// auto ctlz = llvm::Intrinsic::getDeclaration(getModule(), llvm::Intrinsic::ctlz, Type::Word); -// auto lz256 = m_builder.CreateCall2(ctlz, _exponent, m_builder.getInt1(false)); -// auto lz = m_builder.CreateTrunc(lz256, Type::Gas, "lz"); -// auto sigBits = m_builder.CreateSub(m_builder.getInt64(256), lz, "sigBits"); -// auto sigBytes = m_builder.CreateUDiv(m_builder.CreateAdd(sigBits, m_builder.getInt64(7)), m_builder.getInt64(8)); - count(m_builder.CreateNUWMul(c, m_builder.getInt64(c_expByteGas))); + auto ctlz = llvm::Intrinsic::getDeclaration(getModule(), llvm::Intrinsic::ctlz, Type::Word); + auto lz256 = m_builder.CreateCall2(ctlz, _exponent, m_builder.getInt1(false)); + auto lz = m_builder.CreateTrunc(lz256, Type::Gas, "lz"); + auto sigBits = m_builder.CreateSub(m_builder.getInt64(256), lz, "sigBits"); + auto sigBytes = m_builder.CreateUDiv(m_builder.CreateAdd(sigBits, m_builder.getInt64(7)), m_builder.getInt64(8)); + count(m_builder.CreateNUWMul(sigBytes, m_builder.getInt64(c_expByteGas))); } void GasMeter::countSStore(Ext& _ext, llvm::Value* _index, llvm::Value* _newValue) diff --git a/evmjit/libevmjit/Optimizer.cpp b/evmjit/libevmjit/Optimizer.cpp index 731fda5c6..df88b4df8 100644 --- a/evmjit/libevmjit/Optimizer.cpp +++ b/evmjit/libevmjit/Optimizer.cpp @@ -16,9 +16,9 @@ namespace jit bool optimize(llvm::Module& _module) { auto pm = llvm::legacy::PassManager{}; - //pm.add(llvm::createFunctionInliningPass(2, 2)); // Produces invalid IR + //pm.add(llvm::createFunctionInliningPass(2, 2)); // Problem with APInt value bigger than 64bit pm.add(llvm::createCFGSimplificationPass()); - //pm.add(llvm::createInstructionCombiningPass()); // Produces invalid runtime results + pm.add(llvm::createInstructionCombiningPass()); pm.add(llvm::createAggressiveDCEPass()); pm.add(llvm::createLowerSwitchPass()); return pm.run(_module); diff --git a/evmjit/libevmjit/preprocessor/llvm_includes_end.h b/evmjit/libevmjit/preprocessor/llvm_includes_end.h index 2ead6dda3..643e03064 100644 --- a/evmjit/libevmjit/preprocessor/llvm_includes_end.h +++ b/evmjit/libevmjit/preprocessor/llvm_includes_end.h @@ -1,7 +1,3 @@ #if defined(_MSC_VER) #pragma warning(pop) -#elif defined(__clang__) - #pragma clang diagnostic pop -#else - #pragma GCC diagnostic pop #endif diff --git a/evmjit/libevmjit/preprocessor/llvm_includes_start.h b/evmjit/libevmjit/preprocessor/llvm_includes_start.h index 9077bf43f..9499f9835 100644 --- a/evmjit/libevmjit/preprocessor/llvm_includes_start.h +++ b/evmjit/libevmjit/preprocessor/llvm_includes_start.h @@ -1,12 +1,4 @@ #if defined(_MSC_VER) #pragma warning(push) #pragma warning(disable: 4267 4244 4800) -#elif defined(__clang__) - #pragma clang diagnostic push - #pragma clang diagnostic ignored "-Wunused-parameter" - #pragma clang diagnostic ignored "-Wconversion" -#else - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wunused-parameter" - #pragma GCC diagnostic ignored "-Wconversion" #endif From f86009c9e82888e478690166373b1b6526991831 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Thu, 23 Apr 2015 12:16:07 +0200 Subject: [PATCH 03/20] Add support for building with llvm-3.7-deb Debian package --- evmjit/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/evmjit/CMakeLists.txt b/evmjit/CMakeLists.txt index 5ab394a80..35332f232 100644 --- a/evmjit/CMakeLists.txt +++ b/evmjit/CMakeLists.txt @@ -25,12 +25,12 @@ if(LLVM_DIR OR APPLE) # local LLVM build llvm_map_components_to_libnames(LLVM_LIBS core support mcjit x86asmparser x86codegen bitwriter ipo) else() # Workaround for Ubuntu broken LLVM package - message(STATUS "Using llvm-3.5-dev package from Ubuntu. If does not work, build LLVM and set -DLLVM_DIR=llvm-build/share/llvm/cmake") - execute_process(COMMAND llvm-config-3.5 --includedir OUTPUT_VARIABLE LLVM_INCLUDE_DIRS) + message(STATUS "Using llvm-3.7-dev package from Ubuntu. If does not work, build LLVM and set -DLLVM_DIR=llvm-build/share/llvm/cmake") + execute_process(COMMAND llvm-config-3.7 --includedir OUTPUT_VARIABLE LLVM_INCLUDE_DIRS) message(STATUS "LLVM include dirs: ${LLVM_INCLUDE_DIRS}") - set(LLVM_LIBS "-lLLVMBitWriter -lLLVMX86CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMX86AsmParser -lLLVMX86Desc -lLLVMX86Info -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMMCJIT -lLLVMTarget -lLLVMRuntimeDyld -lLLVMObject -lLLVMMCParser -lLLVMBitReader -lLLVMExecutionEngine -lLLVMMC -lLLVMCore -lLLVMSupport -lz -lpthread -lffi -ltinfo -ldl -lm") + set(LLVM_LIBS "-lLLVMBitWriter -lLLVMX86CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMX86AsmParser -lLLVMX86Desc -lLLVMX86Info -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMMCJIT -lLLVMExecutionEngine -lLLVMRuntimeDyld -lLLVMTarget -lLLVMRuntimeDyld -lLLVMObject -lLLVMMCParser -lLLVMBitReader -lLLVMMC -lLLVMMCDisassembler -lLLVMCore -lLLVMSupport -lz -lpthread -lffi -ltinfo -ldl -lm") add_definitions(-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS) - link_directories(/usr/lib/llvm-3.5/lib) + link_directories(/usr/lib/llvm-3.7/lib) endif() add_subdirectory(libevmjit) From 7a276c2eee24b1953e3c9a64806be23401a65de8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Wed, 10 Jun 2015 18:01:37 +0200 Subject: [PATCH 04/20] Disable some warnings in LLVM headers for GCC/clang compilers. --- evmjit/libevmjit/preprocessor/llvm_includes_end.h | 4 ++++ evmjit/libevmjit/preprocessor/llvm_includes_start.h | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/evmjit/libevmjit/preprocessor/llvm_includes_end.h b/evmjit/libevmjit/preprocessor/llvm_includes_end.h index 643e03064..2ead6dda3 100644 --- a/evmjit/libevmjit/preprocessor/llvm_includes_end.h +++ b/evmjit/libevmjit/preprocessor/llvm_includes_end.h @@ -1,3 +1,7 @@ #if defined(_MSC_VER) #pragma warning(pop) +#elif defined(__clang__) + #pragma clang diagnostic pop +#else + #pragma GCC diagnostic pop #endif diff --git a/evmjit/libevmjit/preprocessor/llvm_includes_start.h b/evmjit/libevmjit/preprocessor/llvm_includes_start.h index 9499f9835..9077bf43f 100644 --- a/evmjit/libevmjit/preprocessor/llvm_includes_start.h +++ b/evmjit/libevmjit/preprocessor/llvm_includes_start.h @@ -1,4 +1,12 @@ #if defined(_MSC_VER) #pragma warning(push) #pragma warning(disable: 4267 4244 4800) +#elif defined(__clang__) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wunused-parameter" + #pragma clang diagnostic ignored "-Wconversion" +#else + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wunused-parameter" + #pragma GCC diagnostic ignored "-Wconversion" #endif From 3ed12d4851c5a0737de01f41f54a7cec2efe7abd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Thu, 21 May 2015 14:28:19 +0200 Subject: [PATCH 05/20] Remove LLVM cmake files workaround. --- evmjit/CMakeLists.txt | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/evmjit/CMakeLists.txt b/evmjit/CMakeLists.txt index 4343ddc31..fa9b08f48 100644 --- a/evmjit/CMakeLists.txt +++ b/evmjit/CMakeLists.txt @@ -16,22 +16,11 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") endif() # LLVM -if(LLVM_DIR OR APPLE) # local LLVM build - find_package(LLVM REQUIRED CONFIG) - message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") - message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") - add_definitions(${LLVM_DEFINITIONS}) - # TODO: bitwriter is needed only for evmcc - llvm_map_components_to_libnames(LLVM_LIBS core support mcjit x86asmparser x86codegen bitwriter ipo) -else() - # Workaround for Ubuntu broken LLVM package - message(STATUS "Using llvm-3.7-dev package from Ubuntu. If does not work, build LLVM and set -DLLVM_DIR=llvm-build/share/llvm/cmake") - execute_process(COMMAND llvm-config-3.7 --includedir OUTPUT_VARIABLE LLVM_INCLUDE_DIRS) - message(STATUS "LLVM include dirs: ${LLVM_INCLUDE_DIRS}") - set(LLVM_LIBS "-lLLVMBitWriter -lLLVMX86CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMX86AsmParser -lLLVMX86Desc -lLLVMX86Info -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMMCJIT -lLLVMExecutionEngine -lLLVMRuntimeDyld -lLLVMTarget -lLLVMRuntimeDyld -lLLVMObject -lLLVMMCParser -lLLVMBitReader -lLLVMMC -lLLVMMCDisassembler -lLLVMCore -lLLVMSupport -lz -lpthread -lffi -ltinfo -ldl -lm") - add_definitions(-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS) - link_directories(/usr/lib/llvm-3.7/lib) -endif() +find_package(LLVM REQUIRED CONFIG) +message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") +message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") +add_definitions(${LLVM_DEFINITIONS}) +llvm_map_components_to_libnames(LLVM_LIBS core support mcjit x86asmparser x86codegen ipo) get_filename_component(EVMJIT_INCLUDE_DIR include ABSOLUTE) From 4b5a036a6ba9b14ebc914819f6699477d2cf13b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Mon, 15 Jun 2015 14:43:15 +0200 Subject: [PATCH 06/20] Suppress LLVM compile warnings. --- evmjit/libevmjit/Cache.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/evmjit/libevmjit/Cache.h b/evmjit/libevmjit/Cache.h index 6b8457f4b..1d5927705 100644 --- a/evmjit/libevmjit/Cache.h +++ b/evmjit/libevmjit/Cache.h @@ -3,7 +3,9 @@ #include #include +#include "preprocessor/llvm_includes_start.h" #include +#include "preprocessor/llvm_includes_end.h" namespace llvm { From efd1ff7bb5f43cb56d420b1da84250b56937d7a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Mon, 15 Jun 2015 14:43:42 +0200 Subject: [PATCH 07/20] Update llvm::IRBuilder::CreateCall to new API version. Buildbot bump. --- evmjit/libevmjit/Arith256.cpp | 4 ++-- evmjit/libevmjit/Compiler.cpp | 2 +- evmjit/libevmjit/GasMeter.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/evmjit/libevmjit/Arith256.cpp b/evmjit/libevmjit/Arith256.cpp index 029eb9370..95ca2aee5 100644 --- a/evmjit/libevmjit/Arith256.cpp +++ b/evmjit/libevmjit/Arith256.cpp @@ -167,8 +167,8 @@ llvm::Function* Arith256::getDivFunc(llvm::Type* _type) m_builder.SetInsertPoint(mainBB); auto ctlzIntr = llvm::Intrinsic::getDeclaration(getModule(), llvm::Intrinsic::ctlz, _type); // both y and r are non-zero - auto yLz = m_builder.CreateCall2(ctlzIntr, yArg, m_builder.getInt1(true), "y.lz"); - auto rLz = m_builder.CreateCall2(ctlzIntr, r0, m_builder.getInt1(true), "r.lz"); + auto yLz = m_builder.CreateCall(ctlzIntr, {yArg, m_builder.getInt1(true)}, "y.lz"); + auto rLz = m_builder.CreateCall(ctlzIntr, {r0, m_builder.getInt1(true)}, "r.lz"); auto i0 = m_builder.CreateNUWSub(yLz, rLz, "i0"); auto y0 = m_builder.CreateShl(yArg, i0); m_builder.CreateBr(loopBB); diff --git a/evmjit/libevmjit/Compiler.cpp b/evmjit/libevmjit/Compiler.cpp index d5cb493ab..e49979294 100644 --- a/evmjit/libevmjit/Compiler.cpp +++ b/evmjit/libevmjit/Compiler.cpp @@ -148,7 +148,7 @@ std::unique_ptr Compiler::compile(code_iterator _begin, code_itera auto fp = m_builder.CreateCall(frameaddress, m_builder.getInt32(0), "fp"); m_builder.CreateStore(fp, jmpBufWords); auto stacksave = llvm::Intrinsic::getDeclaration(module.get(), llvm::Intrinsic::stacksave); - auto sp = m_builder.CreateCall(stacksave, "sp"); + auto sp = m_builder.CreateCall(stacksave, {}, "sp"); auto jmpBufSp = m_builder.CreateConstInBoundsGEP1_64(jmpBufWords, 2, "jmpBuf.sp"); m_builder.CreateStore(sp, jmpBufSp); auto setjmp = llvm::Intrinsic::getDeclaration(module.get(), llvm::Intrinsic::eh_sjlj_setjmp); diff --git a/evmjit/libevmjit/GasMeter.cpp b/evmjit/libevmjit/GasMeter.cpp index c0a2ed287..4cd053316 100644 --- a/evmjit/libevmjit/GasMeter.cpp +++ b/evmjit/libevmjit/GasMeter.cpp @@ -217,7 +217,7 @@ void GasMeter::countExp(llvm::Value* _exponent) // OPT: Can gas update be done in exp algorithm? auto ctlz = llvm::Intrinsic::getDeclaration(getModule(), llvm::Intrinsic::ctlz, Type::Word); - auto lz256 = m_builder.CreateCall2(ctlz, _exponent, m_builder.getInt1(false)); + auto lz256 = m_builder.CreateCall(ctlz, {_exponent, m_builder.getInt1(false)}); auto lz = m_builder.CreateTrunc(lz256, Type::Gas, "lz"); auto sigBits = m_builder.CreateSub(m_builder.getInt64(256), lz, "sigBits"); auto sigBytes = m_builder.CreateUDiv(m_builder.CreateAdd(sigBits, m_builder.getInt64(7)), m_builder.getInt64(8)); From 9ae15d5474d245ace0dc590bf9c24a2ebf5a55b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Tue, 16 Jun 2015 09:18:53 +0200 Subject: [PATCH 08/20] Set required LLVM version to 3.7. --- evmjit/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evmjit/CMakeLists.txt b/evmjit/CMakeLists.txt index fa9b08f48..5da512c99 100644 --- a/evmjit/CMakeLists.txt +++ b/evmjit/CMakeLists.txt @@ -16,7 +16,7 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") endif() # LLVM -find_package(LLVM REQUIRED CONFIG) +find_package(LLVM 3.7 REQUIRED CONFIG) message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") add_definitions(${LLVM_DEFINITIONS}) From 8ec447166fee8970eb8ce05813710a59890b8d0e Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 17 Jun 2015 17:45:04 +0200 Subject: [PATCH 09/20] Scenario Panel: UI changes --- mix/qml/Block.qml | 43 +++-- mix/qml/BlockChain.qml | 46 +++--- mix/qml/ScenarioButton.qml | 41 ++++- mix/qml/ScenarioExecution.qml | 13 +- mix/qml/ScenarioLoader.qml | 290 ++++++++++++++++++++-------------- 5 files changed, 279 insertions(+), 154 deletions(-) diff --git a/mix/qml/Block.qml b/mix/qml/Block.qml index 6fb274ccd..46689e0f2 100644 --- a/mix/qml/Block.qml +++ b/mix/qml/Block.qml @@ -21,6 +21,7 @@ ColumnLayout property int openedTr: 0 property int blockIndex property variant scenario + property string labelColor: "#414141" function calculateHeight() { @@ -41,18 +42,17 @@ ColumnLayout height = calculateHeight() } - - RowLayout { Layout.preferredHeight: trHeight Layout.preferredWidth: blockWidth id: rowHeader + Rectangle { - color: "#DEDCDC" Layout.preferredWidth: blockWidth Layout.preferredHeight: trHeight + color: "#DEDCDC" radius: 4 anchors.left: parent.left anchors.leftMargin: statusWidth + 5 @@ -60,12 +60,32 @@ ColumnLayout anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left anchors.leftMargin: horizontalMargin + color: "#adadad" text: { - if (status === "mined") + if (number === -2) + return qsTr("STARTING PARAMETERS") + else if (status === "mined") return qsTr("BLOCK") + " " + number else - return qsTr("BLOCK") + " pending" + return qsTr("PENDING TRANSACTIONS") + } + } + + Label + { + text: qsTr("EDIT") + color: "#1397da" + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + anchors.rightMargin: 14 + MouseArea + { + anchors.fill: parent + onClicked: + { + // load edit block panel + } } } } @@ -75,7 +95,6 @@ ColumnLayout { id: transactionRepeater model: transactions - RowLayout { id: rowTransaction @@ -99,7 +118,7 @@ ColumnLayout var p = log.param.get(i) logsText.text += p.name + " = " + p.value + " - indexed:" + p.indexed + "\n" } - else{ + else { logsText.text += "From : " + log.address + "\n" } } @@ -112,18 +131,18 @@ ColumnLayout { id: trSaveStatus Layout.preferredWidth: statusWidth - Layout.preferredHeight: trHeight + Layout.preferredHeight: parent.height color: "transparent" anchors.top: parent.top property bool saveStatus Image { + anchors.top: parent.top + anchors.topMargin: -7 id: saveStatusImage source: "qrc:/qml/img/recyclediscard@2x.png" width: statusWidth fillMode: Image.PreserveAspectFit - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter } Component.onCompleted: @@ -177,6 +196,7 @@ ColumnLayout Layout.preferredWidth: fromWidth elide: Text.ElideRight maximumLineCount: 1 + color: labelColor text: { if (index >= 0) return transactions.get(index).sender @@ -195,6 +215,7 @@ ColumnLayout return "" } elide: Text.ElideRight + color: labelColor maximumLineCount: 1 Layout.preferredWidth: toWidth } @@ -217,6 +238,7 @@ ColumnLayout id: returnValue elide: Text.ElideRight maximumLineCount: 1 + color: labelColor Layout.preferredWidth: valueWidth text: { if (index >= 0 && transactions.get(index).returned) @@ -237,6 +259,7 @@ ColumnLayout id: logs anchors.left: parent.left anchors.leftMargin: 10 + color: labelColor text: { if (index >= 0 && transactions.get(index).logs && transactions.get(index).logs.count) return transactions.get(index).logs.count diff --git a/mix/qml/BlockChain.qml b/mix/qml/BlockChain.qml index d3fad6fda..f6a56fb4f 100644 --- a/mix/qml/BlockChain.qml +++ b/mix/qml/BlockChain.qml @@ -20,7 +20,7 @@ ColumnLayout { signal chainChanged onChainChanged: { - reBuildNeeded.start() + rebuild.startBlinking() } onWidthChanged: @@ -55,12 +55,12 @@ ColumnLayout { previousWidth = width } - property int statusWidth: 30 + property int statusWidth: 40 property int fromWidth: 100 property int toWidth: 100 property int valueWidth: 200 - property int logsWidth: 50 - property int debugActionWidth: 50 + property int logsWidth: 40 + property int debugActionWidth: 40 property int horizontalMargin: 10 property int cellSpacing: 10 @@ -68,12 +68,12 @@ ColumnLayout { { id: header spacing: 0 - Layout.preferredHeight: 25 + Layout.preferredHeight: 30 Image { id: debugImage source: "qrc:/qml/img/recycleicon@2x.png" Layout.preferredWidth: statusWidth - Layout.preferredHeight: 25 + Layout.preferredHeight: parent.height fillMode: Image.PreserveAspectFit } Rectangle @@ -126,6 +126,19 @@ ColumnLayout { id: blockChainLayout width: parent.width spacing: 10 + + Block + { + scenario: blockChainPanel.model + Layout.preferredWidth: blockChainScrollView.width + Layout.preferredHeight: 60 + blockIndex: -1 + transactions: [] + status: "" + number: -2 + trHeight: 60 + } + Repeater // List of blocks { id: blockChainRepeater @@ -229,7 +242,7 @@ ColumnLayout { { if (ensureNotFuturetime.running) return; - reBuildNeeded.stop() + stopBlinking() var retBlocks = []; var bAdded = 0; for (var j = 0; j < model.blocks.length; j++) @@ -282,23 +295,8 @@ ColumnLayout { Layout.preferredHeight: 30 buttonShortcut: "" sourceImg: "qrc:/qml/img/recycleicon@2x.png" - Timer - { - id: reBuildNeeded - repeat: true - interval: 1000 - running: false - onTriggered: { - if (!parent.fillColor || parent.fillColor === "white") - parent.fillColor = "orange" - else - parent.fillColor = "white" - } - onRunningChanged: { - if (!running) - parent.fillColor = "white" - } - } + + } ScenarioButton { diff --git a/mix/qml/ScenarioButton.qml b/mix/qml/ScenarioButton.qml index 4dd7bc53f..7f8b5d202 100644 --- a/mix/qml/ScenarioButton.qml +++ b/mix/qml/ScenarioButton.qml @@ -11,13 +11,52 @@ Rectangle { property string fillColor signal clicked + function startBlinking() + { + blinkTimer.start() + } + + function stopBlinking() + { + blinkTimer.stop() + } + Rectangle { id: contentRectangle anchors.fill: parent border.color: "#cccccc" border.width: 1 radius: 4 - color: parent.fillColor ? parent.fillColor : "white" + color: "white" + property variant colorGradient: ["#FFFFFF", "#FFFEFC", "#FFFDF9", "#FFFCF7", "#FFFBF4", "#FFFAF2", "#FFF9EF", "#FFF8EC", "#FFF7EA", "#FFF6E7", "#FFF5E5", "#FFF5E2", "#FFF4E0", "#FFF3DD", "#FFF2DA", "#FFF1D8", "#FFF0D5", "#FFEFD3", "#FFEED0", "#FFEDCE", "#FFECCB", "#FFEBC8", "#FFEBC6", "#FFEAC3", "#FFE9C1", "#FFE8BE", "#FFE7BC", "#FFE6B9", "#FFE5B6", "#FFE4B4", "#FFE3B1", "#FFE2AF", "#FFE1AC", "#FFE1AA", "#FFE0A7", "#FFDFA4", "#FFDEA2", "#FFDD9F", "#FFDC9D", "#FFDB9A", "#FFDA97", "#FFD995", "#FFD892", "#FFD790", "#FFD78D", "#FFD68B", "#FFD588", "#FFD485", "#FFD383", "#FFD280", "#FFD17E", "#FFD07B", "#FFCF79", "#FFCE76", "#FFCD73", "#FFCD71", "#FFCC6E", "#FFCB6C", "#FFCA69", "#FFC967", "#FFC864", "#FFC761", "#FFC65F", "#FFC55C", "#FFC45A", "#FFC357", "#FFC355", "#FFC252", "#FFC14F", "#FFC04D", "#FFBF4A", "#FFBE48", "#FFBD45", "#FFBC42", "#FFBB40", "#FFBA3D", "#FFB93B", "#FFB938", "#FFB836", "#FFB733", "#FFB630", "#FFB52E", "#FFB42B", "#FFB329", "#FFB226", "#FFB124", "#FFB021", "#FFAF1E", "#FFAF1C", "#FFAE19", "#FFAD17", "#FFAC14", "#FFAB12", "#FFAA0F", "#FFA90C", "#FFA80A", "#FFA707", "#FFA605", "#FFA502", "#FFA500"] + + Timer + { + id: blinkTimer + repeat: true + interval: 40 + running: false + property int index: 0 + property int direction: 1 + onTriggered: { + index = index + direction + parent.color = parent.colorGradient[index] + if (index >= parent.colorGradient.length - 1) + direction = -1 + else if (index <= 0) + direction = 1 + } + onRunningChanged: { + if (!running) + { + parent.color = "white" + index = 0 + direction = 1 + } + } + } + + Image { id: debugImage anchors { diff --git a/mix/qml/ScenarioExecution.qml b/mix/qml/ScenarioExecution.qml index bc872bff7..85f1990c8 100644 --- a/mix/qml/ScenarioExecution.qml +++ b/mix/qml/ScenarioExecution.qml @@ -28,14 +28,23 @@ Rectangle { spacing: 10 ScenarioLoader { - height: 70 + height: 100 width: parent.width id: loader } + Connections + { + target: blockChain + onChainChanged: + { + loader.needSaveOrReload() + } + } + Rectangle { - width: parent.width + width: parent.parent.width height: 1 color: "#cccccc" } diff --git a/mix/qml/ScenarioLoader.qml b/mix/qml/ScenarioLoader.qml index 93f4f059b..dd67a6f0a 100644 --- a/mix/qml/ScenarioLoader.qml +++ b/mix/qml/ScenarioLoader.qml @@ -10,8 +10,9 @@ import "js/Debugger.js" as Debugger import "js/ErrorLocationFormater.js" as ErrorLocationFormater import "." -RowLayout +ColumnLayout { + id: blockChainSelector signal restored(variant scenario) signal saved(variant scenario) signal duplicated(variant scenario) @@ -22,154 +23,209 @@ RowLayout scenarioList.load() } - id: blockChainSelector - - Dialog { - id: newStateWin - modality: Qt.ApplicationModal - title: qsTr("New Project"); - - width: 320 - height: 120 + function needSaveOrReload() + { + editStatus.visible = true + } - visible: false + //anchors.margins: 10 + //width: parent.width + Rectangle + { + Layout.fillWidth: true + Layout.preferredHeight: 30 + color: "transparent" + Rectangle + { + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + color: "transparent" + Text + { + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + id: scenarioName + } - contentItem: Rectangle { - anchors.fill: parent - anchors.margins: 10 - RowLayout { + TextInput + { + id: scenarioNameEdit + visible: false anchors.verticalCenter: parent.verticalCenter - Text { - text: qsTr("Name:") + anchors.horizontalCenter: parent.horizontalCenter + Keys.onEnterPressed: + { + save() } - Rectangle + function edit() { - Layout.preferredWidth: 250 - Layout.preferredHeight: parent.height - border.width: 1 - border.color: "#cccccc" - TextInput - { - anchors.fill: parent - id: stateName - } + editIconRect.anchors.left = scenarioNameEdit.right + editStatus.parent.anchors.left = scenarioNameEdit.right + scenarioNameEdit.forceActiveFocus() + } + + function save() + { + editIconRect.anchors.left = scenarioName.right + editStatus.parent.anchors.left = scenarioName.right + scenarioName.text = scenarioNameEdit.text + scenarioName.visible = true + scenarioNameEdit.visible = false + projectModel.stateListModel.getState(scenarioList.currentIndex).title = scenarioName.text + projectModel.saveProjectFile() + saved(state) } } - RowLayout + + Connections { - anchors.bottom: parent.bottom - anchors.right: parent.right; - function acceptAndClose() + target: blockChainSelector + onLoaded: { - var item = projectModel.stateListModel.createDefaultState(); - item.title = stateName.text - projectModel.stateListModel.appendState(item) - projectModel.stateListModel.save() - close() - scenarioList.currentIndex = projectModel.stateListModel.count - 1 + scenarioName.text = scenario.title + scenarioNameEdit.text = scenario.title } + } - function close() - { - newStateWin.close() - stateName.text = "" + Rectangle + { + anchors.left: scenarioName.right + anchors.top: scenarioName.top + anchors.leftMargin: 2 + Layout.preferredWidth: 20 + Text { + id: editStatus + text: "*" + visible: false } + } - Button { - id: okButton; - enabled: stateName.text !== "" - text: qsTr("OK"); - onClicked: { - parent.acceptAndClose(); + Rectangle + { + id: editIconRect + anchors.left: scenarioName.right + anchors.leftMargin: 15 + Image { + source: "qrc:/qml/img/edit.png" + width: 10 + fillMode: Image.PreserveAspectFit + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + MouseArea + { + anchors.fill: parent + onClicked: + { + scenarioName.visible = !scenarioName.visible + scenarioNameEdit.visible = !scenarioNameEdit.visible + if (!scenarioNameEdit.visible) + scenarioNameEdit.save() + else + scenarioNameEdit.edit() + + } } } - Button { - text: qsTr("Cancel"); - onClicked: parent.close(); - } } } } - ComboBox + RowLayout { - id: scenarioList - model: projectModel.stateListModel - textRole: "title" - onCurrentIndexChanged: - { - restoreScenario.restore() - } + Layout.fillWidth: true + Layout.preferredHeight: 50 + spacing: 0 - function load() + Row { - var state = projectModel.stateListModel.getState(currentIndex) - loaded(state) - } - } + Layout.preferredWidth: 100 * 5 + Layout.preferredHeight: 50 + spacing: 0 - Row - { - Layout.preferredWidth: 100 * 4 - Layout.preferredHeight: 30 - spacing: 0 - ScenarioButton { - id: restoreScenario - width: 100 - height: 30 - buttonShortcut: "" - sourceImg: "qrc:/qml/img/restoreicon@2x.png" - onClicked: { - restore() - } - text: qsTr("Restore") - function restore() + ComboBox { - var state = projectModel.stateListModel.reloadStateFromFromProject(scenarioList.currentIndex) - restored(state) - loaded(state) + id: scenarioList + model: projectModel.stateListModel + textRole: "title" + height: 30 + onCurrentIndexChanged: + { + restoreScenario.restore() + } + + function load() + { + var state = projectModel.stateListModel.getState(currentIndex) + loaded(state) + } + } + + ScenarioButton { + id: restoreScenario + width: 100 + height: 30 + buttonShortcut: "" + sourceImg: "qrc:/qml/img/restoreicon@2x.png" + onClicked: { + restore() + } + text: qsTr("Restore") + function restore() + { + var state = projectModel.stateListModel.reloadStateFromFromProject(scenarioList.currentIndex) + if (state) + { + editStatus.visible = false + restored(state) + loaded(state) + } + } } - } - ScenarioButton { - id: saveScenario - text: qsTr("Save") - onClicked: { - projectModel.saveProjectFile() - saved(state) + ScenarioButton { + id: saveScenario + text: qsTr("Save") + onClicked: { + projectModel.saveProjectFile() + saved(state) + } + width: 100 + height: 30 + buttonShortcut: "" + sourceImg: "qrc:/qml/img/saveicon@2x.png" } - width: 100 - height: 30 - buttonShortcut: "" - sourceImg: "qrc:/qml/img/saveicon@2x.png" - } - ScenarioButton - { - id: duplicateScenario - text: qsTr("Duplicate") - onClicked: { - projectModel.stateListModel.duplicateState(scenarioList.currentIndex) - duplicated(state) + ScenarioButton + { + id: duplicateScenario + text: qsTr("Duplicate") + onClicked: { + projectModel.stateListModel.duplicateState(scenarioList.currentIndex) + duplicated(state) + } + width: 100 + height: 30 + buttonShortcut: "" + sourceImg: "qrc:/qml/img/duplicateicon@2x.png" } - width: 100 - height: 30 - buttonShortcut: "" - sourceImg: "qrc:/qml/img/duplicateicon@2x.png" - } - ScenarioButton { - id: addScenario - width: 100 - height: 30 - buttonShortcut: "" - sourceImg: "qrc:/qml/img/plus.png" - onClicked: { - newStateWin.open() + ScenarioButton { + id: addScenario + width: 100 + height: 30 + buttonShortcut: "" + sourceImg: "qrc:/qml/img/plus.png" + onClicked: { + var item = projectModel.stateListModel.createDefaultState(); + item.title = qsTr("New Scenario") + projectModel.stateListModel.appendState(item) + projectModel.stateListModel.save() + scenarioList.currentIndex = projectModel.stateListModel.count - 1 + scenarioNameEdit.edit() + } + text: qsTr("New") } - text: qsTr("New") } } - } From ec71a9c69ff1fb9fd7d8e31137570686b2313550 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 18 Jun 2015 12:38:09 +0200 Subject: [PATCH 10/20] - Scenario Panel UI changes --- libethereum/BlockChain.cpp | 2 +- mix/qml/Block.qml | 106 ++++++++++++++++------------------ mix/qml/BlockChain.qml | 24 ++++++-- mix/qml/ScenarioButton.qml | 3 +- mix/qml/ScenarioExecution.qml | 3 +- mix/qml/ScenarioLoader.qml | 44 +++++++++++++- 6 files changed, 115 insertions(+), 67 deletions(-) diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index 195f65f1d..36f2d3e11 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -391,7 +391,7 @@ ImportRoute BlockChain::import(bytes const& _block, OverlayDB const& _db, Import try #endif { - block = verifyBlock(_block, m_onBad); + block = verifyBlock(_block, m_onBad, _ir); } #if ETH_CATCH catch (Exception& ex) diff --git a/mix/qml/Block.qml b/mix/qml/Block.qml index 46689e0f2..8fc282246 100644 --- a/mix/qml/Block.qml +++ b/mix/qml/Block.qml @@ -47,7 +47,7 @@ ColumnLayout Layout.preferredHeight: trHeight Layout.preferredWidth: blockWidth id: rowHeader - + spacing: 0 Rectangle { Layout.preferredWidth: blockWidth @@ -55,7 +55,7 @@ ColumnLayout color: "#DEDCDC" radius: 4 anchors.left: parent.left - anchors.leftMargin: statusWidth + 5 + anchors.leftMargin: statusWidth Label { anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left @@ -99,6 +99,7 @@ ColumnLayout { id: rowTransaction Layout.preferredHeight: trHeight + spacing: 0 function displayContent() { logsText.text = "" @@ -138,7 +139,7 @@ ColumnLayout Image { anchors.top: parent.top - anchors.topMargin: -7 + anchors.topMargin: -10 id: saveStatusImage source: "qrc:/qml/img/recyclediscard@2x.png" width: statusWidth @@ -179,14 +180,27 @@ ColumnLayout color: "#DEDCDC" id: rowContentTr anchors.top: parent.top + + MouseArea + { + anchors.fill: parent + onDoubleClicked: + { + transactionDialog.stateAccounts = scenario.accounts + transactionDialog.execute = false + transactionDialog.open(index, blockIndex, transactions.get(index)) + } + } + ColumnLayout { anchors.top: parent.top + width: parent.width spacing: 10 RowLayout { anchors.top: parent.top - anchors.verticalCenter: parent.verticalCenter + Layout.fillWidth: true spacing: cellSpacing Text { @@ -275,59 +289,7 @@ ColumnLayout } } - Rectangle - { - Layout.preferredWidth: debugActionWidth - Layout.preferredHeight: trHeight - 10 - color: "transparent" - - Image { - source: "qrc:/qml/img/edit.png" - width: 18 - fillMode: Image.PreserveAspectFit - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - } - MouseArea - { - anchors.fill: parent - onClicked: - { - transactionDialog.stateAccounts = scenario.accounts - transactionDialog.execute = false - transactionDialog.open(index, blockIndex, transactions.get(index)) - } - } - } - - Rectangle - { - Layout.preferredWidth: debugActionWidth - Layout.preferredHeight: trHeight - 10 - color: "transparent" - Image { - id: debugImg - source: "qrc:/qml/img/rightarrow@2x.png" - width: statusWidth - fillMode: Image.PreserveAspectFit - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - visible: transactions.get(index).recordIndex !== undefined - } - MouseArea - { - anchors.fill: parent - onClicked: - { - if (transactions.get(index).recordIndex !== undefined) - { - debugTrRequested = [ blockIndex, index ] - clientModel.debugRecord(transactions.get(index).recordIndex); - } - } - } - } } RowLayout @@ -363,6 +325,38 @@ ColumnLayout } } } + + Rectangle + { + width: debugActionWidth + height: trHeight - 10 + anchors.left: rowContentTr.right + anchors.top: rowContentTr.top + anchors.leftMargin: -50 + color: "transparent" + + Image { + id: debugImg + source: "qrc:/qml/img/rightarrow@2x.png" + width: debugActionWidth + fillMode: Image.PreserveAspectFit + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + visible: transactions.get(index).recordIndex !== undefined + } + MouseArea + { + anchors.fill: parent + onClicked: + { + if (transactions.get(index).recordIndex !== undefined) + { + debugTrRequested = [ blockIndex, index ] + clientModel.debugRecord(transactions.get(index).recordIndex); + } + } + } + } } } } diff --git a/mix/qml/BlockChain.qml b/mix/qml/BlockChain.qml index f6a56fb4f..6467009da 100644 --- a/mix/qml/BlockChain.qml +++ b/mix/qml/BlockChain.qml @@ -18,6 +18,18 @@ ColumnLayout { property int previousWidth property variant debugTrRequested: [] signal chainChanged + signal chainReloaded + + Connections + { + target: codeModel + onContractRenamed: { + rebuild.startBlinking() + } + onNewContractCompiled: { + rebuild.startBlinking() + } + } onChainChanged: { rebuild.startBlinking() @@ -30,14 +42,14 @@ ColumnLayout { { fromWidth = 100 toWidth = 100 - valueWidth = 200 + valueWidth = 250 } else { var diff = (width - previousWidth) / 3; fromWidth = fromWidth + diff < 100 ? 100 : fromWidth + diff toWidth = toWidth + diff < 100 ? 100 : toWidth + diff - valueWidth = valueWidth + diff < 200 ? 200 : valueWidth + diff + valueWidth = valueWidth + diff < 250 ? 250 : valueWidth + diff } previousWidth = width } @@ -47,7 +59,7 @@ ColumnLayout { if (!scenario) return; if (model) - chainChanged() + rebuild.startBlinking() model = scenario blockModel.clear() for (var b in model.blocks) @@ -55,10 +67,10 @@ ColumnLayout { previousWidth = width } - property int statusWidth: 40 + property int statusWidth: 50 property int fromWidth: 100 property int toWidth: 100 - property int valueWidth: 200 + property int valueWidth: 250 property int logsWidth: 40 property int debugActionWidth: 40 property int horizontalMargin: 10 @@ -68,7 +80,7 @@ ColumnLayout { { id: header spacing: 0 - Layout.preferredHeight: 30 + Layout.preferredHeight: 40 Image { id: debugImage source: "qrc:/qml/img/recycleicon@2x.png" diff --git a/mix/qml/ScenarioButton.qml b/mix/qml/ScenarioButton.qml index 7f8b5d202..1577ec955 100644 --- a/mix/qml/ScenarioButton.qml +++ b/mix/qml/ScenarioButton.qml @@ -13,7 +13,8 @@ Rectangle { function startBlinking() { - blinkTimer.start() + if (!blinkTimer.running) + blinkTimer.start() } function stopBlinking() diff --git a/mix/qml/ScenarioExecution.qml b/mix/qml/ScenarioExecution.qml index 85f1990c8..3e9d8e089 100644 --- a/mix/qml/ScenarioExecution.qml +++ b/mix/qml/ScenarioExecution.qml @@ -52,7 +52,8 @@ Rectangle { Connections { target: loader - onLoaded: { + onLoaded: + { blockChain.load(scenario) } } diff --git a/mix/qml/ScenarioLoader.qml b/mix/qml/ScenarioLoader.qml index dd67a6f0a..9323300ab 100644 --- a/mix/qml/ScenarioLoader.qml +++ b/mix/qml/ScenarioLoader.qml @@ -17,6 +17,7 @@ ColumnLayout signal saved(variant scenario) signal duplicated(variant scenario) signal loaded(variant scenario) + signal renamed(variant scenario) spacing: 0 function init() { @@ -28,8 +29,6 @@ ColumnLayout editStatus.visible = true } - //anchors.margins: 10 - //width: parent.width Rectangle { Layout.fillWidth: true @@ -75,6 +74,9 @@ ColumnLayout projectModel.stateListModel.getState(scenarioList.currentIndex).title = scenarioName.text projectModel.saveProjectFile() saved(state) + scenarioList.model.get(scenarioList.currentIndex).title = scenarioName.text + scenarioList.currentIndex = scenarioList.currentIndex + renamed(projectModel.stateListModel.getState(scenarioList.currentIndex)) } } @@ -149,6 +151,7 @@ ColumnLayout model: projectModel.stateListModel textRole: "title" height: 30 + width: 150 onCurrentIndexChanged: { restoreScenario.restore() @@ -159,6 +162,43 @@ ColumnLayout var state = projectModel.stateListModel.getState(currentIndex) loaded(state) } + + style: ComboBoxStyle { + background: Rectangle { + color: "white" + border.color: "#cccccc" + border.width: 1 + radius: 4 + anchors.fill: parent + } + label: Rectangle { + anchors.fill: parent + color: "white" + Text { + id: comboLabel + maximumLineCount: 1 + elide: Text.ElideRight + width: parent.width + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + text: { + if (projectModel.stateListModel.getState(scenarioList.currentIndex)) + return projectModel.stateListModel.getState(scenarioList.currentIndex).title + else + return "" + } + Connections { + target: blockChainSelector + onLoaded: { + comboLabel.text = projectModel.stateListModel.getState(scenarioList.currentIndex).title + } + onRenamed: { + comboLabel.text = scenario.title + } + } + } + } + } } ScenarioButton { From f75e1fbdcdf29ac3c24739ebe647b9deda3ec0a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Thu, 18 Jun 2015 16:57:46 +0200 Subject: [PATCH 11/20] Eliminate undefied behavior in RLPStream. --- libdevcore/RLP.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libdevcore/RLP.cpp b/libdevcore/RLP.cpp index 846664cfd..330893c76 100644 --- a/libdevcore/RLP.cpp +++ b/libdevcore/RLP.cpp @@ -202,9 +202,7 @@ unsigned RLP::items() const RLPStream& RLPStream::appendRaw(bytesConstRef _s, unsigned _itemCount) { - unsigned os = m_out.size(); - m_out.resize(os + _s.size()); - memcpy(m_out.data() + os, _s.data(), _s.size()); + m_out.insert(m_out.end(), _s.begin(), _s.end()); noteAppended(_itemCount); return *this; } From 2b4ddf80ab9fd4c1c3ec0391e1e6fade749c7198 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 18 Jun 2015 17:38:26 +0200 Subject: [PATCH 12/20] Added fallback function to gas estimation and fixed mix gas estimation. Fixes #2156 --- mix/CodeModel.cpp | 54 ++++++++++++++++++++++++++--------- solc/CommandLineInterface.cpp | 5 ++++ solc/jsonCompiler.cpp | 2 ++ 3 files changed, 47 insertions(+), 14 deletions(-) diff --git a/mix/CodeModel.cpp b/mix/CodeModel.cpp index 1ca5d9160..a67d2b59c 100644 --- a/mix/CodeModel.cpp +++ b/mix/CodeModel.cpp @@ -374,29 +374,55 @@ void CodeModel::gasEstimation(solidity::CompilerStack const& _cs) dev::solidity::SourceUnit const& sourceUnit = _cs.getAST(*contractDefinition.getLocation().sourceName); AssemblyItems const* items = _cs.getRuntimeAssemblyItems(n); std::map gasCosts = GasEstimator::breakToStatementLevel(GasEstimator::structuralEstimation(*items, std::vector({&sourceUnit})), {&sourceUnit}); + + auto gasToString = [](GasMeter::GasConsumption const& _gas) + { + if (_gas.isInfinite) + return QString("0"); + else + return QString::fromStdString(toString(_gas.value)); + }; + + // Structural gas costs (per opcode) for (auto gasItem = gasCosts.begin(); gasItem != gasCosts.end(); ++gasItem) { SourceLocation const& location = gasItem->first->getLocation(); GasMeter::GasConsumption cost = gasItem->second; - std::stringstream v; - v << cost.value; - m_gasCostsMaps->push(sourceName, location.start, location.end, QString::fromStdString(v.str()), cost.isInfinite, GasMap::type::Statement); + m_gasCostsMaps->push(sourceName, location.start, location.end, gasToString(cost), cost.isInfinite, GasMap::type::Statement); } - if (contractDefinition.getConstructor() != nullptr) + eth::AssemblyItems const& runtimeAssembly = *_cs.getRuntimeAssemblyItems(n); + // Functional gas costs (per function, but also for accessors) + for (auto it: contractDefinition.getInterfaceFunctions()) { - GasMeter::GasConsumption cost = GasEstimator::functionalEstimation(*_cs.getRuntimeAssemblyItems(n), contractDefinition.getConstructor()->externalSignature()); - std::stringstream v; - v << cost.value; - m_gasCostsMaps->push(sourceName, contractDefinition.getConstructor()->getLocation().start, contractDefinition.getConstructor()->getLocation().end, QString::fromStdString(v.str()), cost.isInfinite, GasMap::type::Constructor); + if (!it.second->hasDeclaration()) + continue; + SourceLocation loc = it.second->getDeclaration().getLocation(); + GasMeter::GasConsumption cost = GasEstimator::functionalEstimation(runtimeAssembly, it.second->externalSignature()); + m_gasCostsMaps->push(sourceName, loc.start, loc.end, gasToString(cost), cost.isInfinite, GasMap::type::Function); } - - for (auto func: contractDefinition.getDefinedFunctions()) + if (auto const* fallback = contractDefinition.getFallbackFunction()) + { + SourceLocation loc = fallback->getLocation(); + GasMeter::GasConsumption cost = GasEstimator::functionalEstimation(runtimeAssembly, "INVALID"); + m_gasCostsMaps->push(sourceName, loc.start, loc.end, gasToString(cost), cost.isInfinite, GasMap::type::Function); + } + for (auto const& it: contractDefinition.getDefinedFunctions()) + { + if (it->isPartOfExternalInterface() || it->isConstructor()) + continue; + SourceLocation loc = it->getLocation(); + size_t entry = _cs.getFunctionEntryPoint(n, *it); + GasEstimator::GasConsumption cost = GasEstimator::GasConsumption::infinite(); + if (entry > 0) + cost = GasEstimator::functionalEstimation(runtimeAssembly, entry, *it); + m_gasCostsMaps->push(sourceName, loc.start, loc.end, gasToString(cost), cost.isInfinite, GasMap::type::Function); + } + if (auto const* constructor = contractDefinition.getConstructor()) { - GasMeter::GasConsumption cost = GasEstimator::functionalEstimation(*_cs.getRuntimeAssemblyItems(n), func->externalSignature()); - std::stringstream v; - v << cost.value; - m_gasCostsMaps->push(sourceName, func->getLocation().start, func->getLocation().end, QString::fromStdString(v.str()), cost.isInfinite, GasMap::type::Function); + SourceLocation loc = constructor->getLocation(); + GasMeter::GasConsumption cost = GasEstimator::functionalEstimation(*_cs.getAssemblyItems(n)); + m_gasCostsMaps->push(sourceName, loc.start, loc.end, gasToString(cost), cost.isInfinite, GasMap::type::Constructor); } } } diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index ec2a90033..c95f34f62 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -273,6 +273,11 @@ void CommandLineInterface::handleGasEstimation(string const& _contract) GasEstimator::GasConsumption gas = GasEstimator::functionalEstimation(*items, sig); cout << " " << sig << ":\t" << gas << endl; } + if (contract.getFallbackFunction()) + { + GasEstimator::GasConsumption gas = GasEstimator::functionalEstimation(*items, "INVALID"); + cout << " fallback:\t" << gas << endl; + } cout << "internal:" << endl; for (auto const& it: contract.getDefinedFunctions()) { diff --git a/solc/jsonCompiler.cpp b/solc/jsonCompiler.cpp index 7bde3e47c..340713b1d 100644 --- a/solc/jsonCompiler.cpp +++ b/solc/jsonCompiler.cpp @@ -91,6 +91,8 @@ Json::Value estimateGas(CompilerStack const& _compiler, string const& _contract) string sig = it.second->externalSignature(); externalFunctions[sig] = gasToJson(GasEstimator::functionalEstimation(*items, sig)); } + if (contract.getFallbackFunction()) + externalFunctions[""] = gasToJson(GasEstimator::functionalEstimation(*items, "INVALID")); gasEstimates["external"] = externalFunctions; Json::Value internalFunctions(Json::objectValue); for (auto const& it: contract.getDefinedFunctions()) From 5953778e3cdf4a0acb7f9430291db20de22c8bfd Mon Sep 17 00:00:00 2001 From: yann300 Date: Fri, 19 Jun 2015 10:34:30 +0200 Subject: [PATCH 13/20] ui changes --- mix/qml/Block.qml | 105 ++++++++++++++++++++++++------------- mix/qml/BlockChain.qml | 13 +++-- mix/qml/StateListModel.qml | 1 + mix/qml/WebPreview.qml | 4 +- 4 files changed, 77 insertions(+), 46 deletions(-) diff --git a/mix/qml/Block.qml b/mix/qml/Block.qml index 8fc282246..2f7d04a20 100644 --- a/mix/qml/Block.qml +++ b/mix/qml/Block.qml @@ -16,7 +16,7 @@ ColumnLayout property int number property int blockWidth: Layout.preferredWidth - statusWidth - horizontalMargin property int horizontalMargin: 10 - property int trHeight: 30 + property int trHeight: 35 spacing: 0 property int openedTr: 0 property int blockIndex @@ -42,6 +42,10 @@ ColumnLayout height = calculateHeight() } + DebuggerPaneStyle { + id: dbgStyle + } + RowLayout { Layout.preferredHeight: trHeight @@ -60,6 +64,7 @@ ColumnLayout anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left anchors.leftMargin: horizontalMargin + font.pointSize: dbgStyle.absoluteSize(1) color: "#adadad" text: { @@ -196,44 +201,61 @@ ColumnLayout { anchors.top: parent.top width: parent.width - spacing: 10 + spacing: 7 RowLayout { anchors.top: parent.top Layout.fillWidth: true spacing: cellSpacing - Text + Rectangle { - id: hash + Layout.preferredWidth: fromWidth anchors.left: parent.left anchors.leftMargin: horizontalMargin - Layout.preferredWidth: fromWidth - elide: Text.ElideRight - maximumLineCount: 1 - color: labelColor - text: { - if (index >= 0) - return transactions.get(index).sender - else - return "" + Text + { + id: hash + width: parent.width - 30 + elide: Text.ElideRight + anchors.verticalCenter: parent.verticalCenter + maximumLineCount: 1 + color: labelColor + font.pointSize: dbgStyle.absoluteSize(1) + font.bold: true + text: { + if (index >= 0) + return transactions.get(index).sender + else + return "" + } } } - Text + + Rectangle { - id: func - text: { - if (index >= 0) - parent.userFrienldyToken(transactions.get(index).label) - else - return "" - } - elide: Text.ElideRight - color: labelColor - maximumLineCount: 1 Layout.preferredWidth: toWidth + Text + { + id: func + text: { + if (index >= 0) + parent.parent.userFrienldyToken(transactions.get(index).label) + else + return "" + } + elide: Text.ElideRight + anchors.verticalCenter: parent.verticalCenter + color: labelColor + font.pointSize: dbgStyle.absoluteSize(1) + font.bold: true + maximumLineCount: 1 + width: parent.width + } } + + function userFrienldyToken(value) { if (value && value.indexOf("<") === 0) @@ -247,18 +269,25 @@ ColumnLayout return value } - Text + Rectangle { - id: returnValue - elide: Text.ElideRight - maximumLineCount: 1 - color: labelColor Layout.preferredWidth: valueWidth - text: { - if (index >= 0 && transactions.get(index).returned) - return transactions.get(index).returned - else - return "" + Text + { + id: returnValue + elide: Text.ElideRight + anchors.verticalCenter: parent.verticalCenter + maximumLineCount: 1 + color: labelColor + font.bold: true + font.pointSize: dbgStyle.absoluteSize(1) + width: parent.width -30 + text: { + if (index >= 0 && transactions.get(index).returned) + return transactions.get(index).returned + else + return "" + } } } @@ -272,8 +301,11 @@ ColumnLayout { id: logs anchors.left: parent.left + anchors.verticalCenter: parent.verticalCenter anchors.leftMargin: 10 color: labelColor + font.bold: true + font.pointSize: dbgStyle.absoluteSize(1) text: { if (index >= 0 && transactions.get(index).logs && transactions.get(index).logs.count) return transactions.get(index).logs.count @@ -288,8 +320,6 @@ ColumnLayout } } } - - } RowLayout @@ -329,8 +359,9 @@ ColumnLayout Rectangle { width: debugActionWidth - height: trHeight - 10 + height: trHeight anchors.left: rowContentTr.right + anchors.topMargin: -6 anchors.top: rowContentTr.top anchors.leftMargin: -50 color: "transparent" diff --git a/mix/qml/BlockChain.qml b/mix/qml/BlockChain.qml index 6467009da..b7411de16 100644 --- a/mix/qml/BlockChain.qml +++ b/mix/qml/BlockChain.qml @@ -40,16 +40,16 @@ ColumnLayout { if (width <= 630 || previousWidth <= 630) { - fromWidth = 100 + fromWidth = 150 toWidth = 100 - valueWidth = 250 + valueWidth = 200 } else { var diff = (width - previousWidth) / 3; - fromWidth = fromWidth + diff < 100 ? 100 : fromWidth + diff + fromWidth = fromWidth + diff < 150 ? 150 : fromWidth + diff toWidth = toWidth + diff < 100 ? 100 : toWidth + diff - valueWidth = valueWidth + diff < 250 ? 250 : valueWidth + diff + valueWidth = valueWidth + diff < 200 ? 200 : valueWidth + diff } previousWidth = width } @@ -68,9 +68,9 @@ ColumnLayout { } property int statusWidth: 50 - property int fromWidth: 100 + property int fromWidth: 150 property int toWidth: 100 - property int valueWidth: 250 + property int valueWidth: 200 property int logsWidth: 40 property int debugActionWidth: 40 property int horizontalMargin: 10 @@ -422,7 +422,6 @@ ColumnLayout { return; } } - // tr is not in the list. var itemTr = TransactionHelper.defaultTransaction() itemTr.saveStatus = false diff --git a/mix/qml/StateListModel.qml b/mix/qml/StateListModel.qml index 992113cc6..26817441c 100644 --- a/mix/qml/StateListModel.qml +++ b/mix/qml/StateListModel.qml @@ -256,6 +256,7 @@ Item { if (!_secret) _secret = clientModel.newSecret(); var address = clientModel.address(_secret); + console.log(address); var name = qsTr("Account") + "-" + address.substring(0, 4); return { name: name, secret: _secret, balance: QEtherHelper.createEther(_balance, _unit), address: address }; } diff --git a/mix/qml/WebPreview.qml b/mix/qml/WebPreview.qml index e4d0b61a5..c45f2cab4 100644 --- a/mix/qml/WebPreview.qml +++ b/mix/qml/WebPreview.qml @@ -89,10 +89,10 @@ Item { } } - Connections { + /*Connections { target: clientModel onRunComplete: reload(); - } + }*/ Connections { target: codeModel From 56f68beb81b6de0bc2d5db153f6ca230f06fab36 Mon Sep 17 00:00:00 2001 From: yann300 Date: Fri, 19 Jun 2015 16:55:19 +0200 Subject: [PATCH 14/20] ui changes --- mix/qml/Block.qml | 10 +- mix/qml/BlockChain.qml | 261 +++++++++++++++++++++---------------- mix/qml/ScenarioButton.qml | 37 +++++- mix/qml/ScenarioLoader.qml | 259 ++++++++++++++++++++++-------------- 4 files changed, 347 insertions(+), 220 deletions(-) diff --git a/mix/qml/Block.qml b/mix/qml/Block.qml index 2f7d04a20..796518f11 100644 --- a/mix/qml/Block.qml +++ b/mix/qml/Block.qml @@ -57,7 +57,6 @@ ColumnLayout Layout.preferredWidth: blockWidth Layout.preferredHeight: trHeight color: "#DEDCDC" - radius: 4 anchors.left: parent.left anchors.leftMargin: statusWidth Label { @@ -141,13 +140,14 @@ ColumnLayout color: "transparent" anchors.top: parent.top property bool saveStatus - Image { anchors.top: parent.top - anchors.topMargin: -10 + anchors.left: parent.left + anchors.leftMargin: -9 + anchors.topMargin: -9 id: saveStatusImage source: "qrc:/qml/img/recyclediscard@2x.png" - width: statusWidth + width: statusWidth + 20 fillMode: Image.PreserveAspectFit } @@ -206,7 +206,7 @@ ColumnLayout { anchors.top: parent.top Layout.fillWidth: true - spacing: cellSpacing + //spacing: cellSpacing Rectangle { Layout.preferredWidth: fromWidth diff --git a/mix/qml/BlockChain.qml b/mix/qml/BlockChain.qml index b7411de16..ed1c4a4ad 100644 --- a/mix/qml/BlockChain.qml +++ b/mix/qml/BlockChain.qml @@ -67,7 +67,7 @@ ColumnLayout { previousWidth = width } - property int statusWidth: 50 + property int statusWidth: 30 property int fromWidth: 150 property int toWidth: 100 property int valueWidth: 200 @@ -80,13 +80,20 @@ ColumnLayout { { id: header spacing: 0 - Layout.preferredHeight: 40 - Image { - id: debugImage - source: "qrc:/qml/img/recycleicon@2x.png" + Layout.preferredHeight: 30 + Rectangle + { Layout.preferredWidth: statusWidth Layout.preferredHeight: parent.height - fillMode: Image.PreserveAspectFit + color: "transparent" + Image { + id: debugImage + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + source: "qrc:/qml/img/recycleicon@2x.png" + width: statusWidth + 20 + fillMode: Image.PreserveAspectFit + } } Rectangle { @@ -96,7 +103,7 @@ ColumnLayout { anchors.verticalCenter: parent.verticalCenter text: "From" anchors.left: parent.left - anchors.leftMargin: horizontalMargin + 5 + anchors.leftMargin: horizontalMargin } } Label @@ -243,143 +250,171 @@ ColumnLayout { Layout.preferredWidth: parent.width RowLayout { - width: 4 * 100 + anchors.horizontalCenter: parent.horizontalCenter anchors.top: parent.top anchors.topMargin: 10 - spacing: 0 - ScenarioButton { - id: rebuild - text: qsTr("Rebuild") - onClicked: - { - if (ensureNotFuturetime.running) - return; - stopBlinking() - var retBlocks = []; - var bAdded = 0; - for (var j = 0; j < model.blocks.length; j++) + spacing: 20 + + Rectangle { + Layout.preferredWidth: 100 + Layout.preferredHeight: 30 + + ScenarioButton { + id: rebuild + text: qsTr("Rebuild") + width: 100 + height: 30 + roundLeft: true + roundRight: true + onClicked: { - var b = model.blocks[j]; - var block = { - hash: b.hash, - number: b.number, - transactions: [], - status: b.status - } - for (var k = 0; k < model.blocks[j].transactions.length; k++) + if (ensureNotFuturetime.running) + return; + stopBlinking() + var retBlocks = []; + var bAdded = 0; + for (var j = 0; j < model.blocks.length; j++) { - if (blockModel.get(j).transactions.get(k).saveStatus) + var b = model.blocks[j]; + var block = { + hash: b.hash, + number: b.number, + transactions: [], + status: b.status + } + for (var k = 0; k < model.blocks[j].transactions.length; k++) + { + if (blockModel.get(j).transactions.get(k).saveStatus) + { + var tr = model.blocks[j].transactions[k] + tr.saveStatus = true + block.transactions.push(tr); + } + + } + if (block.transactions.length > 0) { - var tr = model.blocks[j].transactions[k] - tr.saveStatus = true - block.transactions.push(tr); + bAdded++ + block.number = bAdded + block.status = "mined" + retBlocks.push(block) } } - if (block.transactions.length > 0) + if (retBlocks.length === 0) + retBlocks.push(projectModel.stateListModel.createEmptyBlock()) + else { - bAdded++ - block.number = bAdded - block.status = "mined" - retBlocks.push(block) + var last = retBlocks[retBlocks.length - 1] + last.number = -1 + last.status = "pending" } - } - if (retBlocks.length === 0) - retBlocks.push(projectModel.stateListModel.createEmptyBlock()) - else - { - var last = retBlocks[retBlocks.length - 1] - last.number = -1 - last.status = "pending" - } - - model.blocks = retBlocks - blockModel.clear() - for (var j = 0; j < model.blocks.length; j++) - blockModel.append(model.blocks[j]) + model.blocks = retBlocks + blockModel.clear() + for (var j = 0; j < model.blocks.length; j++) + blockModel.append(model.blocks[j]) - ensureNotFuturetime.start() - clientModel.setupScenario(model); + ensureNotFuturetime.start() + clientModel.setupScenario(model); + } + buttonShortcut: "" + sourceImg: "qrc:/qml/img/recycleicon@2x.png" } - - Layout.preferredWidth: 100 - Layout.preferredHeight: 30 - buttonShortcut: "" - sourceImg: "qrc:/qml/img/recycleicon@2x.png" + } - } + Rectangle + { + Layout.preferredWidth: 200 + Layout.preferredHeight: 30 + color: "transparent" - ScenarioButton { - id: addTransaction - text: qsTr("Add Transaction") - onClicked: - { - var lastBlock = model.blocks[model.blocks.length - 1]; - if (lastBlock.status === "mined") + ScenarioButton { + id: addTransaction + text: qsTr("Add Tx") + onClicked: { - var newblock = projectModel.stateListModel.createEmptyBlock() - blockModel.appendBlock(newblock) - model.blocks.push(newblock); - } + var lastBlock = model.blocks[model.blocks.length - 1]; + if (lastBlock.status === "mined") + { + var newblock = projectModel.stateListModel.createEmptyBlock() + blockModel.appendBlock(newblock) + model.blocks.push(newblock); + } - var item = TransactionHelper.defaultTransaction() - transactionDialog.stateAccounts = model.accounts - transactionDialog.execute = true - transactionDialog.open(model.blocks[model.blocks.length - 1].transactions.length, model.blocks.length - 1, item) + var item = TransactionHelper.defaultTransaction() + transactionDialog.stateAccounts = model.accounts + transactionDialog.execute = true + transactionDialog.open(model.blocks[model.blocks.length - 1].transactions.length, model.blocks.length - 1, item) + } + width: 100 + height: 30 + buttonShortcut: "" + sourceImg: "qrc:/qml/img/sendtransactionicon@2x.png" + roundLeft: true + roundRight: false } - Layout.preferredWidth: 100 - Layout.preferredHeight: 30 - buttonShortcut: "" - sourceImg: "qrc:/qml/img/sendtransactionicon@2x.png" - } - Timer - { - id: ensureNotFuturetime - interval: 1000 - repeat: false - running: false - } + Timer + { + id: ensureNotFuturetime + interval: 1000 + repeat: false + running: false + } - ScenarioButton { - id: addBlockBtn - text: qsTr("Add Block") - onClicked: + Rectangle { - if (ensureNotFuturetime.running) - return - if (clientModel.mining || clientModel.running) - return - if (model.blocks.length > 0) + width: 1 + height: parent.height + anchors.right: addBlockBtn.left + color: "#ededed" + } + + ScenarioButton { + id: addBlockBtn + text: qsTr("Add Block..") + anchors.left: addTransaction.right + roundLeft: false + roundRight: true + onClicked: { - var lastBlock = model.blocks[model.blocks.length - 1] - if (lastBlock.status === "pending") + if (ensureNotFuturetime.running) + return + if (clientModel.mining || clientModel.running) + return + if (model.blocks.length > 0) { - ensureNotFuturetime.start() - clientModel.mine() + var lastBlock = model.blocks[model.blocks.length - 1] + if (lastBlock.status === "pending") + { + ensureNotFuturetime.start() + clientModel.mine() + } + else + addNewBlock() } else addNewBlock() + } - else - addNewBlock() - } + function addNewBlock() + { + var block = projectModel.stateListModel.createEmptyBlock() + model.blocks.push(block) + blockModel.appendBlock(block) + } + width: 100 + height: 30 - function addNewBlock() - { - var block = projectModel.stateListModel.createEmptyBlock() - model.blocks.push(block) - blockModel.appendBlock(block) + buttonShortcut: "" + sourceImg: "qrc:/qml/img/addblock@2x.png" } - Layout.preferredWidth: 100 - Layout.preferredHeight: 30 - buttonShortcut: "" - sourceImg: "qrc:/qml/img/addblock@2x.png" } + Connections { target: clientModel @@ -447,7 +482,7 @@ ColumnLayout { ScenarioButton { id: newAccount - text: qsTr("New Account") + text: qsTr("New Account..") onClicked: { model.accounts.push(projectModel.stateListModel.newAccount("1000000", QEther.Ether)) } @@ -455,6 +490,8 @@ ColumnLayout { Layout.preferredHeight: 30 buttonShortcut: "" sourceImg: "qrc:/qml/img/newaccounticon@2x.png" + roundLeft: true + roundRight: true } } } diff --git a/mix/qml/ScenarioButton.qml b/mix/qml/ScenarioButton.qml index 1577ec955..d4beaefaa 100644 --- a/mix/qml/ScenarioButton.qml +++ b/mix/qml/ScenarioButton.qml @@ -2,6 +2,7 @@ import QtQuick 2.2 import QtQuick.Controls 1.1 import QtQuick.Layouts 1.0 import QtQuick.Controls.Styles 1.1 +import QtGraphicalEffects 1.0 Rectangle { id: buttonActionContainer @@ -9,6 +10,8 @@ Rectangle { property string buttonShortcut property string sourceImg property string fillColor + property alias roundLeft: left.visible + property alias roundRight: right.visible signal clicked function startBlinking() @@ -22,12 +25,19 @@ Rectangle { blinkTimer.stop() } + Rectangle + { + id: left + width: 10 + height: parent.height + anchors.left: parent.left + anchors.leftMargin: -8 + radius: 15 + } + Rectangle { id: contentRectangle anchors.fill: parent - border.color: "#cccccc" - border.width: 1 - radius: 4 color: "white" property variant colorGradient: ["#FFFFFF", "#FFFEFC", "#FFFDF9", "#FFFCF7", "#FFFBF4", "#FFFAF2", "#FFF9EF", "#FFF8EC", "#FFF7EA", "#FFF6E7", "#FFF5E5", "#FFF5E2", "#FFF4E0", "#FFF3DD", "#FFF2DA", "#FFF1D8", "#FFF0D5", "#FFEFD3", "#FFEED0", "#FFEDCE", "#FFECCB", "#FFEBC8", "#FFEBC6", "#FFEAC3", "#FFE9C1", "#FFE8BE", "#FFE7BC", "#FFE6B9", "#FFE5B6", "#FFE4B4", "#FFE3B1", "#FFE2AF", "#FFE1AC", "#FFE1AA", "#FFE0A7", "#FFDFA4", "#FFDEA2", "#FFDD9F", "#FFDC9D", "#FFDB9A", "#FFDA97", "#FFD995", "#FFD892", "#FFD790", "#FFD78D", "#FFD68B", "#FFD588", "#FFD485", "#FFD383", "#FFD280", "#FFD17E", "#FFD07B", "#FFCF79", "#FFCE76", "#FFCD73", "#FFCD71", "#FFCC6E", "#FFCB6C", "#FFCA69", "#FFC967", "#FFC864", "#FFC761", "#FFC65F", "#FFC55C", "#FFC45A", "#FFC357", "#FFC355", "#FFC252", "#FFC14F", "#FFC04D", "#FFBF4A", "#FFBE48", "#FFBD45", "#FFBC42", "#FFBB40", "#FFBA3D", "#FFB93B", "#FFB938", "#FFB836", "#FFB733", "#FFB630", "#FFB52E", "#FFB42B", "#FFB329", "#FFB226", "#FFB124", "#FFB021", "#FFAF1E", "#FFAF1C", "#FFAE19", "#FFAD17", "#FFAC14", "#FFAB12", "#FFAA0F", "#FFA90C", "#FFA80A", "#FFA707", "#FFA605", "#FFA502", "#FFA500"] @@ -41,6 +51,9 @@ Rectangle { property int direction: 1 onTriggered: { index = index + direction + var color = parent.colorGradient[index] + left.color = color + right.color = color parent.color = parent.colorGradient[index] if (index >= parent.colorGradient.length - 1) direction = -1 @@ -50,6 +63,8 @@ Rectangle { onRunningChanged: { if (!running) { + left.color = "white" + right.color = "white" parent.color = "white" index = 0 direction = 1 @@ -57,7 +72,6 @@ Rectangle { } } - Image { id: debugImage anchors { @@ -65,12 +79,11 @@ Rectangle { right: parent.right top: parent.top bottom: parent.bottom - bottomMargin: debugImg.pressed ? 0 : 2; + bottomMargin: debugImg.pressed ? -2 : 0; topMargin: debugImg.pressed ? 2 : 0; } source: sourceImg fillMode: Image.PreserveAspectFit - height: 30 } Button { @@ -93,12 +106,22 @@ Rectangle { } } + Rectangle + { + id: right + width: 10 + height: parent.height + anchors.left: contentRectangle.right + anchors.leftMargin: -8 + radius: 15 + } + Rectangle { anchors.top: contentRectangle.bottom anchors.topMargin: 15 width: parent.width - Text + Label { text: buttonActionContainer.text anchors.centerIn: parent diff --git a/mix/qml/ScenarioLoader.qml b/mix/qml/ScenarioLoader.qml index 9323300ab..bc26b103d 100644 --- a/mix/qml/ScenarioLoader.qml +++ b/mix/qml/ScenarioLoader.qml @@ -39,11 +39,12 @@ ColumnLayout anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: parent.horizontalCenter color: "transparent" - Text + Label { anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: parent.horizontalCenter id: scenarioName + font.bold: true } TextInput @@ -135,7 +136,8 @@ ColumnLayout RowLayout { - Layout.fillWidth: true + Layout.preferredWidth: 560 + anchors.horizontalCenter: parent.horizontalCenter Layout.preferredHeight: 50 spacing: 0 @@ -143,128 +145,193 @@ ColumnLayout { Layout.preferredWidth: 100 * 5 Layout.preferredHeight: 50 - spacing: 0 + spacing: 15 - ComboBox + Rectangle { - id: scenarioList - model: projectModel.stateListModel - textRole: "title" + color: "transparent" + width: 251 height: 30 - width: 150 - onCurrentIndexChanged: + Rectangle { - restoreScenario.restore() + width: 10 + height: parent.height + anchors.right: scenarioList.left + anchors.rightMargin: -8 + radius: 15 } - function load() + ComboBox { - var state = projectModel.stateListModel.getState(currentIndex) - loaded(state) - } + id: scenarioList + model: projectModel.stateListModel + textRole: "title" + height: parent.height + width: 150 + onCurrentIndexChanged: + { + restoreScenario.restore() + } - style: ComboBoxStyle { - background: Rectangle { - color: "white" - border.color: "#cccccc" - border.width: 1 - radius: 4 - anchors.fill: parent + function load() + { + var state = projectModel.stateListModel.getState(currentIndex) + loaded(state) } - label: Rectangle { - anchors.fill: parent - color: "white" - Text { - id: comboLabel - maximumLineCount: 1 - elide: Text.ElideRight - width: parent.width - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - text: { - if (projectModel.stateListModel.getState(scenarioList.currentIndex)) - return projectModel.stateListModel.getState(scenarioList.currentIndex).title - else - return "" - } - Connections { - target: blockChainSelector - onLoaded: { - comboLabel.text = projectModel.stateListModel.getState(scenarioList.currentIndex).title + + style: ComboBoxStyle { + background: Rectangle { + color: "white" + anchors.fill: parent + } + label: Rectangle { + anchors.fill: parent + color: "white" + Label { + id: comboLabel + maximumLineCount: 1 + elide: Text.ElideRight + width: parent.width + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + text: { + if (projectModel.stateListModel.getState(scenarioList.currentIndex)) + return projectModel.stateListModel.getState(scenarioList.currentIndex).title + else + return "" } - onRenamed: { - comboLabel.text = scenario.title + Connections { + target: blockChainSelector + onLoaded: { + comboLabel.text = projectModel.stateListModel.getState(scenarioList.currentIndex).title + } + onRenamed: { + comboLabel.text = scenario.title + } } } } } } + + Rectangle + { + width: 1 + height: parent.height + anchors.right: addScenario.left + color: "#ededed" + } + + ScenarioButton { + id: addScenario + anchors.left: scenarioList.right + width: 100 + height: parent.height + buttonShortcut: "" + sourceImg: "qrc:/qml/img/restoreicon@2x.png" + onClicked: { + var item = projectModel.stateListModel.createDefaultState(); + item.title = qsTr("New Scenario") + projectModel.stateListModel.appendState(item) + projectModel.stateListModel.save() + scenarioList.currentIndex = projectModel.stateListModel.count - 1 + scenarioNameEdit.edit() + } + text: qsTr("New..") + roundRight: true + roundLeft: false + } } - ScenarioButton { - id: restoreScenario - width: 100 + + Rectangle + { + width: 100 * 3 height: 30 - buttonShortcut: "" - sourceImg: "qrc:/qml/img/restoreicon@2x.png" - onClicked: { - restore() - } - text: qsTr("Restore") - function restore() + color: "transparent" + + Rectangle { - var state = projectModel.stateListModel.reloadStateFromFromProject(scenarioList.currentIndex) - if (state) + width: 10 + height: parent.height + anchors.right: restoreScenario.left + anchors.rightMargin: -4 + radius: 15 + } + + ScenarioButton { + id: restoreScenario + width: 100 + height: parent.height + buttonShortcut: "" + sourceImg: "qrc:/qml/img/restoreicon@2x.png" + onClicked: { + restore() + } + text: qsTr("Restore") + function restore() { - editStatus.visible = false - restored(state) - loaded(state) + var state = projectModel.stateListModel.reloadStateFromFromProject(scenarioList.currentIndex) + if (state) + { + editStatus.visible = false + restored(state) + loaded(state) + } } + roundRight: false + roundLeft: true } - } - ScenarioButton { - id: saveScenario - text: qsTr("Save") - onClicked: { - projectModel.saveProjectFile() - saved(state) + + Rectangle + { + width: 1 + height: parent.height + anchors.right: saveScenario.left + color: "#ededed" } - width: 100 - height: 30 - buttonShortcut: "" - sourceImg: "qrc:/qml/img/saveicon@2x.png" - } - ScenarioButton - { - id: duplicateScenario - text: qsTr("Duplicate") - onClicked: { - projectModel.stateListModel.duplicateState(scenarioList.currentIndex) - duplicated(state) + ScenarioButton { + id: saveScenario + anchors.left: restoreScenario.right + text: qsTr("Save") + onClicked: { + projectModel.saveProjectFile() + saved(state) + } + width: 100 + height: parent.height + buttonShortcut: "" + sourceImg: "qrc:/qml/img/saveicon@2x.png" + roundRight: false + roundLeft: false } - width: 100 - height: 30 - buttonShortcut: "" - sourceImg: "qrc:/qml/img/duplicateicon@2x.png" - } - ScenarioButton { - id: addScenario - width: 100 - height: 30 - buttonShortcut: "" - sourceImg: "qrc:/qml/img/plus.png" - onClicked: { - var item = projectModel.stateListModel.createDefaultState(); - item.title = qsTr("New Scenario") - projectModel.stateListModel.appendState(item) - projectModel.stateListModel.save() - scenarioList.currentIndex = projectModel.stateListModel.count - 1 - scenarioNameEdit.edit() + Rectangle + { + width: 1 + height: parent.height + anchors.right: duplicateScenario.left + color: "#ededed" + } + + ScenarioButton + { + id: duplicateScenario + anchors.left: saveScenario.right + text: qsTr("Duplicate") + onClicked: { + projectModel.stateListModel.duplicateState(scenarioList.currentIndex) + duplicated(state) + } + width: 100 + height: parent.height + buttonShortcut: "" + sourceImg: "qrc:/qml/img/duplicateicon@2x.png" + roundRight: true + roundLeft: false } - text: qsTr("New") } } } From ce3a05f8f3824e046b84978ccd70c57afa9bbc33 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 19 Jun 2015 20:51:09 +0200 Subject: [PATCH 15/20] mv BlockTestsFiller -> BlockchainTestsFiller --- .../bcGasPricerTestFiller.json | 0 .../bcInvalidHeaderTestFiller.json | 0 .../bcRPC_API_TestFiller.json | 0 .../bcTotalDifficultyTestFiller.json | 0 .../bcUncleHeaderValiditiyFiller.json | 0 .../bcUncleTestFiller.json | 0 .../bcValidBlockTestFiller.json | 0 .../bcWalletTestFiller.json | 0 8 files changed, 0 insertions(+), 0 deletions(-) rename test/libethereum/{BlockTestsFiller => BlockchainTestsFiller}/bcGasPricerTestFiller.json (100%) rename test/libethereum/{BlockTestsFiller => BlockchainTestsFiller}/bcInvalidHeaderTestFiller.json (100%) rename test/libethereum/{BlockTestsFiller => BlockchainTestsFiller}/bcRPC_API_TestFiller.json (100%) rename test/libethereum/{BlockTestsFiller => BlockchainTestsFiller}/bcTotalDifficultyTestFiller.json (100%) rename test/libethereum/{BlockTestsFiller => BlockchainTestsFiller}/bcUncleHeaderValiditiyFiller.json (100%) rename test/libethereum/{BlockTestsFiller => BlockchainTestsFiller}/bcUncleTestFiller.json (100%) rename test/libethereum/{BlockTestsFiller => BlockchainTestsFiller}/bcValidBlockTestFiller.json (100%) rename test/libethereum/{BlockTestsFiller => BlockchainTestsFiller}/bcWalletTestFiller.json (100%) diff --git a/test/libethereum/BlockTestsFiller/bcGasPricerTestFiller.json b/test/libethereum/BlockchainTestsFiller/bcGasPricerTestFiller.json similarity index 100% rename from test/libethereum/BlockTestsFiller/bcGasPricerTestFiller.json rename to test/libethereum/BlockchainTestsFiller/bcGasPricerTestFiller.json diff --git a/test/libethereum/BlockTestsFiller/bcInvalidHeaderTestFiller.json b/test/libethereum/BlockchainTestsFiller/bcInvalidHeaderTestFiller.json similarity index 100% rename from test/libethereum/BlockTestsFiller/bcInvalidHeaderTestFiller.json rename to test/libethereum/BlockchainTestsFiller/bcInvalidHeaderTestFiller.json diff --git a/test/libethereum/BlockTestsFiller/bcRPC_API_TestFiller.json b/test/libethereum/BlockchainTestsFiller/bcRPC_API_TestFiller.json similarity index 100% rename from test/libethereum/BlockTestsFiller/bcRPC_API_TestFiller.json rename to test/libethereum/BlockchainTestsFiller/bcRPC_API_TestFiller.json diff --git a/test/libethereum/BlockTestsFiller/bcTotalDifficultyTestFiller.json b/test/libethereum/BlockchainTestsFiller/bcTotalDifficultyTestFiller.json similarity index 100% rename from test/libethereum/BlockTestsFiller/bcTotalDifficultyTestFiller.json rename to test/libethereum/BlockchainTestsFiller/bcTotalDifficultyTestFiller.json diff --git a/test/libethereum/BlockTestsFiller/bcUncleHeaderValiditiyFiller.json b/test/libethereum/BlockchainTestsFiller/bcUncleHeaderValiditiyFiller.json similarity index 100% rename from test/libethereum/BlockTestsFiller/bcUncleHeaderValiditiyFiller.json rename to test/libethereum/BlockchainTestsFiller/bcUncleHeaderValiditiyFiller.json diff --git a/test/libethereum/BlockTestsFiller/bcUncleTestFiller.json b/test/libethereum/BlockchainTestsFiller/bcUncleTestFiller.json similarity index 100% rename from test/libethereum/BlockTestsFiller/bcUncleTestFiller.json rename to test/libethereum/BlockchainTestsFiller/bcUncleTestFiller.json diff --git a/test/libethereum/BlockTestsFiller/bcValidBlockTestFiller.json b/test/libethereum/BlockchainTestsFiller/bcValidBlockTestFiller.json similarity index 100% rename from test/libethereum/BlockTestsFiller/bcValidBlockTestFiller.json rename to test/libethereum/BlockchainTestsFiller/bcValidBlockTestFiller.json diff --git a/test/libethereum/BlockTestsFiller/bcWalletTestFiller.json b/test/libethereum/BlockchainTestsFiller/bcWalletTestFiller.json similarity index 100% rename from test/libethereum/BlockTestsFiller/bcWalletTestFiller.json rename to test/libethereum/BlockchainTestsFiller/bcWalletTestFiller.json From 691482c1fd1b2fe85316b288ab7da07eee217c80 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 19 Jun 2015 20:51:56 +0200 Subject: [PATCH 16/20] mv BlockTestsFiller -> BlockchainTestsFiller in blockchain.cpp --- test/libethereum/blockchain.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/test/libethereum/blockchain.cpp b/test/libethereum/blockchain.cpp index 4621708bd..0314de78b 100644 --- a/test/libethereum/blockchain.cpp +++ b/test/libethereum/blockchain.cpp @@ -788,58 +788,58 @@ BOOST_AUTO_TEST_SUITE(BlockChainTests) BOOST_AUTO_TEST_CASE(bcForkBlockTest) { - dev::test::executeTests("bcForkBlockTest", "/BlockTests",dev::test::getFolder(__FILE__) + "/BlockTestsFiller", dev::test::doBlockchainTests); + dev::test::executeTests("bcForkBlockTest", "/BlockchainTests",dev::test::getFolder(__FILE__) + "/BlockchainTestsFiller", dev::test::doBlockchainTests); } BOOST_AUTO_TEST_CASE(bcTotalDifficultyTest) { - dev::test::executeTests("bcTotalDifficultyTest", "/BlockTests",dev::test::getFolder(__FILE__) + "/BlockTestsFiller", dev::test::doBlockchainTests); + dev::test::executeTests("bcTotalDifficultyTest", "/BlockchainTests",dev::test::getFolder(__FILE__) + "/BlockchainTestsFiller", dev::test::doBlockchainTests); } BOOST_AUTO_TEST_CASE(bcInvalidRLPTest) { - dev::test::executeTests("bcInvalidRLPTest", "/BlockTests",dev::test::getFolder(__FILE__) + "/BlockTestsFiller", dev::test::doBlockchainTests); + dev::test::executeTests("bcInvalidRLPTest", "/BlockchainTests",dev::test::getFolder(__FILE__) + "/BlockchainTestsFiller", dev::test::doBlockchainTests); } BOOST_AUTO_TEST_CASE(bcRPC_API_Test) { - dev::test::executeTests("bcRPC_API_Test", "/BlockTests",dev::test::getFolder(__FILE__) + "/BlockTestsFiller", dev::test::doBlockchainTests); + dev::test::executeTests("bcRPC_API_Test", "/BlockchainTests",dev::test::getFolder(__FILE__) + "/BlockchainTestsFiller", dev::test::doBlockchainTests); } BOOST_AUTO_TEST_CASE(bcValidBlockTest) { - dev::test::executeTests("bcValidBlockTest", "/BlockTests",dev::test::getFolder(__FILE__) + "/BlockTestsFiller", dev::test::doBlockchainTests); + dev::test::executeTests("bcValidBlockTest", "/BlockchainTests",dev::test::getFolder(__FILE__) + "/BlockchainTestsFiller", dev::test::doBlockchainTests); } BOOST_AUTO_TEST_CASE(bcInvalidHeaderTest) { - dev::test::executeTests("bcInvalidHeaderTest", "/BlockTests",dev::test::getFolder(__FILE__) + "/BlockTestsFiller", dev::test::doBlockchainTests); + dev::test::executeTests("bcInvalidHeaderTest", "/BlockchainTests",dev::test::getFolder(__FILE__) + "/BlockchainTestsFiller", dev::test::doBlockchainTests); } BOOST_AUTO_TEST_CASE(bcUncleTest) { - dev::test::executeTests("bcUncleTest", "/BlockTests",dev::test::getFolder(__FILE__) + "/BlockTestsFiller", dev::test::doBlockchainTests); + dev::test::executeTests("bcUncleTest", "/BlockchainTests",dev::test::getFolder(__FILE__) + "/BlockchainTestsFiller", dev::test::doBlockchainTests); } BOOST_AUTO_TEST_CASE(bcUncleHeaderValiditiy) { - dev::test::executeTests("bcUncleHeaderValiditiy", "/BlockTests",dev::test::getFolder(__FILE__) + "/BlockTestsFiller", dev::test::doBlockchainTests); + dev::test::executeTests("bcUncleHeaderValiditiy", "/BlockchainTests",dev::test::getFolder(__FILE__) + "/BlockchainTestsFiller", dev::test::doBlockchainTests); } BOOST_AUTO_TEST_CASE(bcGasPricerTest) { - dev::test::executeTests("bcGasPricerTest", "/BlockTests",dev::test::getFolder(__FILE__) + "/BlockTestsFiller", dev::test::doBlockchainTests); + dev::test::executeTests("bcGasPricerTest", "/BlockchainTests",dev::test::getFolder(__FILE__) + "/BlockchainTestsFiller", dev::test::doBlockchainTests); } BOOST_AUTO_TEST_CASE(bcBruncleTest) { - dev::test::executeTests("bcBruncleTest", "/BlockTests",dev::test::getFolder(__FILE__) + "/BlockTestsFiller", dev::test::doBlockchainTests); + dev::test::executeTests("bcBruncleTest", "/BlockchainTests",dev::test::getFolder(__FILE__) + "/BlockchainTestsFiller", dev::test::doBlockchainTests); } BOOST_AUTO_TEST_CASE(bcWalletTest) { if (test::Options::get().wallet) - dev::test::executeTests("bcWalletTest", "/BlockTests",dev::test::getFolder(__FILE__) + "/BlockTestsFiller", dev::test::doBlockchainTests); + dev::test::executeTests("bcWalletTest", "/BlockchainTests",dev::test::getFolder(__FILE__) + "/BlockchainTestsFiller", dev::test::doBlockchainTests); } BOOST_AUTO_TEST_CASE(userDefinedFile) From 87690214d60c9ce852c0cfe0ec1211c8be5a9467 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Mon, 22 Jun 2015 07:17:07 +0200 Subject: [PATCH 17/20] update gas pricer test path --- test/libethereum/gaspricer.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/libethereum/gaspricer.cpp b/test/libethereum/gaspricer.cpp index 68a55ab42..105f4c2d7 100644 --- a/test/libethereum/gaspricer.cpp +++ b/test/libethereum/gaspricer.cpp @@ -90,51 +90,51 @@ BOOST_AUTO_TEST_CASE(basicGasPricerNoUpdate) BOOST_AUTO_TEST_CASE(basicGasPricer_RPC_API_Test) { - dev::test::executeGasPricerTest("RPC_API_Test", 30.679, 15.0, "/BlockTests/bcRPC_API_Test.json", TransactionPriority::Medium, 155632494086, 1); + dev::test::executeGasPricerTest("RPC_API_Test", 30.679, 15.0, "/BlockchainTests/bcRPC_API_Test.json", TransactionPriority::Medium, 155632494086, 1); } BOOST_AUTO_TEST_CASE(basicGasPricer_bcValidBlockTest) { - dev::test::executeGasPricerTest("SimpleTx", 30.679, 15.0, "/BlockTests/bcValidBlockTest.json", TransactionPriority::Medium, 155632494086, 10); + dev::test::executeGasPricerTest("SimpleTx", 30.679, 15.0, "/BlockchainTests/bcValidBlockTest.json", TransactionPriority::Medium, 155632494086, 10); } BOOST_AUTO_TEST_CASE(basicGasPricer_bcUncleTest) { - dev::test::executeGasPricerTest("twoUncle", 30.679, 15.0, "/BlockTests/bcUncleTest.json", TransactionPriority::Medium, 155632494086, 1); + dev::test::executeGasPricerTest("twoUncle", 30.679, 15.0, "/BlockchainTests/bcUncleTest.json", TransactionPriority::Medium, 155632494086, 1); } BOOST_AUTO_TEST_CASE(basicGasPricer_bcUncleHeaderValiditiy) { - dev::test::executeGasPricerTest("correct", 30.679, 15.0, "/BlockTests/bcUncleHeaderValiditiy.json", TransactionPriority::Medium, 155632494086, 1); + dev::test::executeGasPricerTest("correct", 30.679, 15.0, "/BlockchainTests/bcUncleHeaderValiditiy.json", TransactionPriority::Medium, 155632494086, 1); } BOOST_AUTO_TEST_CASE(basicGasPricer_notxs) { - dev::test::executeGasPricerTest("notxs", 30.679, 15.0, "/BlockTests/bcGasPricerTest.json", TransactionPriority::Medium, 155632494086, 155632494086); + dev::test::executeGasPricerTest("notxs", 30.679, 15.0, "/BlockchainTests/bcGasPricerTest.json", TransactionPriority::Medium, 155632494086, 155632494086); } BOOST_AUTO_TEST_CASE(basicGasPricer_highGasUsage_LowestPrio) { - dev::test::executeGasPricerTest("highGasUsage", 30.679, 15.0, "/BlockTests/bcGasPricerTest.json", TransactionPriority::Lowest, 15731282021, 10000000000000); + dev::test::executeGasPricerTest("highGasUsage", 30.679, 15.0, "/BlockchainTests/bcGasPricerTest.json", TransactionPriority::Lowest, 15731282021, 10000000000000); } BOOST_AUTO_TEST_CASE(basicGasPricer_highGasUsage_LowPrio) { - dev::test::executeGasPricerTest("highGasUsage", 30.679, 15.0, "/BlockTests/bcGasPricerTest.json", TransactionPriority::Low, 15731282021, 15734152261884); + dev::test::executeGasPricerTest("highGasUsage", 30.679, 15.0, "/BlockchainTests/bcGasPricerTest.json", TransactionPriority::Low, 15731282021, 15734152261884); } BOOST_AUTO_TEST_CASE(basicGasPricer_highGasUsage_MediumPrio) { - dev::test::executeGasPricerTest("highGasUsage", 30.679, 15.0, "/BlockTests/bcGasPricerTest.json", TransactionPriority::Medium, 15731282021, 20000000000000); + dev::test::executeGasPricerTest("highGasUsage", 30.679, 15.0, "/BlockchainTests/bcGasPricerTest.json", TransactionPriority::Medium, 15731282021, 20000000000000); } BOOST_AUTO_TEST_CASE(basicGasPricer_highGasUsage_HighPrio) { - dev::test::executeGasPricerTest("highGasUsage", 30.679, 15.0, "/BlockTests/bcGasPricerTest.json", TransactionPriority::High, 15731282021, 24265847738115); + dev::test::executeGasPricerTest("highGasUsage", 30.679, 15.0, "/BlockchainTests/bcGasPricerTest.json", TransactionPriority::High, 15731282021, 24265847738115); } BOOST_AUTO_TEST_CASE(basicGasPricer_highGasUsage_HighestPrio) { - dev::test::executeGasPricerTest("highGasUsage", 30.679, 15.0, "/BlockTests/bcGasPricerTest.json", TransactionPriority::Highest, 15731282021, 30000000000000); + dev::test::executeGasPricerTest("highGasUsage", 30.679, 15.0, "/BlockchainTests/bcGasPricerTest.json", TransactionPriority::Highest, 15731282021, 30000000000000); } BOOST_AUTO_TEST_SUITE_END() From 58c17301053b44e65f600bcb368d6e394b633b19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Mon, 22 Jun 2015 11:01:13 +0200 Subject: [PATCH 18/20] Add support for clang sanitizer to cmake scripts. To build with the sanitizer support use clang compiler and set CMAKE_BUILD_TYPE to "DebugSan". More info: http://clang.llvm.org/docs/AddressSanitizer.html. --- cmake/EthCompilerSettings.cmake | 1 + evmjit/CMakeLists.txt | 2 +- sanitizer-blacklist.txt | 8 ++++++++ 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 sanitizer-blacklist.txt diff --git a/cmake/EthCompilerSettings.cmake b/cmake/EthCompilerSettings.cmake index 85574d5f0..6701cf824 100644 --- a/cmake/EthCompilerSettings.cmake +++ b/cmake/EthCompilerSettings.cmake @@ -19,6 +19,7 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") set(CMAKE_CXX_FLAGS "-std=c++11 -Wall -Wno-unknown-pragmas -Wextra -DSHAREDLIB -fPIC") set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -DETH_DEBUG") + set(CMAKE_CXX_FLAGS_DEBUGSAN "-O1 -g -fsanitize=address,integer,undefined -fsanitize-blacklist=${CMAKE_SOURCE_DIR}/sanitizer-blacklist.txt -fno-omit-frame-pointer -DETH_DEBUG") set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG -DETH_RELEASE") set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG -DETH_RELEASE") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DETH_RELEASE") diff --git a/evmjit/CMakeLists.txt b/evmjit/CMakeLists.txt index 280fec212..d9a01255c 100644 --- a/evmjit/CMakeLists.txt +++ b/evmjit/CMakeLists.txt @@ -10,7 +10,7 @@ else() set(CMAKE_CXX_FLAGS "-std=c++11 -Wall -Wextra -Wconversion -Wno-sign-conversion -Wno-unknown-pragmas ${CMAKE_CXX_FLAGS}") endif() -if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") +if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND NOT ${CMAKE_BUILD_TYPE} STREQUAL "DebugSan") # Do not allow unresovled symbols in shared library (default on linux) set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined") endif() diff --git a/sanitizer-blacklist.txt b/sanitizer-blacklist.txt new file mode 100644 index 000000000..0faf73cf4 --- /dev/null +++ b/sanitizer-blacklist.txt @@ -0,0 +1,8 @@ +# Ignore standard library headers. +src:*/include/c\+\+/* + +# Ignore boost libraries headers. +src:*/include/boost/* + +# Ignore Crypto++ library. We plan to remove it in the future. It exploits interger overflow and uses memcpy incorrectly. +src:*/include/cryptopp/* From 42a3432947670f27dcf1ab61452b10094735ea49 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 22 Jun 2015 11:27:56 +0200 Subject: [PATCH 19/20] ui changes --- mix/qml/Block.qml | 35 ++++++++++++++++++++++++++++++----- mix/qml/BlockChain.qml | 14 +++++++------- mix/qml/MainContent.qml | 10 ++++++---- 3 files changed, 43 insertions(+), 16 deletions(-) diff --git a/mix/qml/Block.qml b/mix/qml/Block.qml index 796518f11..31d3e924c 100644 --- a/mix/qml/Block.qml +++ b/mix/qml/Block.qml @@ -28,12 +28,12 @@ ColumnLayout if (transactions) { if (index >= 0) - return 30 + 30 * transactions.count + openedTr + return trHeight + trHeight * transactions.count + openedTr else - return 30 + return trHeight } else - return 30 + return trHeight } onOpenedTrChanged: @@ -46,6 +46,19 @@ ColumnLayout id: dbgStyle } + Rectangle + { + id: top + Layout.preferredWidth: blockWidth + height: 10 + anchors.bottom: rowHeader.top + color: "#DEDCDC" + radius: 15 + anchors.left: parent.left + anchors.leftMargin: statusWidth + anchors.bottomMargin: -5 + } + RowLayout { Layout.preferredHeight: trHeight @@ -201,12 +214,11 @@ ColumnLayout { anchors.top: parent.top width: parent.width - spacing: 7 + spacing: 20 RowLayout { anchors.top: parent.top Layout.fillWidth: true - //spacing: cellSpacing Rectangle { Layout.preferredWidth: fromWidth @@ -390,5 +402,18 @@ ColumnLayout } } } + + Rectangle + { + id: right + Layout.preferredWidth: blockWidth + height: 10 + anchors.top: parent.bottom + anchors.topMargin: 5 + color: "#DEDCDC" + radius: 15 + anchors.left: parent.left + anchors.leftMargin: statusWidth + } } diff --git a/mix/qml/BlockChain.qml b/mix/qml/BlockChain.qml index ed1c4a4ad..02ff72be2 100644 --- a/mix/qml/BlockChain.qml +++ b/mix/qml/BlockChain.qml @@ -37,17 +37,17 @@ ColumnLayout { onWidthChanged: { - - if (width <= 630 || previousWidth <= 630) + var minWidth = scenarioMinWidth - 20 // margin + if (width <= minWidth || previousWidth <= minWidth) { - fromWidth = 150 + fromWidth = 100 toWidth = 100 valueWidth = 200 } else { var diff = (width - previousWidth) / 3; - fromWidth = fromWidth + diff < 150 ? 150 : fromWidth + diff + fromWidth = fromWidth + diff < 100 ? 100 : fromWidth + diff toWidth = toWidth + diff < 100 ? 100 : toWidth + diff valueWidth = valueWidth + diff < 200 ? 200 : valueWidth + diff } @@ -97,7 +97,7 @@ ColumnLayout { } Rectangle { - Layout.preferredWidth: fromWidth + cellSpacing + Layout.preferredWidth: fromWidth Label { anchors.verticalCenter: parent.verticalCenter @@ -139,12 +139,12 @@ ColumnLayout { { id: blockChainScrollView anchors.fill: parent - anchors.topMargin: 10 + anchors.topMargin: 8 ColumnLayout { id: blockChainLayout width: parent.width - spacing: 10 + spacing: 20 Block { diff --git a/mix/qml/MainContent.qml b/mix/qml/MainContent.qml index de19baf35..7f180a899 100644 --- a/mix/qml/MainContent.qml +++ b/mix/qml/MainContent.qml @@ -31,6 +31,7 @@ Rectangle { property alias codeEditor: codeEditor property bool webViewHorizontal: codeWebSplitter.orientation === Qt.Vertical //vertical splitter positions elements vertically, splits screen horizontally property bool firstCompile: true + property int scenarioMinWidth: 590 Connections { target: codeModel @@ -110,6 +111,7 @@ Rectangle { property alias webHeight: webPreview.height property alias showProjectView: projectList.visible property bool runOnProjectLoad: true + property int scenarioMinWidth: scenarioMinWidth } ColumnLayout @@ -205,7 +207,7 @@ Rectangle { visible: false; Layout.fillHeight: true Keys.onEscapePressed: visible = false - Layout.minimumWidth: 650 + Layout.minimumWidth: scenarioMinWidth anchors.right: parent.right } @@ -215,7 +217,7 @@ Rectangle { visible: false Layout.fillHeight: true Keys.onEscapePressed: visible = false - Layout.minimumWidth: 650 + Layout.minimumWidth: scenarioMinWidth anchors.right: parent.right } @@ -224,10 +226,9 @@ Rectangle { onDebugDataReady: { scenarioExe.visible = false debugPanel.visible = true + debugPanel.width = scenarioExe.width if (scenarioExe.bc.debugTrRequested) - { debugPanel.setTr(scenarioExe.bc.model.blocks[scenarioExe.bc.debugTrRequested[0]].transactions[scenarioExe.bc.debugTrRequested[1]]) - } } } @@ -236,6 +237,7 @@ Rectangle { onPanelClosed: { debugPanel.visible = false scenarioExe.visible = true + scenarioExe.width = debugPanel.width } } } From 893d6fe788810980bc74033cbb2454239d60fb3d Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 22 Jun 2015 11:35:01 +0200 Subject: [PATCH 20/20] clean code --- mix/qml/StateListModel.qml | 1 - mix/qml/WebPreview.qml | 5 ----- 2 files changed, 6 deletions(-) diff --git a/mix/qml/StateListModel.qml b/mix/qml/StateListModel.qml index 26817441c..992113cc6 100644 --- a/mix/qml/StateListModel.qml +++ b/mix/qml/StateListModel.qml @@ -256,7 +256,6 @@ Item { if (!_secret) _secret = clientModel.newSecret(); var address = clientModel.address(_secret); - console.log(address); var name = qsTr("Account") + "-" + address.substring(0, 4); return { name: name, secret: _secret, balance: QEtherHelper.createEther(_balance, _unit), address: address }; } diff --git a/mix/qml/WebPreview.qml b/mix/qml/WebPreview.qml index c45f2cab4..5d0f208af 100644 --- a/mix/qml/WebPreview.qml +++ b/mix/qml/WebPreview.qml @@ -89,11 +89,6 @@ Item { } } - /*Connections { - target: clientModel - onRunComplete: reload(); - }*/ - Connections { target: codeModel onContractInterfaceChanged: reload();