diff --git a/.gitignore b/.gitignore index 3b93d9318..cb8bb482f 100644 --- a/.gitignore +++ b/.gitignore @@ -26,7 +26,7 @@ build_xc *.user.* *~ -build/ +build.*/ *.pyc diff --git a/libethcore/CommonEth.cpp b/libethcore/CommonEth.cpp index 90708c12f..45f4e70bc 100644 --- a/libethcore/CommonEth.cpp +++ b/libethcore/CommonEth.cpp @@ -29,7 +29,7 @@ using namespace eth; //#define ETH_ADDRESS_DEBUG 1 -const unsigned eth::c_protocolVersion = 22; +const unsigned eth::c_protocolVersion = 23; static const vector> g_units = { diff --git a/libethcore/Dagger.cpp b/libethcore/Dagger.cpp index 2b759fb7c..1651a1941 100644 --- a/libethcore/Dagger.cpp +++ b/libethcore/Dagger.cpp @@ -39,8 +39,8 @@ namespace eth MineInfo Dagger::mine(h256& o_solution, h256 const& _root, u256 const& _difficulty, uint _msTimeout, bool const& _continue) { MineInfo ret{0.f, 1e99, 0, false}; - static std::mt19937_64 s_eng((time(0))); - u256 s = h256::random(s_eng); + static std::mt19937_64 s_eng((time(0) + (unsigned)m_last)); + u256 s = (m_last = h256::random(s_eng)); bigint d = (bigint(1) << 256) / _difficulty; ret.requirement = log2((double)d); diff --git a/libethcore/Dagger.h b/libethcore/Dagger.h index 1adb59a9c..e0c993ea7 100644 --- a/libethcore/Dagger.h +++ b/libethcore/Dagger.h @@ -53,6 +53,8 @@ public: static bool verify(h256 const& _root, h256 const& _nonce, u256 const& _difficulty) { return (bigint)(u256)eval(_root, _nonce) <= (bigint(1) << 256) / _difficulty; } MineInfo mine(h256& o_solution, h256 const& _root, u256 const& _difficulty, uint _msTimeout = 100, bool const& _continue = bool(true)); + + h256 m_last; }; #else diff --git a/libethereum/Executive.cpp b/libethereum/Executive.cpp index 335681f7c..eed1ef917 100644 --- a/libethereum/Executive.cpp +++ b/libethereum/Executive.cpp @@ -110,17 +110,16 @@ bool Executive::call(Address _receiveAddress, Address _senderAddress, u256 _valu m_vm = new VM(_gas); bytes const& c = m_s.code(_receiveAddress); m_ext = new ExtVM(m_s, _receiveAddress, _senderAddress, _originAddress, _value, _gasPrice, _data, &c); - return false; } else - { m_endGas = _gas; - return true; - } + return !m_ext; } bool Executive::create(Address _sender, u256 _endowment, u256 _gasPrice, u256 _gas, bytesConstRef _init, Address _origin) { + // We can allow for the reverted state (i.e. that with which m_ext is constructed) to contain the m_newAddress, since + // we delete it explicitly if we decide we need to revert. m_newAddress = right160(sha3(rlpList(_sender, m_s.transactionsFrom(_sender) - 1))); while (m_s.addressInUse(m_newAddress)) m_newAddress = (u160)m_newAddress + 1; @@ -197,6 +196,7 @@ bool Executive::go(uint64_t _steps) if (revert) { m_ext->revert(); + // Explicitly delete a newly created address - this will still be in the reverted state. if (m_newAddress) { m_s.m_cache.erase(m_newAddress); diff --git a/libethereum/PeerServer.cpp b/libethereum/PeerServer.cpp index cf5e2c672..8dd982cbb 100644 --- a/libethereum/PeerServer.cpp +++ b/libethereum/PeerServer.cpp @@ -430,6 +430,7 @@ bool PeerServer::sync(BlockChain& _bc, TransactionQueue& _tq, OverlayDB& _o) if (m_incomingBlocks.size()) for (auto it = prev(m_incomingBlocks.end());; --it) { + cdebug << "Importing new block"; try { _bc.import(*it, _o); diff --git a/libethereum/PeerSession.cpp b/libethereum/PeerSession.cpp index ad3ec673e..9ceb949c9 100644 --- a/libethereum/PeerSession.cpp +++ b/libethereum/PeerSession.cpp @@ -229,6 +229,7 @@ bool PeerSession::interpret(RLP const& _r) auto h = sha3(_r[i].data()); if (!m_server->m_chain->details(h)) { + cdebug << "Pushing new block"; m_server->m_incomingBlocks.push_back(_r[i].data().toBytes()); m_knownBlocks.insert(h); used++; diff --git a/libethereum/State.cpp b/libethereum/State.cpp index d137053c4..c5a4098ac 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -952,22 +952,11 @@ bool State::isTrieGood(bool _enforceRefs, bool _requireNoLeftOvers) const return true; } -// TODO: run this often. -// POSSIBLE RACE CONDITION: check if mining clears intermediate nodes in trie before clearing pending. -// HOW DID TRIE NODES GO BUT PENDING STAY? -void State::checkPendingInTrie() const -{ - bool x = true; - - - assert(x); -} - // TODO: maintain node overlay revisions for stateroots -> each commit gives a stateroot + OverlayDB; allow overlay copying for rewind operations. u256 State::execute(bytesConstRef _rlp) { -#ifndef RELEASE +#ifndef ETH_RELEASE commit(); // get an updated hash #endif diff --git a/libethereum/State.h b/libethereum/State.h index bce267bb4..518c17e9a 100644 --- a/libethereum/State.h +++ b/libethereum/State.h @@ -324,7 +324,6 @@ private: bool isTrieGood(bool _enforceRefs, bool _requireNoLeftOvers) const; void paranoia(std::string const& _when, bool _enforceRefs = false) const; - void checkPendingInTrie() const; OverlayDB m_db; ///< Our overlay for the state tree. TrieDB m_state; ///< Our state tree, as an OverlayDB DB. diff --git a/libserpent/rewriter.cpp b/libserpent/rewriter.cpp index 3ea6e0b7a..0192607bd 100644 --- a/libserpent/rewriter.cpp +++ b/libserpent/rewriter.cpp @@ -398,6 +398,7 @@ Node apply_rules(Node node) { if (mr.success) { Node pattern2 = nodeMacros[pos][1]; node = subst(pattern2, mr.map, prefix, node.metadata); + pos = 0; } } // Array_lit special instruction @@ -405,12 +406,16 @@ Node apply_rules(Node node) { node = array_lit_transform(node); if (node.type == ASTNODE && node.val != "ref" && node.val != "get") { unsigned i = 0; - if (node.val == "set") i = 1; + if (node.val == "set") { + node.args[0].val = "'" + node.args[0].val; + i = 1; + } for (i = i; i < node.args.size(); i++) { node.args[i] = apply_rules(node.args[i]); } } else if (node.type == TOKEN && !isNumberLike(node)) { + node.val = "'" + node.val; std::vector args; args.push_back(node); node = astnode("get", args, node.metadata); diff --git a/secp256k1/CMakeLists.txt b/secp256k1/CMakeLists.txt index 5591ed2d1..23bccfa43 100644 --- a/secp256k1/CMakeLists.txt +++ b/secp256k1/CMakeLists.txt @@ -2,6 +2,9 @@ cmake_policy(SET CMP0015 NEW) set(CMAKE_ASM_COMPILER "yasm") +set(EXECUTABLE secp256k1) + +file(GLOB HEADERS "*.h") #aux_source_directory(. SRC_LIST) if ("${TARGET_PLATFORM}" STREQUAL "w64") @@ -14,27 +17,29 @@ if ("${TARGET_PLATFORM}" STREQUAL "w64") DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/field_5x52_asm.o ) if(ETH_STATIC) - add_library(secp256k1 STATIC secp256k1.c ${CMAKE_CURRENT_BINARY_DIR}/field_5x52_asm.o) + add_library(${EXECUTABLE} STATIC ${EXECUTABLE}.c ${CMAKE_CURRENT_BINARY_DIR}/field_5x52_asm.o) else() - add_library(secp256k1 SHARED secp256k1.c ${CMAKE_CURRENT_BINARY_DIR}/field_5x52_asm.o) + add_library(${EXECUTABLE} SHARED ${EXECUTABLE}.c ${CMAKE_CURRENT_BINARY_DIR}/field_5x52_asm.o) endif() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -DUSE_FIELD_5X52 -DUSE_FIELD_5X52_ASM -DUSE_NUM_GMP -DUSE_FIELD_INV_NUM") elseif(APPLE) # set(CMAKE_INSTALL_PREFIX ../lib) if(ETH_STATIC) - add_library(secp256k1 STATIC secp256k1.c field_5x52_asm.asm) + add_library(${EXECUTABLE} STATIC ${EXECUTABLE}.c field_5x52_asm.asm) else() - add_library(secp256k1 SHARED secp256k1.c field_5x52_asm.asm) + add_library(${EXECUTABLE} SHARED ${EXECUTABLE}.c field_5x52_asm.asm) endif() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -DUSE_FIELD_GMP -DUSE_NUM_GMP -DUSE_FIELD_INV_NUM") else() if(ETH_STATIC) - add_library(secp256k1 STATIC secp256k1.c field_5x52_asm.asm) + add_library(${EXECUTABLE} STATIC ${EXECUTABLE}.c field_5x52_asm.asm) else() - add_library(secp256k1 SHARED secp256k1.c field_5x52_asm.asm) + add_library(${EXECUTABLE} SHARED ${EXECUTABLE}.c field_5x52_asm.asm) endif() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -DUSE_FIELD_GMP -DUSE_NUM_GMP -DUSE_FIELD_INV_NUM") endif() -target_link_libraries(secp256k1 gmp) +target_link_libraries(${EXECUTABLE} gmp) +install( TARGETS ${EXECUTABLE} ARCHIVE DESTINATION lib LIBRARY DESTINATION lib ) +install( FILES ${HEADERS} DESTINATION include/${EXECUTABLE} )