New proof of work algo #3

Closed
jimmykiselak wants to merge 11 commits from realnewpow2 into real
12 changed files with 133 additions and 36 deletions

View file

@ -1 +1,2 @@
52.27.78.56:9246
45.32.39.241:9246
45.32.40.180:9246

View file

@ -1,5 +1,7 @@
# List of fixed seed nodes for testnet
45.32.39.241:19246
# Onion nodes
#thfsmmn2jbitcoin.onion
#it2pj4f7657g3rhi.onion

View file

@ -1,6 +1,8 @@
sudo apt-get install build-essential python-dev libbz2-dev libtool autotools-dev autoconf git pkg-config
mkdir dependencies
cd dependencies
wget http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz
tar xf db-4.8.30.NC.tar.gz
export BDB_PREFIX="`pwd`/bdb"
@ -9,26 +11,41 @@ cd db-4.8.30.NC/build_unix
make
make install
cd ../../
wget https://www.openssl.org/source/openssl-1.0.1p.tar.gz
tar xf openssl-1.0.1p.tar.gz
export OPENSSL_PREFIX="`pwd`/openssl_build"
mkdir $OPENSSL_PREFIX
cd openssl-1.0.1p
./Configure --prefix=$OPENSSL_PREFIX --openssldir=$OPENSSL_PREFIX/ssl [linux-generic32/linux-x86_64] -fPIC -static no-shared no-dso
./Configure --prefix=$OPENSSL_PREFIX --openssldir=$OPENSSL_PREFIX/ssl linux-x86_64 -fPIC -static no-shared no-dso
make
make install
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:${OPENSSL_BUILD}/lib/pkgconfig/"
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:${OPENSSL_PREFIX}/lib/pkgconfig/"
cd ..
wget http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.bz2/download -O boost_1_59_0.tar.bz2
tar xf boost_1_59_0.tar.bz2
export BOOST_ROOT="`pwd`/boost_1_59_0"
cd boost_1_59_0
export BOOST_ROOT=`pwd`
./bootstrap.sh
./b2 link=static cxxflags=-fPIC stage
cd ../../
mkdir libevent_build
git clone https://github.com/libevent/libevent.git
export LIBEVENT_PREFIX="`pwd`/libevent_build"
cd libevent
./autogen.sh
./configure --prefix=$LIBEVENT_PREFIX --enable-static --disable-shared --with-pic LDFLAGS="-L${OPENSSL_PREFIX}/lib/" CPPFLAGS="-I${OPENSSL_PREFIX}/include"
make
make install
cd ..
git clone https://github.com/lbryio/lbrycrd
cd lbrycrd
git checkout real
./autogen.sh
./configure --without-gui LDFLAGS="-L${OPENSSL_PREFIX}/lib/ -L${BDB_PREFIX}/lib/ -static-libstdc++" CPPFLAGS="-I${OPENSSL_PREFIX}/include -I${BDB_PREFIX}/include"
./configure --without-gui LDFLAGS="-L${OPENSSL_PREFIX}/lib/ -L${BDB_PREFIX}/lib/ -L${LIBEVENT_PREFIX}/lib/ -static-libstdc++" CPPFLAGS="-I${OPENSSL_PREFIX}/include -I${BDB_PREFIX}/include -I${LIBEVENT_PREFIX}/include/"
make
strip src/lbrycrdd
strip src/lbrycrd-cli

View file

