Adding canary hashes for enabling ublock parsing and generation.

This commit is contained in:
clemahieu 2018-03-09 18:23:57 -06:00
commit 91099d9d84
12 changed files with 137 additions and 13 deletions

View file

@ -221,6 +221,7 @@ enum class process_result
unreceivable, // Source block doesn't exist or has already been received
gap_previous, // Block marked as previous is unknown
gap_source, // Block marked as source is unknown
utx_disabled, // Awaiting UTX canary block
not_receive_from_send, // Receive does not have a send source
account_mismatch, // Account number in open block doesn't match send destination
opened_burn_account, // The impossible happened, someone found the private key associated with the public key '0'.

View file

@ -1478,6 +1478,7 @@ TEST (ledger, block_destination_source)
ASSERT_TRUE (!init);
rai::ledger ledger (store);
rai::genesis genesis;
ledger.utx_parse_canary = genesis.hash ();
rai::transaction transaction (store.environment, nullptr, true);
genesis.initialize (transaction, store);
rai::keypair dest;
@ -1522,6 +1523,7 @@ TEST (ledger, utx_account)
ASSERT_TRUE (!init);
rai::ledger ledger (store);
rai::genesis genesis;
ledger.utx_parse_canary = genesis.hash ();
rai::transaction transaction (store.environment, nullptr, true);
genesis.initialize (transaction, store);
rai::utx_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
@ -1536,6 +1538,7 @@ TEST (ledger, utx_send_receive)
ASSERT_TRUE (!init);
rai::ledger ledger (store);
rai::genesis genesis;
ledger.utx_parse_canary = genesis.hash ();
rai::transaction transaction (store.environment, nullptr, true);
genesis.initialize (transaction, store);
rai::utx_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
@ -1567,6 +1570,7 @@ TEST (ledger, utx_receive)
ASSERT_TRUE (!init);
rai::ledger ledger (store);
rai::genesis genesis;
ledger.utx_parse_canary = genesis.hash ();
rai::transaction transaction (store.environment, nullptr, true);
genesis.initialize (transaction, store);
rai::send_block send1 (genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
@ -1596,6 +1600,7 @@ TEST (ledger, utx_rep_change)
ASSERT_TRUE (!init);
rai::ledger ledger (store);
rai::genesis genesis;
ledger.utx_parse_canary = genesis.hash ();
rai::transaction transaction (store.environment, nullptr, true);
genesis.initialize (transaction, store);
rai::keypair rep;
@ -1618,6 +1623,7 @@ TEST (ledger, utx_open)
ASSERT_TRUE (!init);
rai::ledger ledger (store);
rai::genesis genesis;
ledger.utx_parse_canary = genesis.hash ();
rai::transaction transaction (store.environment, nullptr, true);
genesis.initialize (transaction, store);
rai::keypair destination;
@ -1651,6 +1657,7 @@ TEST (ledger, send_after_utx_fail)
ASSERT_TRUE (!init);
rai::ledger ledger (store);
rai::genesis genesis;
ledger.utx_parse_canary = genesis.hash ();
rai::transaction transaction (store.environment, nullptr, true);
genesis.initialize (transaction, store);
rai::utx_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
@ -1667,6 +1674,7 @@ TEST (ledger, receive_after_utx_fail)
ASSERT_TRUE (!init);
rai::ledger ledger (store);
rai::genesis genesis;
ledger.utx_parse_canary = genesis.hash ();
rai::transaction transaction (store.environment, nullptr, true);
genesis.initialize (transaction, store);
rai::utx_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
@ -1683,6 +1691,7 @@ TEST (ledger, change_after_utx_fail)
ASSERT_TRUE (!init);
rai::ledger ledger (store);
rai::genesis genesis;
ledger.utx_parse_canary = genesis.hash ();
rai::transaction transaction (store.environment, nullptr, true);
genesis.initialize (transaction, store);
rai::utx_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
@ -1699,6 +1708,7 @@ TEST (ledger, utx_unreceivable_fail)
ASSERT_TRUE (!init);
rai::ledger ledger (store);
rai::genesis genesis;
ledger.utx_parse_canary = genesis.hash ();
rai::transaction transaction (store.environment, nullptr, true);
genesis.initialize (transaction, store);
rai::send_block send1 (genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
@ -1721,6 +1731,7 @@ TEST (ledger, utx_receive_bad_amount_fail)
ASSERT_TRUE (!init);
rai::ledger ledger (store);
rai::genesis genesis;
ledger.utx_parse_canary = genesis.hash ();
rai::transaction transaction (store.environment, nullptr, true);
genesis.initialize (transaction, store);
rai::send_block send1 (genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
@ -1743,6 +1754,7 @@ TEST (ledger, utx_no_link_amount_fail)
ASSERT_TRUE (!init);
rai::ledger ledger (store);
rai::genesis genesis;
ledger.utx_parse_canary = genesis.hash ();
rai::transaction transaction (store.environment, nullptr, true);
genesis.initialize (transaction, store);
rai::utx_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
@ -1759,6 +1771,7 @@ TEST (ledger, utx_receive_wrong_account_fail)
ASSERT_TRUE (!init);
rai::ledger ledger (store);
rai::genesis genesis;
ledger.utx_parse_canary = genesis.hash ();
rai::transaction transaction (store.environment, nullptr, true);
genesis.initialize (transaction, store);
rai::utx_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
@ -1782,6 +1795,7 @@ TEST (ledger, utx_open_utx_fork)
ASSERT_TRUE (!init);
rai::ledger ledger (store);
rai::genesis genesis;
ledger.utx_parse_canary = genesis.hash ();
rai::transaction transaction (store.environment, nullptr, true);
genesis.initialize (transaction, store);
rai::keypair destination;
@ -1801,6 +1815,7 @@ TEST (ledger, utx_utx_open_fork)
ASSERT_TRUE (!init);
rai::ledger ledger (store);
rai::genesis genesis;
ledger.utx_parse_canary = genesis.hash ();
rai::transaction transaction (store.environment, nullptr, true);
genesis.initialize (transaction, store);
rai::keypair destination;
@ -1820,6 +1835,7 @@ TEST (ledger, utx_open_previous_fail)
ASSERT_TRUE (!init);
rai::ledger ledger (store);
rai::genesis genesis;
ledger.utx_parse_canary = genesis.hash ();
rai::transaction transaction (store.environment, nullptr, true);
genesis.initialize (transaction, store);
rai::keypair destination;
@ -1836,6 +1852,7 @@ TEST (ledger, utx_send_change)
ASSERT_TRUE (!init);
rai::ledger ledger (store);
rai::genesis genesis;
ledger.utx_parse_canary = genesis.hash ();
rai::transaction transaction (store.environment, nullptr, true);
genesis.initialize (transaction, store);
rai::keypair rep;
@ -1858,6 +1875,7 @@ TEST (ledger, utx_receive_change)
ASSERT_TRUE (!init);
rai::ledger ledger (store);
rai::genesis genesis;
ledger.utx_parse_canary = genesis.hash ();
rai::transaction transaction (store.environment, nullptr, true);
genesis.initialize (transaction, store);
rai::utx_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
@ -1889,6 +1907,7 @@ TEST (ledger, utx_open_old)
ASSERT_TRUE (!init);
rai::ledger ledger (store);
rai::genesis genesis;
ledger.utx_parse_canary = genesis.hash ();
rai::transaction transaction (store.environment, nullptr, true);
genesis.initialize (transaction, store);
rai::keypair destination;
@ -1908,6 +1927,7 @@ TEST (ledger, utx_receive_old)
ASSERT_TRUE (!init);
rai::ledger ledger (store);
rai::genesis genesis;
ledger.utx_parse_canary = genesis.hash ();
rai::transaction transaction (store.environment, nullptr, true);
genesis.initialize (transaction, store);
rai::keypair destination;
@ -1931,6 +1951,7 @@ TEST (ledger, utx_rollback_send)
ASSERT_TRUE (!init);
rai::ledger ledger (store);
rai::genesis genesis;
ledger.utx_parse_canary = genesis.hash ();
rai::transaction transaction (store.environment, nullptr, true);
genesis.initialize (transaction, store);
rai::utx_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
@ -1960,6 +1981,7 @@ TEST (ledger, utx_rollback_receive)
ASSERT_TRUE (!init);
rai::ledger ledger (store);
rai::genesis genesis;
ledger.utx_parse_canary = genesis.hash ();
rai::transaction transaction (store.environment, nullptr, true);
genesis.initialize (transaction, store);
rai::utx_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
@ -1984,6 +2006,7 @@ TEST (ledger, utx_rollback_received_send)
ASSERT_TRUE (!init);
rai::ledger ledger (store);
rai::genesis genesis;
ledger.utx_parse_canary = genesis.hash ();
rai::transaction transaction (store.environment, nullptr, true);
genesis.initialize (transaction, store);
rai::keypair key;
@ -2009,6 +2032,7 @@ TEST (ledger, utx_rep_change_rollback)
ASSERT_TRUE (!init);
rai::ledger ledger (store);
rai::genesis genesis;
ledger.utx_parse_canary = genesis.hash ();
rai::transaction transaction (store.environment, nullptr, true);
genesis.initialize (transaction, store);
rai::keypair rep;
@ -2028,6 +2052,7 @@ TEST (ledger, utx_open_rollback)
ASSERT_TRUE (!init);
rai::ledger ledger (store);
rai::genesis genesis;
ledger.utx_parse_canary = genesis.hash ();
rai::transaction transaction (store.environment, nullptr, true);
genesis.initialize (transaction, store);
rai::keypair destination;
@ -2052,6 +2077,7 @@ TEST (ledger, utx_send_change_rollback)
ASSERT_TRUE (!init);
rai::ledger ledger (store);
rai::genesis genesis;
ledger.utx_parse_canary = genesis.hash ();
rai::transaction transaction (store.environment, nullptr, true);
genesis.initialize (transaction, store);
rai::keypair rep;
@ -2071,6 +2097,7 @@ TEST (ledger, utx_receive_change_rollback)
ASSERT_TRUE (!init);
rai::ledger ledger (store);
rai::genesis genesis;
ledger.utx_parse_canary = genesis.hash ();
rai::transaction transaction (store.environment, nullptr, true);
genesis.initialize (transaction, store);
rai::utx_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
@ -2084,3 +2111,26 @@ TEST (ledger, utx_receive_change_rollback)
ASSERT_EQ (rai::genesis_amount - rai::Gxrb_ratio, ledger.weight (transaction, rai::genesis_account));
ASSERT_EQ (0, ledger.weight (transaction, rep.pub));
}
TEST (ledger, utx_canary_blocks)
{
bool init (false);
rai::block_store store (init, rai::unique_path ());
ASSERT_TRUE (!init);
rai::genesis genesis;
rai::send_block parse_canary (genesis.hash (), rai::test_genesis_key.pub, rai::genesis_amount, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
rai::send_block generate_canary (parse_canary.hash (), rai::test_genesis_key.pub, rai::genesis_amount, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
rai::ledger ledger (store, 0, parse_canary.hash (), generate_canary.hash ());
rai::transaction transaction (store.environment, nullptr, true);
genesis.initialize (transaction, store);
rai::utx_block utx (rai::test_genesis_key.pub, genesis.hash (), rai::test_genesis_key.pub, rai::genesis_amount - rai::Gxrb_ratio, rai::test_genesis_key.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
ASSERT_FALSE (ledger.utx_parsing_enabled (transaction));
ASSERT_FALSE (ledger.utx_generation_enabled (transaction));
ASSERT_EQ (rai::process_result::utx_disabled, ledger.process (transaction, utx).code);
ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, parse_canary).code);
ASSERT_TRUE (ledger.utx_parsing_enabled (transaction));
ASSERT_FALSE (ledger.utx_generation_enabled (transaction));
ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, generate_canary).code);
ASSERT_TRUE (ledger.utx_parsing_enabled (transaction));
ASSERT_TRUE (ledger.utx_generation_enabled (transaction));
}

View file

@ -554,8 +554,10 @@ TEST (bootstrap_processor, process_two)
TEST (bootstrap_processor, process_utx)
{
rai::system system (24000, 1);
rai::genesis genesis;
system.wallet (0)->insert_adhoc (rai::test_genesis_key.prv);
auto node0 (system.nodes[0]);
node0->ledger.utx_parse_canary = genesis.hash ();
std::unique_ptr<rai::block> block1 (new rai::utx_block (rai::test_genesis_key.pub, node0->latest (rai::test_genesis_key.pub), rai::test_genesis_key.pub, rai::genesis_amount - 100, rai::test_genesis_key.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0));
std::unique_ptr<rai::block> block2 (new rai::utx_block (rai::test_genesis_key.pub, block1->hash (), rai::test_genesis_key.pub, rai::genesis_amount, block1->hash (), rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0));
node0->generate_work (*block1);
@ -564,6 +566,7 @@ TEST (bootstrap_processor, process_utx)
node0->process (*block2);
rai::node_init init1;
auto node1 (std::make_shared<rai::node> (init1, system.service, 24001, rai::unique_path (), system.alarm, system.logging, system.work));
node1->ledger.utx_parse_canary = genesis.hash ();
ASSERT_EQ (node0->latest (rai::test_genesis_key.pub), block2->hash ());
ASSERT_NE (node1->latest (rai::test_genesis_key.pub), block2->hash ());
node1->bootstrap_initiator.bootstrap (node0->network.endpoint ());

View file

@ -880,6 +880,8 @@ TEST (rpc, history)
auto receive (system.wallet (0)->receive_action (static_cast<rai::send_block &> (*send), rai::test_genesis_key.pub, system.nodes[0]->config.receive_minimum.number ()));
ASSERT_NE (nullptr, receive);
auto node0 (system.nodes[0]);
rai::genesis genesis;
node0->ledger.utx_parse_canary = genesis.hash ();
rai::utx_block usend (rai::genesis_account, node0->latest (rai::genesis_account), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
rai::utx_block ureceive (rai::genesis_account, usend.hash (), rai::genesis_account, rai::genesis_amount, usend.hash (), rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
rai::utx_block uchange (rai::genesis_account, ureceive.hash (), rai::keypair ().pub, rai::genesis_amount, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0);
@ -925,7 +927,6 @@ TEST (rpc, history)
ASSERT_EQ (rai::test_genesis_key.pub.to_account (), std::get<1> (history_l[3]));
ASSERT_EQ (system.nodes[0]->config.receive_minimum.to_string_dec (), std::get<2> (history_l[3]));
ASSERT_EQ (send->hash ().to_string (), std::get<3> (history_l[3]));
rai::genesis genesis;
ASSERT_EQ ("receive", std::get<0> (history_l[4]));
ASSERT_EQ (rai::test_genesis_key.pub.to_account (), std::get<1> (history_l[4]));
ASSERT_EQ (rai::genesis_amount.convert_to<std::string> (), std::get<2> (history_l[4]));
@ -3172,6 +3173,7 @@ TEST (rpc, block_create_utx)
rai::system system (24000, 1);
rai::keypair key;
rai::genesis genesis;
system.nodes[0]->ledger.utx_parse_canary = genesis.hash ();
system.wallet (0)->insert_adhoc (rai::test_genesis_key.prv);
boost::property_tree::ptree request;
request.put ("action", "block_create");

View file

@ -167,12 +167,22 @@ public:
void open_block (rai::open_block const &) override;
void change_block (rai::change_block const &) override;
void utx_block (rai::utx_block const &) override;
void utx_block_impl (rai::utx_block const &);
rai::ledger & ledger;
MDB_txn * transaction;
rai::process_return result;
};
void ledger_processor::utx_block (rai::utx_block const & block_a)
{
result.code = ledger.utx_parsing_enabled (transaction) ? rai::process_result::progress : rai::process_result::utx_disabled;
if (result.code == rai::process_result::progress)
{
utx_block_impl (block_a);
}
}
void ledger_processor::utx_block_impl (rai::utx_block const & block_a)
{
auto hash (block_a.hash ());
auto existing (ledger.store.block_exists (transaction, hash));
@ -481,10 +491,12 @@ bool rai::shared_ptr_block_hash::operator() (std::shared_ptr<rai::block> const &
return *lhs == *rhs;
}
rai::ledger::ledger (rai::block_store & store_a, rai::uint128_t const & inactive_supply_a) :
rai::ledger::ledger (rai::block_store & store_a, rai::uint128_t const & inactive_supply_a, rai::block_hash const & utx_parse_canary_a, rai::block_hash const & utx_generate_canary_a) :
store (store_a),
inactive_supply (inactive_supply_a),
check_bootstrap_weights (true)
check_bootstrap_weights (true),
utx_parse_canary (utx_parse_canary_a),
utx_generate_canary (utx_generate_canary_a)
{
}
@ -778,9 +790,14 @@ void rai::ledger::dump_account_chain (rai::account const & account_a)
}
}
bool rai::ledger::utx_enabled (MDB_txn * transaction_a)
bool rai::ledger::utx_parsing_enabled (MDB_txn * transaction_a)
{
return false;
return store.block_exists (transaction_a, utx_parse_canary);
}
bool rai::ledger::utx_generation_enabled (MDB_txn * transaction_a)
{
return utx_parsing_enabled (transaction_a) && store.block_exists (transaction_a, utx_generate_canary);
}
void rai::ledger::checksum_update (MDB_txn * transaction_a, rai::block_hash const & hash_a)

View file

@ -16,7 +16,7 @@ public:
class ledger
{
public:
ledger (rai::block_store &, rai::uint128_t const & = 0);
ledger (rai::block_store &, rai::uint128_t const & = 0, rai::block_hash const & = 0, rai::block_hash const & = 0);
std::pair<rai::uint128_t, std::shared_ptr<rai::block>> winner (MDB_txn *, rai::votes const & votes_a);
// Map of weight -> associated block, ordered greatest to least
std::map<rai::uint128_t, std::shared_ptr<rai::block>, std::greater<rai::uint128_t>> tally (MDB_txn *, rai::votes const &);
@ -45,12 +45,15 @@ public:
void checksum_update (MDB_txn *, rai::block_hash const &);
rai::checksum checksum (MDB_txn *, rai::account const &, rai::account const &);
void dump_account_chain (rai::account const &);
bool utx_enabled (MDB_txn *);
bool utx_parsing_enabled (MDB_txn *);
bool utx_generation_enabled (MDB_txn *);
static rai::uint128_t const unit;
rai::block_store & store;
rai::uint128_t inactive_supply;
std::unordered_map<rai::account, rai::uint128_t> bootstrap_weights;
uint64_t bootstrap_weight_max_blocks;
std::atomic<bool> check_bootstrap_weights;
rai::block_hash utx_parse_canary;
rai::block_hash utx_generate_canary;
};
};

View file

@ -1295,6 +1295,16 @@ rai::process_return rai::block_processor::process_receive_one (MDB_txn * transac
node.gap_cache.add (transaction_a, block_a);
break;
}
case rai::process_result::utx_disabled:
{
if (node.config.logging.ledger_logging ())
{
BOOST_LOG (node.log) << boost::str (boost::format ("UTX blocks are disabled: %1%") % block_a->hash ().to_string ());
}
node.store.unchecked_put (transaction_a, node.ledger.utx_parse_canary, block_a);
node.gap_cache.add (transaction_a, block_a);
break;
}
case rai::process_result::old:
{
{

View file

@ -2507,6 +2507,11 @@ void rai::rpc_handler::process ()
error_response (response, "Gap source block");
break;
}
case rai::process_result::utx_disabled:
{
error_response (response, "UTX blocks are disabled");
break;
}
case rai::process_result::old:
{
error_response (response, "Old block");

View file

@ -303,7 +303,7 @@ void rai::system::generate_mass_activity (uint32_t count_a, rai::node & node_a)
count = block_counts.sum ();
utx = block_counts.utx;
}
std::cerr << boost::str (boost::format ("Mass activity iteration %1% us %2% us/t %3% utx: %4% count: %5%\n") % i % us % (us / 256) % utx % count);
std::cerr << boost::str (boost::format ("Mass activity iteration %1% us %2% us/t %3% utx: %4% old: %5%\n") % i % us % (us / 256) % utx % (count - utx));
previous = now;
}
generate_activity (node_a, accounts);

View file

@ -865,7 +865,7 @@ std::shared_ptr<rai::block> rai::wallet::receive_action (rai::block const & send
{
std::shared_ptr<rai::block> rep_block = node.ledger.store.block_get (transaction, info.rep_block);
assert (rep_block != nullptr);
if (node.ledger.utx_enabled (transaction))
if (node.ledger.utx_generation_enabled (transaction))
{
block.reset (new rai::utx_block (account, info.head, rep_block->representative (), info.balance.number () + pending_info.amount.number (), hash, prv, account, generate_work_a ? work_fetch (transaction, account, info.head) : 0));
}
@ -876,7 +876,7 @@ std::shared_ptr<rai::block> rai::wallet::receive_action (rai::block const & send
}
else
{
if (node.ledger.utx_enabled (transaction))
if (node.ledger.utx_generation_enabled (transaction))
{
block.reset (new rai::utx_block (account, info.head, representative_a, pending_info.amount, hash, prv, account, generate_work_a ? work_fetch (transaction, account, account) : 0));
}
@ -940,7 +940,7 @@ std::shared_ptr<rai::block> rai::wallet::change_action (rai::account const & sou
rai::raw_key prv;
auto error2 (store.fetch (transaction, source_a, prv));
assert (!error2);
if (node.ledger.utx_enabled (transaction))
if (node.ledger.utx_generation_enabled (transaction))
{
block.reset (new rai::utx_block (source_a, info.head, representative_a, info.balance, 0, prv, source_a, generate_work_a ? work_fetch (transaction, source_a, info.head) : 0));
}
@ -1017,7 +1017,7 @@ std::shared_ptr<rai::block> rai::wallet::send_action (rai::account const & sourc
assert (!error2);
std::shared_ptr<rai::block> rep_block = node.ledger.store.block_get (transaction, info.rep_block);
assert (rep_block != nullptr);
if (node.ledger.utx_enabled (transaction))
if (node.ledger.utx_generation_enabled (transaction))
{
block.reset (new rai::utx_block (source_a, info.head, rep_block->representative (), balance - amount_a, account_a, prv, source_a, generate_work_a ? work_fetch (transaction, source_a, info.head) : 0));
}

View file

@ -1103,7 +1103,7 @@ void rai_qt::wallet::start ()
if (auto this_l = this_w.lock ())
{
auto account (result_a.account);
this_l->application.postEvent (&this_l->processor, new eventloop_event ([ this_w, block_a, account ]() {
this_l->application.postEvent (&this_l->processor, new eventloop_event ([this_w, block_a, account]() {
if (auto this_l = this_w.lock ())
{
if (this_l->wallet_m->exists (account))

View file

@ -34,6 +34,39 @@ TEST (system, generate_mass_activity_long)
runner.join ();
}
TEST (system, generate_mass_activity_utx_enable)
{
rai::system system (24000, 1);
rai::thread_runner runner (system.service, system.nodes[0]->config.io_threads);
system.wallet (0)->insert_adhoc (rai::test_genesis_key.prv);
system.nodes[0]->alarm.add (std::chrono::steady_clock::now () + std::chrono::minutes (1), [&system]() {
std::cerr << boost::str (boost::format ("Enabling utx block parsing\n"));
rai::transaction transaction (system.nodes[0]->store.environment, nullptr, true);
ASSERT_FALSE (system.nodes[0]->ledger.utx_parsing_enabled (transaction));
rai::genesis genesis;
system.nodes[0]->ledger.utx_parse_canary = genesis.hash ();
ASSERT_TRUE (system.nodes[0]->ledger.utx_parsing_enabled (transaction));
});
system.nodes[0]->alarm.add (std::chrono::steady_clock::now () + std::chrono::minutes (2), [&system]() {
std::cerr << boost::str (boost::format ("Enabling utx block generation\n"));
rai::transaction transaction (system.nodes[0]->store.environment, nullptr, true);
ASSERT_FALSE (system.nodes[0]->ledger.utx_generation_enabled (transaction));
rai::genesis genesis;
system.nodes[0]->ledger.utx_generate_canary = genesis.hash ();
ASSERT_TRUE (system.nodes[0]->ledger.utx_generation_enabled (transaction));
});
size_t count (1000000000);
system.generate_mass_activity (count, *system.nodes[0]);
size_t accounts (0);
rai::transaction transaction (system.nodes[0]->store.environment, nullptr, false);
for (auto i (system.nodes[0]->store.latest_begin (transaction)), n (system.nodes[0]->store.latest_end ()); i != n; ++i)
{
++accounts;
}
system.stop ();
runner.join ();
}
TEST (system, receive_while_synchronizing)
{
std::vector<std::thread> threads;