Skip to content

Commit 05b5b50

Browse files
committed
fee: fix fee too low issue
1 parent b80a201 commit 05b5b50

File tree

2 files changed

+25
-99
lines changed

2 files changed

+25
-99
lines changed

src/checkpoints/checkpoints.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -182,18 +182,20 @@ bool checkpoints::check_for_conflicts(const checkpoints &other) const {
182182

183183
bool checkpoints::init_default_checkpoints(network_type nettype) {
184184
if (nettype == TESTNET) {
185-
ADD_CHECKPOINT2(
186-
10, "a76e3b124834af91af028718e9dc03277bcd08845deecf1e52061b6411b3356c",
187-
"0x25");
188-
ADD_CHECKPOINT2(
189-
100, "0f15b75b65d7c4c3709ceae9e46a6432ea36458b765633e1e0c057cb047c0817",
190-
"0x9450c84");
191-
ADD_CHECKPOINT2(
192-
1000, "66160d3d15f2f585a1d015c37ecaa531afd30a4cbe3708ec9f80fb86326646d6",
193-
"0x2dd67170");
194-
ADD_CHECKPOINT2(
195-
9000, "dfda0b4ab55db760aac40164f4043e89b3733c31ebae00381b343c085056c57d",
196-
"0x3ceb638a1");
185+
ADD_CHECKPOINT2(
186+
10, "a76e3b124834af91af028718e9dc03277bcd08845deecf1e52061b6411b3356c",
187+
"0x25");
188+
ADD_CHECKPOINT2(
189+
100, "0f15b75b65d7c4c3709ceae9e46a6432ea36458b765633e1e0c057cb047c0817",
190+
"0x9450c84");
191+
ADD_CHECKPOINT2(
192+
1000,
193+
"66160d3d15f2f585a1d015c37ecaa531afd30a4cbe3708ec9f80fb86326646d6",
194+
"0x2dd67170");
195+
ADD_CHECKPOINT2(
196+
9000,
197+
"dfda0b4ab55db760aac40164f4043e89b3733c31ebae00381b343c085056c57d",
198+
"0x3ceb638a1");
197199

198200
return true;
199201
}

src/wallet/wallet2.cpp

Lines changed: 11 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,13 +1007,15 @@ size_t estimate_rct_tx_size(int n_inputs, int mixin, int n_outputs,
10071007
size += (2 * 64 * 32 + 32 + 64 * 32) * n_outputs;
10081008

10091009
// MGs/CLSAGs
1010-
if (clsag)
1010+
if (clsag) {
10111011
size += n_inputs * (32 * (mixin + 1) + 64);
1012-
else
1012+
} else {
10131013
size += n_inputs * (64 * (mixin + 1) + 32);
1014+
}
10141015

1015-
if (use_view_tags)
1016+
if (use_view_tags) {
10161017
size += n_outputs * sizeof(crypto::view_tag);
1018+
}
10171019

10181020
// mixRing - not serialized, can be reconstructed
10191021
/* size += 2 * 32 * (mixin+1) * n_inputs; */
@@ -1027,7 +1029,7 @@ size_t estimate_rct_tx_size(int n_inputs, int mixin, int n_outputs,
10271029
// txnFee
10281030
size += 4;
10291031

1030-
LOG_PRINT_L2("estimated "
1032+
LOG_PRINT_L0("estimated "
10311033
<< (bulletproof_plus ? "bulletproof plus"
10321034
: bulletproof ? "bulletproof"
10331035
: "borromean")
@@ -8424,85 +8426,7 @@ uint64_t wallet2::adjust_mixin(uint64_t mixin) {
84248426
return mixin;
84258427
}
84268428
//----------------------------------------------------------------------------------------------------
8427-
uint32_t wallet2::adjust_priority(uint32_t priority) {
8428-
if (priority == 0 && m_default_priority == 0 && auto_low_priority()) {
8429-
try {
8430-
// check if there's a backlog in the tx pool
8431-
const bool use_per_byte_fee = use_fork_rules(HF_VERSION_PER_BYTE_FEE, 0);
8432-
const uint64_t base_fee = get_base_fee();
8433-
const double fee_level =
8434-
base_fee * (use_per_byte_fee ? 1 : (12 / (double)13 / (double)1024));
8435-
const std::vector<std::pair<uint64_t, uint64_t>> blocks =
8436-
estimate_backlog({std::make_pair(fee_level, fee_level)});
8437-
if (blocks.size() != 1) {
8438-
MERROR("Bad estimated backlog array size");
8439-
return priority;
8440-
} else if (blocks[0].first > 0) {
8441-
MINFO("We don't use the low priority because there's a backlog in the "
8442-
"tx pool.");
8443-
return priority;
8444-
}
8445-
8446-
// get the current full reward zone
8447-
uint64_t block_weight_limit = 0;
8448-
const auto result =
8449-
m_node_rpc_proxy.get_block_weight_limit(block_weight_limit);
8450-
if (result)
8451-
return priority;
8452-
const uint64_t full_reward_zone = block_weight_limit / 2;
8453-
8454-
// get the last N block headers and sum the block sizes
8455-
const size_t N = 10;
8456-
if (m_blockchain.size() < N) {
8457-
MERROR("The blockchain is too short");
8458-
return priority;
8459-
}
8460-
cryptonote::COMMAND_RPC_GET_BLOCK_HEADERS_RANGE::request getbh_req =
8461-
AUTO_VAL_INIT(getbh_req);
8462-
cryptonote::COMMAND_RPC_GET_BLOCK_HEADERS_RANGE::response getbh_res =
8463-
AUTO_VAL_INIT(getbh_res);
8464-
getbh_req.start_height = m_blockchain.size() - N;
8465-
getbh_req.end_height = m_blockchain.size() - 1;
8466-
8467-
{
8468-
const boost::lock_guard<boost::recursive_mutex> lock{
8469-
m_daemon_rpc_mutex};
8470-
bool r = net_utils::invoke_http_json_rpc(
8471-
"/json_rpc", "getblockheadersrange", getbh_req, getbh_res,
8472-
*m_http_client, rpc_timeout);
8473-
THROW_ON_RPC_RESPONSE_ERROR(r, {}, getbh_res, "getblockheadersrange",
8474-
error::get_blocks_error,
8475-
get_rpc_status(getbh_res.status));
8476-
}
8477-
8478-
if (getbh_res.headers.size() != N) {
8479-
MERROR("Bad blockheaders size");
8480-
return priority;
8481-
}
8482-
size_t block_weight_sum = 0;
8483-
for (const cryptonote::block_header_response &i : getbh_res.headers) {
8484-
block_weight_sum += i.block_weight;
8485-
}
8486-
8487-
// estimate how 'full' the last N blocks are
8488-
const size_t P = 100 * block_weight_sum / (N * full_reward_zone);
8489-
MINFO((boost::format("The last %d blocks fill roughly %d%% of the full "
8490-
"reward zone.") %
8491-
N % P)
8492-
.str());
8493-
if (P > 80) {
8494-
MINFO("We don't use the low priority because recent blocks are quite "
8495-
"full.");
8496-
return priority;
8497-
}
8498-
MINFO("We'll use the low priority because probably it's safe to do so.");
8499-
return 1;
8500-
} catch (const std::exception &e) {
8501-
MERROR(e.what());
8502-
}
8503-
}
8504-
return priority;
8505-
}
8429+
uint32_t wallet2::adjust_priority(uint32_t priority) { return priority; }
85068430
//----------------------------------------------------------------------------------------------------
85078431
bool wallet2::set_ring_database(const std::string &filename) {
85088432
m_ring_database = filename;
@@ -10518,7 +10442,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(
1051810442
const bool use_view_tags = use_fork_rules(get_view_tag_fork(), 0);
1051910443
std::unordered_set<crypto::public_key> valid_public_keys_cache;
1052010444

10521-
const uint64_t base_fee = get_base_fee();
10445+
const uint64_t base_fee = get_base_fee(priority);
1052210446
const uint64_t fee_quantization_mask = get_fee_quantization_mask();
1052310447

1052410448
// throw if attempting a transaction with no destinations
@@ -11255,7 +11179,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_all(
1125511179
const bool bulletproof_plus = use_fork_rules(get_bulletproof_plus_fork(), 0);
1125611180
const bool clsag = use_fork_rules(get_clsag_fork(), 0);
1125711181
const bool use_view_tags = use_fork_rules(get_view_tag_fork(), 0);
11258-
const uint64_t base_fee = get_base_fee();
11182+
const uint64_t base_fee = get_base_fee(priority);
1125911183
const size_t tx_weight_one_ring =
1126011184
estimate_tx_weight(use_rct, 1, fake_outs_count, 2, 0, bulletproof, clsag,
1126111185
bulletproof_plus, use_view_tags);
@@ -11407,7 +11331,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_from(
1140711331
const rct::RCTConfig rct_config{rct::RangeProofPaddedBulletproof,
1140811332
bulletproof_plus ? 4 : 2};
1140911333
const bool use_view_tags = use_fork_rules(get_view_tag_fork(), 0);
11410-
const uint64_t base_fee = get_base_fee();
11334+
const uint64_t base_fee = get_base_fee(priority);
1141111335
const uint64_t fee_quantization_mask = get_fee_quantization_mask();
1141211336

1141311337
LOG_PRINT_L2("Starting with "
@@ -11927,7 +11851,7 @@ wallet2::create_unmixable_sweep_transactions() {
1192711851
const bool hf1_rules = use_fork_rules(2, 10); // first hard fork has version 2
1192811852
tx_dust_policy dust_policy(hf1_rules ? 0 : ::config::DEFAULT_DUST_THRESHOLD);
1192911853

11930-
const uint64_t base_fee = get_base_fee();
11854+
const uint64_t base_fee = get_base_fee(1);
1193111855

1193211856
// may throw
1193311857
std::vector<size_t> unmixable_outputs = select_available_unmixable_outputs();

0 commit comments

Comments
 (0)