Skip to content

Commit

Permalink
Beta reset with new genesis and lower work threshold (#2207)
Browse files Browse the repository at this point in the history
* Add beta threshold 16x lower ( 0.0625 multiplier )

* New beta genesis

* Remove rep_weights_beta.bin

* Allow non-existent rep_weights_beta.bin

* Format

* Preconfigured representatives

* Making network thresholds accessible and testing the new beta threshold
  • Loading branch information
guilhermelawless authored Aug 7, 2019
1 parent 6567d43 commit 295f8b5
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 22 deletions.
5 changes: 5 additions & 0 deletions nano/core_test/difficulty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@ TEST (difficulty, multipliers)
#endif
}
}

TEST (difficulty, network_constants)
{
ASSERT_NEAR (16., nano::difficulty::to_multiplier (nano::network_constants::publish_full_threshold, nano::network_constants::publish_beta_threshold), 1e-10);
}
10 changes: 6 additions & 4 deletions nano/lib/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ class network_constants
network_constants (nano_networks network_a) :
current_network (network_a)
{
// Local work threshold for rate-limiting publishing blocks. ~5 seconds of work.
uint64_t constexpr publish_test_threshold = 0xff00000000000000;
uint64_t constexpr publish_full_threshold = 0xffffffc000000000;
publish_threshold = is_test_network () ? publish_test_threshold : publish_full_threshold;
publish_threshold = is_test_network () ? publish_test_threshold : is_beta_network () ? publish_beta_threshold : publish_full_threshold;

// A representative is classified as principal based on its weight and this factor
principal_weight_factor = 1000; // 0.1%
Expand All @@ -76,6 +73,11 @@ class network_constants
request_interval_ms = is_test_network () ? (is_sanitizer_build ? 100 : 20) : 16000;
}

/** Network work thresholds. ~5 seconds of work for the live network */
static uint64_t const publish_full_threshold{ 0xffffffc000000000 };
static uint64_t const publish_beta_threshold{ 0xfffffc0000000000 }; // 16x lower than full
static uint64_t const publish_test_threshold{ 0xff00000000000000 }; // very low for tests

/** The network this param object represents. This may differ from the global active network; this is needed for certain --debug... commands */
nano_networks current_network;
uint64_t publish_threshold;
Expand Down
3 changes: 0 additions & 3 deletions nano/node/nodeconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,8 @@ logging (logging_a)
break;
case nano::nano_networks::nano_beta_network:
preconfigured_peers.push_back (default_beta_peer_network);
preconfigured_representatives.emplace_back ("A59A47CC4F593E75AE9AD653FDA9358E2F7898D9ACC8C60E80D0495CE20FBA9F");
preconfigured_representatives.emplace_back ("259A4011E6CAD1069A97C02C3C1F2AAA32BC093C8D82EE1334F937A4BE803071");
preconfigured_representatives.emplace_back ("259A40656144FAA16D2A8516F7BE9C74A63C6CA399960EDB747D144ABB0F7ABD");
preconfigured_representatives.emplace_back ("259A40A92FA42E2240805DE8618EC4627F0BA41937160B4CFF7F5335FD1933DF");
preconfigured_representatives.emplace_back ("259A40FF3262E273EC451E873C4CDF8513330425B38860D882A16BCC74DA9B73");
break;
case nano::nano_networks::nano_live_network:
preconfigured_peers.push_back (default_live_peer_network);
Expand Down
20 changes: 11 additions & 9 deletions nano/secure/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,23 @@ endif ()
# Embed bootstrap representative weights in executable. Both live
# and beta weights are added to accommodate switching networks
# from the command line.
file (READ ${CMAKE_SOURCE_DIR}/rep_weights_live.bin filedata HEX)
string (REGEX REPLACE "(..)" "0x\\1," filedata ${filedata})
file(READ ${CMAKE_SOURCE_DIR}/rep_weights_live.bin liveweights HEX)
string(REGEX REPLACE "(..)" "0x\\1," liveweights ${liveweights})
file (WRITE ${CMAKE_BINARY_DIR}/bootstrap_weights_live.cpp "#include <cstddef>\n"
"namespace nano {\n"
" unsigned char nano_bootstrap_weights_live[] = {${filedata} 0x00};\n"
" unsigned char nano_bootstrap_weights_live[] = {${liveweights} 0x00};\n"
" size_t nano_bootstrap_weights_live_size = sizeof(nano_bootstrap_weights_live) - 1;\n"
"}\n")

