Skip to content
Merged

hf21 #201

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ message(STATUS "CMake version ${CMAKE_VERSION}")
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.15 CACHE STRING "macOS deployment target (Apple clang only)")

project(beldex
VERSION 7.0.0
VERSION 7.0.2
LANGUAGES CXX C)
set(BELDEX_RELEASE_CODENAME "Obscura")

Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ WORKDIR /usr/local/src
# && make -j$(nproc) \
# && make install_sw -j$(nproc)

ARG BOOST_VERSION=1_72_0
ARG BOOST_VERSION_DOT=1.72.0
ARG BOOST_HASH=59c9b274bc451cf91a9ba1dd2c7fdcaf5d60b1b3aa83f2c9fa143417cc660722
ARG BOOST_VERSION=1_83_0
ARG BOOST_VERSION_DOT=1.83.0
ARG BOOST_HASH=6478edfe2f3305127cffe8caf73ea0176c53769f4bf1585be237eb30798c3b8e
RUN set -ex \
&& curl -s -L -O https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION_DOT}/source/boost_${BOOST_VERSION}.tar.bz2 \
&& curl -s -L -O https://archives.boost.io/release/${BOOST_VERSION_DOT}/source/boost_${BOOST_VERSION}.tar.bz2 \
&& tar xf boost_${BOOST_VERSION}.tar.bz2 \
&& cd boost_${BOOST_VERSION} \
&& ./bootstrap.sh \
Expand Down
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@ Portions Copyright (c) 2012-2013 The Cryptonote developers.
## Development resources

- Web: [beldex.io](https://beldex.io)
- Telegram: [t.me/beldexcoin](https://t.me/beldex_official)
- Telegram: [t.me/beldexcoin](https://t.me/beldexcoin)
- GitHub: [https://github.com/Beldex-Coin/beldex](https://github.com/Beldex-Coin/beldex)

## Vulnerability disclosure

- Check out our [Vulnerability Response Process](https://beldex-project.github.io/beldex-docs/Contributing/VULNERABILITY_RESPONSE_BELDEX), encourages prompt disclosure of any Vulnerabilities

## Information

Expand Down
17 changes: 10 additions & 7 deletions contrib/epee/include/epee/storages/portable_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,18 @@ namespace epee
bool portable_storage::get_value(const std::string& value_name, T& val, section* parent_section)
{
static_assert(variant_contains<T, storage_entry>);
//TRY_ENTRY();
if(!parent_section) parent_section = &m_root;
if (!parent_section)
parent_section = &m_root;
storage_entry* pentry = find_storage_entry(value_name, parent_section);
if(!pentry)
return false;
if (!pentry)
return false;

var::visit([&val](const auto& v) { convert_t(v, val); }, *pentry);
return true;
//CATCH_ENTRY("portable_storage::template<>get_value", false);
try {
var::visit([&val](const auto& v) { convert_t(v, val); }, *pentry);
return true;
} catch (const std::exception&) {
return false;
}
}
//---------------------------------------------------------------------------------------------------------------
template <typename T>
Expand Down
13 changes: 8 additions & 5 deletions contrib/epee/src/portable_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,18 @@ namespace epee {

bool portable_storage::get_value(const std::string& value_name, storage_entry& val, section* parent_section)
{
//TRY_ENTRY();
if(!parent_section) parent_section = &m_root;
if (!parent_section)
parent_section = &m_root;
storage_entry* pentry = find_storage_entry(value_name, parent_section);
if(!pentry)
return false;

val = *pentry;
return true;
//CATCH_ENTRY("portable_storage::template<>get_value", false);
try {
val = *pentry;
return true;
} catch (const std::exception&) {
return false;
}
}

storage_entry* portable_storage::find_storage_entry(const std::string& pentry_name, section* psection)
Expand Down
2 changes: 1 addition & 1 deletion src/checkpoints/checkpoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ namespace cryptonote
{266284, "446fb044ad9f920d2c1607b792b7667b1d9994edc7fcc72f89282983cb7044cc"},
{301187, "a9676c3fbae6ad42434db2d1ebac90c2e75dbbd02a6b2d45c69d123554c7578f"},
{3126052,"d3c6d7e2b79c3b455861e99eaed7fc9c47677abe665d0e6b27bf9311397e4c9b"},

{5170000,"36c013fb4223e0d003e7f0fad473f08e123d0233026531d1cf9f9a7bc55da05f"},
};

crypto::hash get_newest_hardcoded_checkpoint(cryptonote::network_type nettype, uint64_t *height)
Expand Down
26 changes: 15 additions & 11 deletions src/cryptonote_core/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1264,8 +1264,8 @@ bool Blockchain::prevalidate_miner_transaction(const block& b, uint64_t height,
return false;
}

txversion min_version = transaction::get_max_version_for_hf(hf_version);
txversion max_version = transaction::get_min_version_for_hf(hf_version);
txversion min_version = transaction::get_min_version_for_hf(hf_version);
txversion max_version = transaction::get_max_version_for_hf(hf_version);
if (b.miner_tx.version < min_version || b.miner_tx.version > max_version)
{
MERROR_VER("Coinbase invalid version: " << b.miner_tx.version << " for hardfork: " << static_cast<int>(hf_version) << " min/max version: " << min_version << "/" << max_version);
Expand Down Expand Up @@ -1342,7 +1342,7 @@ bool Blockchain::validate_miner_transaction(const block& b, size_t cumulative_bl
}
}

if (already_generated_coins != 0 && block_has_governance_output(nettype(), b) && version > hf::hf20_bulletproof_plus)
if (already_generated_coins != 0 && block_has_governance_output(nettype(), b))
{
if (version >= hf::hf17_POS && reward_parts.governance_paid == 0)
{
Expand Down Expand Up @@ -1372,7 +1372,7 @@ bool Blockchain::validate_miner_transaction(const block& b, size_t cumulative_bl
// TODO(beldex): eliminate all floating point math in reward calculations.
uint64_t max_base_reward = reward_parts.base_miner + reward_parts.governance_paid + reward_parts.master_node_total + 1;
uint64_t max_money_in_use = max_base_reward + reward_parts.miner_fee;
if (money_in_use > max_money_in_use && version > hf::hf20_bulletproof_plus)
if (money_in_use > max_money_in_use)
{
MERROR_VER("coinbase transaction spends too much money (" << print_money(money_in_use) << "). Maximum block reward is "
<< print_money(max_money_in_use) << " (= " << print_money(max_base_reward) << " base + " << print_money(reward_parts.miner_fee) << " fees)");
Expand Down Expand Up @@ -3417,7 +3417,8 @@ bool Blockchain::check_tx_inputs(transaction& tx, tx_verification_context &tvc,
CHECK_AND_ASSERT_MES((*pmax_used_block_height + spendable_age) <= m_db->height(),
false, "Transaction spends at least one output which is too young");
}
if (tx.version >= cryptonote::txversion::v2_ringct)

if (tx.version >= cryptonote::txversion::v2_ringct)
{
if (!expand_transaction_2(tx, tx_prefix_hash, pubkeys))
{
Expand Down Expand Up @@ -3605,14 +3606,17 @@ if (tx.version >= cryptonote::txversion::v2_ringct)
}
else if (tx.type == txtype::coin_burn)
{
uint64_t burn = cryptonote::get_burned_amount_from_tx_extra(tx.extra);
if (burn == 0)
const uint64_t burn = cryptonote::get_burned_amount_from_tx_extra(tx.extra);
const uint64_t fee = tx.rct_signatures.txnFee;
if (burn == 0 || burn > fee)
{
std::string fail_reason = "Burn amount must not equals to zero";
MERROR_VER("Failed to validate Burn TX reason: " << fail_reason);
tvc.m_verbose_error = std::move(fail_reason);
tvc.m_verbose_error = (burn == 0)
? "Burn amount must not be zero"
: "Burn amount must be <= fee";

MERROR_VER("Failed to validate Burn TX reason: " << tvc.m_verbose_error);
return false;
}
}
}
}
}
Expand Down
23 changes: 15 additions & 8 deletions src/cryptonote_core/cryptonote_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1758,9 +1758,10 @@ namespace cryptonote
return m_mempool.check_for_key_images(key_im, spent);
}
//-----------------------------------------------------------------------------------------------
std::optional<std::tuple<int64_t, int64_t, int64_t>> core::get_coinbase_tx_sum(uint64_t start_offset, size_t count)
std::optional<std::tuple<unsigned long long, unsigned long long, unsigned long long>>
core::get_coinbase_tx_sum(uint64_t start_offset, size_t count)
{
std::optional<std::tuple<int64_t, int64_t, int64_t>> result{{0, 0, 0}};
std::optional<std::tuple<unsigned long long, unsigned long long, unsigned long long>> result{{0ULL, 0ULL, 0ULL}};
if (count == 0)
return result;

Expand All @@ -1787,6 +1788,8 @@ namespace cryptonote
{
std::shared_lock lock{m_coinbase_cache.mutex};
if (count >= m_coinbase_cache.height) {
// NOTE: if m_coinbase_cache.emissions/fees/burnt are signed types, they will be implicitly
// converted to unsigned here. If they are signed, consider static_cast<unsigned long long>.
emission_amount = m_coinbase_cache.emissions;
total_fee_amount = m_coinbase_cache.fees;
burnt_beldex = m_coinbase_cache.burnt;
Expand Down Expand Up @@ -1837,20 +1840,24 @@ namespace cryptonote
[this, &cache_to, &result, &cache_build_started](uint64_t height, const crypto::hash& hash, const block& b){
auto& [emission_amount, total_fee_amount, burnt_beldex] = *result;
std::vector<transaction> txs;
auto coinbase_amount = static_cast<int64_t>(get_outs_money_amount(b.miner_tx));

// Convert amounts into unsigned accumulators
const unsigned long long coinbase_amount = static_cast<unsigned long long>(get_outs_money_amount(b.miner_tx));
get_transactions(b.tx_hashes, txs);
int64_t tx_fee_amount = 0;
for(const auto& tx: txs)

unsigned long long tx_fee_amount = 0ULL;
for (const auto& tx: txs)
{
tx_fee_amount += static_cast<int64_t>(get_tx_miner_fee(tx, b.major_version >= feature::FEE_BURNING));
if(b.major_version >= feature::FEE_BURNING)
tx_fee_amount += static_cast<unsigned long long>(get_tx_miner_fee(tx, b.major_version >= feature::FEE_BURNING));
if (b.major_version >= feature::FEE_BURNING)
{
burnt_beldex += static_cast<int64_t>(get_burned_amount_from_tx_extra(tx.extra));
burnt_beldex += static_cast<unsigned long long>(get_burned_amount_from_tx_extra(tx.extra));
}
}

emission_amount += coinbase_amount - tx_fee_amount;
total_fee_amount += tx_fee_amount;

if (cache_to && cache_to == height)
{
std::unique_lock lock{m_coinbase_cache.mutex};
Expand Down
2 changes: 1 addition & 1 deletion src/cryptonote_core/cryptonote_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ namespace cryptonote
* requested range. The optional value will be empty only if requesting the full chain *and*
* another thread is already calculating it.
*/
std::optional<std::tuple<int64_t, int64_t, int64_t>> get_coinbase_tx_sum(uint64_t start_offset, size_t count);
std::optional<std::tuple<unsigned long long, unsigned long long, unsigned long long>> get_coinbase_tx_sum(uint64_t start_offset, size_t count);

/**
* @brief get the network type we're on
Expand Down
1 change: 0 additions & 1 deletion src/cryptonote_core/master_node_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1589,7 +1589,6 @@ namespace master_nodes
// NOTE: No POS quorums are generated when the network has insufficient nodes to generate quorums
// Or, block specifies time after all the rounds have timed out
bool miner_block = !POS_hf || !POS_quorum;
// std::cout << "miner_block : " << miner_block << std::endl;

result = verify_block_components(m_blockchain.nettype(),
block,
Expand Down
Loading
Loading