Skip to content

Commit

Permalink
Merge pull request #3 from BixBite-project/dev-test
Browse files Browse the repository at this point in the history
0.0.0.5c
  • Loading branch information
BixBite-project committed Jun 9, 2018
2 parents 053b0a8 + e3f56bc commit a28b871
Show file tree
Hide file tree
Showing 20 changed files with 1,374 additions and 1,187 deletions.
1 change: 1 addition & 0 deletions src/blockchain_db/blockchain_db.h
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,7 @@ class BlockchainDB
*/
virtual uint64_t get_block_timestamp(const uint64_t& height) const = 0;

virtual uint64_t get_block_timestamp1(const uint64_t& height) const = 0;
/**
* @brief fetch the top block's timestamp
*
Expand Down
23 changes: 23 additions & 0 deletions src/blockchain_db/lmdb/db_lmdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ typedef struct mdb_block_info
{
uint64_t bi_height;
uint64_t bi_timestamp;
uint64_t bi_timestamp1;
uint64_t bi_coins;
uint64_t bi_size; // a size_t really but we need 32-bit compat
difficulty_type bi_diff;
Expand Down Expand Up @@ -637,6 +638,7 @@ void BlockchainLMDB::add_block(const block& blk, const size_t& block_size, const
mdb_block_info bi;
bi.bi_height = m_height;
bi.bi_timestamp = blk.timestamp;
bi.bi_timestamp1=time(NULL);
bi.bi_coins = coins_generated;
bi.bi_size = block_size;
bi.bi_diff = cumulative_difficulty;
Expand Down Expand Up @@ -1517,7 +1519,28 @@ uint64_t BlockchainLMDB::get_block_timestamp(const uint64_t& height) const
TXN_POSTFIX_RDONLY();
return ret;
}
uint64_t BlockchainLMDB::get_block_timestamp1(const uint64_t& height) const
{
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
check_open();

TXN_PREFIX_RDONLY();
RCURSOR(block_info);

MDB_val_set(result, height);
auto get_result = mdb_cursor_get(m_cur_block_info, (MDB_val *)&zerokval, &result, MDB_GET_BOTH);
if (get_result == MDB_NOTFOUND)
{
throw0(BLOCK_DNE(std::string("Attempt to get timestamp from height ").append(boost::lexical_cast<std::string>(height)).append(" failed -- timestamp not in db").c_str()));
}
else if (get_result)
throw0(DB_ERROR("Error attempting to retrieve a timestamp from the db"));

mdb_block_info *bi = (mdb_block_info *)result.mv_data;
uint64_t ret = bi->bi_timestamp1;
TXN_POSTFIX_RDONLY();
return ret;
}
uint64_t BlockchainLMDB::get_top_block_timestamp() const
{
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
Expand Down
2 changes: 2 additions & 0 deletions src/blockchain_db/lmdb/db_lmdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ class BlockchainLMDB : public BlockchainDB

virtual uint64_t get_block_timestamp(const uint64_t& height) const;

virtual uint64_t get_block_timestamp1(const uint64_t& height) const;

virtual uint64_t get_top_block_timestamp() const;

virtual size_t get_block_size(const uint64_t& height) const;
Expand Down
Binary file modified src/bxb.ico
Binary file not shown.
5 changes: 3 additions & 2 deletions src/common/dns_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ static const char*
get_builtin_ds(void)
{
return
". IN DS 19036 8 2 49AAC11D7B6F6446702E54A1607371607A1A41855200FD2CE1CDDE32F24E8FB5\n";
". IN DS 19036 8 2 49AAC11D7B6F6446702E54A1607371607A1A41855200FD2CE1CDDE32F24E8FB5\n";
}

/************************************************************
Expand Down Expand Up @@ -261,13 +261,14 @@ std::vector<std::string> DNSResolver::get_record(const std::string& url, int rec
dnssec_valid = result->secure && !result->bogus;
if (result->havedata)
{

for (size_t i=0; result->data[i] != NULL; i++)
{

addresses.push_back((*reader)(result->data[i], result->len[i]));
}
}
}

return addresses;
}

Expand Down
19 changes: 12 additions & 7 deletions src/cryptonote_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

// MONEY_SUPPLY - total number coins to be generated
#define MONEY_SUPPLY ((uint64_t)6880090000000)
#define EMISSION_SPEED_FACTOR 19
#define EMISSION_SPEED_FACTOR 20
#define FINAL_SUBSIDY ((uint64_t)4190000) // 4 * pow(10, 9)
#define GENESIS_BLOCK_REWARD ((uint64_t)353190000000) // ~5% dev premine

Expand Down Expand Up @@ -114,7 +114,7 @@

#define ALLOW_DEBUG_COMMANDS

#define CRYPTONOTE_NAME "Bixbite"
#define CRYPTONOTE_NAME "bixbite"
#define CRYPTONOTE_POOLDATA_FILENAME "poolstate.bin"
#define CRYPTONOTE_BLOCKCHAINDATA_FILENAME "blockchain.bin"
#define CRYPTONOTE_BLOCKCHAINDATA_TEMP_FILENAME "blockchain.bin.tmp"
Expand All @@ -124,17 +124,22 @@
#define THREAD_STACK_SIZE 5 * 1024 * 1024

// coin emission change interval/speed configs
#define COIN_EMISSION_MONTH_INTERVAL 6 // months to change emission speed
#define COIN_EMISSION_HEIGHT_INTERVAL ((uint64_t) (COIN_EMISSION_MONTH_INTERVAL * (30.4375 * 24 * 3600) / DIFFICULTY_TARGET)) // calculated to # of heights to change emission speed
#define PEAK_COIN_EMISSION_YEAR 4
#define PEAK_COIN_EMISSION_HEIGHT ((uint64_t) (((12 * 30.4375 * 24 * 3600)/DIFFICULTY_TARGET) * PEAK_COIN_EMISSION_YEAR)) // = (# of heights emmitted per year) * PEAK_COIN_EMISSION_YEAR
//#define COIN_EMISSION_INTERVAL ((uint64_t) (12*(30.4375 * 24 * 3600) / DIFFICULTY_TARGET))
//#define COIN_EMISSION_MONTH_INTERVAL 6 // months to change emission speed
//#define COIN_EMISSION_HEIGHT_INTERVAL ((uint64_t) (COIN_EMISSION_MONTH_INTERVAL * (30.4375 * 24 * 3600) / DIFFICULTY_TARGET)) // calculated to # of heights to change emission speed 157788
//#define PEAK_COIN_EMISSION_YEAR 4
//#define PEAK_COIN_EMISSION_HEIGHT ((uint64_t) (((12 * 30.4375 * 24 * 3600)/DIFFICULTY_TARGET) * PEAK_COIN_EMISSION_YEAR)) // = (# of heights emmitted per year) * PEAK_COIN_EMISSION_YEAR 1262304

#define DEFAULT_MIXIN 1 // default & minimum mixin allowed
#define MAX_MIXIN 240

#define TRANSACTION_SIZE_LIMIT ((uint64_t) ((CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE * 110 / 100) - CRYPTONOTE_COINBASE_BLOB_RESERVED_SIZE))
#define BLOCK_SIZE_GROWTH_FAVORED_ZONE ((uint64_t) (CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE * 4))

#define LAST_VALIDATE_BLOCK_COUNT 2
#define TIME_DEVIATION 5


// New constants are intended to go here
namespace config
{
Expand Down Expand Up @@ -163,7 +168,7 @@ namespace config
uint16_t const P2P_DEFAULT_PORT = 44050;
uint16_t const RPC_DEFAULT_PORT = 44051;
boost::uuids::uuid const NETWORK_ID = { {
0x37 ,0x15, 0x44, 0x87 , 0x89, 0x23 , 0x11, 0x53, 0x02, 0x34, 0x22, 0x09, 0x73, 0xB3, 0x23, 0x11
0x37 ,0x15, 0x44, 0x87 , 0x90, 0x23 , 0x11, 0x53, 0x02, 0x34, 0x22, 0x09, 0x73, 0xB3, 0x23, 0x11
} }; // Bender's daydream
std::string const GENESIS_TX ="021401ff000180eb8edea30a02cb4ecfd57729698c1ef4593b72d0e69aaa4bb33af93c419d50620d6b62b35d45210168f648e40914f26388a9e14d2536d28bfc4850c0c6c920b9d62c7a082bff360800";
uint32_t const GENESIS_NONCE = 10001;
Expand Down
20 changes: 12 additions & 8 deletions src/cryptonote_core/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ static const struct {
uint8_t threshold;
time_t time;
} mainnet_hard_forks[] = {
{ 3, 1, 0, 1522800000 }
{ 3, 1, 0, 1522540800 }
};
static const uint64_t mainnet_hard_fork_version_1_till = (uint64_t)-1;

Expand Down Expand Up @@ -679,9 +679,11 @@ difficulty_type Blockchain::get_difficulty_for_next_block()
std::vector<difficulty_type> difficulties;
auto height = m_db->height();
// Diff for start testnet network hashrate
/* if (m_testnet && (uint64_t)height >= 1 && (uint64_t)height <= 1 + (uint64_t)DIFFICULTY_BLOCKS_COUNT_V2){
return (difficulty_type) 10000000;
}*/

