Compare commits

...
Sign in to create a new pull request.

20 commits
dev ... master

Author SHA1 Message Date
dependabot[bot]
3334756ce4
Bump axios from 1.8.2 to 1.12.0 in /utils/JS (#579)
Bumps [axios](https://github.com/axios/axios) from 1.8.2 to 1.12.0.
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md)
- [Commits](https://github.com/axios/axios/compare/v1.8.2...v1.12.0)

---
updated-dependencies:
- dependency-name: axios
  dependency-version: 1.12.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-09-15 19:34:14 +02:00
sowle
c0bb2dddda
hotfix for incorrect handling of SSL certs on Linux/macOS
This reverts commit 6a4fc0d34f.
2025-09-05 03:54:33 +03:00
sowle
36a09972c9
Merge branch 'release' 2025-08-29 02:55:07 +03:00
sowle
03ce1e6c9d
Merge branch 'develop' into release 2025-08-27 16:23:03 +03:00
sowle
7ebedbbe9e
typo fixed 2025-08-27 16:22:07 +03:00
sowle
cccd97fa01
Merge branch 'develop' into release 2025-08-27 15:36:56 +03:00
sowle
0de1633f83
=== version bump: 2.1.8.430 -> 2.1.9.431 === 2025-08-27 15:36:45 +03:00
sowle
fa21489237
wallet rpc: tx_comment enabled back 2025-08-27 15:32:45 +03:00
sowle
8e237a054c
tests: PCH fixed for db_size_test 2025-08-26 21:51:49 +03:00
Dmitry Matsiukhov
6a4fc0d34f
Add cert verification (#564)
* Add cert verification

* Refactor, stackoverflow windows solution

* Finalize

* Add more verifications
2025-08-25 18:19:38 +01:00
zano build machine
d92c4bfdd5 === build number: 429 -> 430 === 2025-08-22 14:39:40 +03:00
sowle
a9b981f30b
ui update (PR 160) 2025-08-22 13:59:51 +03:00
Dmitry Matsiukhov
db96e6638d
bulk writer (#561)
* bulk writer

* delete

* refactor
2025-08-20 14:42:46 +01:00
zano build machine
a91b097f4e === build number: 428 -> 429 === 2025-08-18 14:44:19 +03:00
sowle
c3b7ac9691
ui update (PR 159) 2025-08-18 14:32:07 +03:00
sowle
2884df9edc
wallet: minor improvements 2025-08-16 05:13:45 +03:00
sowle
5ff0399568
simplewallet: transfer_so fixed 2025-08-16 05:13:15 +03:00
sowle
935feb66f5
wallet: fixed/improved: set_tids_to_be_only_used_in_the_next_transfer(), get_transfer_info_by_index(), get_asset_info() 2025-08-16 05:12:34 +03:00
sowle
c25641b0e0
get_last_alt_x_block_cumulative_precise_difficulty() clarified 2025-08-16 05:10:01 +03:00
sowle
8460d07e24
Merge branch 'release' into develop 2025-08-16 02:41:28 +03:00
12 changed files with 563 additions and 45 deletions

View file

@ -6852,9 +6852,8 @@ wide_difficulty_type blockchain_storage::get_last_alt_x_block_cumulative_precise
return res;
}
//------------------------------------------------------------------
wide_difficulty_type blockchain_storage::get_last_alt_x_block_cumulative_precise_difficulty(const alt_chain_type& alt_chain, uint64_t block_height, bool pos, wide_difficulty_type& cumulative_diff_precise_adj) const
wide_difficulty_type blockchain_storage::get_last_alt_x_block_cumulative_precise_difficulty(const alt_chain_type& alt_chain, uint64_t main_chain_start_block_height, bool pos, wide_difficulty_type& cumulative_diff_precise_adj) const
{
uint64_t main_chain_first_block = block_height;
for (auto it = alt_chain.rbegin(); it != alt_chain.rend(); it++)
{
if (is_pos_block((*it)->second.bl) == pos)
@ -6862,14 +6861,14 @@ wide_difficulty_type blockchain_storage::get_last_alt_x_block_cumulative_precise
cumulative_diff_precise_adj = (*it)->second.cumulative_diff_precise_adjusted;
return (*it)->second.cumulative_diff_precise;
}
main_chain_first_block = (*it)->second.height - 1;
main_chain_start_block_height = (*it)->second.height - 1;
}
CRITICAL_REGION_LOCAL(m_read_lock);
CHECK_AND_ASSERT_MES(main_chain_first_block < m_db_blocks.size(), false, "Intrnal error: main_chain_first_block(" << main_chain_first_block << ") < m_blocks.size() (" << m_db_blocks.size() << ")");
CHECK_AND_ASSERT_MES(main_chain_start_block_height < m_db_blocks.size(), false, "Internal error: main_chain_start_block_height (" << main_chain_start_block_height << ") < m_blocks.size() (" << m_db_blocks.size() << ")");
for (uint64_t i = main_chain_first_block; i != 0; i--)
for (uint64_t i = main_chain_start_block_height; i != 0; i--)
{
if (is_pos_block(m_db_blocks[i]->bl) == pos)
{

@ -1 +1 @@
Subproject commit bcd4021364bbcd29a4208225de33a359ee35a447
Subproject commit 1b8e3da0d15c76f285f97c8fe29f6e7f6cab2fe6

View file

@ -1840,7 +1840,14 @@ bool simple_wallet::transfer_so(const std::vector<std::string> &args)
std::stringstream ss;
for (auto i : outs_idxs)
{
ss << i << " ";
tools::transfer_details td{};
if (!m_wallet->get_transfer_info_by_index(i, td) || !td.is_spendable())
{
fail_msg_writer() << "output #" << i << ": wrong index or not spendable";
}
}
success_msg_writer() << "outputs' indicies allowed to spent: " << (outs_idxs.empty() ? std::string("all") : ss.str());
// 2nd arg: fee
@ -2109,7 +2116,7 @@ bool simple_wallet::list_outputs(const std::vector<std::string> &args)
arg_spent_flags = true, include_spent = false;
else if (!arg_spent_flags && (arg == "s" || arg == "spent" || arg == "unavailable"))
arg_spent_flags = true, include_unspent = false;
else if (!arg_unknown_assets && (arg == "unknown"))
else if (!arg_unknown_assets && (arg == "unknown" || arg == "unk"))
arg_unknown_assets = true, show_only_unknown = true;
else if (!arg_ticker_filer && (arg.find("ticker=") == 0 || arg.find("t=") == 0))
arg_ticker_filer = true, filter_asset_ticker = boost::erase_all_copy(boost::erase_all_copy(arg, "ticker="), "t=");

View file

@ -5,9 +5,9 @@
#define PROJECT_MAJOR_VERSION "2"
#define PROJECT_MINOR_VERSION "1"
#define PROJECT_REVISION "8"
#define PROJECT_REVISION "9"
#define PROJECT_VERSION PROJECT_MAJOR_VERSION "." PROJECT_MINOR_VERSION "." PROJECT_REVISION
#define PROJECT_VERSION_BUILD_NO 428
#define PROJECT_VERSION_BUILD_NO 431
#define PROJECT_VERSION_BUILD_NO_STR STRINGIFY_EXPAND(PROJECT_VERSION_BUILD_NO)
#define PROJECT_VERSION_LONG PROJECT_VERSION "." PROJECT_VERSION_BUILD_NO_STR "[" BUILD_COMMIT_ID "]"

View file

@ -223,8 +223,10 @@ bool wallet2::get_transfer_info_by_key_image(const crypto::key_image& ki, transf
//----------------------------------------------------------------------------------------------------
bool wallet2::get_transfer_info_by_index(size_t i, transfer_details& td)
{
//WLT_CHECK_AND_ASSERT_MES(i < m_transfers.size(), false, "wrong out in transaction: internal index, m_transfers.size()=" << m_transfers.size());
td = m_transfers.at(i);
auto it = m_transfers.find(i);
if (it == m_transfers.end())
return false;
td = it->second;
return true;
}
//----------------------------------------------------------------------------------------------------
@ -3865,7 +3867,7 @@ bool wallet2::get_asset_info(const crypto::public_key& asset_id, currency::asset
asset_flags |= aif_custom;
}
if (ask_daemon_for_unknown)
if (asset_flags == aif_none && ask_daemon_for_unknown)
{
if (daemon_get_asset_info(asset_id, asset_info))
{
@ -4012,7 +4014,7 @@ bool wallet2::generate_utxo_defragmentation_transaction_if_needed(currency::tran
//----------------------------------------------------------------------------------------------------
std::string wallet2::get_transfers_str(bool include_spent /*= true*/, bool include_unspent /*= true*/, bool show_only_unknown /*= false*/, const std::string& filter_asset_ticker /*= std::string{}*/) const
{
static const char* header = " index amount ticker g_index flags block tx out# asset id";
static const char* header = " index amount ticker g_index flags block tx out# asset id";
std::stringstream ss;
ss << header << ENDL;
size_t count = 0;
@ -4043,7 +4045,7 @@ std::string wallet2::get_transfers_str(bool include_spent /*= true*/, bool inclu
ss << std::right << (is_locked ? "*" : " ") <<
std::setw(5) << i << " " <<
std::setw(21) << print_asset_money(td.m_amount, adb.decimal_point) << " " <<
std::setw(6) << std::left << (native_coin ? std::string(" ") : adb.ticker) << " " << std::right <<
std::setw(14) << std::left << (native_coin ? std::string(" ") : adb.ticker) << " " << std::right <<
std::setw(7) << td.m_global_output_index << " " <<
std::setw(2) << std::setfill('0') << td.m_flags << std::setfill(' ') << ":" <<
std::setw(8) << transfer_flags_to_str(td.m_flags) << " " <<
@ -4062,21 +4064,21 @@ std::string wallet2::get_transfers_str(bool include_spent /*= true*/, bool inclu
ss << "printed " << count << " outputs of " << m_transfers.size() << " total" << ENDL;
if (unknown_assets_outs_count == 1)
ss << "(" << unknown_assets_outs_count << " output with unrecognized asset id is not shown, use 'list_outputs unknown' to see it)" << ENDL;
ss << "(" << unknown_assets_outs_count << " output with unrecognized asset id is not shown, use 'list_outputs unknown' or 'lo unk' to see it)" << ENDL;
else if (unknown_assets_outs_count > 1)
ss << "(" << unknown_assets_outs_count << " outputs with unrecognized asset ids are not shown, use 'list_outputs unknown' to see them)" << ENDL;
ss << "(" << unknown_assets_outs_count << " outputs with unrecognized asset ids are not shown, use 'list_outputs unknown' or 'lo unk' to see them)" << ENDL;
return ss.str();
}
//----------------------------------------------------------------------------------------------------
std::string wallet2::get_balance_str() const
{
// balance unlocked / [balance total] ticker asset id
// 0.21 / 98.51 DP2 a6974d5874e97e5f4ed5ad0a62f0975edbccb1bb55502fc75c7fe808f12f44d3
// 190.123456789012 / 199.123456789012 ZANO d6329b5b1f7c0805b5c345f4957554002a2f557845f64d7645dae0e051a6498a NATIVE
// 98.0 BGTVUW af2b12f3033337f9aea1845a6bc3fc966ed4d13227a3ace7706fca7dbcdaa7e2
// 1000.034 DP3 d4aba1020f26927571771e04b585b4ffb211f52708d5e4c465bbdfa4a12e6271
// balance unlocked / [balance total] ticker asset id
// 0.21 / 98.51 DP2 a6974d5874e97e5f4ed5ad0a62f0975edbccb1bb55502fc75c7fe808f12f44d3
// 190.123456789012 / 199.123456789012 ZANO d6329b5b1f7c0805b5c345f4957554002a2f557845f64d7645dae0e051a6498a NATIVE
// 98.0 BGTVUW af2b12f3033337f9aea1845a6bc3fc966ed4d13227a3ace7706fca7dbcdaa7e2
// 1000.034 DP3 d4aba1020f26927571771e04b585b4ffb211f52708d5e4c465bbdfa4a12e6271
static const char* header = " balance unlocked / [balance total] ticker asset id";
static const char* header = " balance unlocked / [balance total] ticker asset id";
std::stringstream ss;
ss << header << ENDL;
@ -4098,7 +4100,7 @@ std::string wallet2::get_balance_str() const
ss << std::string(21 + 3, ' ');
else
ss << " / " << std::setw(21) << print_fixed_decimal_point_with_trailing_spaces(b.total, b.asset_info.decimal_point);
ss << " " << std::setw(8) << std::left << b.asset_info.ticker << " " << b.asset_info.asset_id;
ss << " " << std::setw(14) << std::left << b.asset_info.ticker << " " << b.asset_info.asset_id;
if (b.asset_info.asset_id == native_coin_asset_id)
ss << " NATIVE";
ss << ENDL;
@ -4109,15 +4111,15 @@ std::string wallet2::get_balance_str() const
//----------------------------------------------------------------------------------------------------
std::string wallet2::get_balance_str_raw() const
{
// balance unlocked / [balance total] ticker asset id DP flags
// 0.21 / 98.51 ZANO d6329b5b1f7c0805b5c345f4957554002a2f557845f64d7645dae0e051a6498a 12 NATIVE
// 2.0 MYFB 13615ffdfbdc09275a1dfc0fbdaf6a9b07849b835ffdfed0b9e1478ea8924774 1 custom
// 1000.0 BurnCT 14608811180d4bbad96a6b91405e329e4f2a10519e6dcea644f83b9f8ccb5863 12 unknown asset
// balance unlocked / [balance total] ticker asset id DP flags
// 0.21 / 98.51 ZANO d6329b5b1f7c0805b5c345f4957554002a2f557845f64d7645dae0e051a6498a 12 NATIVE
// 2.0 MYFB 13615ffdfbdc09275a1dfc0fbdaf6a9b07849b835ffdfed0b9e1478ea8924774 1 custom
// 1000.0 BurnCT 14608811180d4bbad96a6b91405e329e4f2a10519e6dcea644f83b9f8ccb5863 12 unknown asset
//WHITELIST:
// a7e8e5b31c24f2d6a07e141701237b136d704c9a89f9a5d1ca4a8290df0b9edc WETH
// ...
static const char* header = " balance unlocked / [balance total] ticker asset id DP flags";
static const char* header = " balance unlocked / [balance total] ticker asset id DP flags";
std::stringstream ss;
ss << header << ENDL;
@ -4138,7 +4140,7 @@ std::string wallet2::get_balance_str_raw() const
else
ss << " / " << std::setw(21) << print_fixed_decimal_point_with_trailing_spaces(entry.second.total, asset_info.decimal_point);
ss << " " << std::setw(8) << std::left << asset_info.ticker;
ss << " " << std::setw(14) << std::left << asset_info.ticker;
ss << " " << entry.first << " ";
if (has_info)

View file

@ -588,7 +588,6 @@ namespace tools
void set_tids_to_be_only_used_in_the_next_transfer(const std::vector<uint64_t>& tids)
{
WLT_THROW_IF_FALSE_WALLET_CMN_ERR_EX(std::all_of(tids.cbegin(), tids.cend(), [&](size_t i){ return i < m_transfers.size(); }), "some transfers IDs are out of range");
m_found_free_amounts.clear();
add_transfers_to_transfers_cache(tids);
}

View file

@ -529,10 +529,9 @@ namespace tools
if (!req.comment.empty() && payment_id.empty())
{
// tx_comment is temporary disabled -- sowle
//currency::tx_comment comment = AUTO_VAL_INIT(comment);
//comment.comment = req.comment;
//extra.push_back(comment);
currency::tx_comment comment{};
comment.comment = req.comment;
extra.push_back(comment);
}
if (req.push_payer && !wrap)

View file

@ -67,4 +67,5 @@ if(MSVC AND USE_PCH)
set_property(SOURCE "core_tests/chaingen_pch.cpp" APPEND_STRING PROPERTY COMPILE_FLAGS " /Ycchaingen.h /Zm1000")
set_property(TARGET coretests functional_tests hash-target-tests performance_tests unit_tests APPEND_STRING PROPERTY LINK_FLAGS "$(MSBuildProjectDirectory)/../src/$(ConfigurationName)/stdafx.obj")
set_property(TARGET db_tests APPEND_STRING PROPERTY LINK_FLAGS "$(MSBuildProjectDirectory)/../../src/$(ConfigurationName)/stdafx.obj")
set_property(TARGET db_size_test APPEND_STRING PROPERTY LINK_FLAGS "$(MSBuildProjectDirectory)/../../src/$(ConfigurationName)/stdafx.obj")
endif()

View file

@ -1,3 +1,4 @@
add_executable(db_tests db_tests.cpp)
add_executable(db_size_test db_size_test.cpp)
target_link_libraries(db_tests crypto common lmdb zlibstatic ${Boost_LIBRARIES})
target_link_libraries(db_size_test crypto common lmdb zlibstatic ${Boost_LIBRARIES})

View file

@ -0,0 +1,324 @@
#include <random>
#include <array>
#include <vector>
#include <string>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <chrono>
#include "epee/include/include_base_utils.h"
#include "include_base_utils.h"
#include "common/db_backend_lmdb.h"
#include "common/db_abstract_accessor.h"
#include "readwrite_lock.h"
// #undef LOG_DEFAULT_CHANNEL
// #define LOG_DEFAULT_CHANNEL "db-bulk-writer"
using namespace tools::db;
enum class Mode { kv, array };
struct first_item_cb : public i_db_callback
{
std::string k, v;
bool got = false;
bool on_enum_item(uint64_t /*i*/, const void* pkey, uint64_t ks, const void* pval, uint64_t vs) override
{
k.assign(static_cast<const char*>(pkey), static_cast<size_t>(ks));
v.assign(static_cast<const char*>(pval), static_cast<size_t>(vs));
got = true;
return false; // stop
}
};
static void gen_key_bytes(std::mt19937_64& gen, uint64_t counter, std::string& out, size_t size)
{
out.resize(size);
for (size_t i = 0; i < size; i += 8)
{
uint64_t r = gen() ^ (0x9E3779B97F4A7C15ull * (counter + i));
std::memcpy(&out[i], &r, std::min<size_t>(8, size - i));
}
}
class bulk_writer
{
public:
bulk_writer(basic_db_accessor& db, i_db_backend& _be, const std::string& table, container_handle h, Mode mode)
: _db(db), _be_(_be), _table(table), _h(h), _mode(mode) {}
bool init_sample()
{
if (_mode == Mode::kv)
{
if (_be_.size(_h) == 0)
{
LOG_ERROR("[" << _table << "] empty");
return false;
}
first_item_cb cb;
if (!_be_.enumerate(_h, &cb) || !cb.got)
{
LOG_ERROR("[" << _table << "] enumerate failed");
return false;
}
_sample_key = cb.k;
_sample_val = cb.v;
_key_size = _sample_key.size();
_bytes_per_put = _key_size + _sample_val.size();
_entries = _be_.size(_h);
return true;
}
else
{ // array
_entries = _be_.size(_h);
if (_entries == 0)
{
LOG_ERROR("[" << _table << "] empty");
return false;
}
uint64_t last_key = _entries - 1;
if (!_be_.get(_h, reinterpret_cast<const char*>(&last_key), sizeof(last_key), _sample_val))
{
LOG_ERROR("[" << _table << "] get(last) failed");
return false;
}
_key_size = sizeof(uint64_t);
_bytes_per_put = _key_size + _sample_val.size();
return true;
}
}
void print_initial_estimate() const
{
const long double MB_DEC = 1'000'000.0L;
long double approx_initial_bytes = static_cast<long double>(_entries) * _bytes_per_put;
LOG_PRINT_L0("[" << _table << "] entries=" << _entries
<< ", sample_value=" << _sample_val.size() << " B"
<< ", approx bytes/put=" << _bytes_per_put << " B");
LOG_PRINT_L0("[" << _table << "] Approx initial size: "
<< (approx_initial_bytes / MB_DEC) << " MB");
}
bool write(uint64_t target_mb, uint64_t step_mb)
{
using clock = std::chrono::steady_clock;
const uint64_t MB_DEC = 1'000'000;
const uint64_t target_bytes = target_mb * MB_DEC;
const uint64_t step_bytes = step_mb * MB_DEC;
if (!_db.begin_transaction(false))
{
LOG_ERROR("begin_transaction failed");
return false;
}
bool tx_open = true;
bool ok = true;
std::random_device rd;
std::mt19937_64 gen(rd());
uint64_t written_total = 0;
uint64_t next_report = step_bytes;
uint64_t chunks_done = 0;
uint64_t counter = 0;
uint64_t array_key = _entries;
const auto all_start = clock::now();
auto chunk_start = all_start;
while (written_total < target_bytes)
{
if (_mode == Mode::kv)
{
std::string new_key;
gen_key_bytes(gen, counter++, new_key, _key_size);
if (!_be_.set(_h, new_key.data(), new_key.size(), _sample_val.data(), _sample_val.size()))
{
LOG_ERROR("[" << _table << "] set(new kv) failed");
ok = false; break;
}
}
else
{ // array
if (!_be_.set(_h, reinterpret_cast<const char*>(&array_key), sizeof(array_key),
_sample_val.data(), _sample_val.size()))
{
LOG_ERROR("[" << _table << "] set(new array) failed");
ok = false; break;
}
++array_key;
}
written_total += _bytes_per_put;
if (written_total >= next_report)
{
const auto t_fill_done = clock::now();
if (tx_open)
{
_db.commit_transaction();
tx_open = false;
}
const auto t_after_commit = clock::now();
const double fill_sec = std::chrono::duration<double>(t_fill_done - chunk_start).count();
const double commit_sec = std::chrono::duration<double>(t_after_commit - t_fill_done).count();
const double chunk_sec = fill_sec + commit_sec;
const double total_sec = std::chrono::duration<double>(t_after_commit - all_start).count();
++chunks_done;
const long double approx_now_mb =
(static_cast<long double>(_entries) * _bytes_per_put
+ static_cast<long double>(chunks_done) * step_mb * MB_DEC) / 1'000'000.0L;
const double chunk_mb = static_cast<double>(step_mb);
const double fill_mb_s = chunk_mb / (fill_sec > 0 ? fill_sec : 1e-9);
const double commit_mb_s = chunk_mb / (commit_sec > 0 ? commit_sec : 1e-9);
const double chunk_mb_s = chunk_mb / (chunk_sec > 0 ? chunk_sec : 1e-9);
const double total_written = static_cast<double>(chunks_done * step_mb);
const double total_mb_s = total_written / (total_sec > 0 ? total_sec : 1e-9);
LOG_PRINT_L0(
"Writed " << step_mb << "MB in " << _table
<< " | fill: " << fill_sec << " s (" << fill_mb_s << " MB/s)"
<< ", commit: " << commit_sec << " s (" << commit_mb_s << " MB/s)"
<< ", total: " << chunk_sec << " s (" << chunk_mb_s << " MB/s). "
<< "Total written: " << total_written << " MB, total time: "
<< total_sec << " s (" << total_mb_s << " MB/s avg). "
<< "Est. table size now: " << approx_now_mb << " MB."
);
if (written_total < target_bytes)
{
if (!_db.begin_transaction(false))
{
LOG_ERROR("begin_transaction failed (after commit)");
ok = false; break;
}
tx_open = true;
chunk_start = clock::now();
}
next_report += step_bytes;
}
}
if (tx_open)
{
if (ok) _db.commit_transaction();
else _db.abort_transaction();
}
return ok;
}
private:
basic_db_accessor& _db;
i_db_backend& _be_;
std::string _table;
container_handle _h;
Mode _mode;
uint64_t _entries = 0;
size_t _key_size = 0;
uint64_t _bytes_per_put = 0;
std::string _sample_key;
std::string _sample_val;
};
static Mode parse_mode(const char* s)
{
if (!s)
return Mode::kv;
std::string v(s);
std::transform(v.begin(), v.end(), v.begin(), ::tolower);
if (v == "array")
return Mode::array;
return Mode::kv;
}
int main(int argc, char** argv)
{
epee::string_tools::set_module_name_and_folder(argv[0]);
epee::log_space::get_set_log_detalisation_level(true, LOG_LEVEL_0);
epee::log_space::log_singletone::add_logger(LOGGER_CONSOLE, nullptr, nullptr, LOG_LEVEL_0);
epee::log_space::log_singletone::set_thread_log_prefix("[db-bulk-writer] ");
if (argc < 3)
{
LOG_PRINT_L0(
std::string("Usage:\n ") + argv[0] +
" <env_path> <table_name> [--mode=kv|array] [--target-mb=N] [--step-mb=M]\n\n"
"Examples:\n " + argv[0] +
" ~/.Zano/blockchain_lmdb_v3 transactions --mode=kv --target-mb=1000 --step-mb=100\n " +
argv[0] +
" ~/.Zano/blockchain_lmdb_v3 blocks --mode=array --target-mb=200 --step-mb=50");
return 0;
}
std::string env_path = argv[1];
std::string table_name = argv[2];
Mode mode = Mode::kv;
uint64_t target_mb = 1000;
uint64_t step_mb = 100;
for (int i = 3; i < argc; ++i)
{
std::string a = argv[i];
auto eat = [&](const char* pfx)->const char*
{
size_t L = std::strlen(pfx);
if (a.size() > L && a.compare(0,L,pfx) == 0)
return a.c_str()+L;
return nullptr;
};
if (const char* v = eat("--mode="))
mode = parse_mode(v);
else if (const char* v = eat("--target-mb="))
target_mb = std::strtoull(v, nullptr, 10);
else if (const char* v = eat("--step-mb="))
step_mb = std::strtoull(v, nullptr, 10);
}
epee::shared_recursive_mutex rwlock;
std::shared_ptr<i_db_backend> be(new lmdb_db_backend());
basic_db_accessor db(be, rwlock);
uint64_t max_db_size = uint64_t(1UL * 512UL) * 1024UL * 1024UL * 1024UL;
if (!db.open(env_path, max_db_size))
{
LOG_ERROR("Failed to open LMDB env at " << env_path);
return EXIT_FAILURE;
}
container_handle h = 0;
if (!be->open_container(table_name, h))
{
LOG_ERROR("open_container(" << table_name << ") failed");
return EXIT_FAILURE;
}
bulk_writer writer(db, *be, table_name, h, mode);
if (!writer.init_sample())
return EXIT_FAILURE;
writer.print_initial_estimate();
bool ok = writer.write(target_mb, step_mb);
db.close();
if (ok)
{
LOG_PRINT_L0("DONE");
return EXIT_SUCCESS;
}
else
{
LOG_ERROR("FAILED");
return EXIT_FAILURE;
}
}

View file

@ -5,7 +5,7 @@
"packages": {
"": {
"dependencies": {
"axios": "^1.8.2",
"axios": "^1.12.0",
"ethers": "^6.13.2"
}
},
@ -49,23 +49,38 @@
"node_modules/asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==",
"license": "MIT"
},
"node_modules/axios": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.8.2.tgz",
"integrity": "sha512-ls4GYBm5aig9vWx8AWDSGLpnpDQRtWAfrjU+EuytuODrFBkqesN2RkOQCBzrA1RQNHw1SmRMSDDDSwzNAYQ6Rg==",
"version": "1.12.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.12.0.tgz",
"integrity": "sha512-oXTDccv8PcfjZmPGlWsPSwtOJCZ/b6W5jAMCNcfwJbCzDckwG0jrYJFaWH1yvivfCXjVzV/SPDEhMB3Q+DSurg==",
"license": "MIT",
"dependencies": {
"follow-redirects": "^1.15.6",
"form-data": "^4.0.0",
"form-data": "^4.0.4",
"proxy-from-env": "^1.1.0"
}
},
"node_modules/call-bind-apply-helpers": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
"integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"function-bind": "^1.1.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/combined-stream": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
"license": "MIT",
"dependencies": {
"delayed-stream": "~1.0.0"
},
@ -77,10 +92,70 @@
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
"license": "MIT",
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/dunder-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
"integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.1",
"es-errors": "^1.3.0",
"gopd": "^1.2.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-define-property": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
"integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-errors": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-object-atoms": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz",
"integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-set-tostringtag": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz",
"integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"get-intrinsic": "^1.2.6",
"has-tostringtag": "^1.0.2",
"hasown": "^2.0.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/ethers": {
"version": "6.13.2",
"resolved": "https://registry.npmjs.org/ethers/-/ethers-6.13.2.tgz",
@ -128,22 +203,132 @@
}
},
"node_modules/form-data": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.4.tgz",
"integrity": "sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow==",
"license": "MIT",
"dependencies": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"es-set-tostringtag": "^2.1.0",
"hasown": "^2.0.2",
"mime-types": "^2.1.12"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/function-bind": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/get-intrinsic": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
"integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.2",
"es-define-property": "^1.0.1",
"es-errors": "^1.3.0",
"es-object-atoms": "^1.1.1",
"function-bind": "^1.1.2",
"get-proto": "^1.0.1",
"gopd": "^1.2.0",
"has-symbols": "^1.1.0",
"hasown": "^2.0.2",
"math-intrinsics": "^1.1.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/get-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
"integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
"license": "MIT",
"dependencies": {
"dunder-proto": "^1.0.1",
"es-object-atoms": "^1.0.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/gopd": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
"integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/has-symbols": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
"integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/has-tostringtag": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz",
"integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==",
"license": "MIT",
"dependencies": {
"has-symbols": "^1.0.3"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/hasown": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
"integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
"license": "MIT",
"dependencies": {
"function-bind": "^1.1.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/math-intrinsics": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
"integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
@ -152,6 +337,7 @@
"version": "2.1.35",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"license": "MIT",
"dependencies": {
"mime-db": "1.52.0"
},

View file

@ -1,6 +1,6 @@
{
"dependencies": {
"axios": "^1.8.2",
"axios": "^1.12.0",
"ethers": "^6.13.2"
}
}