CJentzsch
10 years ago
88 changed files with 1741 additions and 1067 deletions
@ -1,27 +0,0 @@ |
|||
#!/usr/bin/python |
|||
# cpp-ethereum build script |
|||
# to be used from CI server, or to build locally |
|||
# uses python instead of bash script for better cross-platform support |
|||
|
|||
# TODO Initial version. Needs much more improvements |
|||
|
|||
import argparse |
|||
import os |
|||
import subprocess |
|||
|
|||
def build_dependencies(): |
|||
if os.path.exists("extdep"): |
|||
os.chdir("extdep") |
|||
if not os.path.exists("build"): |
|||
os.makedirs("build") |
|||
os.chdir("build") |
|||
subprocess.check_call(["cmake", ".."]) |
|||
subprocess.check_call("make") |
|||
|
|||
parser = argparse.ArgumentParser() |
|||
parser.add_argument("cmd", help="what to build") |
|||
|
|||
args = parser.parse_args() |
|||
if args.cmd == "dep": |
|||
build_dependencies() |
|||
|
@ -0,0 +1,38 @@ |
|||
#pragma once |
|||
|
|||
#include <evmjit/libevmjit/Common.h> |
|||
|
|||
namespace dev |
|||
{ |
|||
namespace eth |
|||
{ |
|||
|
|||
inline u256 llvm2eth(jit::i256 _i) |
|||
{ |
|||
u256 u = 0; |
|||
u |= _i.d; |
|||
u <<= 64; |
|||
u |= _i.c; |
|||
u <<= 64; |
|||
u |= _i.b; |
|||
u <<= 64; |
|||
u |= _i.a; |
|||
return u; |
|||
} |
|||
|
|||
inline jit::i256 eth2llvm(u256 _u) |
|||
{ |
|||
jit::i256 i; |
|||
u256 mask = 0xFFFFFFFFFFFFFFFF; |
|||
i.a = static_cast<uint64_t>(_u & mask); |
|||
_u >>= 64; |
|||
i.b = static_cast<uint64_t>(_u & mask); |
|||
_u >>= 64; |
|||
i.c = static_cast<uint64_t>(_u & mask); |
|||
_u >>= 64; |
|||
i.d = static_cast<uint64_t>(_u & mask); |
|||
return i; |
|||
} |
|||
|
|||
} |
|||
} |
@ -1,34 +1,41 @@ |
|||
#include "interface.h" |
|||
#include <cstdio> |
|||
#include "ExecutionEngine.h" |
|||
|
|||
extern "C" |
|||
{ |
|||
|
|||
evmjit_result evmjit_run(void* _data, void* _env) |
|||
{ |
|||
using namespace dev::eth::jit; |
|||
using namespace dev::eth::jit; |
|||
|
|||
auto data = static_cast<RuntimeData*>(_data); |
|||
#ifdef _MSC_VER |
|||
#define _ALLOW_KEYWORD_MACROS |
|||
#define noexcept throw() |
|||
#endif |
|||
|
|||
ExecutionEngine engine; |
|||
EXPORT void* evmjit_create() noexcept |
|||
{ |
|||
return new(std::nothrow) ExecutionEngine; |
|||
} |
|||
|
|||
EXPORT void evmjit_destroy(ExecutionEngine* _engine) noexcept |
|||
{ |
|||
delete _engine; |
|||
} |
|||
|
|||
auto codePtr = data->code; |
|||
auto codeSize = data->elems[RuntimeData::CodeSize].a; |
|||
EXPORT int evmjit_run(ExecutionEngine* _engine, RuntimeData* _data, Env* _env) noexcept |
|||
{ |
|||
try |
|||
{ |
|||
auto codePtr = _data->code; |
|||
auto codeSize = _data->codeSize; |
|||
bytes bytecode; |
|||
bytecode.insert(bytecode.end(), codePtr, codePtr + codeSize); |
|||
|
|||
auto returnCode = engine.run(bytecode, data, static_cast<Env*>(_env)); |
|||
evmjit_result result = {static_cast<int32_t>(returnCode), 0, nullptr}; |
|||
if (returnCode == ReturnCode::Return && !engine.returnData.empty()) |
|||
auto returnCode = _engine->run(bytecode, _data, _env); |
|||
return static_cast<int>(returnCode); |
|||
} |
|||
catch(...) |
|||
{ |
|||
// TODO: Optimized returning data. Allocating memory on client side by callback function might be a good idea
|
|||
result.returnDataSize = engine.returnData.size(); |
|||
result.returnData = std::malloc(result.returnDataSize); |
|||
std::memcpy(result.returnData, engine.returnData.data(), result.returnDataSize); |
|||
return static_cast<int>(ReturnCode::UnexpectedException); |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
|
|||
} |
|||
|
@ -1,12 +1,86 @@ |
|||
/*
|
|||
This file is part of cpp-ethereum. |
|||
|
|||
cpp-ethereum is free software: you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation, either version 3 of the License, or |
|||
(at your option) any later version. |
|||
|
|||
cpp-ethereum is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License |
|||
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
/** @file CanonBlockChain.cpp
|
|||
* @author Gav Wood <i@gavwood.com> |
|||
* @date 2014 |
|||
*/ |
|||
|
|||
#include "CanonBlockChain.h" |
|||
|
|||
CanonBlockChain::CanonBlockChain() |
|||
{ |
|||
#include <boost/filesystem.hpp> |
|||
#include <libdevcore/Common.h> |
|||
#include <libdevcore/RLP.h> |
|||
#include <libdevcrypto/FileSystem.h> |
|||
#include <libethcore/Exceptions.h> |
|||
#include <libethcore/ProofOfWork.h> |
|||
#include <libethcore/BlockInfo.h> |
|||
#include <liblll/Compiler.h> |
|||
#include "State.h" |
|||
#include "Defaults.h" |
|||
using namespace std; |
|||
using namespace dev; |
|||
using namespace dev::eth; |
|||
|
|||
#define ETH_CATCH 1 |
|||
|
|||
std::map<Address, Account> const& dev::eth::genesisState() |
|||
{ |
|||
static std::map<Address, Account> s_ret; |
|||
if (s_ret.empty()) |
|||
{ |
|||
// Initialise.
|
|||
for (auto i: vector<string>({ |
|||
"dbdbdb2cbd23b783741e8d7fcf51e459b497e4a6", |
|||
"e6716f9544a56c530d868e4bfbacb172315bdead", |
|||
"b9c015918bdaba24b4ff057a92a3873d6eb201be", |
|||
"1a26338f0d905e295fccb71fa9ea849ffa12aaf4", |
|||
"2ef47100e0787b915105fd5e3f4ff6752079d5cb", |
|||
"cd2a3d9f938e13cd947ec05abc7fe734df8dd826", |
|||
"6c386a4b26f73c802f34673f7248bb118f97424a", |
|||
"e4157b34ea9615cfbde6b4fda419828124b70c78" |
|||
})) |
|||
s_ret[Address(fromHex(i))] = Account(u256(1) << 200, Account::NormalCreation); |
|||
} |
|||
return s_ret; |
|||
} |
|||
|
|||
CanonBlockChain::~CanonBlockChain() |
|||
std::unique_ptr<BlockInfo> CanonBlockChain::s_genesis; |
|||
boost::shared_mutex CanonBlockChain::x_genesis; |
|||
|
|||
bytes CanonBlockChain::createGenesisBlock() |
|||
{ |
|||
RLPStream block(3); |
|||
|
|||
h256 stateRoot; |
|||
{ |
|||
MemoryDB db; |
|||
TrieDB<Address, MemoryDB> state(&db); |
|||
state.init(); |
|||
dev::eth::commit(genesisState(), db, state); |
|||
stateRoot = state.root(); |
|||
} |
|||
|
|||
block.appendList(14) |
|||
<< h256() << EmptyListSHA3 << h160() << stateRoot << EmptyTrie << EmptyTrie << LogBloom() << c_genesisDifficulty << 0 << 1000000 << 0 << (unsigned)0 << string() << sha3(bytes(1, 42)); |
|||
block.appendRaw(RLPEmptyList); |
|||
block.appendRaw(RLPEmptyList); |
|||
return block.out(); |
|||
} |
|||
|
|||
CanonBlockChain::CanonBlockChain(std::string _path, bool _killExisting): BlockChain(CanonBlockChain::createGenesisBlock(), _path, _killExisting) |
|||
{ |
|||
} |
|||
|
@ -1,12 +1,76 @@ |
|||
#ifndef CANONBLOCKCHAIN_H |
|||
#define CANONBLOCKCHAIN_H |
|||
/*
|
|||
This file is part of cpp-ethereum. |
|||
|
|||
cpp-ethereum is free software: you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation, either version 3 of the License, or |
|||
(at your option) any later version. |
|||
|
|||
class CanonBlockChain |
|||
cpp-ethereum is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License |
|||
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
/** @file CanonBlockChain.h
|
|||
* @author Gav Wood <i@gavwood.com> |
|||
* @date 2014 |
|||
*/ |
|||
|
|||
#pragma once |
|||
|
|||
#pragma warning(push) |
|||
#pragma warning(disable: 4100 4267) |
|||
#include <leveldb/db.h> |
|||
#pragma warning(pop) |
|||
|
|||
#include <mutex> |
|||
#include <libdevcore/Log.h> |
|||
#include <libdevcore/Exceptions.h> |
|||
#include <libethcore/CommonEth.h> |
|||
#include <libethcore/BlockInfo.h> |
|||
#include <libdevcore/Guards.h> |
|||
#include "BlockDetails.h" |
|||
#include "Account.h" |
|||
#include "BlockQueue.h" |
|||
#include "BlockChain.h" |
|||
namespace ldb = leveldb; |
|||
|
|||
namespace dev |
|||
{ |
|||
|
|||
namespace eth |
|||
{ |
|||
|
|||
// TODO: Move all this Genesis stuff into Genesis.h/.cpp
|
|||
std::map<Address, Account> const& genesisState(); |
|||
|
|||
/**
|
|||
* @brief Implements the blockchain database. All data this gives is disk-backed. |
|||
* @threadsafe |
|||
* @todo Make not memory hog (should actually act as a cache and deallocate old entries). |
|||
*/ |
|||
class CanonBlockChain: public BlockChain |
|||
{ |
|||
public: |
|||
CanonBlockChain(); |
|||
~CanonBlockChain(); |
|||
CanonBlockChain(bool _killExisting = false): CanonBlockChain(std::string(), _killExisting) {} |
|||
CanonBlockChain(std::string _path, bool _killExisting = false); |
|||
~CanonBlockChain() {} |
|||
|
|||
/// @returns the genesis block header.
|
|||
static BlockInfo const& genesis() { UpgradableGuard l(x_genesis); if (!s_genesis) { auto gb = createGenesisBlock(); UpgradeGuard ul(l); s_genesis.reset(new BlockInfo); s_genesis->populate(&gb); } return *s_genesis; } |
|||
|
|||
/// @returns the genesis block as its RLP-encoded byte array.
|
|||
/// @note This is slow as it's constructed anew each call. Consider genesis() instead.
|
|||
static bytes createGenesisBlock(); |
|||
|
|||
private: |
|||
/// Static genesis info and its lock.
|
|||
static boost::shared_mutex x_genesis; |
|||
static std::unique_ptr<BlockInfo> s_genesis; |
|||
}; |
|||
|
|||
#endif // CANONBLOCKCHAIN_H
|
|||
} |
|||
} |
|||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,45 @@ |
|||
#!/bin/bash |
|||
|
|||
# solves problem with macdeployqt on Qt 5.4 RC |
|||
# http://qt-project.org/forums/viewthread/50118 |
|||
|
|||
BUILD_FOLDER_PATH=$1 |
|||
BUILD_QML_FOLDER_PATH="$BUILD_FOLDER_PATH/Resources/qml" |
|||
BUILD_PLUGINS_FOLDER_PATH="$BUILD_FOLDER_PATH/PlugIns" |
|||
|
|||
if [ ! -d ${BUILD_QML_FOLDER_PATH} ]; then |
|||
# we are not using any qml files |
|||
# gracefully exit |
|||
exit 0 |
|||
fi |
|||
|
|||
declare -a BROKEN_FILES; |
|||
k=0; |
|||
for j in $(find ${BUILD_QML_FOLDER_PATH} -name *.dylib); do |
|||
BROKEN_FILES[${k}]=$j |
|||
|
|||
((k=k+1)) |
|||
done |
|||
|
|||
|
|||
for i in "${BROKEN_FILES[@]}"; do |
|||
REPLACE_STRING="$BUILD_FOLDER_PATH/" |
|||
APP_CONTENT_FILE=${i//$REPLACE_STRING/""} |
|||
IFS='/' read -a array <<< "$APP_CONTENT_FILE" |
|||
LENGTH=${#array[@]} |
|||
LAST_ITEM_INDEX=$((LENGTH-1)) |
|||
FILE=${array[${LENGTH} - 1]} |
|||
|
|||
ORIGINE_PATH=$(find ${BUILD_PLUGINS_FOLDER_PATH} -name ${FILE}) |
|||
ORIGINE_PATH=${ORIGINE_PATH//$REPLACE_STRING/""} |
|||
s="" |
|||
for((l=0;l<${LAST_ITEM_INDEX};l++)) do |
|||
s=$s"../" |
|||
done |
|||
s=$s$ORIGINE_PATH |
|||
echo "s: $s" |
|||
|
|||
REMOVE_BROKEN_ALIAS=$(rm -rf $i) |
|||
RESULT=$(ln -s $s $i) |
|||
done |
|||
|
Loading…
Reference in new issue