Skip to content

Commit

Permalink
Add the batch of release v3.4.0-beta-20181218 commits
Browse files Browse the repository at this point in the history
  • Loading branch information
developer-at-bcn committed Dec 18, 2018
1 parent d721103 commit f99781a
Show file tree
Hide file tree
Showing 60 changed files with 1,342 additions and 879 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ if(WIN32)
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maes -g -Wall -Wextra -Werror=return-type -Wno-unused-parameter")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maes -g -Wall -Wextra -Werror=return-type -Wno-unused-parameter")
# We can use -Wshadow with clang occasionally
if(BETTER_DEBUG)
message(STATUS "Using better debug: " ${BETTER_DEBUG})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0")
Expand Down Expand Up @@ -90,6 +91,7 @@ file(GLOB SRC_HTTP src/http/*.cpp src/http/*.hpp)
file(GLOB SRC_PLATFORM
src/platform/ExclusiveLock.cpp src/platform/ExclusiveLock.hpp
src/platform/Files.cpp src/platform/Files.hpp
src/platform/Ledger.cpp src/platform/Ledger.hpp
src/platform/Time.cpp src/platform/Time.hpp
src/platform/Network.cpp src/platform/Network.hpp
src/platform/PathTools.cpp src/platform/PathTools.hpp
Expand Down
8 changes: 8 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
## Release Notes

### v3.4.0-beta-20181218

- Signatures are now fully prunable (but not yet pruned) via modification to transaction hash calculations.
- A view-only wallet now shows address balance even for non-auditable unlinkable addresses, but only if sender follows the protocol. If in doubt about sender's fair play, auditable addresses should be used instead.
- A view-only wallet can now be exported with or without ability to view transaction destination addresses.
- `bytecoind` will not automatically look for `blocks.bin` anywhere. If you need to import blocks from file, use `--import-blocks=<folder>` command line parameter.
- `bytecoind` command line parameters `--ssl-certificate-pem-file`, `--ssl-certificate-password` removed, use ngnx in https proxy mode!

### v3.4.0-beta-20181212

*Consensus update (hard fork)*
Expand Down
4 changes: 4 additions & 0 deletions src/Core/BlockChainState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ static Amount validate_semantic(const Currency &currency, uint8_t block_major_ve
amount = key_output.amount;
if (check_output_key && !key_isvalid(key_output.public_key))
throw ConsensusError(common::to_string("Output key not valid elliptic point", key_output.public_key));
if (check_output_key && tx.version >= currency.amethyst_transaction_version &&
!key_isvalid(key_output.encrypted_secret))
throw ConsensusError(
common::to_string("Output encrypted secret not valid elliptic point", key_output.encrypted_secret));
if (tx.version < currency.amethyst_transaction_version && key_output.is_auditable)
throw ConsensusError(
common::to_string("Transaction version", tx.version, "insufficient for output with audit"));
Expand Down
14 changes: 0 additions & 14 deletions src/Core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,6 @@ Config::Config(common::CommandLine &cmd)
if (!common::parse_ip_address_and_port(pa, &walletd_bind_ip, &walletd_bind_port))
throw std::runtime_error("Wrong address format " + std::string(pa) + ", should be ip:port");
}
if (const char *pa = cmd.get("--ssl-certificate-pem-file")) {
ssl_certificate_pem_file = pa;
#if !platform_USE_SSL
throw std::runtime_error(
"Setting --ssl-certificate-pem-file impossible - this binary is built without OpenSSL");
#endif
}
if (const char *pa = cmd.get("--ssl-certificate-password")) {
ssl_certificate_password = pa;
#if !platform_USE_SSL
throw std::runtime_error(
"Setting --ssl_certificate_password impossible - this binary is built without OpenSSL");
#endif
}
if (const char *pa = cmd.get("--" CRYPTONOTE_NAME "d-authorization")) {
bytecoind_authorization = common::base64::encode(BinaryArray(pa, pa + strlen(pa)));
bytecoind_authorization_private = bytecoind_authorization;
Expand Down
2 changes: 0 additions & 2 deletions src/Core/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ class Config { // Consensus does not depend on those parameters
float multicast_period;
bool secrets_via_api;

std::string ssl_certificate_pem_file;
boost::optional<std::string> ssl_certificate_password;
std::string bytecoind_authorization;
std::string bytecoind_authorization_private;
uint16_t bytecoind_bind_port;
Expand Down
18 changes: 10 additions & 8 deletions src/Core/Currency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ Currency::Currency(const std::string &net)
if (net == "stage") {
upgrade_heights = {1, 1}; // block 1 is already V3
upgrade_desired_major_version = 4;
upgrade_window = EXPECTED_NUMBER_OF_BLOCKS_PER_DAY;
}
{
BinaryArray miner_tx_blob;
Expand Down Expand Up @@ -291,7 +290,8 @@ Height Currency::largest_window() const {
Transaction Currency::construct_miner_tx(
uint8_t block_major_version, Height height, Amount block_reward, const AccountAddress &miner_address) const {
Transaction tx;
const size_t max_outs = get_max_coinbase_outputs();
const bool is_tx_amethyst = miner_address.type() != typeid(AccountAddressSimple);
const size_t max_outs = get_max_coinbase_outputs();
// If we wish to limit number of outputs, it makes sense to round miner reward to some arbitrary number
// Though this solution will reduce number of coins to mix

Expand All @@ -300,7 +300,8 @@ Transaction Currency::construct_miner_tx(
Hash tx_inputs_hash = get_transaction_inputs_hash(tx);
KeyPair txkey = crypto::random_keypair();

extra_add_transaction_public_key(tx.extra, txkey.public_key);
if (!is_tx_amethyst)
extra_add_transaction_public_key(tx.extra, txkey.public_key);

std::vector<Amount> out_amounts;
decompose_amount(block_reward, min_dust_threshold, &out_amounts);
Expand All @@ -312,17 +313,17 @@ Transaction Currency::construct_miner_tx(

Amount summary_amounts = 0;
for (size_t out_index = 0; out_index < out_amounts.size(); out_index++) {
Hash output_secret = crypto::rand<Hash>();
OutputKey tk = TransactionBuilder::create_output(
miner_address, txkey.secret_key, tx_inputs_hash, out_index, output_secret);
const KeyPair output_det_keys = crypto::random_keypair();
OutputKey tk = TransactionBuilder::create_output(
is_tx_amethyst, miner_address, txkey.secret_key, tx_inputs_hash, out_index, output_det_keys);
tk.amount = out_amounts.at(out_index);
summary_amounts += tk.amount;
tx.outputs.push_back(tk);
}

invariant(summary_amounts == block_reward, "");

tx.version = miner_address.type() == typeid(AccountAddressSimple) ? 1 : amethyst_transaction_version;
tx.version = is_tx_amethyst ? amethyst_transaction_version : 1;
// if mining on old address, we maintain binary compatibility
if (block_major_version < amethyst_block_version)
tx.unlock_block_or_timestamp = height + mined_money_unlock_window;
Expand Down Expand Up @@ -557,7 +558,8 @@ bool Currency::amount_allowed_in_output(uint8_t block_major_version, Amount amou
}*/

Hash cn::get_transaction_inputs_hash(const TransactionPrefix &tx) {
BinaryArray ba = seria::to_binary(tx.inputs);
const bool is_tx_amethyst = (tx.version >= parameters::TRANSACTION_VERSION_AMETHYST);
BinaryArray ba = seria::to_binary(tx.inputs, is_tx_amethyst);
return crypto::cn_fast_hash(ba.data(), ba.size());
}

Expand Down
5 changes: 2 additions & 3 deletions src/Core/Currency.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ class Currency { // Consensus calculations depend on those parameters
bool is_transaction_unlocked(uint8_t block_major_version, BlockOrTimestamp unlock_time, Height block_height,
Timestamp block_time, Timestamp block_median_time) const;

// bool is_dust(Amount amount) const;
bool amount_allowed_in_output(uint8_t block_major_version, Amount amount) const;

static uint64_t get_penalized_amount(uint64_t amount, size_t median_size, size_t current_transactions_size);
Expand All @@ -128,13 +127,13 @@ class Currency { // Consensus calculations depend on those parameters
const HardCheckpoint *checkpoints_end = nullptr;
};

// we should probaly find better place for these global funs
// we should probably find better place for these global funs
Hash get_transaction_inputs_hash(const TransactionPrefix &);
Hash get_transaction_prefix_hash(const TransactionPrefix &);
Hash get_transaction_hash(const Transaction &);

Hash get_block_hash(const BlockHeader &, const BlockBodyProxy &);
Hash get_auxiliary_block_header_hash(const BlockHeader &, const BlockBodyProxy &);
// Auxilary hash, or prehash - inserted into MM or CM tree
// Auxiliary or Pre- hash - inserted into MM or CM tree

} // namespace cn
20 changes: 8 additions & 12 deletions src/Core/Multicore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,8 @@ WalletPreparatorMulticore::~WalletPreparatorMulticore() {
th.join();
}

PreparedWalletTransaction::PreparedWalletTransaction(
TransactionPrefix &&ttx, TransactionSignatures &&sigs, const Wallet::OutputHandler &o_handler)
: tx(std::move(ttx)), sigs(std::move(sigs)) {
PreparedWalletTransaction::PreparedWalletTransaction(TransactionPrefix &&ttx, const Wallet::OutputHandler &o_handler)
: tx(std::move(ttx)) {
// We ignore results of most crypto calls here and absence of tx_public_key
// All errors will lead to spend_key not found in our wallet
PublicKey tx_public_key = extra_get_transaction_public_key(tx.extra);
Expand All @@ -275,19 +274,16 @@ PreparedWalletTransaction::PreparedWalletTransaction(
}

PreparedWalletTransaction::PreparedWalletTransaction(Transaction &&tx, const Wallet::OutputHandler &o_handler)
: PreparedWalletTransaction(std::move(static_cast<TransactionPrefix &&>(tx)), std::move(tx.signatures), o_handler) {
}
: PreparedWalletTransaction(std::move(static_cast<TransactionPrefix &&>(tx)), o_handler) {}

PreparedWalletBlock::PreparedWalletBlock(BlockTemplate &&bc_header, std::vector<TransactionPrefix> &&raw_transactions,
std::vector<TransactionSignatures> &&signatures, Hash base_transaction_hash, const Wallet::OutputHandler &o_handler)
Hash base_transaction_hash, const Wallet::OutputHandler &o_handler)
: base_transaction_hash(base_transaction_hash) {
header = bc_header;
base_transaction =
PreparedWalletTransaction(std::move(bc_header.base_transaction), TransactionSignatures{}, o_handler);
header = bc_header;
base_transaction = PreparedWalletTransaction(std::move(bc_header.base_transaction), o_handler);
transactions.reserve(raw_transactions.size());
for (size_t tx_index = 0; tx_index != raw_transactions.size(); ++tx_index) {
transactions.emplace_back(std::move(raw_transactions.at(tx_index)),
tx_index < signatures.size() ? std::move(signatures.at(tx_index)) : TransactionSignatures{}, o_handler);
transactions.emplace_back(std::move(raw_transactions.at(tx_index)), o_handler);
}
}

Expand All @@ -314,7 +310,7 @@ void WalletPreparatorMulticore::thread_run() {
work.blocks.erase(work.blocks.begin());
}
PreparedWalletBlock result(std::move(sync_block.raw_header), std::move(sync_block.raw_transactions),
std::move(sync_block.signatures), sync_block.transactions.at(0).hash, o_handler);
sync_block.transactions.at(0).hash, o_handler);
{
std::unique_lock<std::mutex> lock(mu);
if (local_work_counter == work_counter) {
Expand Down
7 changes: 2 additions & 5 deletions src/Core/Multicore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,14 @@ class RingCheckerMulticore {

struct PreparedWalletTransaction {
TransactionPrefix tx;
TransactionSignatures sigs;
Hash prefix_hash;
Hash inputs_hash;
boost::optional<KeyDerivation> derivation; // Will be assigned on first actual use
std::vector<PublicKey> spend_keys;
std::vector<SecretKey> output_secret_scalars;

PreparedWalletTransaction() = default;
PreparedWalletTransaction(
TransactionPrefix &&tx, TransactionSignatures &&sigs, const Wallet::OutputHandler &o_handler);
PreparedWalletTransaction(TransactionPrefix &&tx, const Wallet::OutputHandler &o_handler);
PreparedWalletTransaction(Transaction &&tx, const Wallet::OutputHandler &o_handler);
};

Expand All @@ -112,8 +110,7 @@ struct PreparedWalletBlock {
std::vector<PreparedWalletTransaction> transactions;
PreparedWalletBlock() = default;
PreparedWalletBlock(BlockTemplate &&bc_header, std::vector<TransactionPrefix> &&raw_transactions,
std::vector<TransactionSignatures> &&signatures, Hash base_transaction_hash,
const Wallet::OutputHandler &o_handler);
Hash base_transaction_hash, const Wallet::OutputHandler &o_handler);
};

class WalletPreparatorMulticore {
Expand Down
Loading

0 comments on commit f99781a

Please sign in to comment.