file (READ ${CMAKE_SOURCE_DIR}/rep_weights_beta.bin filedata HEX)
string (REGEX REPLACE "(..)" "0x\\1," filedata ${filedata})
if (EXISTS ${CMAKE_SOURCE_DIR}/rep_weights_beta.bin)
file(READ ${CMAKE_SOURCE_DIR}/rep_weights_beta.bin betaweights HEX)
string(REGEX REPLACE "(..)" "0x\\1," betaweights ${betaweights})
endif ()
file (WRITE ${CMAKE_BINARY_DIR}/bootstrap_weights_beta.cpp "#include <cstddef>\n"
"namespace nano {\n"
" unsigned char nano_bootstrap_weights_beta[] = {${filedata} 0x00};\n"
" size_t nano_bootstrap_weights_beta_size = sizeof(nano_bootstrap_weights_beta) - 1;\n"
"}\n")
"namespace nano {\n"
" unsigned char nano_bootstrap_weights_beta[] = {${betaweights} 0x00};\n"
" size_t nano_bootstrap_weights_beta_size = sizeof(nano_bootstrap_weights_beta) - 1;\n"
"}\n")

add_library (secure
${PLATFORM_SECURE_SOURCE}
Expand Down
12 changes: 6 additions & 6 deletions nano/secure/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace
{
char const * test_private_key_data = "34F0A37AAD20F4A260F0A5B3CB3D7FB50673212263E58A380BC10474BB039CE4";
char const * test_public_key_data = "B0311EA55708D6A53C75CDBF88300259C6D018522FE3D4D0A242E431F9E8B6D0"; // xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpiij4txtdo
char const * beta_public_key_data = "A59A47CC4F593E75AE9AD653FDA9358E2F7898D9ACC8C60E80D0495CE20FBA9F"; // xrb_3betaz86ypbygpqbookmzpnmd5jhh4efmd8arr9a3n4bdmj1zgnzad7xpmfp
char const * beta_public_key_data = "A59A439B34662385D48F7FF9CA50030F889BAA9AC320EA5A85AAD777CF82B088"; // nano_3betagfmasj5iqcayzzssba185wamgobois1xbfadcpqgz9r7e6a1zwztn5o
char const * live_public_key_data = "E89208DD038FBB269987689621D52292AE9C35941A7484756ECCED92A65093BA"; // xrb_3t6k35gi95xu6tergt6p69ck76ogmitsa8mnijtpxm9fkcm736xtoncuohr3
char const * test_genesis_data = R"%%%({
"type": "open",
Expand All @@ -39,11 +39,11 @@ char const * test_genesis_data = R"%%%({

char const * beta_genesis_data = R"%%%({
"type": "open",
"source": "A59A47CC4F593E75AE9AD653FDA9358E2F7898D9ACC8C60E80D0495CE20FBA9F",
"representative": "xrb_3betaz86ypbygpqbookmzpnmd5jhh4efmd8arr9a3n4bdmj1zgnzad7xpmfp",
"account": "xrb_3betaz86ypbygpqbookmzpnmd5jhh4efmd8arr9a3n4bdmj1zgnzad7xpmfp",
"work": "000000000f0aaeeb",
"signature": "A726490E3325E4FA59C1C900D5B6EEBB15FE13D99F49D475B93F0AACC5635929A0614CF3892764A04D1C6732A0D716FFEB254D4154C6F544D11E6630F201450B"
"source": "A59A439B34662385D48F7FF9CA50030F889BAA9AC320EA5A85AAD777CF82B088",
"representative": "nano_3betagfmasj5iqcayzzssba185wamgobois1xbfadcpqgz9r7e6a1zwztn5o",
"account": "nano_3betagfmasj5iqcayzzssba185wamgobois1xbfadcpqgz9r7e6a1zwztn5o",
"work": "cb4efb49972c7106",
"signature": "C14ACC986C0561871B3382A93F5E64AFE55A3FA2EEE6892A7358DC817E2034AA56160CAA807A21EDFCFA528D034CD266F9ABFA4E2FF221D856255265BFDC0608"
})%%%";

char const * live_genesis_data = R"%%%({
Expand Down
Binary file removed rep_weights_beta.bin
Binary file not shown.

0 comments on commit 295f8b5

Please sign in to comment.