Browse Source

Fixed SECP256k1 installation woes.

Protocol fix for PoC-5.
cl-refactor
Gav Wood 11 years ago
parent
commit
c4a39e42e2
  1. 2
      .gitignore
  2. 2
      libethcore/CommonEth.cpp
  3. 4
      libethcore/Dagger.cpp
  4. 2
      libethcore/Dagger.h
  5. 8
      libethereum/Executive.cpp
  6. 1
      libethereum/PeerServer.cpp
  7. 1
      libethereum/PeerSession.cpp
  8. 13
      libethereum/State.cpp
  9. 1
      libethereum/State.h
  10. 7
      libserpent/rewriter.cpp
  11. 19
      secp256k1/CMakeLists.txt

2
.gitignore

@ -26,7 +26,7 @@ build_xc
*.user.*
*~
build/
build.*/
*.pyc

2
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<pair<u256, string>> g_units =
{

4
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);

2
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

8
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);

1
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);

1
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++;

13
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

1
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<Address, OverlayDB> m_state; ///< Our state tree, as an OverlayDB DB.

7
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<Node> args;
args.push_back(node);
node = astnode("get", args, node.metadata);

19
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} )

Loading…
Cancel
Save