@ -18,10 +18,12 @@
#include "chainparamsseeds.h"
#include "arith_uint256.h"
//#define FIND_GENESIS
#define GENESIS_MERKLE_ROOT "b8211c82c3d15bcd78bba57005b86fed515149a53a425eb592c07af99fe559cc"
#define MAINNET_GENESIS_HASH "0000678ddce6b9b57e58fab6b89a1cf63519ffb4bc097debb1836577ead9a3be"
#define MAINNET_GENESIS_NONCE 71748
#define MAINNET_GENESIS_HASH "9c89283ba0f3227f6c03b70216b9f665f0118d5e0fa729cedf4fb34d6a34f463"
#define MAINNET_GENESIS_NONCE 1287
#define REGTEST_GENESIS_HASH "6e3fcf1299d4ec5d79c3a4c91d624a4acf9e2e173d95a1a0504f677669687556"
#define REGTEST_GENESIS_NONCE 1
@ -68,7 +70,8 @@ static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesi
genesis.hashMerkleRoot = BlockMerkleRoot(genesis);
genesis.hashClaimTrie = uint256S("0x0000000000000000000000000000000000000000000000000000000000000001");
/*while (true)
#ifdef FIND_GENESIS
while (true)
{
genesis.nNonce += 1;
if (CheckProofOfWork2(genesis.GetPoWHash(), nBits, consensus))
@ -78,7 +81,8 @@ static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesi
std::cout << "pow hash: " << genesis.GetPoWHash().GetHex() << std::endl;
break;
}
}*/
}
#endif
return genesis;
}
@ -151,15 +155,20 @@ public:
genesis = CreateGenesisBlock(1446058291, MAINNET_GENESIS_NONCE, 0x1f00ffff, 1, 400000000 * COIN, consensus);
consensus.hashGenesisBlock = genesis.GetHash();
//std::cout << "hex: " << consensus.hashGenesisBlock.GetHex() << std::endl;
//std::cout << "merkle root: " << genesis.hashMerkleRoot.GetHex() << std::endl;
#ifdef FIND_GENESIS
std::cout << "hex: " << consensus.hashGenesisBlock.GetHex() << std::endl;
std::cout << "merkle root: " << genesis.hashMerkleRoot.GetHex() << std::endl;
#else
assert(consensus.hashGenesisBlock == uint256S(MAINNET_GENESIS_HASH));
assert(genesis.hashMerkleRoot == uint256S(GENESIS_MERKLE_ROOT));
#endif
vSeeds.clear();
vFixedSeeds.clear();
vSeeds.push_back(CDNSSeedData("lbrycrd.lbry.io", "seed.lbrycrd.lbry.io")); // lbry.io
vSeeds.push_back(CDNSSeedData("lbry.io", "dnsseed1.lbry.io")); // lbry.io
vSeeds.push_back(CDNSSeedData("lbry.io", "dnsseed2.lbry.io")); // lbry.io
vSeeds.push_back(CDNSSeedData("lbry.io", "dnsseed3.lbry.io")); // lbry.io
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,0x55);
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,0x7a);
@ -225,10 +234,13 @@ public:
genesis = CreateGenesisBlock(1446058291, MAINNET_GENESIS_NONCE, 0x1f00ffff, 1, 400000000 * COIN, consensus);
consensus.hashGenesisBlock = genesis.GetHash();
//std::cout << "testnet genesis hash: " << genesis.GetHash().GetHex() << std::endl;
//std::cout << "testnet merkle hash: " << genesis.hashMerkleRoot.GetHex() << std::endl;
#ifdef FIND_GENESIS
std::cout << "testnet genesis hash: " << genesis.GetHash().GetHex() << std::endl;
std::cout << "testnet merkle hash: " << genesis.hashMerkleRoot.GetHex() << std::endl;
#else
assert(consensus.hashGenesisBlock == uint256S(MAINNET_GENESIS_HASH));
assert(genesis.hashMerkleRoot == uint256S(GENESIS_MERKLE_ROOT));
#endif
vFixedSeeds.clear();
vSeeds.clear();
@ -298,10 +310,13 @@ public:
genesis = CreateGenesisBlock(1446058291, REGTEST_GENESIS_NONCE, 0x207fffff, 1, 400000000 * COIN, consensus);
consensus.hashGenesisBlock = genesis.GetHash();
//std::cout << "regtest genensis hash: " << genesis.GetHash().GetHex() << std::endl;
//std::cout << "regtest hashmerkleroot: " << genesis.hashMerkleRoot.GetHex() << std::endl;
#ifdef FIND_GENESIS
std::cout << "regtest genensis hash: " << genesis.GetHash().GetHex() << std::endl;
std::cout << "regtest hashmerkleroot: " << genesis.hashMerkleRoot.GetHex() << std::endl;
#else
assert(consensus.hashGenesisBlock == uint256S(REGTEST_GENESIS_HASH));
assert(genesis.hashMerkleRoot == uint256S(GENESIS_MERKLE_ROOT));
#endif
vFixedSeeds.clear(); //!< Regtest mode doesn't have any fixed seeds.
vSeeds.clear(); //!< Regtest mode doesn't have any DNS seeds.

View file

