Skip to content

Commit

Permalink
Merge pull request #41 from victor-tucci/dev
Browse files Browse the repository at this point in the history
Governance wallet added and Rebranding Belnet
  • Loading branch information
scilicet64 authored Nov 16, 2021
2 parents 75b9efa + 89aeb5b commit be49a3d
Show file tree
Hide file tree
Showing 39 changed files with 418 additions and 421 deletions.
10 changes: 5 additions & 5 deletions .drone.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ local debian_pipeline(name, image,
'mkdir build',
'cd build',
'cmake .. -G Ninja -DCMAKE_CXX_FLAGS=-fdiagnostics-color=always -DCMAKE_BUILD_TYPE='+build_type+' ' +
'-DLOCAL_MIRROR=https://builds.beldexnet.dev/deps -DUSE_LTO=' + (if lto then 'ON ' else 'OFF ') +
'-DLOCAL_MIRROR=https://builds.belnet.dev/deps -DUSE_LTO=' + (if lto then 'ON ' else 'OFF ') +
(if werror then '-DWARNINGS_AS_ERRORS=ON ' else '') +
(if build_tests || run_tests then '-DBUILD_TESTS=ON ' else '') +
cmake_extra
Expand Down Expand Up @@ -105,7 +105,7 @@ local mac_builder(name,
'mkdir build',
'cd build',
'cmake .. -G Ninja -DCMAKE_CXX_FLAGS=-fcolor-diagnostics -DCMAKE_BUILD_TYPE='+build_type+' ' +
'-DLOCAL_MIRROR=https://builds.beldexnet.dev/deps -DUSE_LTO=' + (if lto then 'ON ' else 'OFF ') +
'-DLOCAL_MIRROR=https://builds.belnet.dev/deps -DUSE_LTO=' + (if lto then 'ON ' else 'OFF ') +
(if werror then '-DWARNINGS_AS_ERRORS=ON ' else '') +
(if build_tests || run_tests then '-DBUILD_TESTS=ON ' else '') +
cmake_extra,
Expand Down Expand Up @@ -138,7 +138,7 @@ local android_build_steps(android_abi, android_platform=21, jobs=6, cmake_extra=
'-DCMAKE_TOOLCHAIN_FILE=/usr/lib/android-sdk/ndk-bundle/build/cmake/android.toolchain.cmake ' +
'-DANDROID_PLATFORM=' + android_platform + ' -DANDROID_ABI=' + android_abi + ' ' +
'-DMONERO_SLOW_HASH=ON ' +
'-DLOCAL_MIRROR=https://builds.beldexnet.dev/deps ' +
'-DLOCAL_MIRROR=https://builds.belnet.dev/deps ' +
'-DBUILD_STATIC_DEPS=ON -DSTATIC=ON -G Ninja ' + cmake_extra,
'ninja -j' + jobs + ' -v wallet_merged',
'cd ..',
Expand Down Expand Up @@ -204,13 +204,13 @@ local gui_wallet_step_darwin = {
debian_pipeline("Debian (ARM64)", "debian:sid", arch="arm64", build_tests=false),
debian_pipeline("Debian buster (armhf)", "arm32v7/debian:buster", arch="arm64", build_tests=false, cmake_extra='-DDOWNLOAD_SODIUM=ON -DARCH_ID=armhf'),

// Static build (on bionic) which gets uploaded to builds.beldexnet.dev:
// Static build (on bionic) which gets uploaded to builds.belnet.dev:
debian_pipeline("Static (bionic amd64)", "ubuntu:bionic", deps='g++-8 '+static_build_deps,
cmake_extra='-DBUILD_STATIC_DEPS=ON -DCMAKE_C_COMPILER=gcc-8 -DCMAKE_CXX_COMPILER=g++-8 -DARCH=x86-64',
build_tests=false, lto=true, extra_cmds=static_check_and_upload,
extra_steps=[gui_wallet_step('ubuntu:bionic')]),

// Static mingw build (on focal) which gets uploaded to builds.beldexnet.dev:
// Static mingw build (on focal) which gets uploaded to builds.belnet.dev:
debian_pipeline("Static (win64)", "ubuntu:focal", deps='g++ g++-mingw-w64-x86-64 '+static_build_deps,
cmake_extra='-DCMAKE_TOOLCHAIN_FILE=../cmake/64-bit-toolchain.cmake -DBUILD_STATIC_DEPS=ON -DARCH=x86-64',
build_tests=false, lto=false, test_beldexd=false, extra_cmds=[
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"streambuf": "cpp",
"thread": "cpp",
"typeindex": "cpp",
"typeinfo": "cpp"
"typeinfo": "cpp",
"valarray": "cpp"
}
}
8 changes: 4 additions & 4 deletions contrib/lns-lookup-example.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import sys

name = "Jason.beldex"
type = 2 # 2 == beldexnet, 0 == session
type = 2 # 2 == belnet, 0 == session

# Calculate the blake2b hash of the lower-case full name (including the .beldex):
name_hash = nacl.hash.blake2b(name.lower().encode(), encoder=nacl.encoding.RawEncoder)
Expand All @@ -31,7 +31,7 @@
else:
raise RuntimeError("BNS request failed: didn't get any result")

# For beldexnet addresses and HF16+ session addresses we'll always have an encrypted value and an
# For belnet addresses and HF16+ session addresses we'll always have an encrypted value and an
# encryption nonce. (For HF15 Session addresses the nonce can be missing, in which case the
# encryption involves a much more expensive argon2-based calculation; most external code isn't
# expected to support them and existing registration owners should submit an update after HF16 to
Expand All @@ -51,8 +51,8 @@
decrypt_key
)

# val will currently be the raw beldexnet ed25519 pubkey (32 bytes). We can convert it to the more
# common beldexnet address (which is the same value but encoded in z-base-32) and convert the bytes to
# val will currently be the raw belnet ed25519 pubkey (32 bytes). We can convert it to the more
# common belnet address (which is the same value but encoded in z-base-32) and convert the bytes to
# a string:
val = b32encode(val).decode()

Expand Down
22 changes: 11 additions & 11 deletions src/beldex_economy.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,25 @@ enum struct mapping_type : uint16_t
{
session = 0,
wallet = 1,
beldexnet = 2, // the type value stored in the database; counts as 1-year when used in a buy tx.
beldexnet_2years,
beldexnet_5years,
beldexnet_10years,
belnet = 2, // the type value stored in the database; counts as 1-year when used in a buy tx.
belnet_2years,
belnet_5years,
belnet_10years,
_count,
update_record_internal,
};

constexpr bool is_beldexnet_type(mapping_type t) { return t >= mapping_type::beldexnet && t <= mapping_type::beldexnet_10years; }
constexpr bool is_belnet_type(mapping_type t) { return t >= mapping_type::belnet && t <= mapping_type::belnet_10years; }

// How many days we add per "year" of BNS beldexnet registration. We slightly extend this to the 368
// How many days we add per "year" of BNS belnet registration. We slightly extend this to the 368
// days per registration "year" to allow for some blockchain time drift + leap years.
constexpr uint64_t REGISTRATION_YEAR_DAYS = 368;

constexpr uint64_t burn_needed(uint8_t hf_version, mapping_type type)
{
uint64_t result = 0;

// The base amount for session/wallet/beldexnet-1year:
// The base amount for session/wallet/belnet-1year:
const uint64_t basic_fee = (
hf_version >= 16 ? 15*COIN : // cryptonote::network_version_16_POS -- but don't want to add cryptonote_config.h include
20*COIN // cryptonote::network_version_15_bns
Expand All @@ -85,16 +85,16 @@ constexpr uint64_t burn_needed(uint8_t hf_version, mapping_type type)
result = 0;
break;

case mapping_type::beldexnet: /* FALLTHRU */
case mapping_type::belnet: /* FALLTHRU */
case mapping_type::session: /* FALLTHRU */
case mapping_type::wallet: /* FALLTHRU */
default:
result = basic_fee;
break;

case mapping_type::beldexnet_2years: result = 2 * basic_fee; break;
case mapping_type::beldexnet_5years: result = 4 * basic_fee; break;
case mapping_type::beldexnet_10years: result = 6 * basic_fee; break;
case mapping_type::belnet_2years: result = 2 * basic_fee; break;
case mapping_type::belnet_5years: result = 4 * basic_fee; break;
case mapping_type::belnet_10years: result = 6 * basic_fee; break;
}
return result;
}
Expand Down
8 changes: 4 additions & 4 deletions src/blockchain_db/lmdb/db_lmdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6245,7 +6245,7 @@ struct master_node_proof_serialized_old
info.proof->qnet_port = little_to_native(quorumnet_port);
info.proof->version = little_to_native_container(version);
info.proof->storage_server_version = {0, 0, 0};
info.proof->beldexnet_version = {0, 0, 0};
info.proof->belnet_version = {0, 0, 0};
info.update_pubkey(pubkey_ed25519);
}

Expand All @@ -6271,17 +6271,17 @@ struct master_node_proof_serialized : master_node_proof_serialized_old {
master_node_proof_serialized(const master_nodes::proof_info &info)
: master_node_proof_serialized_old{info},
storage_server_version{native_to_little_container(info.proof->storage_server_version)},
beldexnet_version{native_to_little_container(info.proof->beldexnet_version)}
belnet_version{native_to_little_container(info.proof->belnet_version)}
{}
std::array<uint16_t, 3> storage_server_version;
std::array<uint16_t, 3> beldexnet_version;
std::array<uint16_t, 3> belnet_version;
char _padding[4];

void update(master_nodes::proof_info& info) const {
if (!info.proof) info.proof = std::unique_ptr<uptime_proof::Proof>(new uptime_proof::Proof());
master_node_proof_serialized_old::update(info);
info.proof->storage_server_version = little_to_native_container(storage_server_version);
info.proof->beldexnet_version = little_to_native_container(beldexnet_version);
info.proof->belnet_version = little_to_native_container(belnet_version);
}

operator master_nodes::proof_info() const
Expand Down
6 changes: 3 additions & 3 deletions src/blockchain_utilities/mn_key_tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ int generate(bool ed25519, std::list<std::string_view> args) {
std::cout <<
"Public key: " << oxenmq::to_hex(pubkey.begin(), pubkey.end()) <<
"\nX25519 pubkey: " << oxenmq::to_hex(x_pubkey.begin(), x_pubkey.end()) <<
"\nBeldexnet address: " << oxenmq::to_base32z(pubkey.begin(), pubkey.end()) << ".mnode\n";
"\nBelnet address: " << oxenmq::to_base32z(pubkey.begin(), pubkey.end()) << ".mnode\n";
} else {
std::cout << "Public key: " << oxenmq::to_hex(pubkey.begin(), pubkey.end()) << "\n";
}
Expand Down Expand Up @@ -243,7 +243,7 @@ int show(std::list<std::string_view> args) {
"\nSecret key: " << oxenmq::to_hex(seckey.begin(), seckey.begin() + 32) <<
"\nPublic key: " << oxenmq::to_hex(pubkey.begin(), pubkey.end()) <<
"\nX25519 pubkey: " << oxenmq::to_hex(x_pubkey.begin(), x_pubkey.end()) <<
"\nBeldexnet address: " << oxenmq::to_base32z(pubkey.begin(), pubkey.end()) << ".mnode\n\n";
"\nBelnet address: " << oxenmq::to_base32z(pubkey.begin(), pubkey.end()) << ".mnode\n\n";
return 0;
}

Expand Down Expand Up @@ -300,7 +300,7 @@ int restore(bool ed25519, std::list<std::string_view> args) {
if (0 != crypto_sign_ed25519_pk_to_curve25519(x_pubkey.data(), pubkey.data()))
return error(14, "Unable to convert Ed25519 pubkey to X25519 pubkey; is this a really valid secret key?");
std::cout << "X25519 pubkey: " << oxenmq::to_hex(x_pubkey.begin(), x_pubkey.end()) <<
"\nBeldexnet address: " << oxenmq::to_base32z(pubkey.begin(), pubkey.end()) << ".mnode";
"\nBelnet address: " << oxenmq::to_base32z(pubkey.begin(), pubkey.end()) << ".mnode";
}

if (pubkey_expected) {
Expand Down
6 changes: 3 additions & 3 deletions src/cryptonote_basic/tx_extra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ tx_extra_beldex_name_system tx_extra_beldex_name_system::make_buy(
tx_extra_beldex_name_system tx_extra_beldex_name_system::make_renew(
bns::mapping_type type, crypto::hash const &name_hash, crypto::hash const &prev_txid)
{
assert(is_beldexnet_type(type) && prev_txid);
assert(is_belnet_type(type) && prev_txid);

tx_extra_beldex_name_system result{};
result.fields = bns::extra_field::none;
Expand Down Expand Up @@ -84,7 +84,7 @@ std::vector<std::string> readable_reasons(uint16_t decomm_reason) {
if (decomm_reason & storage_server_unreachable) results.push_back("Storage Server Unreachable");
if (decomm_reason & timestamp_response_unreachable) results.push_back("Unreachable for Timestamp Check");
if (decomm_reason & timesync_status_out_of_sync) results.push_back("Time out of sync");
if (decomm_reason & beldexnet_unreachable) results.push_back("Beldexnet Unreachable");
if (decomm_reason & belnet_unreachable) results.push_back("Belnet Unreachable");
return results;
}

Expand All @@ -96,7 +96,7 @@ std::vector<std::string> coded_reasons(uint16_t decomm_reason) {
if (decomm_reason & storage_server_unreachable) results.push_back("storage");
if (decomm_reason & timestamp_response_unreachable) results.push_back("timecheck");
if (decomm_reason & timesync_status_out_of_sync) results.push_back("timesync");
if (decomm_reason & beldexnet_unreachable) results.push_back("beldexnet");
if (decomm_reason & belnet_unreachable) results.push_back("belnet");
return results;
}

Expand Down
6 changes: 3 additions & 3 deletions src/cryptonote_basic/tx_extra.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ namespace cryptonote
storage_server_unreachable = 1 << 3,
timestamp_response_unreachable = 1 << 4,
timesync_status_out_of_sync = 1 << 5,
beldexnet_unreachable = 1 << 6,
belnet_unreachable = 1 << 6,
};

// Returns human-readable reason strings (e.g. "Missed Uptime Proofs") for the given reason bits
Expand Down Expand Up @@ -559,9 +559,9 @@ namespace cryptonote
bool is_updating() const { return field_is_set(bns::extra_field::signature) && field_any_set(bns::extra_field::updatable_fields); }
// True if this is buying a new BNS record
bool is_buying() const { return (fields == bns::extra_field::buy || fields == bns::extra_field::buy_no_backup); }
// True if this is renewing an existing BNS: has no fields at all, is a renewal registration (i.e. beldexnet),
// True if this is renewing an existing BNS: has no fields at all, is a renewal registration (i.e. belnet),
// and has a non-null txid set (which should point to the most recent registration or update).
bool is_renewing() const { return fields == bns::extra_field::none && prev_txid && is_beldexnet_type(type); }
bool is_renewing() const { return fields == bns::extra_field::none && prev_txid && is_belnet_type(type); }

static tx_extra_beldex_name_system make_buy(
bns::generic_owner const& owner,
Expand Down
12 changes: 4 additions & 8 deletions src/cryptonote_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,16 +242,16 @@ namespace config
inline constexpr uint64_t GOVERNANCE_REWARD_INTERVAL_IN_BLOCKS = PRE_POS_BLOCKS_EXPECTED_IN_DAYS(7);//Governance added from V17
inline constexpr std::array GOVERNANCE_WALLET_ADDRESS =
{
"bxcguQiBhYaDW5wAdPLSwRHA6saX1nCEYUF89SPKZfBY1BENdLQWjti59aEtAEgrVZjnCJEVFoCDrG1DCoz2HeeN2pxhxL9xa"sv, // hardfork v7-10
"bxcguQiBhYaDW5wAdPLSwRHA6saX1nCEYUF89SPKZfBY1BENdLQWjti59aEtAEgrVZjnCJEVFoCDrG1DCoz2HeeN2pxhxL9xa"sv,
"bxcguQiBhYaDW5wAdPLSwRHA6saX1nCEYUF89SPKZfBY1BENdLQWjti59aEtAEgrVZjnCJEVFoCDrG1DCoz2HeeN2pxhxL9xa"sv, // <V17
"bxdwQ4ruRpW9QTfBpStRAMNKgdt7Rr39UcThNZ7mwsfxH7StmykPe9ah1KgJL2LwEAgqRXHLvZYBm1aaUVR8mLtB1u3WauV6P"sv, // V17
};

inline constexpr auto UPTIME_PROOF_TOLERANCE = 5min; // How much an uptime proof timestamp can deviate from our timestamp before we refuse it
inline constexpr auto UPTIME_PROOF_STARTUP_DELAY = 30s; // How long to wait after startup before broadcasting a proof
inline constexpr auto UPTIME_PROOF_CHECK_INTERVAL = 30s; // How frequently to check whether we need to broadcast a proof
inline constexpr auto UPTIME_PROOF_FREQUENCY = 1h; // How often to send proofs out to the network since the last proof we successfully sent. (Approximately; this can be up to CHECK_INTERFACE/2 off in either direction). The minimum accepted time between proofs is half of this.
inline constexpr auto UPTIME_PROOF_VALIDITY = 2h + 5min; // The maximum time that we consider an uptime proof to be valid (i.e. after this time since the last proof we consider the SN to be down)
inline constexpr auto REACHABLE_MAX_FAILURE_VALIDITY = 5min; // If we don't hear any SS ping/beldexnet session test failures for more than this long then we start considering the SN as passing for the purpose of obligation testing until we get another test result. This should be somewhat larger than SS/beldexnet's max re-test backoff (2min).
inline constexpr auto REACHABLE_MAX_FAILURE_VALIDITY = 5min; // If we don't hear any SS ping/belnet session test failures for more than this long then we start considering the SN as passing for the purpose of obligation testing until we get another test result. This should be somewhat larger than SS/belnet's max re-test backoff (2min).
// Hash domain separators
inline constexpr std::string_view HASH_KEY_BULLETPROOF_EXPONENT = "bulletproof"sv;
inline constexpr std::string_view HASH_KEY_RINGDB = "ringdsb\0"sv;
Expand Down Expand Up @@ -396,11 +396,7 @@ namespace cryptonote
std::chrono::seconds UPTIME_PROOF_VALIDITY;

inline constexpr std::string_view governance_wallet_address(int hard_fork_version) const {
const auto wallet_switch =
(NETWORK_TYPE == MAINNET || NETWORK_TYPE == FAKECHAIN)
? network_version_11_infinite_staking
: network_version_10_bulletproofs;
return GOVERNANCE_WALLET_ADDRESS[hard_fork_version >= wallet_switch ? 1 : 0];
return GOVERNANCE_WALLET_ADDRESS[hard_fork_version >= cryptonote::network_version_17_POS ? 1 : 0];
}
};
inline constexpr network_config mainnet_config{
Expand Down
Loading

0 comments on commit be49a3d

Please sign in to comment.