Skip to content

Commit

Permalink
Merge pull request #1227 from sumoprojects/dev
Browse files Browse the repository at this point in the history
[wallet2] fix precision of average_output_time and harden code against invalid input types
  • Loading branch information
quangvu3 authored Jul 18, 2021
2 parents ffa3eb4 + f63dae3 commit 1a0b6df
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ jobs:
run: |
git clone https://github.com/libunwind/libunwind
cd libunwind
sudo ./autogen.sh
sudo autoreconf -i
sudo ./configure
sudo make -j 3
sudo make install
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <deque>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/contains_fwd.hpp>
#include <boost/mpl/contains.hpp>

#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "serialization"
Expand Down
1 change: 1 addition & 0 deletions contrib/epee/include/storages/portable_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "portable_storage_val_converters.h"
#include "misc_log_ex.h"
#include "span.h"
#include <boost/mpl/contains.hpp>

namespace epee
{
Expand Down
11 changes: 2 additions & 9 deletions src/blockchain_db/blockchain_db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,8 @@ void BlockchainDB::add_transaction(const crypto::hash& blk_hash, const std::pair
}
else
{
LOG_PRINT_L1("Unsupported input type, removing key images and aborting transaction addition");
for (const txin_v& tx_input : tx.vin)
{
if (tx_input.type() == typeid(txin_to_key))
{
remove_spent_key(boost::get<txin_to_key>(tx_input).k_image);
}
}
return;
LOG_PRINT_L1("Unsupported input type, aborting transaction addition");
throw std::runtime_error("Unexpected input type, aborting");
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/wallet/wallet2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,8 @@ gamma_picker::gamma_picker(const std::vector<uint64_t> &rct_offsets, double shap
num_rct_outputs = *(end - 1);
THROW_WALLET_EXCEPTION_IF(num_rct_outputs == 0, error::wallet_internal_error, "No rct outputs");
average_output_time = DIFFICULTY_TARGET * blocks_to_consider / outputs_to_consider; // this assumes constant target over the whole rct range
if (average_output_time == 0)
average_output_time = DIFFICULTY_TARGET * blocks_to_consider / static_cast<double>(outputs_to_consider);
};

gamma_picker::gamma_picker(const std::vector<uint64_t> &rct_offsets): gamma_picker(rct_offsets, GAMMA_SHAPE, GAMMA_SCALE) {}
Expand Down

0 comments on commit 1a0b6df

Please sign in to comment.