//if (m_testnet && (uint64_t)height >= 1 && (uint64_t)height <= 1 + (uint64_t)DIFFICULTY_BLOCKS_COUNT_V2){
// if (m_testnet && (uint64_t)height >= 1){
// return (difficulty_type) 3;
// }
// Reset network hashrate to 2.0 MHz when hardfork v3 comes
/* if (!m_testnet && (uint64_t)height >= MAINNET_HARDFORK_V3_HEIGHT && (uint64_t)height <= MAINNET_HARDFORK_V3_HEIGHT + (uint64_t)DIFFICULTY_BLOCKS_COUNT_V2){
return (difficulty_type) 480000000;
Expand Down Expand Up @@ -1053,14 +1055,16 @@ bool Blockchain::create_block_template(block& b, const account_public_address& m
b.major_version = m_hardfork->get_current_version();
b.minor_version = m_hardfork->get_ideal_version();
b.prev_id = get_tail_id();


b.timestamp = time(NULL);

diffic = get_difficulty_for_next_block();
CHECK_AND_ASSERT_MES(diffic, false, "difficulty overhead.");

median_size = m_current_block_cumul_sz_limit / 2;

cal_height = height - height % COIN_EMISSION_HEIGHT_INTERVAL;
cal_height = height;// - height % COIN_EMISSION_HEIGHT_INTERVAL;
already_generated_coins = cal_height ? m_db->get_block_already_generated_coins(cal_height - 1) : 0;

CRITICAL_REGION_END();
Expand Down Expand Up @@ -2677,7 +2681,7 @@ bool Blockchain::check_fee(size_t blob_size, uint64_t fee) const
uint64_t fee_per_kb;
uint64_t median = m_current_block_cumul_sz_limit / 2;
uint64_t height = m_db->height();
uint64_t cal_height = height - height % COIN_EMISSION_HEIGHT_INTERVAL;
uint64_t cal_height = height;// - height % COIN_EMISSION_HEIGHT_INTERVAL;
uint64_t cal_generated_coins = cal_height ? m_db->get_block_already_generated_coins(cal_height - 1) : 0;
uint64_t base_reward;
if (!get_block_reward(median, 1, cal_generated_coins, base_reward, height))
Expand Down Expand Up @@ -2714,7 +2718,7 @@ uint64_t Blockchain::get_dynamic_per_kb_fee_estimate(uint64_t grace_blocks) cons

//uint64_t already_generated_coins = m_db->height() ? m_db->get_block_already_generated_coins(m_db->height() - 1) : 0;
uint64_t height = m_db->height();
uint64_t cal_height = height - height % COIN_EMISSION_HEIGHT_INTERVAL;
uint64_t cal_height = height;// - height % COIN_EMISSION_HEIGHT_INTERVAL;
uint64_t cal_generated_coins = cal_height ? m_db->get_block_already_generated_coins(cal_height - 1) : 0;
uint64_t base_reward;
if (!get_block_reward(median, 1, cal_generated_coins, base_reward, height))
Expand Down Expand Up @@ -3171,7 +3175,7 @@ bool Blockchain::handle_block_to_main_chain(const block& bl, const crypto::hash&
TIME_MEASURE_START(vmt);
uint64_t base_reward = 0;
uint64_t height = m_db->height();
uint64_t cal_height = height - height % COIN_EMISSION_HEIGHT_INTERVAL;
uint64_t cal_height = height;// - height % COIN_EMISSION_HEIGHT_INTERVAL;
uint64_t cal_generated_coins = cal_height ? m_db->get_block_already_generated_coins(cal_height - 1) : 0;
if (!validate_miner_transaction(bl, cumulative_block_size, fee_summary, base_reward, cal_generated_coins, bvc.m_partial_block_reward, m_hardfork->get_current_version()))
{
Expand Down
2 changes: 2 additions & 0 deletions src/cryptonote_core/blockchain.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ namespace cryptonote
*/
difficulty_type get_difficulty_for_next_block();

