Rebase LBRY on top of Bitcoin 0.17 #263

Closed
lbrynaut wants to merge 18 commits from updated-rebase-0.17-deps into bitcoin-0.17
5 changed files with 52 additions and 45 deletions
Showing only changes of commit 550929c10d - Show all commits

View file

@ -1,6 +1,6 @@
all:
$(MAKE) -C .. bitcoin_test
$(MAKE) -C .. lbrycrd_test
clean:
$(MAKE) -C .. bitcoin_test_clean
$(MAKE) -C .. lbrycrd_test_clean
check:
$(MAKE) -C .. bitcoin_test_check
$(MAKE) -C .. lbrycrd_test_check

View file

@ -114,6 +114,13 @@ CMutableTransaction BuildTransaction(const CTransaction& prev, uint32_t prevout=
return tx;
}
static BlockAssembler AssemblerForTest() {
BlockAssembler::Options options;
options.nBlockMaxWeight = DEFAULT_BLOCK_MAX_WEIGHT;
options.blockMinFeeRate = CFeeRate(0);
return BlockAssembler(Params(), options);
}
// Test Fixtures
struct ClaimTrieChainFixture{
std::vector<CTransaction> coinbase_txs;
@ -155,8 +162,8 @@ struct ClaimTrieChainFixture{
bool CreateBlock(const std::unique_ptr<CBlockTemplate>& pblocktemplate)
{
CBlock* pblock = &pblocktemplate->block;
pblock->hashPrevBlock = chainActive.Tip()->GetBlockHash();
pblock->nVersion = 5;
pblock->hashPrevBlock = chainActive.Tip()->GetBlockHash();
pblock->nTime = chainActive.Tip()->GetBlockTime() + Params().GetConsensus().nPowTargetSpacing;
CMutableTransaction txCoinbase(*pblock->vtx[0]);
txCoinbase.vin[0].scriptSig = CScript() << int(chainActive.Height() + 1) << int(++unique_block_counter);
@ -176,9 +183,8 @@ struct ClaimTrieChainFixture{
{
std::unique_ptr<CBlockTemplate> pblocktemplate;
coinbases.clear();
BOOST_CHECK(pblocktemplate = BlockAssembler(Params()).CreateNewBlock(CScript() << OP_TRUE));
BOOST_CHECK(pblocktemplate = AssemblerForTest().CreateNewBlock(CScript() << OP_TRUE));
BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), 1);
pblocktemplate->block.hashPrevBlock = chainActive.Tip()->GetBlockHash();
for (unsigned int i = 0; i < 100 + num_coinbases; ++i) {
BOOST_CHECK(CreateBlock(pblocktemplate));
if (coinbases.size() < num_coinbases)
@ -277,9 +283,8 @@ struct ClaimTrieChainFixture{
std::unique_ptr<CBlockTemplate> pblocktemplate;
CScript coinbase_scriptpubkey;
coinbase_scriptpubkey << CScriptNum(chainActive.Height());
BOOST_CHECK(pblocktemplate = BlockAssembler(Params()).CreateNewBlock(coinbase_scriptpubkey));
BOOST_CHECK(pblocktemplate->block.vtx.size() == num_txs_for_next_block+1);
pblocktemplate->block.hashPrevBlock = chainActive.Tip()->GetBlockHash();
BOOST_CHECK(pblocktemplate = AssemblerForTest().CreateNewBlock(coinbase_scriptpubkey));
BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), num_txs_for_next_block + 1);
BOOST_CHECK(CreateBlock(pblocktemplate));
num_txs_for_next_block = 0 ;
}
@ -3067,7 +3072,7 @@ BOOST_AUTO_TEST_CASE(bogus_claimtrie_hash_test)
CMutableTransaction tx1 = fixture.MakeClaim(fixture.GetCoinbase(), sName, sValue1, 1);
std::unique_ptr<CBlockTemplate> pblockTemp;
BOOST_CHECK(pblockTemp = BlockAssembler(Params()).CreateNewBlock(tx1.vout[0].scriptPubKey));
BOOST_CHECK(pblockTemp = AssemblerForTest().CreateNewBlock(tx1.vout[0].scriptPubKey));
pblockTemp->block.hashPrevBlock = chainActive.Tip()->GetBlockHash();
pblockTemp->block.nVersion = 5;
pblockTemp->block.nTime = chainActive.Tip()->GetBlockTime() + Params().GetConsensus().nPowTargetSpacing;

View file

@ -709,7 +709,7 @@ BOOST_AUTO_TEST_CASE(ccoins_spend)
CheckSpendCoins(VALUE1, VALUE2, PRUNED, DIRTY , DIRTY );
CheckSpendCoins(VALUE1, VALUE2, ABSENT, DIRTY|FRESH, NO_ENTRY );
}
/*
static void CheckAddCoinBase(CAmount base_value, CAmount cache_value, CAmount modify_value, CAmount expected_value, char cache_flags, char expected_flags, bool coinbase)
{
SingleEntryCacheTest test(base_value, cache_value, cache_flags);
@ -743,35 +743,35 @@ static void CheckAddCoin(Args&&... args)
CheckAddCoinBase(base_value, std::forward<Args>(args)...);
}
/* BOOST_AUTO_TEST_CASE(ccoins_add) */
/* { */
/* /\* Check AddCoin behavior, requesting a new coin from a cache view, */
/* * writing a modification to the coin, and then checking the resulting */
/* * entry in the cache after the modification. Verify behavior with the */
/* * with the AddCoin potential_overwrite argument set to false, and to true. */
/* * */
/* * Cache Write Result Cache Result potential_overwrite */
/* * Value Value Value Flags Flags */
/* *\/ */
/* CheckAddCoin(ABSENT, VALUE3, VALUE3, NO_ENTRY , DIRTY|FRESH, false); */
/* CheckAddCoin(ABSENT, VALUE3, VALUE3, NO_ENTRY , DIRTY , true ); */
/* CheckAddCoin(PRUNED, VALUE3, VALUE3, 0 , DIRTY|FRESH, false); */
/* CheckAddCoin(PRUNED, VALUE3, VALUE3, 0 , DIRTY , true ); */
/* CheckAddCoin(PRUNED, VALUE3, VALUE3, FRESH , DIRTY|FRESH, false); */
/* CheckAddCoin(PRUNED, VALUE3, VALUE3, FRESH , DIRTY|FRESH, true ); */
/* CheckAddCoin(PRUNED, VALUE3, VALUE3, DIRTY , DIRTY , false); */
/* CheckAddCoin(PRUNED, VALUE3, VALUE3, DIRTY , DIRTY , true ); */
/* CheckAddCoin(PRUNED, VALUE3, VALUE3, DIRTY|FRESH, DIRTY|FRESH, false); */
/* CheckAddCoin(PRUNED, VALUE3, VALUE3, DIRTY|FRESH, DIRTY|FRESH, true ); */
/* CheckAddCoin(VALUE2, VALUE3, FAIL , 0 , NO_ENTRY , false); */
/* CheckAddCoin(VALUE2, VALUE3, VALUE3, 0 , DIRTY , true ); */
/* CheckAddCoin(VALUE2, VALUE3, FAIL , FRESH , NO_ENTRY , false); */
/* CheckAddCoin(VALUE2, VALUE3, VALUE3, FRESH , DIRTY|FRESH, true ); */
/* CheckAddCoin(VALUE2, VALUE3, FAIL , DIRTY , NO_ENTRY , false); */
/* CheckAddCoin(VALUE2, VALUE3, VALUE3, DIRTY , DIRTY , true ); */
/* CheckAddCoin(VALUE2, VALUE3, FAIL , DIRTY|FRESH, NO_ENTRY , false); */
/* CheckAddCoin(VALUE2, VALUE3, VALUE3, DIRTY|FRESH, DIRTY|FRESH, true ); */
/* } */
BOOST_AUTO_TEST_CASE(ccoins_add)
{
// * Check AddCoin behavior, requesting a new coin from a cache view,
// * writing a modification to the coin, and then checking the resulting
// * entry in the cache after the modification. Verify behavior with the
// * with the AddCoin potential_overwrite argument set to false, and to true.
// *
// * Cache Write Result Cache Result potential_overwrite
// * Value Value Value Flags Flags
// *
CheckAddCoin(ABSENT, VALUE3, VALUE3, NO_ENTRY , DIRTY|FRESH, false);
CheckAddCoin(ABSENT, VALUE3, VALUE3, NO_ENTRY , DIRTY , true );
CheckAddCoin(PRUNED, VALUE3, VALUE3, 0 , DIRTY|FRESH, false);
CheckAddCoin(PRUNED, VALUE3, VALUE3, 0 , DIRTY , true );
CheckAddCoin(PRUNED, VALUE3, VALUE3, FRESH , DIRTY|FRESH, false);
CheckAddCoin(PRUNED, VALUE3, VALUE3, FRESH , DIRTY|FRESH, true );
CheckAddCoin(PRUNED, VALUE3, VALUE3, DIRTY , DIRTY , false);
CheckAddCoin(PRUNED, VALUE3, VALUE3, DIRTY , DIRTY , true );
CheckAddCoin(PRUNED, VALUE3, VALUE3, DIRTY|FRESH, DIRTY|FRESH, false);
CheckAddCoin(PRUNED, VALUE3, VALUE3, DIRTY|FRESH, DIRTY|FRESH, true );
CheckAddCoin(VALUE2, VALUE3, FAIL , 0 , NO_ENTRY , false);
CheckAddCoin(VALUE2, VALUE3, VALUE3, 0 , DIRTY , true );
CheckAddCoin(VALUE2, VALUE3, FAIL , FRESH , NO_ENTRY , false);
CheckAddCoin(VALUE2, VALUE3, VALUE3, FRESH , DIRTY|FRESH, true );
CheckAddCoin(VALUE2, VALUE3, FAIL , DIRTY , NO_ENTRY , false);
CheckAddCoin(VALUE2, VALUE3, VALUE3, DIRTY , DIRTY , true );
CheckAddCoin(VALUE2, VALUE3, FAIL , DIRTY|FRESH, NO_ENTRY , false);
CheckAddCoin(VALUE2, VALUE3, VALUE3, DIRTY|FRESH, DIRTY|FRESH, true );
} */
void CheckWriteCoins(CAmount parent_value, CAmount child_value, CAmount expected_value, char parent_flags, char child_flags, char expected_flags)
{

View file

@ -38,7 +38,7 @@ private:
const std::string m_reason;
};
static CFeeRate blockMinFeeRate = CFeeRate(DEFAULT_BLOCK_MIN_TX_FEE);
static CFeeRate blockMinFeeRate = CFeeRate(0);
static BlockAssembler AssemblerForTest(const CChainParams& params) {
BlockAssembler::Options options;
@ -267,9 +267,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
}
std::shared_ptr<const CBlock> shared_pblock = std::make_shared<const CBlock>(*pblock);
if (!ProcessNewBlock(chainparams, shared_pblock, true, nullptr)) {
std::cout << pblock->ToString() << '\n';
}
BOOST_CHECK(ProcessNewBlock(chainparams, shared_pblock, true, nullptr));
}
LOCK(::mempool.cs);

View file

@ -11,6 +11,7 @@
#include <validation.h>
#include <miner.h>
#include <net_processing.h>
#include <policy/policy.h>
#include <pow.h>
#include <ui_interface.h>
#include <streams.h>
@ -181,7 +182,10 @@ CBlock
TestChain100Setup::CreateAndProcessBlock(const std::vector<CMutableTransaction>& txns, const CScript& scriptPubKey)
{
const CChainParams& chainparams = Params();
std::unique_ptr<CBlockTemplate> pblocktemplate = BlockAssembler(chainparams).CreateNewBlock(scriptPubKey);
BlockAssembler::Options options;
options.nBlockMaxWeight = DEFAULT_BLOCK_MAX_WEIGHT;
options.blockMinFeeRate = CFeeRate(0);
std::unique_ptr<CBlockTemplate> pblocktemplate = BlockAssembler(chainparams, options).CreateNewBlock(scriptPubKey);
CBlock& block = pblocktemplate->block;
// Replace mempool-selected txns with just coinbase plus passed-in txns: