1
0
Fork 0
forked from lthn/blockchain

Merge branch 'release' into develop

This commit is contained in:
sowle 2023-11-09 19:42:57 +01:00
commit e89462e126
4 changed files with 36 additions and 8 deletions

View file

@ -8,6 +8,6 @@
#define PROJECT_REVISION "2"
#define PROJECT_VERSION PROJECT_MAJOR_VERSION "." PROJECT_MINOR_VERSION "." PROJECT_REVISION
#define PROJECT_VERSION_BUILD_NO 153
#define PROJECT_VERSION_BUILD_NO 156
#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

@ -3512,7 +3512,7 @@ bool wallet2::prepare_and_sign_pos_block(const currency::pos_entry& pe, currency
COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::response decoys_resp = AUTO_VAL_INIT(decoys_resp);
std::vector<const crypto::public_key*> ring;
uint64_t secret_index = 0; // index of the real stake output
if (m_required_decoys_count > 0)
if (m_required_decoys_count > 0 && !is_auditable())
{
COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::request decoys_req = AUTO_VAL_INIT(decoys_req);
decoys_req.use_forced_mix_outs = false;

View file

@ -1935,7 +1935,7 @@ void wallets_manager::wallet_vs_options::worker_func()
{
LOG_PRINT_GREEN("[WALLET_HANDLER] Wallet handler thread started, addr: " << w->get()->get_account().get_public_address_str(), LOG_LEVEL_0);
epee::math_helper::once_a_time_seconds<TX_POOL_SCAN_INTERVAL> scan_pool_interval;
epee::math_helper::once_a_time_seconds<POS_WALLET_MINING_SCAN_INTERVAL> pos_minin_interval;
epee::math_helper::once_a_time_seconds<2> pos_minin_interval;
view::wallet_status_info wsi = AUTO_VAL_INIT(wsi);
while (!major_stop)
{

View file

@ -152,10 +152,11 @@ bool pos_mining_with_decoys::generate(std::vector<test_event_entry>& events) con
{
uint64_t ts = test_core_time::get_time();
m_accounts.resize(TOTAL_ACCS_COUNT);
currency::account_base& miner_acc = m_accounts[MINER_ACC_IDX]; miner_acc.generate(); miner_acc.set_createtime(ts);
currency::account_base& alice_acc = m_accounts[ALICE_ACC_IDX]; alice_acc.generate(); alice_acc.set_createtime(ts);
currency::account_base& bob_acc = m_accounts[BOB_ACC_IDX]; bob_acc.generate(); bob_acc.set_createtime(ts);
currency::account_base& carol_acc = m_accounts[CAROL_ACC_IDX]; carol_acc.generate(); carol_acc.set_createtime(ts);
currency::account_base& miner_acc = m_accounts[MINER_ACC_IDX]; miner_acc.generate(); miner_acc.set_createtime(ts);
currency::account_base& alice_acc = m_accounts[ALICE_ACC_IDX]; alice_acc.generate(); alice_acc.set_createtime(ts);
currency::account_base& bob_acc = m_accounts[BOB_ACC_IDX]; bob_acc.generate(); bob_acc.set_createtime(ts);
currency::account_base& carol_acc = m_accounts[CAROL_ACC_IDX]; carol_acc.generate(); carol_acc.set_createtime(ts);
currency::account_base& dan_acc = m_accounts[DAN_ACC_IDX]; dan_acc.generate(true); dan_acc.set_createtime(ts); // Dan has an auditable wallet
MAKE_GENESIS_BLOCK(events, blk_0, miner_acc, ts);
DO_CALLBACK(events, "configure_core"); // default configure_core callback will initialize core runtime config with m_hardforks
@ -167,7 +168,8 @@ bool pos_mining_with_decoys::generate(std::vector<test_event_entry>& events) con
CHECK_AND_ASSERT_MES(r, false, "fill_tx_sources failed");
std::vector<tx_destination_entry> destinations;
destinations.emplace_back(47 * TESTS_DEFAULT_FEE, alice_acc.get_public_address());
destinations.emplace_back(47 * TESTS_DEFAULT_FEE, miner_acc.get_public_address()); // as a decoy for Alice
destinations.emplace_back(47 * TESTS_DEFAULT_FEE, miner_acc.get_public_address()); // as a decoy for Alice and Dan
destinations.emplace_back(47 * TESTS_DEFAULT_FEE, dan_acc.get_public_address());
destinations.emplace_back(5 * TESTS_DEFAULT_FEE, bob_acc.get_public_address());
destinations.emplace_back(COIN, carol_acc.get_public_address());
@ -204,6 +206,10 @@ bool pos_mining_with_decoys::c1(currency::core& c, size_t ev_index, const std::v
carol_wlt->refresh();
CHECK_AND_ASSERT_MES(check_balance_via_wallet(*carol_wlt, "Carol", COIN, INVALID_BALANCE_VAL, COIN), false, "");
std::shared_ptr<tools::wallet2> dan_wlt = init_playtime_test_wallet(events, c, m_accounts[DAN_ACC_IDX]);
dan_wlt->refresh();
CHECK_AND_ASSERT_MES(check_balance_via_wallet(*dan_wlt, "Dan", 47 * TESTS_DEFAULT_FEE, INVALID_BALANCE_VAL, 47 * TESTS_DEFAULT_FEE), false, "");
// 1. Alice should be able to mine a PoS block with 1 decoys (ring size == 2)
size_t top_block_height = c.get_top_block_height();
@ -225,6 +231,7 @@ bool pos_mining_with_decoys::c1(currency::core& c, size_t ev_index, const std::v
// 2. Bob should only be able to mine a PoS block with zero decoys (ring size == 1)
top_block_height = c.get_top_block_height();
bob_wlt->refresh();
r = bob_wlt->try_mint_pos(m_accounts[BOB_ACC_IDX].get_public_address());
CHECK_AND_ASSERT_MES(r, false, "try_mint_pos failed");
@ -242,6 +249,7 @@ bool pos_mining_with_decoys::c1(currency::core& c, size_t ev_index, const std::v
// 3. Carol should only be able to mine a PoS block with CURRENCY_DEFAULT_DECOY_SET_SIZE decoys (ring size == CURRENCY_DEFAULT_DECOY_SET_SIZE + 1)
top_block_height = c.get_top_block_height();
carol_wlt->refresh();
r = carol_wlt->try_mint_pos(m_accounts[CAROL_ACC_IDX].get_public_address());
CHECK_AND_ASSERT_MES(r, false, "try_mint_pos failed");
@ -255,5 +263,25 @@ bool pos_mining_with_decoys::c1(currency::core& c, size_t ev_index, const std::v
CHECK_AND_ASSERT_MES(intk.key_offsets.size() == CURRENCY_DEFAULT_DECOY_SET_SIZE + 1, false, "unexpected ring size: " << intk.key_offsets.size());
}
// 4. Dan has an auditable wallet that couldn't use mixins, but still he should be able to successfully mine a PoS block (ring size = 1, zero decoys)
top_block_height = c.get_top_block_height();
CHECK_AND_ASSERT_MES(dan_wlt->is_auditable(), false, "Dan's wallet is not auditable, which is unexpected");
dan_wlt->refresh();
r = dan_wlt->try_mint_pos(m_accounts[DAN_ACC_IDX].get_public_address());
CHECK_AND_ASSERT_MES(r, false, "try_mint_pos failed");
{
block b{};
CHECK_AND_ASSERT_MES(c.get_blockchain_storage().get_top_block(b), false, "");
CHECK_AND_ASSERT_MES(get_block_height(b) == top_block_height + 1, false, "unexpected top block height");
txin_to_key& intk = boost::get<txin_to_key>(b.miner_tx.vin[1]);
CHECK_AND_ASSERT_MES(intk.amount == 47 * TESTS_DEFAULT_FEE, false, "incorrect amount: " << intk.amount);
CHECK_AND_ASSERT_MES(intk.key_offsets.size() == 1, false, "unexpected ring size: " << intk.key_offsets.size());
}
return true;
}