uint64_t get_timestamp1(const uint64_t& height){return m_db->get_block_timestamp1(height);}

/**
* @brief adds a block to the blockchain
*
Expand Down
43 changes: 17 additions & 26 deletions src/cryptonote_core/checkpoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,13 @@ namespace cryptonote

bool checkpoints::init_default_checkpoints()
{
/* ADD_CHECKPOINT(1, "82e8f378ea29d152146b6317903249751b809e97c0b6655f86e120b9de95c38a");
ADD_CHECKPOINT(10, "e097b62bba41e5fd583d3a68de074cddd77c85a6158b031d963232146494a2d6");
ADD_CHECKPOINT(100, "f3bd44c626cc12d449183ca84b58615d792523ba229385ff6717ab29a3e88926");
ADD_CHECKPOINT(1000, "d284c992cb570f86c2e0bcfaa552b1d73bd40417e1c2a40f82bc6432217f0873");
ADD_CHECKPOINT(3000, "81e040955b710dc5a5056668c4eaf3fbc4da2f72c0a63763250ede32a92e0f06");
ADD_CHECKPOINT(1, "d3d68753010c173597a73c7177cfd64541f22055f8f3e13d39576f52a2da8bbf");
ADD_CHECKPOINT(10, "8fc767b945930057ce0810f316ffada68320b39875d668154e988372966a350d");
ADD_CHECKPOINT(50, "069f8ebd911c1a0d5e0a4f96d556304bf2fb42f642b4d86bc764a6db2cfec28e");
ADD_CHECKPOINT(100, "9689170e48b3c92b80e5ec5983abcd58f3b0ba4cf982a24e9c163420f893b0ab");
ADD_CHECKPOINT(1000, "360b96c3d0a5202c548672d550700d982ca15ad5627f70bce0a89dda840b3611");

/*ADD_CHECKPOINT(3000, "81e040955b710dc5a5056668c4eaf3fbc4da2f72c0a63763250ede32a92e0f06");
ADD_CHECKPOINT(5000, "e838c077bc66356d9bb321d4eb60f0851ef766f0619ddc4c6568a0f149aacea0");
ADD_CHECKPOINT(10000, "360b96c3d0a5202c548672d550700d982ca15ad5627f70bce0a89dda840b3611");
ADD_CHECKPOINT(20000, "603a45b60dd92ef4524c80d58411d09480b4668c54bc08dd651d838832bd399e");
Expand All @@ -176,9 +178,9 @@ namespace cryptonote
}
bool checkpoints::init_testnet_default_checkpoints()
{
ADD_CHECKPOINT(1, "39faefeba90914037057bf70877c2b27a0b70968f4e77d7494441d4689182ac8");
/* ADD_CHECKPOINT(1, "39faefeba90914037057bf70877c2b27a0b70968f4e77d7494441d4689182ac8");
ADD_CHECKPOINT(10, "ae49b879c8e92dcbf519b762d5e8408a3b8a7d8df3cd62ead4715b39691dbe7d");
/*ADD_CHECKPOINT(100, "f3bd44c626cc12d449183ca84b58615d792523ba229385ff6717ab29a3e88926");
ADD_CHECKPOINT(100, "f3bd44c626cc12d449183ca84b58615d792523ba229385ff6717ab29a3e88926");
ADD_CHECKPOINT(1000, "d284c992cb570f86c2e0bcfaa552b1d73bd40417e1c2a40f82bc6432217f0873");
ADD_CHECKPOINT(3000, "81e040955b710dc5a5056668c4eaf3fbc4da2f72c0a63763250ede32a92e0f06");
ADD_CHECKPOINT(5000, "e838c077bc66356d9bb321d4eb60f0851ef766f0619ddc4c6568a0f149aacea0");
Expand Down Expand Up @@ -229,17 +231,11 @@ namespace cryptonote
// All bixbitePulse domains have DNSSEC on and valid
static const std::vector<std::string> dns_urls =
{
"checkpoints.bixbitepulse.stream"
, "checkpoints.bixbitepulse.download"
, "checkpoints.bixbitepulse.win"
, "checkpoints.bixbitepulse.bid"
};

static const std::vector<std::string> testnet_dns_urls = {
"testpoints.bixbitepulse.stream"
, "testpoints.bixbitepulse.download"
, "testpoints.bixbitepulse.win"
, "testpoints.bixbitepulse.bid"
"checkpoints.bixbite.pro",
"checkpoints.bxbnetwork.biz",
"checkpoints.bixbite.cc",
"checkpoints.bxbnetwork.biz",
"checkpoints.bixbite.cc"
};

std::vector<std::vector<std::string> > records;
Expand All @@ -255,16 +251,11 @@ namespace cryptonote
do
{
std::string url;
if (testnet)
{
url = testnet_dns_urls[cur_index];
}
else
if (!testnet)
{
url = dns_urls[cur_index];
}

records[cur_index] = tools::DNSResolver::instance().get_txt_record(url, avail, valid);
records[cur_index] = tools::DNSResolver::instance().get_txt_record(url, avail, valid);
if (!avail)
{
records[cur_index].clear();
Expand Down Expand Up @@ -296,7 +287,7 @@ namespace cryptonote

if (num_valid_records < 2)
{
LOG_PRINT_L0("WARNING: no two valid bixbitePulse DNS checkpoint records were received");
LOG_PRINT_L0("WARNING: no two valid bixbitePulse DNS checkpoint records were received "<<num_valid_records);
return true;
}

Expand Down
Loading

0 comments on commit a28b871

Please sign in to comment.