Commit f84de488 authored by TyphooN's avatar TyphooN

Merge branch 'ty/v17' into 'master'

Ty/v17

See merge request !11
parents d7ff97ba 02642349
......@@ -1229,6 +1229,8 @@ namespace cryptonote
{
switch (b.major_version)
{
case 17:
return get_block_longhash_v13(b, res, height, bc);
case 16:
return get_block_longhash_v13(b, res, height, bc);
case 15:
......@@ -1291,7 +1293,7 @@ namespace cryptonote
return p;
}
//---------------------------------------------------------------
bool parse_and_validate_block_from_blob(const blobdata& b_blob, block& b)
bool parse_and_validate_block_from_blob(const blobdata& b_blob, block& b, crypto::hash *block_hash)
{
std::stringstream ss;
ss << b_blob;
......@@ -1300,9 +1302,26 @@ namespace cryptonote
CHECK_AND_ASSERT_MES(r, false, "Failed to parse block from blob");
b.invalidate_hashes();
b.miner_tx.invalidate_hashes();
if (block_hash)
{
calculate_block_hash(b, *block_hash);
++block_hashes_calculated_count;
b.hash = *block_hash;
b.set_hash_valid(true);
}
return true;
}
//---------------------------------------------------------------
bool parse_and_validate_block_from_blob(const blobdata& b_blob, block& b)
{
return parse_and_validate_block_from_blob(b_blob, b, NULL);
}
//---------------------------------------------------------------
bool parse_and_validate_block_from_blob(const blobdata& b_blob, block& b, crypto::hash &block_hash)
{
return parse_and_validate_block_from_blob(b_blob, b, &block_hash);
}
//---------------------------------------------------------------
blobdata block_to_blob(const block& b)
{
return t_serializable_object_to_blob(b);
......
......@@ -54,6 +54,7 @@ namespace cryptonote
crypto::hash get_transaction_prefix_hash(const transaction_prefix& tx);
bool parse_and_validate_tx_prefix_from_blob(const blobdata& tx_blob, transaction_prefix& tx);
bool parse_and_validate_tx_from_blob(const blobdata& tx_blob, transaction& tx, crypto::hash& tx_hash, crypto::hash& tx_prefix_hash);
bool parse_and_validate_tx_from_blob(const blobdata& tx_blob, transaction& tx, crypto::hash& tx_hash);
bool parse_and_validate_tx_from_blob(const blobdata& tx_blob, transaction& tx);
bool parse_and_validate_tx_base_from_blob(const blobdata& tx_blob, transaction& tx);
......@@ -113,7 +114,9 @@ namespace cryptonote
crypto::hash get_block_hash(const block& b);
bool get_block_longhash(const block& b, crypto::hash& res, uint64_t height, const cryptonote::Blockchain* bc);
crypto::hash get_block_longhash(const block& b, uint64_t height, const cryptonote::Blockchain* bc);
bool parse_and_validate_block_from_blob(const blobdata& b_blob, block& b, crypto::hash *block_hash);
bool parse_and_validate_block_from_blob(const blobdata& b_blob, block& b);
bool parse_and_validate_block_from_blob(const blobdata& b_blob, block& b, crypto::hash &block_hash);
bool get_inputs_money_amount(const transaction& tx, uint64_t& money);
uint64_t get_outs_money_amount(const transaction& tx);
bool check_inputs_types_supported(const transaction& tx);
......
......@@ -46,8 +46,8 @@
#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "difficulty"
#define MAX_AVERAGE_TIMESPAN (uint64_t) DIFFICULTY_TARGET_V2*6 // 6 minutes
#define MIN_AVERAGE_TIMESPAN (uint64_t) DIFFICULTY_TARGET_V2/24 // 2.5s
#define MAX_AVERAGE_TIMESPAN (uint64_t) DIFFICULTY_TARGET_V2*18 // 6 minutes
#define MIN_AVERAGE_TIMESPAN (uint64_t) DIFFICULTY_TARGET_V2/8 // 2.5s
namespace cryptonote {
......@@ -513,6 +513,62 @@ namespace cryptonote {
return 1;
}
return next_difficulty;
}
difficulty_type next_difficulty_v7(std::vector<std::uint64_t> timestamps, std::vector<difficulty_type> cumulative_difficulties, size_t target_seconds) {
const int64_t T = static_cast<int64_t>(target_seconds);
size_t N = DIFFICULTY_WINDOW_V7;
int64_t FTL = static_cast<int64_t>(CRYPTONOTE_BLOCK_FUTURE_TIME_LIMIT_V6);
// Return a difficulty of 1 for first 3 blocks if it's the start of the chain.
if (timestamps.size() < 4) {
return 1;
}
// Otherwise, use a smaller N if the start of the chain is less than N+1.
else if ( timestamps.size() < N+1 ) {
N = timestamps.size() - 1;
}
// Otherwise make sure timestamps and cumulative_difficulties are correct size.
else {
timestamps.resize(N+1);
cumulative_difficulties.resize(N+1);
}
// To get an average solvetime to within +/- ~0.1%, use an adjustment factor.
// adjust=0.998 for N = 60
const double adjust = 0.998;
// The divisor k normalizes the LWMA sum to a standard LWMA.
const double k = N * (N + 1) / 2;
double LWMA(0), sum_inverse_D(0), harmonic_mean_D(0), nextDifficulty(0);
int64_t solveTime(0);
uint64_t difficulty(0), next_difficulty(0);
// Loop through N most recent blocks. N is most recently solved block.
for (size_t i = 1; i <= N; i++) {
solveTime = static_cast<int64_t>(timestamps[i]) - static_cast<int64_t>(timestamps[i - 1]);
solveTime = std::min<int64_t>((T * 10), std::max<int64_t>(solveTime, -FTL));
difficulty = cumulative_difficulties[i] - cumulative_difficulties[i - 1];
LWMA += (int64_t)(solveTime * i) / k;
sum_inverse_D += 1 / static_cast<double>(difficulty);
}
harmonic_mean_D = N / sum_inverse_D;
// Limit LWMA same as Bitcoin's 1/4 in case something unforeseen occurs.
if (static_cast<int64_t>(boost::math::round(LWMA)) < T / 4)
LWMA = static_cast<double>(T / 4);
nextDifficulty = harmonic_mean_D * T / LWMA * adjust;
// No limits should be employed, but this is correct way to employ a 20% symmetrical limit:
// nextDifficulty=max(previous_Difficulty*0.8,min(previous_Difficulty/0.8, next_Difficulty));
next_difficulty = static_cast<uint64_t>(nextDifficulty);
if (next_difficulty == 0) {
return 1;
}
return next_difficulty;
}
}
......@@ -60,4 +60,5 @@ namespace cryptonote
difficulty_type next_difficulty_v4(std::vector<std::uint64_t> timestamps, std::vector<difficulty_type> cumulative_difficulties, size_t target_seconds);
difficulty_type next_difficulty_v5(std::vector<std::uint64_t> timestamps, std::vector<difficulty_type> cumulative_difficulties, size_t target_seconds);
difficulty_type next_difficulty_v6(std::vector<std::uint64_t> timestamps, std::vector<difficulty_type> cumulative_difficulties, size_t target_seconds);
difficulty_type next_difficulty_v7(std::vector<std::uint64_t> timestamps, std::vector<difficulty_type> cumulative_difficulties, size_t target_seconds);
}
......@@ -50,7 +50,7 @@
#define CURRENT_BLOCK_MAJOR_VERSION 1
#define CURRENT_BLOCK_MINOR_VERSION 1
#define CRYPTONOTE_BLOCK_FUTURE_TIME_LIMIT 60*60*2
#define CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE 5
#define CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE 20
#define BULLETPROOF_MAX_OUTPUTS 16
#define BULLETPROOF_SIMPLE_FORK_HEIGHT 8
......@@ -102,6 +102,8 @@
#define DIFFICULTY_BLOCKS_COUNT_V5 DIFFICULTY_WINDOW_V5 + 1
#define DIFFICULTY_WINDOW_V6 180
#define DIFFICULTY_BLOCKS_COUNT_V6 DIFFICULTY_WINDOW_V6 + 1
#define DIFFICULTY_WINDOW_V7 400
#define DIFFICULTY_BLOCKS_COUNT_V7 DIFFICULTY_WINDOW_V7 + 1
#define UNCLE_DIFFICULTY_TARGET DIFFICULTY_TARGET_V2 / 4
#define UNCLE_REWARD_RATIO 2
......@@ -112,7 +114,7 @@
#define CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS_V2 DIFFICULTY_TARGET_V2 * CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_BLOCKS
#define CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_BLOCKS 1
#define BLOCKS_IDS_SYNCHRONIZING_DEFAULT_COUNT 10000 //by default, blocks ids count in synchronizing
#define BLOCKS_IDS_SYNCHRONIZING_DEFAULT_COUNT 1000 //by default, blocks ids count in synchronizing
#define BLOCKS_SYNCHRONIZING_DEFAULT_COUNT 1 //by default, blocks count in blocks downloading (will have issue getting blobl hash if set >1 currently.
#define CRYPTONOTE_MEMPOOL_TX_LIVETIME (86400*3) //seconds, three days
......@@ -134,8 +136,8 @@
#define P2P_DEFAULT_WHITELIST_CONNECTIONS_PERCENT 70
#define P2P_DEFAULT_ANCHOR_CONNECTIONS_COUNT 2
#define SUPPORTED_MIN_VERSION_STR "1.0.3.7"
#define SUPPORTED_MIN_VERSION_HF_STR "1.0.3.7"
#define SUPPORTED_MIN_VERSION_STR "1.0.4.0"
#define SUPPORTED_MIN_VERSION_HF_STR "1.0.4.0"
#define HF_SUPPORTED_MIN_VERSION version_string_to_integer(SUPPORTED_MIN_VERSION_HF_STR)
#define SUPPORTED_MIN_VERSION version_string_to_integer(SUPPORTED_MIN_VERSION_STR)
......@@ -186,24 +188,6 @@ namespace config
uint32_t const GENESIS_NONCE = 10000;
std::set<std::string> const seed_nodes = {
"35.207.1.250:22423", // gcloud
"35.208.223.239:22423",
"35.210.136.243:22423",
"35.207.113.39:22423",
"35.211.220.53:22423",
"23.116.117.225:22423", // Jake
"23.116.117.226:22423",
"23.116.117.227:22423",
"23.116.117.228:22423",
"23.116.117.229:22423",
"23.116.117.230:22423",
"23.116.117.231:22423",
"23.116.117.232:22423",
"23.116.117.233:22423",
"23.116.117.234:22423",
"23.116.117.235:22423",
"23.116.117.236:22423",
"23.116.117.237:22423",
"74.91.20.250:22423", // Explorer
"74.91.20.251:22423",
"74.91.20.252:22423",
......@@ -213,7 +197,6 @@ namespace config
"54.185.166.16:22423",
"54.186.72.56:22423",
"52.11.240.127:22423",
"52.165.149.50:22423", // Herb
"45.32.127.120:22423", // Public nodes
"69.47.251.80:22423",
"162.198.9.28:22423",
......@@ -232,11 +215,10 @@ namespace config
0x14 ,0x23, 0xF1, 0x56 , 0x43, 0x19 , 0x41, 0x34, 0x17, 0x89, 0x02, 0x93, 0xAB, 0xBD, 0xFF, 0x14
} }; // Bender's daydream
std::set<std::string> const seed_nodes = {
"35.207.1.250:23423",
"35.208.223.239:23423",
"35.210.136.243:23423",
"35.207.113.39:23423",
"35.211.220.53:23423"};
"34.208.55.17:23423",
"35.167.241.90:23423",
"54.184.88.151:23423",
"54.218.61.252:23423"};
}
namespace stagenet
......
This diff is collapsed.
......@@ -958,8 +958,7 @@ namespace cryptonote
* @param txs unused, candidate for removal
*/
void output_scan_worker(const uint64_t amount,const std::vector<uint64_t> &offsets,
std::vector<output_data_t> &outputs, std::unordered_map<crypto::hash,
cryptonote::transaction> &txs) const;
std::vector<output_data_t> &outputs) const;
/**
* @brief computes the "short" and "long" hashes for a set of blocks
......
......@@ -457,7 +457,7 @@ namespace cryptonote
else if(options[0] == "fastest")
{
db_flags = DBF_FASTEST;
blocks_per_sync = 1000; // default to fastest:async:1000
blocks_per_sync = 1; // default to fastest:async:1
sync_mode = db_async;
}
else
......
#define DEF_MONERO_VERSION_TAG "@VERSIONTAG@"
#define DEF_MONERO_VERSION "1.0.3.8"
#define DEF_MONERO_VERSION "1.0.4.0"
#define DEF_MONERO_RELEASE_NAME "Han"
#define DEF_MONERO_VERSION_FULL DEF_MONERO_VERSION "-" DEF_MONERO_VERSION_TAG
......
......@@ -1938,9 +1938,7 @@ void wallet2::get_short_chain_history(std::list<crypto::hash>& ids, uint64_t gra
//----------------------------------------------------------------------------------------------------
void wallet2::parse_block_round(const cryptonote::blobdata &blob, cryptonote::block &bl, crypto::hash &bl_id, bool &error) const
{
error = !cryptonote::parse_and_validate_block_from_blob(blob, bl);
if (!error)
bl_id = get_block_hash(bl);
error = !cryptonote::parse_and_validate_block_from_blob(blob, bl, bl_id);
}
//----------------------------------------------------------------------------------------------------
void wallet2::pull_blocks(uint64_t start_height, uint64_t &blocks_start_height, const std::list<crypto::hash> &short_chain_history, std::vector<cryptonote::block_complete_entry> &blocks, std::vector<cryptonote::COMMAND_RPC_GET_BLOCKS_FAST::block_output_indices> &o_indices)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment