Skip to content

Commit

Permalink
Merge branch 'release'
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptozoidberg committed Dec 3, 2021
2 parents 5600952 + 3657819 commit 854a2f0
Show file tree
Hide file tree
Showing 52 changed files with 961 additions and 214 deletions.
8 changes: 4 additions & 4 deletions contrib/epee/include/console_handler.h
Expand Up @@ -376,7 +376,7 @@ namespace epee
bool run_default_console_handler_no_srv_param(t_server* ptsrv, t_handler handlr, const std::string& prompt, const std::string& usage = "")
{
async_console_handler console_handler;
return console_handler.run(ptsrv, boost::bind<bool>(no_srv_param_adapter<t_server, t_handler>, _1, _2, handlr), prompt, usage);
return console_handler.run(ptsrv, boost::bind<bool>(no_srv_param_adapter<t_server, t_handler>, boost::placeholders::_1, boost::placeholders::_2, handlr), prompt, usage);
}

template<class t_server, class t_handler>
Expand Down Expand Up @@ -460,7 +460,7 @@ namespace epee
/*template<class t_srv>
bool start_handling(t_srv& srv, const std::string& usage_string = "")
{
start_default_console_handler_no_srv_param(&srv, boost::bind(&console_handlers_binder::process_command_str, this, _1));
start_default_console_handler_no_srv_param(&srv, boost::bind(&console_handlers_binder::process_command_str, this, boost::placeholders::_1));
return true;
}*/

Expand Down Expand Up @@ -489,7 +489,7 @@ namespace epee
/*template<class t_srv>
bool run_handling(t_srv& srv, const std::string& usage_string)
{
return run_default_console_handler_no_srv_param(&srv, boost::bind<bool>(&console_handlers_binder::process_command_str, this, _1), usage_string);
return run_default_console_handler_no_srv_param(&srv, boost::bind<bool>(&console_handlers_binder::process_command_str, this, boost::placeholders::_1), usage_string);
}*/
};

Expand All @@ -510,7 +510,7 @@ namespace epee

bool run_handling(t_server* psrv, const std::string& prompt, const std::string& usage_string)
{
return m_console_handler.run(psrv, boost::bind(&srv_console_handlers_binder<t_server>::process_command_str, this, _1, _2), prompt, usage_string);
return m_console_handler.run(psrv, boost::bind(&srv_console_handlers_binder<t_server>::process_command_str, this, boost::placeholders::_1, boost::placeholders::_2), prompt, usage_string);
}

void stop_handling()
Expand Down
40 changes: 40 additions & 0 deletions contrib/epee/include/serialization/keyvalue_helper_structs.h
@@ -0,0 +1,40 @@
// Copyright (c) 2006-2021, Andrey N. Sabelnikov, www.sabelnikov.net
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of the Andrey N. Sabelnikov nor the
// names of its contributors may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//

#pragma once

namespace epee
{

template<class _Ty1, class _Ty2>
struct kvserializable_pair : public std::pair<_Ty1, _Ty2>
{
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(first)
KV_SERIALIZE(second)
END_KV_SERIALIZE_MAP()
};
}
2 changes: 1 addition & 1 deletion contrib/epee/include/time_helper.h
Expand Up @@ -87,7 +87,7 @@ DISABLE_VS_WARNINGS(4996)
POP_VS_WARNINGS

if(pt)
strftime( tmpbuf, 199, "%Y_%m_%d %H_%M_%S", pt );
strftime( tmpbuf, 199, "%Y-%m-%d %H-%M-%S", pt );
else
{
std::stringstream strs;
Expand Down
Binary file modified resources/dmg_installer_bg.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/installer_bg_164x313.bmp
Binary file not shown.
Binary file modified resources/installer_bg_191x385.bmp
Binary file not shown.
Binary file modified resources/installer_bg_246x457.bmp
Binary file not shown.
Binary file modified resources/installer_bg_328x628.bmp
Binary file not shown.
10 changes: 9 additions & 1 deletion src/common/command_line.h
Expand Up @@ -151,14 +151,15 @@ namespace command_line
}

template<typename F>
bool handle_error_helper(const boost::program_options::options_description& desc, F parser)
bool handle_error_helper(const boost::program_options::options_description& desc, std::string& err, F parser)
{
try
{
return parser();
}
catch (std::exception& e)
{
err = e.what();
std::cerr << "Failed to parse arguments: " << e.what() << std::endl;
std::cerr << desc << std::endl;
return false;
Expand All @@ -171,6 +172,13 @@ namespace command_line
}
}

template<typename F>
bool handle_error_helper(const boost::program_options::options_description& desc, F parser)
{
std::string stub_err;
return handle_error_helper(desc, stub_err, parser);
}

template<typename T, bool required>
bool has_arg(const boost::program_options::variables_map& vm, const arg_descriptor<T, required>& arg)
{
Expand Down
7 changes: 5 additions & 2 deletions src/common/db_backend_mdbx.cpp
Expand Up @@ -143,9 +143,10 @@ namespace tools
else
{
int res = 0;
//MDBX_txn_flags_t flags = MDBX_txn_flags_t();
unsigned int flags = 0;
if (read_only)
flags += MDBX_RDONLY;
flags = MDBX_RDONLY;//flags = MDBX_TXN_RDONLY;

//don't use parent tx in write transactions if parent tx was read-only (restriction in mdbx)
//see "Nested transactions: Max 1 child, write txns only, no writemap"
Expand Down Expand Up @@ -340,7 +341,9 @@ namespace tools
data[0].iov_base = (void*)v;
data[0].iov_len = vs;

res = mdbx_put(get_current_tx(), static_cast<MDBX_dbi>(h), &key, data, 0);
//MDBX_put_flags_t flags = MDBX_put_flags_t();
unsigned flags = 0;
res = mdbx_put(get_current_tx(), static_cast<MDBX_dbi>(h), &key, data, flags);
CHECK_AND_ASSERT_MESS_MDBX_DB(res, false, "Unable to mdbx_put");
return true;
}
Expand Down
3 changes: 1 addition & 2 deletions src/currency_core/account.cpp
Expand Up @@ -70,8 +70,7 @@ namespace currency
iv = *((crypto::chacha8_iv*)&pass_hash);
crypto::chacha8(scr_data, src_length, key, iv, (char*)dst_data);
}


//-----------------------------------------------------------------
std::string account_base::get_seed_phrase(const std::string& password) const
{
if (m_keys_seed_binary.empty())
Expand Down
36 changes: 18 additions & 18 deletions src/currency_core/blockchain_storage.cpp
Expand Up @@ -578,13 +578,13 @@ bool blockchain_storage::set_checkpoints(checkpoints&& chk_pts)
catch (const std::exception& ex)
{
m_db.abort_transaction();
LOG_ERROR("UNKNOWN EXCEPTION WHILE ADDINIG NEW BLOCK: " << ex.what());
LOG_ERROR("UNKNOWN EXCEPTION WHILE SETTING CHECKPOINTS: " << ex.what());
return false;
}
catch (...)
{
m_db.abort_transaction();
LOG_ERROR("UNKNOWN EXCEPTION WHILE ADDINIG NEW BLOCK.");
LOG_ERROR("UNKNOWN EXCEPTION WHILE SETTING CHECKPOINTS.");
return false;
}

Expand All @@ -594,7 +594,7 @@ bool blockchain_storage::prune_ring_signatures_and_attachments(uint64_t height,
{
CRITICAL_REGION_LOCAL(m_read_lock);

CHECK_AND_ASSERT_MES(height < m_db_blocks.size(), false, "prune_ring_signatures called with wrong parameter: " << height << ", m_blocks.size() " << m_db_blocks.size());
CHECK_AND_ASSERT_MES(height < m_db_blocks.size(), false, "prune_ring_signatures called with wrong parameter: " << height << ", m_blocks.size() = " << m_db_blocks.size());
auto vptr = m_db_blocks[height];
CHECK_AND_ASSERT_MES(vptr.get(), false, "Failed to get block on height");

Expand Down Expand Up @@ -626,22 +626,20 @@ bool blockchain_storage::prune_ring_signatures_and_attachments_if_need()
{
CRITICAL_REGION_LOCAL(m_read_lock);

if (m_db_blocks.size() > 1 && m_checkpoints.get_top_checkpoint_height() && m_checkpoints.get_top_checkpoint_height() > m_db_current_pruned_rs_height)
{
uint64_t pruning_last_height = std::min(m_db_blocks.size() - 1, m_checkpoints.get_top_checkpoint_height());
if (pruning_last_height > m_db_current_pruned_rs_height)
uint64_t top_block_height = get_top_block_height();
uint64_t pruning_end_height = m_checkpoints.get_checkpoint_before_height(top_block_height);
if (pruning_end_height > m_db_current_pruned_rs_height)
{
LOG_PRINT_CYAN("Starting pruning ring signatues and attachments from height " << m_db_current_pruned_rs_height + 1 << " to height " << pruning_end_height
<< " (" << pruning_end_height - m_db_current_pruned_rs_height << " blocks), top block height is " << top_block_height, LOG_LEVEL_0);
uint64_t tx_count = 0, sig_count = 0, attach_count = 0;
for(uint64_t height = m_db_current_pruned_rs_height + 1; height <= pruning_end_height; height++)
{
LOG_PRINT_CYAN("Starting pruning ring signatues and attachments from height " << m_db_current_pruned_rs_height + 1 << " to height " << pruning_last_height
<< " (" << pruning_last_height - m_db_current_pruned_rs_height << " blocks)", LOG_LEVEL_0);
uint64_t tx_count = 0, sig_count = 0, attach_count = 0;
for(uint64_t height = m_db_current_pruned_rs_height + 1; height <= pruning_last_height; height++)
{
bool res = prune_ring_signatures_and_attachments(height, tx_count, sig_count, attach_count);
CHECK_AND_ASSERT_MES(res, false, "failed to prune_ring_signatures_and_attachments for height = " << height);
}
m_db_current_pruned_rs_height = pruning_last_height;
LOG_PRINT_CYAN("Transaction pruning finished: " << sig_count << " signatures and " << attach_count << " attachments released in " << tx_count << " transactions.", LOG_LEVEL_0);
bool res = prune_ring_signatures_and_attachments(height, tx_count, sig_count, attach_count);
CHECK_AND_ASSERT_MES(res, false, "failed to prune_ring_signatures_and_attachments for height = " << height);
}
m_db_current_pruned_rs_height = pruning_end_height;
LOG_PRINT_CYAN("Transaction pruning finished: " << sig_count << " signatures and " << attach_count << " attachments released in " << tx_count << " transactions.", LOG_LEVEL_0);
}
return true;
}
Expand Down Expand Up @@ -1036,7 +1034,9 @@ void blockchain_storage::purge_alt_block_txs_hashs(const block& b)
//------------------------------------------------------------------
void blockchain_storage::do_erase_altblock(alt_chain_container::iterator it)
{
purge_altblock_keyimages_from_big_heap(it->second.bl, get_block_hash(it->second.bl));
crypto::hash id = get_block_hash(it->second.bl);
LOG_PRINT_L1("erasing alt block " << print16(id) << " @ " << get_block_height(it->second.bl));
purge_altblock_keyimages_from_big_heap(it->second.bl, id);
purge_alt_block_txs_hashs(it->second.bl);
m_alternative_chains.erase(it);
}
Expand Down
2 changes: 1 addition & 1 deletion src/currency_core/blockchain_storage.h
Expand Up @@ -396,7 +396,7 @@ namespace currency
else
{
CHECK_AND_ASSERT_MES(*block_ind_ptr < m_db_blocks.size(), false, "Internal error: bl_id=" << string_tools::pod_to_hex(bl_id)
<< " have index record with offset=" << *block_ind_ptr << ", bigger then m_blocks.size()=" << m_db_blocks.size());
<< " have index record with offset=" << *block_ind_ptr << ", bigger then m_db_blocks.size()=" << m_db_blocks.size());
blocks.push_back(m_db_blocks[*block_ind_ptr]->bl);
}
}
Expand Down
27 changes: 25 additions & 2 deletions src/currency_core/checkpoints.cpp
Expand Up @@ -36,11 +36,11 @@ namespace currency
if(height > blockchain_last_block_height)
return false;

auto it = m_points.lower_bound(height);
auto it = m_points.lower_bound(height); // if found, it->first >= height
if(it == m_points.end())
return false;
if(it->first <= blockchain_last_block_height)
return true;
return true; // this is the case only if height <= it->first <= blockchain_last_block_height
else
return false;
}
Expand Down Expand Up @@ -68,4 +68,27 @@ namespace currency
return false;
}
}
//---------------------------------------------------------------------------
uint64_t checkpoints::get_checkpoint_before_height(uint64_t height) const
{
// returns height of the leftmost CP with height that is LESS than the given height
// ex:
// If there are two CP at 11 and 15:
// get_checkpoint_before_height(10) = 0
// get_checkpoint_before_height(11) = 0
// get_checkpoint_before_height(12) = 11
// get_checkpoint_before_height(13) = 11
// get_checkpoint_before_height(14) = 11
// get_checkpoint_before_height(15) = 11
// get_checkpoint_before_height(16) = 15

uint64_t top_cp = get_top_checkpoint_height();
if (height > top_cp)
return top_cp;

auto it = m_points.lower_bound(height); // if found, it->first >= height
if (it == m_points.end() || it == m_points.begin())
return 0;
return (--it)->first;
}
}
2 changes: 2 additions & 0 deletions src/currency_core/checkpoints.h
Expand Up @@ -20,6 +20,8 @@ namespace currency
bool is_height_passed_zone(uint64_t height, uint64_t blockchain_last_block_height) const;
bool check_block(uint64_t height, const crypto::hash& h) const;
uint64_t get_top_checkpoint_height() const;

uint64_t get_checkpoint_before_height(uint64_t height) const;
private:
std::map<uint64_t, crypto::hash> m_points;
};
Expand Down
2 changes: 1 addition & 1 deletion src/currency_core/currency_config.h
Expand Up @@ -211,7 +211,7 @@
#define MINER_CONFIG_FILENAME "miner_conf.json"
#define GUI_SECURE_CONFIG_FILENAME "gui_secure_conf.bin"
#define GUI_CONFIG_FILENAME "gui_settings.json"
#define GUI_INTERNAL_CONFIG "gui_internal_config.bin"
#define GUI_INTERNAL_CONFIG2 "gui_internal_config.json"



Expand Down
3 changes: 2 additions & 1 deletion src/currency_protocol/currency_protocol_handler.inl
Expand Up @@ -914,7 +914,8 @@ namespace currency
LOG_ERROR_CCONTEXT("sent wrong NOTIFY_RESPONSE_CHAIN_ENTRY, with \r\nm_total_height=" << arg.total_height
<< "\r\nm_start_height=" << arg.start_height
<< "\r\nm_block_ids.size()=" << arg.m_block_ids.size());
//m_p2p->drop_connection(context);
m_p2p->drop_connection(context);
m_p2p->add_ip_fail(context.m_remote_ip);
}

BOOST_FOREACH(auto& bl_details, arg.m_block_ids)
Expand Down
17 changes: 13 additions & 4 deletions src/gui/qt-daemon/Info.plist.in
Expand Up @@ -45,10 +45,19 @@
<true/>
<key>NSHumanReadableCopyright</key>
<string></string>

<key>NSHighResolutionCapable</key>
<string>True</string>

<key>NSHighResolutionCapable</key>
<string>True</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>ZanoApp</string>
<key>CFBundleURLSchemes</key>
<array>
<string>zano</string>
</array>
</dict>
</array>

</dict>
</plist>
Binary file modified src/gui/qt-daemon/app.icns
Binary file not shown.
Binary file modified src/gui/qt-daemon/app.ico
Binary file not shown.

0 comments on commit 854a2f0

Please sign in to comment.