@ -8,10 +8,11 @@
* IPv4 as well as onion addresses are wrapped inside a IPv6 address accordingly.
*/
static SeedSpec6 pnSeed6_main[] = {
{{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x34,0x1b,0x4e,0x38}, 8333}
{{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x2d,0x20,0x27,0xf1}, 9246},
{{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x2d,0x20,0x28,0xb4}, 9246}
};
static SeedSpec6 pnSeed6_test[] = {
{{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x2d,0x20,0x27,0xf1}, 19246}
};
#endif // BITCOIN_CHAINPARAMSSEEDS_H

View file

@ -4,7 +4,9 @@
#include "hash.h"
#include "crypto/common.h"
#include "crypto/ripemd160.h"
#include "crypto/hmac_sha512.h"
#include "crypto/sha512.h"
#include "pubkey.h"
@ -15,10 +17,38 @@ inline uint32_t ROTL32(uint32_t x, int8_t r)
uint256 PoWHash(const std::vector<unsigned char>& input)
{
CHash256 h;
h.Write(input.data(), input.size());
uint256 result;
h.Finalize((unsigned char*)&result);
CHash256 h256;
CSHA512 h512;
CRIPEMD160 h160;
std::vector<unsigned char> out;
out.resize(h512.OUTPUT_SIZE);
std::vector<unsigned char> out_small;
out_small.resize(h160.OUTPUT_SIZE);
h256.Write(input.data(), input.size());
h256.Finalize(&out[0]);
h256.Reset();
h512.Write(out.data(), h256.OUTPUT_SIZE);
h512.Finalize(&out[0]);
h160.Write(out.data(), h512.OUTPUT_SIZE / 2);
h160.Finalize(&out_small[0]);
h160.Reset();
h256.Write(out_small.data(), h160.OUTPUT_SIZE);
h160.Write(out.data() + h512.OUTPUT_SIZE / 2, h512.OUTPUT_SIZE / 2);
h160.Finalize(&out_small[0]);
out.resize(h256.OUTPUT_SIZE);
h256.Write(out_small.data(), h160.OUTPUT_SIZE);
h256.Finalize(&out[0]);
uint256 result(out);
return result;
}

View file

@ -520,3 +520,22 @@ UniValue getnameproof(const UniValue& params, bool fHelp)
return proofToJSON(proof);
}
static const CRPCCommand commands[] =
{ // category name actor (function) okSafeMode
// --------------------- ------------------------ ----------------------- ----------
{ "Claimtrie", "getclaimsintrie", &getclaimsintrie, true },
{ "Claimtrie", "getclaimtrie", &getclaimtrie, true },
{ "Claimtrie", "getvalueforname", &getvalueforname, true },
{ "Claimtrie", "gettotalclaimednames", &gettotalclaimednames, true },
{ "Claimtrie", "gettotalclaims", &gettotalclaims, true },
{ "Claimtrie", "gettotalvalueofclaims", &gettotalvalueofclaims, true },
{ "Claimtrie", "getclaimsfortx", &getclaimsfortx, true },
{ "Claimtrie", "getnameproof", &getnameproof, true },
};
void RegisterClaimTrieRPCCommands(CRPCTable &tableRPC)
{
for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++)
tableRPC.appendCommand(commands[vcidx].name, &commands[vcidx]);
}

View file

@ -857,6 +857,8 @@ static const CRPCCommand commands[] =
{ "mining", "prioritisetransaction", &prioritisetransaction, true },
{ "mining", "getblocktemplate", &getblocktemplate, true },
{ "mining", "submitblock", &submitblock, true },
{ "mining", "setgenerate", &setgenerate, true },
{ "mining", "getgenerate", &getgenerate, true },
{ "generating", "generate", &generate, true },
{ "generating", "generatetoaddress", &generatetoaddress, true },

View file

@ -19,6 +19,9 @@ void RegisterMiscRPCCommands(CRPCTable &tableRPC);
void RegisterMiningRPCCommands(CRPCTable &tableRPC);
/** Register raw transaction RPC commands */
void RegisterRawTransactionRPCCommands(CRPCTable &tableRPC);
/** Register claim trie RPC commands */
void RegisterClaimTrieRPCCommands(CRPCTable &tableRPC);
static inline void RegisterAllCoreRPCCommands(CRPCTable &tableRPC)
{
@ -27,6 +30,7 @@ static inline void RegisterAllCoreRPCCommands(CRPCTable &tableRPC)
RegisterMiscRPCCommands(tableRPC);
RegisterMiningRPCCommands(tableRPC);
RegisterRawTransactionRPCCommands(tableRPC);
RegisterClaimTrieRPCCommands(tableRPC);
}
#endif

