From c6549bf3517a62c4adff5112ce77621ced0116f0 Mon Sep 17 00:00:00 2001 From: Thomas Winget Date: Tue, 10 Apr 2018 15:21:12 -0400 Subject: [PATCH 1/2] fixup loki stagenet changes after upstream merge --- src/cryptonote_config.h | 4 +-- src/cryptonote_core/blockchain.cpp | 20 +++++---------- src/cryptonote_core/cryptonote_tx_utils.cpp | 28 +++++++++++++++------ src/cryptonote_core/cryptonote_tx_utils.h | 2 +- 4 files changed, 30 insertions(+), 24 deletions(-) diff --git a/src/cryptonote_config.h b/src/cryptonote_config.h index 981bd95863..da997b450c 100644 --- a/src/cryptonote_config.h +++ b/src/cryptonote_config.h @@ -198,10 +198,10 @@ namespace config boost::uuids::uuid const NETWORK_ID = { { 0x12 ,0x30, 0xF1, 0x71 , 0x61, 0x04 , 0x41, 0x61, 0x17, 0x31, 0x00, 0x82, 0x16, 0xA1, 0xA1, 0x12 } }; // Bender's daydream - std::string const GENESIS_TX = "013c01ff0001ffffffffffff0302df5d56da0c7d643ddd1ce61901c7bdc5fb1738bfe39fbe69c28a3a7032729c0f2101168d0c4ca86fb55a4cf6a36d31431be1c53a3bd7411bb24e8832410289fa6f3b"; + std::string const GENESIS_TX = "023c01ff000380808d93f5d771027389ebfc2065e669080d96f3b5706958d485d25cf2031c6ecc30a17191fc4fe08080b4ccd4dfc60302a45f41e3ebfca05a9723e6cbbba2caffbd767153d1e1a85230bbcfb8b7482388808088fccdbcc3230252635354495b1282b6510b03fc484884ba82f2a574a59bdbaf749d4a75ea6603210177fb23a01548df63e87a60f8fb41d4bbe293c3d6b2c128dde2d37b27958bdd2f00"; uint32_t const GENESIS_NONCE = 10002; - std::string const GOVERNANCE_WALLET_ADDRESS = "T6U5dnmhyw1XsDryZUZL4hAwkNDYahFLEbhyfipTJ2ZZLV1Epm5zHTf6SQzxre9V8R9zjSPN6WWiT9adBQYt7Wut2xjon6dgT"; + std::string const GOVERNANCE_WALLET_ADDRESS = "52hBAREiNay8bH6JCfWrGdDM3cV6yHMLpcKFnVfnqPcVUrKGLbJCmkuUzJZqLfjzrMRYQgUsoHTuuMA1Z7QKvxFVANKHdGt"; } } diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index 685507ada7..cecd68a88f 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -112,16 +112,8 @@ static const struct { uint8_t threshold; time_t time; } stagenet_hard_forks[] = { - // version 1 from the start of the blockchain - { 1, 1, 0, 1341378000 }, - - // versions 2-7 in rapid succession from March 13th, 2018 - { 2, 32000, 0, 1521000000 }, - { 3, 33000, 0, 1521120000 }, - { 4, 34000, 0, 1521240000 }, - { 5, 35000, 0, 1521360000 }, - { 6, 36000, 0, 1521480000 }, - { 7, 37000, 0, 1521600000 }, + // version 7 from the start of the blockchain, inhereted from Loki testnet + { 7, 1, 0, 1341378000 }, }; //------------------------------------------------------------------ @@ -323,11 +315,11 @@ bool Blockchain::init(BlockchainDB* db, const network_type nettype, bool offline if (m_hardfork == nullptr) { if (m_nettype == FAKECHAIN || m_nettype == STAGENET) - m_hardfork = new HardFork(*db, 1, 0); + m_hardfork = new HardFork(*db, 7, 0); else if (m_nettype == TESTNET) - m_hardfork = new HardFork(*db, 1, testnet_hard_fork_version_1_till); + m_hardfork = new HardFork(*db, 7, testnet_hard_fork_version_1_till); else - m_hardfork = new HardFork(*db, 1, mainnet_hard_fork_version_1_till); + m_hardfork = new HardFork(*db, 7, mainnet_hard_fork_version_1_till); } if (m_nettype == FAKECHAIN) { @@ -1055,7 +1047,7 @@ bool Blockchain::validate_miner_transaction(const block& b, size_t cumulative_bl return false; } - if (!validate_governance_reward_key(m_db->height(), governance_wallet_address_str, b.miner_tx.vout.size() - 1, boost::get(b.miner_tx.vout.back().target).key)) + if (!validate_governance_reward_key(m_db->height(), governance_wallet_address_str, b.miner_tx.vout.size() - 1, boost::get(b.miner_tx.vout.back().target).key, m_nettype)) { MERROR("Governance reward public key incorrect."); return false; diff --git a/src/cryptonote_core/cryptonote_tx_utils.cpp b/src/cryptonote_core/cryptonote_tx_utils.cpp index 7f349a6d52..fbfb1a3827 100644 --- a/src/cryptonote_core/cryptonote_tx_utils.cpp +++ b/src/cryptonote_core/cryptonote_tx_utils.cpp @@ -113,12 +113,25 @@ namespace cryptonote return true; } - bool validate_governance_reward_key(uint64_t height, const std::string& governance_wallet_address_str, size_t output_index, const crypto::public_key& output_key) + bool validate_governance_reward_key(uint64_t height, const std::string& governance_wallet_address_str, size_t output_index, const crypto::public_key& output_key, const cryptonote::network_type nettype) { keypair gov_key = get_deterministic_keypair_from_height(height); cryptonote::address_parse_info governance_wallet_address; - cryptonote::get_account_address_from_str(governance_wallet_address, cryptonote::MAINNET, governance_wallet_address_str); + switch (nettype) + { + case STAGENET: + cryptonote::get_account_address_from_str(governance_wallet_address, cryptonote::STAGENET, governance_wallet_address_str); + break; + case TESTNET: + cryptonote::get_account_address_from_str(governance_wallet_address, cryptonote::TESTNET, governance_wallet_address_str); + break; + case MAINNET: + cryptonote::get_account_address_from_str(governance_wallet_address, cryptonote::MAINNET, governance_wallet_address_str); + break; + default: + return false; + } crypto::public_key correct_key; @@ -231,23 +244,24 @@ namespace cryptonote if (already_generated_coins != 0) { std::string governance_wallet_address_str; + + cryptonote::address_parse_info governance_wallet_address; + switch (nettype) { case STAGENET: - governance_wallet_address_str = ::config::stagenet::GOVERNANCE_WALLET_ADDRESS; + cryptonote::get_account_address_from_str(governance_wallet_address, cryptonote::STAGENET, ::config::stagenet::GOVERNANCE_WALLET_ADDRESS); break; case TESTNET: - governance_wallet_address_str = ::config::testnet::GOVERNANCE_WALLET_ADDRESS; + cryptonote::get_account_address_from_str(governance_wallet_address, cryptonote::TESTNET, ::config::testnet::GOVERNANCE_WALLET_ADDRESS); break; case MAINNET: - governance_wallet_address_str = ::config::GOVERNANCE_WALLET_ADDRESS; + cryptonote::get_account_address_from_str(governance_wallet_address, cryptonote::MAINNET, ::config::GOVERNANCE_WALLET_ADDRESS); break; default: return false; } - cryptonote::address_parse_info governance_wallet_address; - cryptonote::get_account_address_from_str(governance_wallet_address, cryptonote::MAINNET, governance_wallet_address_str); crypto::public_key out_eph_public_key = AUTO_VAL_INIT(out_eph_public_key); diff --git a/src/cryptonote_core/cryptonote_tx_utils.h b/src/cryptonote_core/cryptonote_tx_utils.h index 5fe89a21a4..3aa741fa07 100644 --- a/src/cryptonote_core/cryptonote_tx_utils.h +++ b/src/cryptonote_core/cryptonote_tx_utils.h @@ -45,7 +45,7 @@ namespace cryptonote bool get_deterministic_output_key(const account_public_address& address, const keypair& tx_key, size_t output_index, crypto::public_key& output_key); - bool validate_governance_reward_key(uint64_t height, const std::string& governance_wallet_address_str, size_t output_index, const crypto::public_key& output_key); + bool validate_governance_reward_key(uint64_t height, const std::string& governance_wallet_address_str, size_t output_index, const crypto::public_key& output_key, const cryptonote::network_type nettype); struct tx_source_entry { From 2a2bc7c271f8f1b3ad1930eec0588b7969c93322 Mon Sep 17 00:00:00 2001 From: Thomas Winget Date: Tue, 10 Apr 2018 15:43:01 -0400 Subject: [PATCH 2/2] revert some erroneous Monero->Loki name changes --- src/cryptonote_core/blockchain.cpp | 6 +++--- src/debug_utilities/object_sizes.cpp | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index cecd68a88f..57748561e1 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -90,7 +90,7 @@ static const struct { uint8_t threshold; time_t time; } mainnet_hard_forks[] = { - // version 7 from the start of the blockchain, inhereted from Loki mainnet + // version 7 from the start of the blockchain, inhereted from Monero mainnet { 7, 1, 0, 1503046577 }, }; static const uint64_t mainnet_hard_fork_version_1_till = 0; @@ -101,7 +101,7 @@ static const struct { uint8_t threshold; time_t time; } testnet_hard_forks[] = { - // version 7 from the start of the blockchain, inhereted from Loki testnet + // version 7 from the start of the blockchain, inhereted from Monero testnet { 7, 1, 0, 1512211236 }, }; static const uint64_t testnet_hard_fork_version_1_till = 624633; @@ -112,7 +112,7 @@ static const struct { uint8_t threshold; time_t time; } stagenet_hard_forks[] = { - // version 7 from the start of the blockchain, inhereted from Loki testnet + // version 7 from the start of the blockchain, inhereted from Monero testnet { 7, 1, 0, 1341378000 }, }; diff --git a/src/debug_utilities/object_sizes.cpp b/src/debug_utilities/object_sizes.cpp index 6c337a948f..e5610354d3 100644 --- a/src/debug_utilities/object_sizes.cpp +++ b/src/debug_utilities/object_sizes.cpp @@ -105,12 +105,12 @@ int main(int argc, char* argv[]) SL(tools::wallet2::unsigned_tx_set); SL(tools::wallet2::signed_tx_set); - SL(Loki::WalletImpl); - SL(Loki::AddressBookRow); - SL(Loki::TransactionInfoImpl); - SL(Loki::TransactionHistoryImpl); - SL(Loki::PendingTransactionImpl); - SL(Loki::UnsignedTransactionImpl); + SL(Monero::WalletImpl); + SL(Monero::AddressBookRow); + SL(Monero::TransactionInfoImpl); + SL(Monero::TransactionHistoryImpl); + SL(Monero::PendingTransactionImpl); + SL(Monero::UnsignedTransactionImpl); return 0; }