1
0
Fork 0
forked from lthn/blockchain

fixed coretests

This commit is contained in:
crypro.zoidberg 2019-01-14 19:51:32 +03:00
parent a61ed92e9e
commit 3c1bb1b042
8 changed files with 49 additions and 26 deletions

View file

@ -98,13 +98,20 @@ blockchain_storage::blockchain_storage(tx_memory_pool& tx_pool) :m_db(std::share
m_interprocess_locker_file(0),
m_current_fee_median(0),
m_current_fee_median_effective_index(0),
m_is_reorganize_in_process(false)
m_is_reorganize_in_process(false),
m_deinit_is_done(false)
{
m_services_mgr.set_core_runtime_config(m_core_runtime_config);
m_performance_data.epic_failure_happend = false;
}
blockchain_storage::~blockchain_storage()
{
if (!m_deinit_is_done)
deinit();
}
//------------------------------------------------------------------
bool blockchain_storage::have_tx(const crypto::hash &id) const
{
@ -315,6 +322,7 @@ bool blockchain_storage::deinit()
{
m_db.close();
epee::file_io_utils::unlock_and_close_file(m_interprocess_locker_file);
m_deinit_is_done = true;
return true;
}
//------------------------------------------------------------------

View file

@ -165,6 +165,7 @@ namespace currency
//---------------------------------------------------------------------------------
blockchain_storage(tx_memory_pool& tx_pool);
~blockchain_storage();
bool init(const boost::program_options::variables_map& vm) { return init(tools::get_default_data_dir(), vm); }
@ -512,6 +513,7 @@ namespace currency
bool m_is_reorganize_in_process;
mutable scratchpad_keeper m_scratchpad;
crypto::hash m_current_scratchpad_seed;
mutable std::atomic<bool> m_deinit_is_done;
bool init_tx_fee_median();

View file

@ -11,26 +11,35 @@
namespace currency
{
scratchpad_keeper::scratchpad_keeper():m_seed(null_hash)
{
}
bool scratchpad_keeper::generate(const crypto::hash& scr_seed, uint64_t height)
{
bool r = crypto::generate_scratchpad(scr_seed, m_scratchpad, get_scratchpad_size_for_height(height));
bool r = false;
CRITICAL_REGION_BEGIN(m_lock);
r = crypto::generate_scratchpad(scr_seed, m_scratchpad, get_scratchpad_size_for_height(height));
if (r)
m_seed = scr_seed;
CRITICAL_REGION_END();
return r;
}
crypto::hash scratchpad_keeper::get_pow_hash(const blobdata& bd, uint64_t height, const crypto::hash& scr_seed)
{
crypto::hash res_hash = null_hash;
if (scr_seed != m_seed)
{
bool r = generate(scr_seed, height);
CHECK_AND_ASSERT_THROW_MES(r, "Unable to generate scratchpad");
}
CHECK_AND_ASSERT_THROW_MES(get_scratchpad_size_for_height(height) == this->size(), "Fatal error on hash calculation: scratchpad_size=" << m_scratchpad.size() << " at height=" << height);
CHECK_AND_ASSERT_THROW_MES(scr_seed == m_seed, "Fatal error on hash calculation: scratchpad_seed missmatch");
crypto::hash res_hash = null_hash;
CRITICAL_REGION_BEGIN(m_lock);
CHECK_AND_ASSERT_THROW_MES(get_scratchpad_size_for_height(height) == this->size(), "Fatal error on hash calculation: scratchpad_size=" << m_scratchpad.size() << " at height=" << height << ", scr_seed=" << scr_seed << ", m_seed=" << m_seed);
CHECK_AND_ASSERT_THROW_MES(scr_seed == m_seed, "Fatal error on hash calculation: scratchpad_seed missmatch scr_seed=" << scr_seed << ", m_seed=" << m_seed);
bool res = get_wild_keccak2(bd, res_hash, m_scratchpad);
CHECK_AND_ASSERT_THROW_MES(res, "Fatal error on hash calculation: scratchpad_size=" << m_scratchpad.size());
CRITICAL_REGION_END();
return res_hash;
}
crypto::hash scratchpad_keeper::get_pow_hash(const block& b, const crypto::hash& scr_seed)
@ -42,5 +51,4 @@ namespace currency
{
return m_scratchpad.size();
}
}

View file

@ -12,13 +12,16 @@ namespace currency
class scratchpad_keeper
{
public:
scratchpad_keeper();
bool generate(const crypto::hash& seed, uint64_t height);
crypto::hash get_pow_hash(const blobdata& bd, uint64_t height, const crypto::hash& seed);
crypto::hash get_pow_hash(const block& b, const crypto::hash& seed);
uint64_t size();
private:
scratchpad_keeper(const scratchpad_keeper&) {}
crypto::hash m_seed;
std::vector<crypto::hash> m_scratchpad;
std::recursive_mutex m_lock;
};
}

View file

@ -1291,7 +1291,7 @@ bool gen_alias_switch_and_check_block_template::add_block_from_template(currency
uint64_t height;
crypto::hash seed = currency::null_hash;
blobdata extra = AUTO_VAL_INIT(extra);
bool r = c.get_block_template(b, acc.get_public_address(), acc.get_public_address(), diff, height, extra);
bool r = c.get_block_template(b, seed, acc.get_public_address(), acc.get_public_address(), diff, height, extra);
CHECK_AND_ASSERT_MES(r, false, "get_block_template failed");
r = miner::find_nonce_for_given_block(b, diff, height, seed, m_scratchpad_keeper);

View file

@ -104,6 +104,7 @@ bool generate_and_play(const char* const genclass_name)
else
{
std::cout << concolor::magenta << "#TEST# Failed " << genclass_name << concolor::normal << std::endl;
LOG_PRINT_RED_L0("#TEST# Failed " << genclass_name);
result = false;
}
std::cout << std::endl;
@ -217,7 +218,7 @@ bool gen_and_play_intermitted_by_blockchain_saveload(const char* const genclass_
#define GENERATE_AND_PLAY(genclass) \
if(run_single_test.empty() || run_single_test == #genclass) \
if(!postponed_tests.count(#genclass) && (run_single_test.empty() || run_single_test == #genclass)) \
{ \
TIME_MEASURE_START_MS(t); \
++tests_count; \
@ -678,6 +679,23 @@ int main(int argc, char* argv[])
}
//CALL_TEST("check_hash_and_difficulty_monte_carlo_test", check_hash_and_difficulty_monte_carlo_test); // it's rather an experiment with unclean results than a solid test, for further research...
std::set<std::string> postponed_tests;
// Postponed tests - tests that may fail for the time being (believed that it's a serious issue and should be fixed later for some reason).
// In a perfect world this list is empty.
#define MARK_TEST_AS_POSTPONED(genclass) postponed_tests.insert(#genclass)
MARK_TEST_AS_POSTPONED(gen_checkpoints_reorganize);
MARK_TEST_AS_POSTPONED(gen_alias_update_after_addr_changed);
MARK_TEST_AS_POSTPONED(gen_alias_blocking_reg_by_invalid_tx);
MARK_TEST_AS_POSTPONED(gen_alias_blocking_update_by_invalid_tx);
MARK_TEST_AS_POSTPONED(gen_wallet_fake_outputs_randomness);
MARK_TEST_AS_POSTPONED(gen_wallet_fake_outputs_not_enough);
MARK_TEST_AS_POSTPONED(gen_wallet_spending_coinstake_after_minting);
MARK_TEST_AS_POSTPONED(gen_wallet_fake_outs_while_having_too_little_own_outs);
MARK_TEST_AS_POSTPONED(gen_uint_overflow_1);
#undef MARK_TEST_AS_POSTPONED
GENERATE_AND_PLAY(multisig_wallet_test);
GENERATE_AND_PLAY(multisig_wallet_test_many_dst);
@ -918,22 +936,6 @@ int main(int argc, char* argv[])
//GENERATE_AND_PLAY(gen_block_reward); */
std::set<std::string> postponed_tests;
// Postponed tests - tests that may fail for the time being (believed that it's a serious issue and should be fixed later for some reason).
// In a perfect world this list is empty.
#define MARK_TEST_AS_POSTPONED(genclass) postponed_tests.insert(#genclass)
MARK_TEST_AS_POSTPONED(gen_checkpoints_reorganize);
MARK_TEST_AS_POSTPONED(gen_alias_update_after_addr_changed);
MARK_TEST_AS_POSTPONED(gen_alias_blocking_reg_by_invalid_tx);
MARK_TEST_AS_POSTPONED(gen_alias_blocking_update_by_invalid_tx);
MARK_TEST_AS_POSTPONED(gen_wallet_fake_outputs_randomness);
MARK_TEST_AS_POSTPONED(gen_wallet_fake_outputs_not_enough);
MARK_TEST_AS_POSTPONED(gen_wallet_spending_coinstake_after_minting);
MARK_TEST_AS_POSTPONED(gen_wallet_fake_outs_while_having_too_little_own_outs);
MARK_TEST_AS_POSTPONED(gen_uint_overflow_1);
#undef MARK_TEST_AS_POSTPONED
size_t failed_postponed_tests_count = 0;

View file

@ -628,7 +628,7 @@ bool gen_no_attchments_in_coinbase::init_config_set_cp(currency::core& c, size_t
crc.pos_minimum_heigh = 1;
c.get_blockchain_storage().set_core_runtime_config(crc);
m_checkpoints.add_checkpoint(12, "6cac77f011a1d16c7c64fc16403670b71dbad38268e9bfc94d1c08c349ea19c5");
m_checkpoints.add_checkpoint(12, "57ba6f8b5de551d361d6c56f42ebf3ce1e0b21e42d1499dc9bd2b69c09357062");//"6cac77f011a1d16c7c64fc16403670b71dbad38268e9bfc94d1c08c349ea19c5");
c.set_checkpoints(currency::checkpoints(m_checkpoints));
return true;

View file

@ -1625,7 +1625,7 @@ multisig_and_checkpoints::multisig_and_checkpoints()
bool multisig_and_checkpoints::set_cp(currency::core& c, size_t ev_index, const std::vector<test_event_entry>& events)
{
currency::checkpoints checkpoints;
checkpoints.add_checkpoint(15, "79a45b39dbac12bfc2e432734e64db45d1af83509cfd20f4f73e14968192ea80");
checkpoints.add_checkpoint(15, "06338cf7c4bae725af8fa4424c9ab75ef5cbe1dc93a6ba606add664f2a23cbf6");
c.set_checkpoints(std::move(checkpoints));
return true;