View file

@ -93,17 +93,17 @@ struct {
};*/
const unsigned int nonces[] = {
79715, 115775, 224572, 12063, 35799, 81128, 7459, 3704, 74161, 174952,
179883, 1883, 24971, 12115, 7908, 24791, 78905, 135694, 24855, 6108,
45125, 6200, 326764, 105132, 1706, 243717, 3782, 90681, 130062, 7707,
77604, 62455, 49605, 21726, 119057, 27524, 73984, 1331, 51531, 38874,
52443, 99097, 36007, 27173, 88714, 287757, 235289, 353070, 239689, 1365413,
196645, 94742, 76681, 73463, 267621, 233818, 398669, 606185, 68966, 784609,
486234, 139093, 81707, 173497, 46683, 359339, 110459, 376803, 186202, 113121,
22549, 185881, 237077, 68777, 37739, 18754, 74470, 59347, 68344, 387196,
288599, 63477, 50646, 72807, 1276757, 311156, 350217, 824070, 268004, 203189,
11127, 512344, 101745, 161626, 7476, 92476, 807780, 183217, 1406078, 4693874,
1143704, 89400, 277776, 1555386, 2463291, 1965076, 2377228, 170135, 112842, 118000,
336984, 142281, 190844, 28794, 60108, 38620, 50265, 1467, 51047, 5744,
3125, 3088, 1463, 38012, 136014, 82442, 108217, 67261, 164429, 295896,
5625, 33163, 18912, 17233, 33394, 31250, 90162, 83127, 31836, 245670,
49024, 5885, 121125, 13475, 27802, 92250, 94286, 15970, 11536, 225728,
139479, 120543, 125802, 2277, 29409, 188078, 44811, 777656, 739940, 463139,
98442, 199176, 257878, 1071941, 201178, 3749, 103041, 184443, 32931, 95584,
170413, 218370, 215087, 795280, 232087, 74312, 551792, 105084, 93228, 202816,
142542, 309855, 83512, 136555, 514030, 246349, 687104, 210446, 58494, 164980,
20188, 615074, 73461, 755562, 268257, 119909, 146341, 201954, 169429, 138541,
56238, 211463, 94796, 264180, 46875, 20947, 2127286, 1343640, 481679, 565494,
309051, 191932, 570553, 968624, 3807762, 281065, 1186138, 1168816, 231340, 715540,
};
CBlockIndex CreateBlockIndex(int nHeight)
@ -166,7 +166,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
txFirst.push_back(new CTransaction(pblock->vtx[0]));
pblock->hashMerkleRoot = BlockMerkleRoot(*pblock);
pblock->nNonce = nonces[i];
/*bool fFound = false;
/* bool fFound = false;
for (int j = 0; !fFound; j++)
{
pblock->nNonce = j;

View file

@ -136,7 +136,7 @@ TestChain100Setup::CreateAndProcessBlock(const std::vector<CMutableTransaction>&
unsigned int extraNonce = 0;
IncrementExtraNonce(&block, chainActive.Tip(), extraNonce);
while (!CheckProofOfWork(block.GetHash(), block.nBits, chainparams.GetConsensus())) ++block.nNonce;
while (!CheckProofOfWork(block.GetPoWHash(), block.nBits, chainparams.GetConsensus())) ++block.nNonce;
CValidationState state;
ProcessNewBlock(state, chainparams, NULL, &block, true, NULL);

View file

@ -3138,6 +3138,12 @@ static const CRPCCommand commands[] =
{ "wallet", "walletpassphrasechange", &walletpassphrasechange, true },
{ "wallet", "walletpassphrase", &walletpassphrase, true },
{ "wallet", "removeprunedfunds", &removeprunedfunds, true },
{ "Claimtrie", "claimname", &claimname, true },
{ "Claimtrie", "updateclaim", &updateclaim, true },
{ "Claimtrie", "abandonclaim", &abandonclaim, true },
{ "Claimtrie", "listnameclaims", &listnameclaims, true },
{ "Claimtrie", "supportclaim", &supportclaim, true },
{ "Claimtrie", "abandonsupport", &abandonsupport, true },
};
void RegisterWalletRPCCommands(CRPCTable &tableRPC)