Allow node to work without work generation (#2312)
* Allow node to work without work generation These changes prevent the node from hanging when work generation is requested in any way and generation is not possible. - work_threads 0 and !opencl -> local generation disabled - local generation disabled and 0 work peers -> work generation disabled - Work watcher can still watch the block, but does not rework - Precaching will silently not be done - RPCs send/receive/account_representative_set/block_create will error correctly - QT wallet will show "Work generation disabled" when trying to use, a future PR could display a permanent status message to warn the user that work generation is disabled - Distributed work / work pool will fail when generation is not possible, but the same is checked on callers for custom error messages * Clang-format mismatch * Fix qt_test * File end empty line
This commit is contained in:
parent
1192c0aa91
commit
8ca90f1b27
31 changed files with 810 additions and 564 deletions
|
@ -15,7 +15,7 @@ TEST (active_transactions, bounded_active_elections)
|
|||
auto & node1 = *system.add_node (node_config);
|
||||
nano::genesis genesis;
|
||||
size_t count (1);
|
||||
auto send (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, genesis.hash (), nano::test_genesis_key.pub, nano::genesis_amount - count * nano::xrb_ratio, nano::test_genesis_key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (genesis.hash ())));
|
||||
auto send (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, genesis.hash (), nano::test_genesis_key.pub, nano::genesis_amount - count * nano::xrb_ratio, nano::test_genesis_key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (genesis.hash ())));
|
||||
auto previous_size = node1.active.size ();
|
||||
bool done (false);
|
||||
system.deadline_set (5s);
|
||||
|
@ -27,7 +27,7 @@ TEST (active_transactions, bounded_active_elections)
|
|||
ASSERT_LT (node1.active.size (), node1.config.active_elections_size); //triggers after reverting #2116
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
auto previous_hash = send->hash ();
|
||||
send = std::make_shared<nano::state_block> (nano::test_genesis_key.pub, previous_hash, nano::test_genesis_key.pub, nano::genesis_amount - count * nano::xrb_ratio, nano::test_genesis_key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (previous_hash));
|
||||
send = std::make_shared<nano::state_block> (nano::test_genesis_key.pub, previous_hash, nano::test_genesis_key.pub, nano::genesis_amount - count * nano::xrb_ratio, nano::test_genesis_key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (previous_hash));
|
||||
previous_size = node1.active.size ();
|
||||
//sleep this thread for the max delay between request loop rounds possible for such a small active_elections_size
|
||||
std::this_thread::sleep_for (std::chrono::milliseconds (node1.network_params.network.request_interval_ms + (node_config.active_elections_size * 20)));
|
||||
|
@ -44,10 +44,10 @@ TEST (active_transactions, adjusted_difficulty_priority)
|
|||
nano::genesis genesis;
|
||||
nano::keypair key1, key2, key3;
|
||||
|
||||
auto send1 (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, genesis.hash (), nano::test_genesis_key.pub, nano::genesis_amount - 10 * nano::xrb_ratio, key1.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (genesis.hash ())));
|
||||
auto send2 (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, send1->hash (), nano::test_genesis_key.pub, nano::genesis_amount - 20 * nano::xrb_ratio, key2.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send1->hash ())));
|
||||
auto open1 (std::make_shared<nano::state_block> (key1.pub, 0, key1.pub, 10 * nano::xrb_ratio, send1->hash (), key1.prv, key1.pub, system.work.generate (key1.pub)));
|
||||
auto open2 (std::make_shared<nano::state_block> (key2.pub, 0, key2.pub, 10 * nano::xrb_ratio, send2->hash (), key2.prv, key2.pub, system.work.generate (key2.pub)));
|
||||
auto send1 (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, genesis.hash (), nano::test_genesis_key.pub, nano::genesis_amount - 10 * nano::xrb_ratio, key1.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (genesis.hash ())));
|
||||
auto send2 (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, send1->hash (), nano::test_genesis_key.pub, nano::genesis_amount - 20 * nano::xrb_ratio, key2.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send1->hash ())));
|
||||
auto open1 (std::make_shared<nano::state_block> (key1.pub, 0, key1.pub, 10 * nano::xrb_ratio, send1->hash (), key1.prv, key1.pub, *system.work.generate (key1.pub)));
|
||||
auto open2 (std::make_shared<nano::state_block> (key2.pub, 0, key2.pub, 10 * nano::xrb_ratio, send2->hash (), key2.prv, key2.pub, *system.work.generate (key2.pub)));
|
||||
node1.process_active (send1); // genesis
|
||||
node1.process_active (send2); // genesis
|
||||
node1.process_active (open1); // key1
|
||||
|
@ -92,12 +92,12 @@ TEST (active_transactions, adjusted_difficulty_priority)
|
|||
|
||||
//genesis and key1,key2 are opened
|
||||
//start chain of 2 on each
|
||||
auto send3 (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, send2->hash (), nano::test_genesis_key.pub, 9 * nano::xrb_ratio, key3.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send2->hash (), nano::difficulty::from_multiplier (1500, node1.network_params.network.publish_threshold))));
|
||||
auto send4 (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, send3->hash (), nano::test_genesis_key.pub, 8 * nano::xrb_ratio, key3.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send3->hash (), nano::difficulty::from_multiplier (1500, node1.network_params.network.publish_threshold))));
|
||||
auto send5 (std::make_shared<nano::state_block> (key1.pub, open1->hash (), key1.pub, 9 * nano::xrb_ratio, key3.pub, key1.prv, key1.pub, system.work.generate (open1->hash (), nano::difficulty::from_multiplier (100, node1.network_params.network.publish_threshold))));
|
||||
auto send6 (std::make_shared<nano::state_block> (key1.pub, send5->hash (), key1.pub, 8 * nano::xrb_ratio, key3.pub, key1.prv, key1.pub, system.work.generate (send5->hash (), nano::difficulty::from_multiplier (100, node1.network_params.network.publish_threshold))));
|
||||
auto send7 (std::make_shared<nano::state_block> (key2.pub, open2->hash (), key2.pub, 9 * nano::xrb_ratio, key3.pub, key2.prv, key2.pub, system.work.generate (open2->hash (), nano::difficulty::from_multiplier (500, node1.network_params.network.publish_threshold))));
|
||||
auto send8 (std::make_shared<nano::state_block> (key2.pub, send7->hash (), key2.pub, 8 * nano::xrb_ratio, key3.pub, key2.prv, key2.pub, system.work.generate (send7->hash (), nano::difficulty::from_multiplier (500, node1.network_params.network.publish_threshold))));
|
||||
auto send3 (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, send2->hash (), nano::test_genesis_key.pub, 9 * nano::xrb_ratio, key3.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send2->hash (), nano::difficulty::from_multiplier (1500, node1.network_params.network.publish_threshold))));
|
||||
auto send4 (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, send3->hash (), nano::test_genesis_key.pub, 8 * nano::xrb_ratio, key3.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send3->hash (), nano::difficulty::from_multiplier (1500, node1.network_params.network.publish_threshold))));
|
||||
auto send5 (std::make_shared<nano::state_block> (key1.pub, open1->hash (), key1.pub, 9 * nano::xrb_ratio, key3.pub, key1.prv, key1.pub, *system.work.generate (open1->hash (), nano::difficulty::from_multiplier (100, node1.network_params.network.publish_threshold))));
|
||||
auto send6 (std::make_shared<nano::state_block> (key1.pub, send5->hash (), key1.pub, 8 * nano::xrb_ratio, key3.pub, key1.prv, key1.pub, *system.work.generate (send5->hash (), nano::difficulty::from_multiplier (100, node1.network_params.network.publish_threshold))));
|
||||
auto send7 (std::make_shared<nano::state_block> (key2.pub, open2->hash (), key2.pub, 9 * nano::xrb_ratio, key3.pub, key2.prv, key2.pub, *system.work.generate (open2->hash (), nano::difficulty::from_multiplier (500, node1.network_params.network.publish_threshold))));
|
||||
auto send8 (std::make_shared<nano::state_block> (key2.pub, send7->hash (), key2.pub, 8 * nano::xrb_ratio, key3.pub, key2.prv, key2.pub, *system.work.generate (send7->hash (), nano::difficulty::from_multiplier (500, node1.network_params.network.publish_threshold))));
|
||||
|
||||
node1.process_active (send3); // genesis
|
||||
node1.process_active (send5); // key1
|
||||
|
@ -139,10 +139,10 @@ TEST (active_transactions, adjusted_difficulty_overflow_max)
|
|||
nano::genesis genesis;
|
||||
nano::keypair key1, key2;
|
||||
|
||||
auto send1 (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, genesis.hash (), nano::test_genesis_key.pub, nano::genesis_amount - 10 * nano::xrb_ratio, key1.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (genesis.hash ())));
|
||||
auto send2 (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, send1->hash (), nano::test_genesis_key.pub, nano::genesis_amount - 20 * nano::xrb_ratio, key2.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send1->hash ())));
|
||||
auto open1 (std::make_shared<nano::state_block> (key1.pub, 0, key1.pub, 10 * nano::xrb_ratio, send1->hash (), key1.prv, key1.pub, system.work.generate (key1.pub)));
|
||||
auto open2 (std::make_shared<nano::state_block> (key2.pub, 0, key2.pub, 10 * nano::xrb_ratio, send2->hash (), key2.prv, key2.pub, system.work.generate (key2.pub)));
|
||||
auto send1 (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, genesis.hash (), nano::test_genesis_key.pub, nano::genesis_amount - 10 * nano::xrb_ratio, key1.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (genesis.hash ())));
|
||||
auto send2 (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, send1->hash (), nano::test_genesis_key.pub, nano::genesis_amount - 20 * nano::xrb_ratio, key2.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send1->hash ())));
|
||||
auto open1 (std::make_shared<nano::state_block> (key1.pub, 0, key1.pub, 10 * nano::xrb_ratio, send1->hash (), key1.prv, key1.pub, *system.work.generate (key1.pub)));
|
||||
auto open2 (std::make_shared<nano::state_block> (key2.pub, 0, key2.pub, 10 * nano::xrb_ratio, send2->hash (), key2.prv, key2.pub, *system.work.generate (key2.pub)));
|
||||
node1.process_active (send1); // genesis
|
||||
node1.process_active (send2); // genesis
|
||||
node1.process_active (open1); // key1
|
||||
|
@ -191,11 +191,11 @@ TEST (active_transactions, adjusted_difficulty_overflow_min)
|
|||
nano::genesis genesis;
|
||||
nano::keypair key1, key2, key3;
|
||||
|
||||
auto send1 (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, genesis.hash (), nano::test_genesis_key.pub, nano::genesis_amount - 10 * nano::xrb_ratio, key1.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (genesis.hash ())));
|
||||
auto send2 (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, send1->hash (), nano::test_genesis_key.pub, nano::genesis_amount - 20 * nano::xrb_ratio, key2.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send1->hash ())));
|
||||
auto open1 (std::make_shared<nano::state_block> (key1.pub, 0, key1.pub, 10 * nano::xrb_ratio, send1->hash (), key1.prv, key1.pub, system.work.generate (key1.pub)));
|
||||
auto open2 (std::make_shared<nano::state_block> (key2.pub, 0, key2.pub, 10 * nano::xrb_ratio, send2->hash (), key2.prv, key2.pub, system.work.generate (key2.pub)));
|
||||
auto send3 (std::make_shared<nano::state_block> (key2.pub, open2->hash (), key2.pub, 9 * nano::xrb_ratio, key3.pub, key2.prv, key2.pub, system.work.generate (open2->hash ())));
|
||||
auto send1 (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, genesis.hash (), nano::test_genesis_key.pub, nano::genesis_amount - 10 * nano::xrb_ratio, key1.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (genesis.hash ())));
|
||||
auto send2 (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, send1->hash (), nano::test_genesis_key.pub, nano::genesis_amount - 20 * nano::xrb_ratio, key2.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send1->hash ())));
|
||||
auto open1 (std::make_shared<nano::state_block> (key1.pub, 0, key1.pub, 10 * nano::xrb_ratio, send1->hash (), key1.prv, key1.pub, *system.work.generate (key1.pub)));
|
||||
auto open2 (std::make_shared<nano::state_block> (key2.pub, 0, key2.pub, 10 * nano::xrb_ratio, send2->hash (), key2.prv, key2.pub, *system.work.generate (key2.pub)));
|
||||
auto send3 (std::make_shared<nano::state_block> (key2.pub, open2->hash (), key2.pub, 9 * nano::xrb_ratio, key3.pub, key2.prv, key2.pub, *system.work.generate (open2->hash ())));
|
||||
node1.process_active (send1); // genesis
|
||||
node1.process_active (send2); // genesis
|
||||
node1.process_active (open1); // key1
|
||||
|
@ -276,9 +276,9 @@ TEST (active_transactions, keep_local)
|
|||
it = node1.active.roots.begin ();
|
||||
}
|
||||
}
|
||||
auto open1 (std::make_shared<nano::state_block> (key3.pub, 0, key3.pub, nano::xrb_ratio, send3->hash (), key3.prv, key3.pub, system.work.generate (key3.pub)));
|
||||
auto open1 (std::make_shared<nano::state_block> (key3.pub, 0, key3.pub, nano::xrb_ratio, send3->hash (), key3.prv, key3.pub, *system.work.generate (key3.pub)));
|
||||
node1.process_active (open1);
|
||||
auto open2 (std::make_shared<nano::state_block> (key4.pub, 0, key4.pub, nano::xrb_ratio, send4->hash (), key4.prv, key4.pub, system.work.generate (key4.pub)));
|
||||
auto open2 (std::make_shared<nano::state_block> (key4.pub, 0, key4.pub, nano::xrb_ratio, send4->hash (), key4.prv, key4.pub, *system.work.generate (key4.pub)));
|
||||
node1.process_active (open2);
|
||||
//none are dropped since none are long_unconfirmed
|
||||
system.deadline_set (10s);
|
||||
|
@ -308,14 +308,14 @@ TEST (active_transactions, prioritize_chains)
|
|||
nano::genesis genesis;
|
||||
nano::keypair key1, key2, key3;
|
||||
|
||||
auto send1 (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, genesis.hash (), nano::test_genesis_key.pub, nano::genesis_amount - 10 * nano::xrb_ratio, key1.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (genesis.hash ())));
|
||||
auto open1 (std::make_shared<nano::state_block> (key1.pub, 0, key1.pub, 10 * nano::xrb_ratio, send1->hash (), key1.prv, key1.pub, system.work.generate (key1.pub)));
|
||||
auto send2 (std::make_shared<nano::state_block> (key1.pub, open1->hash (), key1.pub, nano::xrb_ratio * 9, key2.pub, key1.prv, key1.pub, system.work.generate (open1->hash ())));
|
||||
auto send3 (std::make_shared<nano::state_block> (key1.pub, send2->hash (), key1.pub, nano::xrb_ratio * 8, key2.pub, key1.prv, key1.pub, system.work.generate (send2->hash ())));
|
||||
auto send4 (std::make_shared<nano::state_block> (key1.pub, send3->hash (), key1.pub, nano::xrb_ratio * 7, key2.pub, key1.prv, key1.pub, system.work.generate (send3->hash ())));
|
||||
auto send5 (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, send1->hash (), nano::test_genesis_key.pub, nano::genesis_amount - 20 * nano::xrb_ratio, key2.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send1->hash ())));
|
||||
auto send6 (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, send5->hash (), nano::test_genesis_key.pub, nano::genesis_amount - 30 * nano::xrb_ratio, key3.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send5->hash ())));
|
||||
auto open2 (std::make_shared<nano::state_block> (key2.pub, 0, key2.pub, 10 * nano::xrb_ratio, send5->hash (), key2.prv, key2.pub, system.work.generate (key2.pub, nano::difficulty::from_multiplier (50., node1.network_params.network.publish_threshold))));
|
||||
auto send1 (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, genesis.hash (), nano::test_genesis_key.pub, nano::genesis_amount - 10 * nano::xrb_ratio, key1.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (genesis.hash ())));
|
||||
auto open1 (std::make_shared<nano::state_block> (key1.pub, 0, key1.pub, 10 * nano::xrb_ratio, send1->hash (), key1.prv, key1.pub, *system.work.generate (key1.pub)));
|
||||
auto send2 (std::make_shared<nano::state_block> (key1.pub, open1->hash (), key1.pub, nano::xrb_ratio * 9, key2.pub, key1.prv, key1.pub, *system.work.generate (open1->hash ())));
|
||||
auto send3 (std::make_shared<nano::state_block> (key1.pub, send2->hash (), key1.pub, nano::xrb_ratio * 8, key2.pub, key1.prv, key1.pub, *system.work.generate (send2->hash ())));
|
||||
auto send4 (std::make_shared<nano::state_block> (key1.pub, send3->hash (), key1.pub, nano::xrb_ratio * 7, key2.pub, key1.prv, key1.pub, *system.work.generate (send3->hash ())));
|
||||
auto send5 (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, send1->hash (), nano::test_genesis_key.pub, nano::genesis_amount - 20 * nano::xrb_ratio, key2.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send1->hash ())));
|
||||
auto send6 (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, send5->hash (), nano::test_genesis_key.pub, nano::genesis_amount - 30 * nano::xrb_ratio, key3.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send5->hash ())));
|
||||
auto open2 (std::make_shared<nano::state_block> (key2.pub, 0, key2.pub, 10 * nano::xrb_ratio, send5->hash (), key2.prv, key2.pub, *system.work.generate (key2.pub, nano::difficulty::from_multiplier (50., node1.network_params.network.publish_threshold))));
|
||||
uint64_t difficulty1 (0);
|
||||
nano::work_validate (*open2, &difficulty1);
|
||||
uint64_t difficulty2 (0);
|
||||
|
@ -401,7 +401,7 @@ TEST (active_transactions, inactive_votes_cache)
|
|||
nano::system system (24000, 1);
|
||||
nano::block_hash latest (system.nodes[0]->latest (nano::test_genesis_key.pub));
|
||||
nano::keypair key;
|
||||
auto send (std::make_shared<nano::send_block> (latest, key.pub, nano::genesis_amount - 100, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (latest)));
|
||||
auto send (std::make_shared<nano::send_block> (latest, key.pub, nano::genesis_amount - 100, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (latest)));
|
||||
auto vote (std::make_shared<nano::vote> (nano::test_genesis_key.pub, nano::test_genesis_key.prv, 0, std::vector<nano::block_hash> (1, send->hash ())));
|
||||
system.nodes[0]->vote_processor.vote (vote, std::make_shared<nano::transport::channel_udp> (system.nodes[0]->network.udp_channels, system.nodes[0]->network.endpoint (), system.nodes[0]->network_params.protocol.protocol_version));
|
||||
system.deadline_set (5s);
|
||||
|
@ -430,8 +430,8 @@ TEST (active_transactions, inactive_votes_cache_existing_vote)
|
|||
auto node = system.add_node (node_config);
|
||||
nano::block_hash latest (node->latest (nano::test_genesis_key.pub));
|
||||
nano::keypair key;
|
||||
auto send (std::make_shared<nano::send_block> (latest, key.pub, nano::genesis_amount - 100 * nano::Gxrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (latest)));
|
||||
auto open (std::make_shared<nano::state_block> (key.pub, 0, key.pub, 100 * nano::Gxrb_ratio, send->hash (), key.prv, key.pub, system.work.generate (key.pub))); // Increase key weight
|
||||
auto send (std::make_shared<nano::send_block> (latest, key.pub, nano::genesis_amount - 100 * nano::Gxrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (latest)));
|
||||
auto open (std::make_shared<nano::state_block> (key.pub, 0, key.pub, 100 * nano::Gxrb_ratio, send->hash (), key.prv, key.pub, *system.work.generate (key.pub))); // Increase key weight
|
||||
node->process_active (send);
|
||||
node->block_processor.add (open);
|
||||
node->block_processor.flush ();
|
||||
|
@ -486,9 +486,9 @@ TEST (active_transactions, inactive_votes_cache_multiple_votes)
|
|||
auto node = system.add_node (node_config);
|
||||
nano::block_hash latest (system.nodes[0]->latest (nano::test_genesis_key.pub));
|
||||
nano::keypair key1;
|
||||
auto send1 (std::make_shared<nano::send_block> (latest, key1.pub, nano::genesis_amount - 100 * nano::Gxrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (latest)));
|
||||
auto send2 (std::make_shared<nano::send_block> (send1->hash (), key1.pub, 100 * nano::Gxrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send1->hash ()))); // Decrease genesis weight to prevent election confirmation
|
||||
auto open (std::make_shared<nano::state_block> (key1.pub, 0, key1.pub, 100 * nano::Gxrb_ratio, send1->hash (), key1.prv, key1.pub, system.work.generate (key1.pub))); // Increase key1 weight
|
||||
auto send1 (std::make_shared<nano::send_block> (latest, key1.pub, nano::genesis_amount - 100 * nano::Gxrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (latest)));
|
||||
auto send2 (std::make_shared<nano::send_block> (send1->hash (), key1.pub, 100 * nano::Gxrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send1->hash ()))); // Decrease genesis weight to prevent election confirmation
|
||||
auto open (std::make_shared<nano::state_block> (key1.pub, 0, key1.pub, 100 * nano::Gxrb_ratio, send1->hash (), key1.prv, key1.pub, *system.work.generate (key1.pub))); // Increase key1 weight
|
||||
node->block_processor.add (send1);
|
||||
node->block_processor.add (send2);
|
||||
node->block_processor.add (open);
|
||||
|
@ -523,10 +523,10 @@ TEST (active_transactions, update_difficulty)
|
|||
nano::genesis genesis;
|
||||
nano::keypair key1;
|
||||
// Generate blocks & start elections
|
||||
auto send1 (std::make_shared<nano::send_block> (genesis.hash (), key1.pub, nano::genesis_amount - 100, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (genesis.hash ())));
|
||||
auto send1 (std::make_shared<nano::send_block> (genesis.hash (), key1.pub, nano::genesis_amount - 100, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (genesis.hash ())));
|
||||
uint64_t difficulty1 (0);
|
||||
nano::work_validate (*send1, &difficulty1);
|
||||
auto send2 (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, send1->hash (), nano::test_genesis_key.pub, nano::genesis_amount - 200, key1.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send1->hash ())));
|
||||
auto send2 (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, send1->hash (), nano::test_genesis_key.pub, nano::genesis_amount - 200, key1.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send1->hash ())));
|
||||
uint64_t difficulty2 (0);
|
||||
nano::work_validate (*send2, &difficulty2);
|
||||
node1.process_active (send1);
|
||||
|
|
|
@ -801,7 +801,7 @@ TEST (mdb_block_store, upgrade_v2_v3)
|
|||
nano::ledger ledger (store, stats);
|
||||
store.initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::change_block change (hash, key1.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, pool.generate (hash));
|
||||
nano::change_block change (hash, key1.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (hash));
|
||||
change_hash = change.hash ();
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, change).code);
|
||||
ASSERT_EQ (0, ledger.weight (nano::test_genesis_key.pub));
|
||||
|
@ -885,7 +885,7 @@ TEST (mdb_block_store, upgrade_v4_v5)
|
|||
ASSERT_FALSE (store.account_get (transaction, nano::test_genesis_key.pub, info));
|
||||
nano::keypair key0;
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::send_block block0 (info.head, key0.pub, nano::genesis_amount - nano::Gxrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, pool.generate (info.head));
|
||||
nano::send_block block0 (info.head, key0.pub, nano::genesis_amount - nano::Gxrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (info.head));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, block0).code);
|
||||
hash = block0.hash ();
|
||||
auto original (store.block_get (transaction, info.head));
|
||||
|
@ -1197,7 +1197,7 @@ TEST (mdb_block_store, upgrade_sideband_two_blocks)
|
|||
store.version_put (transaction, 11);
|
||||
store.initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::state_block block (nano::test_genesis_key.pub, genesis.hash (), nano::test_genesis_key.pub, nano::genesis_amount - nano::Gxrb_ratio, nano::test_genesis_key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, pool.generate (genesis.hash ()));
|
||||
nano::state_block block (nano::test_genesis_key.pub, genesis.hash (), nano::test_genesis_key.pub, nano::genesis_amount - nano::Gxrb_ratio, nano::test_genesis_key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
hash2 = block.hash ();
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, block).code);
|
||||
store.block_del (transaction, hash2);
|
||||
|
@ -1240,10 +1240,10 @@ TEST (mdb_block_store, upgrade_sideband_two_accounts)
|
|||
store.version_put (transaction, 11);
|
||||
store.initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::state_block block1 (nano::test_genesis_key.pub, genesis.hash (), nano::test_genesis_key.pub, nano::genesis_amount - nano::Gxrb_ratio, key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, pool.generate (genesis.hash ()));
|
||||
nano::state_block block1 (nano::test_genesis_key.pub, genesis.hash (), nano::test_genesis_key.pub, nano::genesis_amount - nano::Gxrb_ratio, key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
hash2 = block1.hash ();
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, block1).code);
|
||||
nano::state_block block2 (key.pub, 0, nano::test_genesis_key.pub, nano::Gxrb_ratio, hash2, key.prv, key.pub, pool.generate (key.pub));
|
||||
nano::state_block block2 (key.pub, 0, nano::test_genesis_key.pub, nano::Gxrb_ratio, hash2, key.prv, key.pub, *pool.generate (key.pub));
|
||||
hash3 = block2.hash ();
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, block2).code);
|
||||
store.block_del (transaction, hash2);
|
||||
|
@ -1289,7 +1289,7 @@ TEST (mdb_block_store, insert_after_legacy)
|
|||
mdb_dbi_open (store.env.tx (transaction), "state_v1", MDB_CREATE, &store.state_blocks_v1);
|
||||
write_sideband_v12 (store, transaction, *genesis.open, 0, store.open_blocks);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::state_block block (nano::test_genesis_key.pub, genesis.hash (), nano::test_genesis_key.pub, nano::genesis_amount - nano::Gxrb_ratio, nano::test_genesis_key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, pool.generate (genesis.hash ()));
|
||||
nano::state_block block (nano::test_genesis_key.pub, genesis.hash (), nano::test_genesis_key.pub, nano::genesis_amount - nano::Gxrb_ratio, nano::test_genesis_key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, block).code);
|
||||
}
|
||||
|
||||
|
@ -1326,7 +1326,7 @@ TEST (mdb_block_store, upgrade_sideband_epoch)
|
|||
auto transaction (store.tx_begin_write ());
|
||||
store.version_put (transaction, 11);
|
||||
store.initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
nano::state_block block1 (nano::test_genesis_key.pub, genesis.hash (), nano::test_genesis_key.pub, nano::genesis_amount, ledger.link (nano::epoch::epoch_1), nano::test_genesis_key.prv, nano::test_genesis_key.pub, pool.generate (genesis.hash ()));
|
||||
nano::state_block block1 (nano::test_genesis_key.pub, genesis.hash (), nano::test_genesis_key.pub, nano::genesis_amount, ledger.link (nano::epoch::epoch_1), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
hash2 = block1.hash ();
|
||||
ASSERT_FALSE (mdb_dbi_open (store.env.tx (transaction), "state_v1", MDB_CREATE, &store.state_blocks_v1));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, block1).code);
|
||||
|
@ -1355,7 +1355,7 @@ TEST (mdb_block_store, upgrade_sideband_epoch)
|
|||
nano::block_sideband sideband;
|
||||
auto block1 (store.block_get (transaction, hash2, &sideband));
|
||||
ASSERT_NE (0, sideband.height);
|
||||
nano::state_block block2 (nano::test_genesis_key.pub, hash2, nano::test_genesis_key.pub, nano::genesis_amount - nano::Gxrb_ratio, nano::test_genesis_key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, pool.generate (hash2));
|
||||
nano::state_block block2 (nano::test_genesis_key.pub, hash2, nano::test_genesis_key.pub, nano::genesis_amount - nano::Gxrb_ratio, nano::test_genesis_key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (hash2));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, block2).code);
|
||||
ASSERT_EQ (nano::epoch::epoch_1, store.block_version (transaction, block2.hash ()));
|
||||
}
|
||||
|
@ -1374,29 +1374,29 @@ TEST (mdb_block_store, sideband_height)
|
|||
auto transaction (store.tx_begin_write ());
|
||||
store.initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::send_block send (genesis.hash (), nano::test_genesis_key.pub, nano::genesis_amount - nano::Gxrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, pool.generate (genesis.hash ()));
|
||||
nano::send_block send (genesis.hash (), nano::test_genesis_key.pub, nano::genesis_amount - nano::Gxrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send).code);
|
||||
nano::receive_block receive (send.hash (), send.hash (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, pool.generate (send.hash ()));
|
||||
nano::receive_block receive (send.hash (), send.hash (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (send.hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, receive).code);
|
||||
nano::change_block change (receive.hash (), 0, nano::test_genesis_key.prv, nano::test_genesis_key.pub, pool.generate (receive.hash ()));
|
||||
nano::change_block change (receive.hash (), 0, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (receive.hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, change).code);
|
||||
nano::state_block state_send1 (nano::test_genesis_key.pub, change.hash (), 0, nano::genesis_amount - nano::Gxrb_ratio, key1.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, pool.generate (change.hash ()));
|
||||
nano::state_block state_send1 (nano::test_genesis_key.pub, change.hash (), 0, nano::genesis_amount - nano::Gxrb_ratio, key1.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (change.hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, state_send1).code);
|
||||
nano::state_block state_send2 (nano::test_genesis_key.pub, state_send1.hash (), 0, nano::genesis_amount - 2 * nano::Gxrb_ratio, key2.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, pool.generate (state_send1.hash ()));
|
||||
nano::state_block state_send2 (nano::test_genesis_key.pub, state_send1.hash (), 0, nano::genesis_amount - 2 * nano::Gxrb_ratio, key2.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (state_send1.hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, state_send2).code);
|
||||
nano::state_block state_send3 (nano::test_genesis_key.pub, state_send2.hash (), 0, nano::genesis_amount - 3 * nano::Gxrb_ratio, key3.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, pool.generate (state_send2.hash ()));
|
||||
nano::state_block state_send3 (nano::test_genesis_key.pub, state_send2.hash (), 0, nano::genesis_amount - 3 * nano::Gxrb_ratio, key3.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (state_send2.hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, state_send3).code);
|
||||
nano::state_block state_open (key1.pub, 0, 0, nano::Gxrb_ratio, state_send1.hash (), key1.prv, key1.pub, pool.generate (key1.pub));
|
||||
nano::state_block state_open (key1.pub, 0, 0, nano::Gxrb_ratio, state_send1.hash (), key1.prv, key1.pub, *pool.generate (key1.pub));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, state_open).code);
|
||||
nano::state_block epoch (key1.pub, state_open.hash (), 0, nano::Gxrb_ratio, ledger.link (nano::epoch::epoch_1), nano::test_genesis_key.prv, nano::test_genesis_key.pub, pool.generate (state_open.hash ()));
|
||||
nano::state_block epoch (key1.pub, state_open.hash (), 0, nano::Gxrb_ratio, ledger.link (nano::epoch::epoch_1), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (state_open.hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, epoch).code);
|
||||
ASSERT_EQ (nano::epoch::epoch_1, store.block_version (transaction, epoch.hash ()));
|
||||
nano::state_block epoch_open (key2.pub, 0, 0, 0, ledger.link (nano::epoch::epoch_1), nano::test_genesis_key.prv, nano::test_genesis_key.pub, pool.generate (key2.pub));
|
||||
nano::state_block epoch_open (key2.pub, 0, 0, 0, ledger.link (nano::epoch::epoch_1), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (key2.pub));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, epoch_open).code);
|
||||
ASSERT_EQ (nano::epoch::epoch_1, store.block_version (transaction, epoch_open.hash ()));
|
||||
nano::state_block state_receive (key2.pub, epoch_open.hash (), 0, nano::Gxrb_ratio, state_send2.hash (), key2.prv, key2.pub, pool.generate (epoch_open.hash ()));
|
||||
nano::state_block state_receive (key2.pub, epoch_open.hash (), 0, nano::Gxrb_ratio, state_send2.hash (), key2.prv, key2.pub, *pool.generate (epoch_open.hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, state_receive).code);
|
||||
nano::open_block open (state_send3.hash (), nano::test_genesis_key.pub, key3.pub, key3.prv, key3.pub, pool.generate (key3.pub));
|
||||
nano::open_block open (state_send3.hash (), nano::test_genesis_key.pub, key3.pub, key3.prv, key3.pub, *pool.generate (key3.pub));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, open).code);
|
||||
nano::block_sideband sideband1;
|
||||
auto block1 (store.block_get (transaction, genesis.hash (), &sideband1));
|
||||
|
@ -1620,9 +1620,9 @@ TEST (mdb_block_store, upgrade_v14_v15)
|
|||
nano::genesis genesis;
|
||||
nano::network_params network_params;
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::send_block send (genesis.hash (), nano::test_genesis_key.pub, nano::genesis_amount - nano::Gxrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, pool.generate (genesis.hash ()));
|
||||
nano::state_block epoch (nano::test_genesis_key.pub, send.hash (), nano::test_genesis_key.pub, nano::genesis_amount - nano::Gxrb_ratio, network_params.ledger.epochs.link (nano::epoch::epoch_1), nano::test_genesis_key.prv, nano::test_genesis_key.pub, pool.generate (send.hash ()));
|
||||
nano::state_block state_send (nano::test_genesis_key.pub, epoch.hash (), nano::test_genesis_key.pub, nano::genesis_amount - nano::Gxrb_ratio * 2, nano::test_genesis_key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, pool.generate (epoch.hash ()));
|
||||
nano::send_block send (genesis.hash (), nano::test_genesis_key.pub, nano::genesis_amount - nano::Gxrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
nano::state_block epoch (nano::test_genesis_key.pub, send.hash (), nano::test_genesis_key.pub, nano::genesis_amount - nano::Gxrb_ratio, network_params.ledger.epochs.link (nano::epoch::epoch_1), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (send.hash ()));
|
||||
nano::state_block state_send (nano::test_genesis_key.pub, epoch.hash (), nano::test_genesis_key.pub, nano::genesis_amount - nano::Gxrb_ratio * 2, nano::test_genesis_key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (epoch.hash ()));
|
||||
{
|
||||
nano::logger_mt logger;
|
||||
nano::mdb_store store (logger, path);
|
||||
|
|
|
@ -23,7 +23,7 @@ TEST (confirmation_height, single)
|
|||
system.wallet (0)->insert_adhoc (nano::test_genesis_key.prv);
|
||||
nano::block_hash latest1 (system.nodes[0]->latest (nano::test_genesis_key.pub));
|
||||
system.wallet (1)->insert_adhoc (key1.prv);
|
||||
auto send1 (std::make_shared<nano::send_block> (latest1, key1.pub, amount - system.nodes[0]->config.receive_minimum.number (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (latest1)));
|
||||
auto send1 (std::make_shared<nano::send_block> (latest1, key1.pub, amount - system.nodes[0]->config.receive_minimum.number (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (latest1)));
|
||||
|
||||
// Check confirmation heights before, should be uninitialized (1 for genesis).
|
||||
uint64_t confirmation_height;
|
||||
|
@ -82,22 +82,22 @@ TEST (confirmation_height, multiple_accounts)
|
|||
system.wallet (1)->insert_adhoc (key3.prv);
|
||||
|
||||
// Send to all accounts
|
||||
nano::send_block send1 (latest1, key1.pub, system.nodes.front ()->config.online_weight_minimum.number () + 300, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (latest1));
|
||||
nano::send_block send2 (send1.hash (), key2.pub, system.nodes.front ()->config.online_weight_minimum.number () + 200, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send1.hash ()));
|
||||
nano::send_block send3 (send2.hash (), key3.pub, system.nodes.front ()->config.online_weight_minimum.number () + 100, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send2.hash ()));
|
||||
nano::send_block send1 (latest1, key1.pub, system.nodes.front ()->config.online_weight_minimum.number () + 300, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (latest1));
|
||||
nano::send_block send2 (send1.hash (), key2.pub, system.nodes.front ()->config.online_weight_minimum.number () + 200, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send1.hash ()));
|
||||
nano::send_block send3 (send2.hash (), key3.pub, system.nodes.front ()->config.online_weight_minimum.number () + 100, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send2.hash ()));
|
||||
|
||||
// Open all accounts
|
||||
nano::open_block open1 (send1.hash (), nano::genesis_account, key1.pub, key1.prv, key1.pub, system.work.generate (key1.pub));
|
||||
nano::open_block open2 (send2.hash (), nano::genesis_account, key2.pub, key2.prv, key2.pub, system.work.generate (key2.pub));
|
||||
nano::open_block open3 (send3.hash (), nano::genesis_account, key3.pub, key3.prv, key3.pub, system.work.generate (key3.pub));
|
||||
nano::open_block open1 (send1.hash (), nano::genesis_account, key1.pub, key1.prv, key1.pub, *system.work.generate (key1.pub));
|
||||
nano::open_block open2 (send2.hash (), nano::genesis_account, key2.pub, key2.prv, key2.pub, *system.work.generate (key2.pub));
|
||||
nano::open_block open3 (send3.hash (), nano::genesis_account, key3.pub, key3.prv, key3.pub, *system.work.generate (key3.pub));
|
||||
|
||||
// Send and recieve various blocks to these accounts
|
||||
nano::send_block send4 (open1.hash (), key2.pub, 50, key1.prv, key1.pub, system.work.generate (open1.hash ()));
|
||||
nano::send_block send5 (send4.hash (), key2.pub, 10, key1.prv, key1.pub, system.work.generate (send4.hash ()));
|
||||
nano::send_block send4 (open1.hash (), key2.pub, 50, key1.prv, key1.pub, *system.work.generate (open1.hash ()));
|
||||
nano::send_block send5 (send4.hash (), key2.pub, 10, key1.prv, key1.pub, *system.work.generate (send4.hash ()));
|
||||
|
||||
nano::receive_block receive1 (open2.hash (), send4.hash (), key2.prv, key2.pub, system.work.generate (open2.hash ()));
|
||||
nano::send_block send6 (receive1.hash (), key3.pub, 10, key2.prv, key2.pub, system.work.generate (receive1.hash ()));
|
||||
nano::receive_block receive2 (send6.hash (), send5.hash (), key2.prv, key2.pub, system.work.generate (send6.hash ()));
|
||||
nano::receive_block receive1 (open2.hash (), send4.hash (), key2.prv, key2.pub, *system.work.generate (open2.hash ()));
|
||||
nano::send_block send6 (receive1.hash (), key3.pub, 10, key2.prv, key2.pub, *system.work.generate (receive1.hash ()));
|
||||
nano::receive_block receive2 (send6.hash (), send5.hash (), key2.prv, key2.pub, *system.work.generate (send6.hash ()));
|
||||
|
||||
for (auto & node : system.nodes)
|
||||
{
|
||||
|
@ -133,7 +133,7 @@ TEST (confirmation_height, multiple_accounts)
|
|||
}
|
||||
|
||||
// The nodes process a live receive which propagates across to all accounts
|
||||
auto receive3 = std::make_shared<nano::receive_block> (open3.hash (), send6.hash (), key3.prv, key3.pub, system.work.generate (open3.hash ()));
|
||||
auto receive3 = std::make_shared<nano::receive_block> (open3.hash (), send6.hash (), key3.prv, key3.pub, *system.work.generate (open3.hash ()));
|
||||
|
||||
for (auto & node : system.nodes)
|
||||
{
|
||||
|
@ -355,22 +355,22 @@ TEST (confirmation_height, send_receive_between_2_accounts)
|
|||
nano::block_hash latest (node->latest (nano::test_genesis_key.pub));
|
||||
system.wallet (0)->insert_adhoc (key1.prv);
|
||||
|
||||
nano::send_block send1 (latest, key1.pub, node->config.online_weight_minimum.number () + 2, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (latest));
|
||||
nano::open_block open1 (send1.hash (), nano::genesis_account, key1.pub, key1.prv, key1.pub, system.work.generate (key1.pub));
|
||||
nano::send_block send1 (latest, key1.pub, node->config.online_weight_minimum.number () + 2, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (latest));
|
||||
nano::open_block open1 (send1.hash (), nano::genesis_account, key1.pub, key1.prv, key1.pub, *system.work.generate (key1.pub));
|
||||
|
||||
nano::send_block send2 (open1.hash (), nano::genesis_account, 1000, key1.prv, key1.pub, system.work.generate (open1.hash ()));
|
||||
nano::send_block send3 (send2.hash (), nano::genesis_account, 900, key1.prv, key1.pub, system.work.generate (send2.hash ()));
|
||||
nano::send_block send4 (send3.hash (), nano::genesis_account, 500, key1.prv, key1.pub, system.work.generate (send3.hash ()));
|
||||
nano::send_block send2 (open1.hash (), nano::genesis_account, 1000, key1.prv, key1.pub, *system.work.generate (open1.hash ()));
|
||||
nano::send_block send3 (send2.hash (), nano::genesis_account, 900, key1.prv, key1.pub, *system.work.generate (send2.hash ()));
|
||||
nano::send_block send4 (send3.hash (), nano::genesis_account, 500, key1.prv, key1.pub, *system.work.generate (send3.hash ()));
|
||||
|
||||
nano::receive_block receive1 (send1.hash (), send2.hash (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send1.hash ()));
|
||||
nano::receive_block receive2 (receive1.hash (), send3.hash (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (receive1.hash ()));
|
||||
nano::receive_block receive3 (receive2.hash (), send4.hash (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (receive2.hash ()));
|
||||
nano::receive_block receive1 (send1.hash (), send2.hash (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send1.hash ()));
|
||||
nano::receive_block receive2 (receive1.hash (), send3.hash (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (receive1.hash ()));
|
||||
nano::receive_block receive3 (receive2.hash (), send4.hash (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (receive2.hash ()));
|
||||
|
||||
nano::send_block send5 (receive3.hash (), key1.pub, node->config.online_weight_minimum.number () + 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (receive3.hash ()));
|
||||
auto receive4 = std::make_shared<nano::receive_block> (send4.hash (), send5.hash (), key1.prv, key1.pub, system.work.generate (send4.hash ()));
|
||||
nano::send_block send5 (receive3.hash (), key1.pub, node->config.online_weight_minimum.number () + 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (receive3.hash ()));
|
||||
auto receive4 = std::make_shared<nano::receive_block> (send4.hash (), send5.hash (), key1.prv, key1.pub, *system.work.generate (send4.hash ()));
|
||||
// Unpocketed send
|
||||
nano::keypair key2;
|
||||
nano::send_block send6 (send5.hash (), key2.pub, node->config.online_weight_minimum.number (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send5.hash ()));
|
||||
nano::send_block send6 (send5.hash (), key2.pub, node->config.online_weight_minimum.number (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send5.hash ()));
|
||||
{
|
||||
auto transaction = node->store.tx_begin_write ();
|
||||
ASSERT_EQ (nano::process_result::progress, node->ledger.process (transaction, send1).code);
|
||||
|
@ -434,17 +434,17 @@ TEST (confirmation_height, send_receive_self)
|
|||
system.wallet (0)->insert_adhoc (nano::test_genesis_key.prv);
|
||||
nano::block_hash latest (node->latest (nano::test_genesis_key.pub));
|
||||
|
||||
nano::send_block send1 (latest, nano::test_genesis_key.pub, nano::genesis_amount - 2, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (latest));
|
||||
nano::receive_block receive1 (send1.hash (), send1.hash (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send1.hash ()));
|
||||
nano::send_block send2 (receive1.hash (), nano::test_genesis_key.pub, nano::genesis_amount - 2, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (receive1.hash ()));
|
||||
nano::send_block send3 (send2.hash (), nano::test_genesis_key.pub, nano::genesis_amount - 3, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send2.hash ()));
|
||||
nano::send_block send1 (latest, nano::test_genesis_key.pub, nano::genesis_amount - 2, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (latest));
|
||||
nano::receive_block receive1 (send1.hash (), send1.hash (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send1.hash ()));
|
||||
nano::send_block send2 (receive1.hash (), nano::test_genesis_key.pub, nano::genesis_amount - 2, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (receive1.hash ()));
|
||||
nano::send_block send3 (send2.hash (), nano::test_genesis_key.pub, nano::genesis_amount - 3, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send2.hash ()));
|
||||
|
||||
nano::receive_block receive2 (send3.hash (), send2.hash (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send3.hash ()));
|
||||
auto receive3 = std::make_shared<nano::receive_block> (receive2.hash (), send3.hash (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (receive2.hash ()));
|
||||
nano::receive_block receive2 (send3.hash (), send2.hash (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send3.hash ()));
|
||||
auto receive3 = std::make_shared<nano::receive_block> (receive2.hash (), send3.hash (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (receive2.hash ()));
|
||||
|
||||
// Send to another account to prevent automatic receiving on the genesis account
|
||||
nano::keypair key1;
|
||||
nano::send_block send4 (receive3->hash (), key1.pub, node->config.online_weight_minimum.number (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (receive3->hash ()));
|
||||
nano::send_block send4 (receive3->hash (), key1.pub, node->config.online_weight_minimum.number (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (receive3->hash ()));
|
||||
{
|
||||
auto transaction = node->store.tx_begin_write ();
|
||||
ASSERT_EQ (nano::process_result::progress, node->ledger.process (transaction, send1).code);
|
||||
|
@ -496,33 +496,33 @@ TEST (confirmation_height, all_block_types)
|
|||
nano::keypair key1;
|
||||
nano::keypair key2;
|
||||
auto & store = node->store;
|
||||
nano::send_block send (latest, key1.pub, nano::genesis_amount - nano::Gxrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (latest));
|
||||
nano::send_block send1 (send.hash (), key2.pub, nano::genesis_amount - nano::Gxrb_ratio * 2, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send.hash ()));
|
||||
nano::send_block send (latest, key1.pub, nano::genesis_amount - nano::Gxrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (latest));
|
||||
nano::send_block send1 (send.hash (), key2.pub, nano::genesis_amount - nano::Gxrb_ratio * 2, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send.hash ()));
|
||||
|
||||
nano::open_block open (send.hash (), nano::test_genesis_key.pub, key1.pub, key1.prv, key1.pub, system.work.generate (key1.pub));
|
||||
nano::state_block state_open (key2.pub, 0, 0, nano::Gxrb_ratio, send1.hash (), key2.prv, key2.pub, system.work.generate (key2.pub));
|
||||
nano::open_block open (send.hash (), nano::test_genesis_key.pub, key1.pub, key1.prv, key1.pub, *system.work.generate (key1.pub));
|
||||
nano::state_block state_open (key2.pub, 0, 0, nano::Gxrb_ratio, send1.hash (), key2.prv, key2.pub, *system.work.generate (key2.pub));
|
||||
|
||||
nano::send_block send2 (open.hash (), key2.pub, 0, key1.prv, key1.pub, system.work.generate (open.hash ()));
|
||||
nano::state_block state_receive (key2.pub, state_open.hash (), 0, nano::Gxrb_ratio * 2, send2.hash (), key2.prv, key2.pub, system.work.generate (state_open.hash ()));
|
||||
nano::send_block send2 (open.hash (), key2.pub, 0, key1.prv, key1.pub, *system.work.generate (open.hash ()));
|
||||
nano::state_block state_receive (key2.pub, state_open.hash (), 0, nano::Gxrb_ratio * 2, send2.hash (), key2.prv, key2.pub, *system.work.generate (state_open.hash ()));
|
||||
|
||||
nano::state_block state_send (key2.pub, state_receive.hash (), 0, nano::Gxrb_ratio, key1.pub, key2.prv, key2.pub, system.work.generate (state_receive.hash ()));
|
||||
nano::receive_block receive (send2.hash (), state_send.hash (), key1.prv, key1.pub, system.work.generate (send2.hash ()));
|
||||
nano::state_block state_send (key2.pub, state_receive.hash (), 0, nano::Gxrb_ratio, key1.pub, key2.prv, key2.pub, *system.work.generate (state_receive.hash ()));
|
||||
nano::receive_block receive (send2.hash (), state_send.hash (), key1.prv, key1.pub, *system.work.generate (send2.hash ()));
|
||||
|
||||
nano::change_block change (receive.hash (), key2.pub, key1.prv, key1.pub, system.work.generate (receive.hash ()));
|
||||
nano::change_block change (receive.hash (), key2.pub, key1.prv, key1.pub, *system.work.generate (receive.hash ()));
|
||||
|
||||
nano::state_block state_change (key2.pub, state_send.hash (), nano::test_genesis_key.pub, nano::Gxrb_ratio, 0, key2.prv, key2.pub, system.work.generate (state_send.hash ()));
|
||||
nano::state_block state_change (key2.pub, state_send.hash (), nano::test_genesis_key.pub, nano::Gxrb_ratio, 0, key2.prv, key2.pub, *system.work.generate (state_send.hash ()));
|
||||
|
||||
nano::state_block epoch (key2.pub, state_change.hash (), nano::test_genesis_key.pub, nano::Gxrb_ratio, node->ledger.link (nano::epoch::epoch_1), nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (state_change.hash ()));
|
||||
nano::state_block epoch (key2.pub, state_change.hash (), nano::test_genesis_key.pub, nano::Gxrb_ratio, node->ledger.link (nano::epoch::epoch_1), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (state_change.hash ()));
|
||||
|
||||
nano::state_block epoch1 (key1.pub, change.hash (), key2.pub, nano::Gxrb_ratio, node->ledger.link (nano::epoch::epoch_1), nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (change.hash ()));
|
||||
nano::state_block state_send1 (key1.pub, epoch1.hash (), 0, nano::Gxrb_ratio - 1, key2.pub, key1.prv, key1.pub, system.work.generate (epoch1.hash ()));
|
||||
nano::state_block state_receive2 (key2.pub, epoch.hash (), 0, nano::Gxrb_ratio + 1, state_send1.hash (), key2.prv, key2.pub, system.work.generate (epoch.hash ()));
|
||||
nano::state_block epoch1 (key1.pub, change.hash (), key2.pub, nano::Gxrb_ratio, node->ledger.link (nano::epoch::epoch_1), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (change.hash ()));
|
||||
nano::state_block state_send1 (key1.pub, epoch1.hash (), 0, nano::Gxrb_ratio - 1, key2.pub, key1.prv, key1.pub, *system.work.generate (epoch1.hash ()));
|
||||
nano::state_block state_receive2 (key2.pub, epoch.hash (), 0, nano::Gxrb_ratio + 1, state_send1.hash (), key2.prv, key2.pub, *system.work.generate (epoch.hash ()));
|
||||
|
||||
auto state_send2 = std::make_shared<nano::state_block> (key2.pub, state_receive2.hash (), 0, nano::Gxrb_ratio, key1.pub, key2.prv, key2.pub, system.work.generate (state_receive2.hash ()));
|
||||
nano::state_block state_send3 (key2.pub, state_send2->hash (), 0, nano::Gxrb_ratio - 1, key1.pub, key2.prv, key2.pub, system.work.generate (state_send2->hash ()));
|
||||
auto state_send2 = std::make_shared<nano::state_block> (key2.pub, state_receive2.hash (), 0, nano::Gxrb_ratio, key1.pub, key2.prv, key2.pub, *system.work.generate (state_receive2.hash ()));
|
||||
nano::state_block state_send3 (key2.pub, state_send2->hash (), 0, nano::Gxrb_ratio - 1, key1.pub, key2.prv, key2.pub, *system.work.generate (state_send2->hash ()));
|
||||
|
||||
nano::state_block state_send4 (key1.pub, state_send1.hash (), 0, nano::Gxrb_ratio - 2, nano::test_genesis_key.pub, key1.prv, key1.pub, system.work.generate (state_send1.hash ()));
|
||||
nano::state_block state_receive3 (nano::genesis_account, send1.hash (), nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio * 2 + 1, state_send4.hash (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send1.hash ()));
|
||||
nano::state_block state_send4 (key1.pub, state_send1.hash (), 0, nano::Gxrb_ratio - 2, nano::test_genesis_key.pub, key1.prv, key1.pub, *system.work.generate (state_send1.hash ()));
|
||||
nano::state_block state_receive3 (nano::genesis_account, send1.hash (), nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio * 2 + 1, state_send4.hash (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send1.hash ()));
|
||||
|
||||
{
|
||||
auto transaction (store.tx_begin_write ());
|
||||
|
@ -602,10 +602,10 @@ TEST (confirmation_height, conflict_rollback_cemented)
|
|||
ASSERT_EQ (1, node1.network.size ());
|
||||
nano::keypair key1;
|
||||
nano::genesis genesis;
|
||||
auto send1 (std::make_shared<nano::send_block> (genesis.hash (), key1.pub, nano::genesis_amount - 100, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (genesis.hash ())));
|
||||
auto send1 (std::make_shared<nano::send_block> (genesis.hash (), key1.pub, nano::genesis_amount - 100, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (genesis.hash ())));
|
||||
nano::publish publish1 (send1);
|
||||
nano::keypair key2;
|
||||
auto send2 (std::make_shared<nano::send_block> (genesis.hash (), key2.pub, nano::genesis_amount - 100, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (genesis.hash ())));
|
||||
auto send2 (std::make_shared<nano::send_block> (genesis.hash (), key2.pub, nano::genesis_amount - 100, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (genesis.hash ())));
|
||||
nano::publish publish2 (send2);
|
||||
auto channel1 (node1.network.udp_channels.create (node1.network.endpoint ()));
|
||||
node1.network.process_message (publish1, channel1);
|
||||
|
@ -666,7 +666,7 @@ TEST (confirmation_height, observers)
|
|||
nano::keypair key1;
|
||||
system.wallet (0)->insert_adhoc (nano::test_genesis_key.prv);
|
||||
nano::block_hash latest1 (node1->latest (nano::test_genesis_key.pub));
|
||||
auto send1 (std::make_shared<nano::send_block> (latest1, key1.pub, amount - node1->config.receive_minimum.number (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (latest1)));
|
||||
auto send1 (std::make_shared<nano::send_block> (latest1, key1.pub, amount - node1->config.receive_minimum.number (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (latest1)));
|
||||
|
||||
add_callback_stats (*node1);
|
||||
|
||||
|
@ -697,7 +697,7 @@ TEST (confirmation_height, modified_chain)
|
|||
|
||||
nano::keypair key1;
|
||||
auto & store = node->store;
|
||||
auto send = std::make_shared<nano::send_block> (latest, key1.pub, nano::genesis_amount - nano::Gxrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (latest));
|
||||
auto send = std::make_shared<nano::send_block> (latest, key1.pub, nano::genesis_amount - nano::Gxrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (latest));
|
||||
|
||||
{
|
||||
auto transaction = node->store.tx_begin_write ();
|
||||
|
@ -734,8 +734,8 @@ TEST (confirmation_height, pending_observer_callbacks)
|
|||
nano::block_hash latest (node->latest (nano::test_genesis_key.pub));
|
||||
|
||||
nano::keypair key1;
|
||||
nano::send_block send (latest, key1.pub, nano::genesis_amount - nano::Gxrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (latest));
|
||||
auto send1 = std::make_shared<nano::send_block> (send.hash (), key1.pub, nano::genesis_amount - nano::Gxrb_ratio * 2, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send.hash ()));
|
||||
nano::send_block send (latest, key1.pub, nano::genesis_amount - nano::Gxrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (latest));
|
||||
auto send1 = std::make_shared<nano::send_block> (send.hash (), key1.pub, nano::genesis_amount - nano::Gxrb_ratio * 2, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send.hash ()));
|
||||
|
||||
{
|
||||
auto transaction = node->store.tx_begin_write ();
|
||||
|
@ -787,26 +787,26 @@ TEST (confirmation_height, prioritize_frontiers)
|
|||
nano::block_hash latest1 (system.nodes[0]->latest (nano::test_genesis_key.pub));
|
||||
|
||||
// Send different numbers of blocks all accounts
|
||||
nano::send_block send1 (latest1, key1.pub, node->config.online_weight_minimum.number () + 10000, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (latest1));
|
||||
nano::send_block send2 (send1.hash (), key1.pub, node->config.online_weight_minimum.number () + 8500, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send1.hash ()));
|
||||
nano::send_block send3 (send2.hash (), key1.pub, node->config.online_weight_minimum.number () + 8000, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send2.hash ()));
|
||||
nano::send_block send4 (send3.hash (), key2.pub, node->config.online_weight_minimum.number () + 7500, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send3.hash ()));
|
||||
nano::send_block send5 (send4.hash (), key3.pub, node->config.online_weight_minimum.number () + 6500, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send4.hash ()));
|
||||
nano::send_block send6 (send5.hash (), key4.pub, node->config.online_weight_minimum.number () + 6000, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send5.hash ()));
|
||||
nano::send_block send1 (latest1, key1.pub, node->config.online_weight_minimum.number () + 10000, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (latest1));
|
||||
nano::send_block send2 (send1.hash (), key1.pub, node->config.online_weight_minimum.number () + 8500, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send1.hash ()));
|
||||
nano::send_block send3 (send2.hash (), key1.pub, node->config.online_weight_minimum.number () + 8000, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send2.hash ()));
|
||||
nano::send_block send4 (send3.hash (), key2.pub, node->config.online_weight_minimum.number () + 7500, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send3.hash ()));
|
||||
nano::send_block send5 (send4.hash (), key3.pub, node->config.online_weight_minimum.number () + 6500, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send4.hash ()));
|
||||
nano::send_block send6 (send5.hash (), key4.pub, node->config.online_weight_minimum.number () + 6000, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send5.hash ()));
|
||||
|
||||
// Open all accounts and add other sends to get different uncemented counts (as well as some which are the same)
|
||||
nano::open_block open1 (send1.hash (), nano::genesis_account, key1.pub, key1.prv, key1.pub, system.work.generate (key1.pub));
|
||||
nano::send_block send7 (open1.hash (), nano::test_genesis_key.pub, 500, key1.prv, key1.pub, system.work.generate (open1.hash ()));
|
||||
nano::open_block open1 (send1.hash (), nano::genesis_account, key1.pub, key1.prv, key1.pub, *system.work.generate (key1.pub));
|
||||
nano::send_block send7 (open1.hash (), nano::test_genesis_key.pub, 500, key1.prv, key1.pub, *system.work.generate (open1.hash ()));
|
||||
|
||||
nano::open_block open2 (send4.hash (), nano::genesis_account, key2.pub, key2.prv, key2.pub, system.work.generate (key2.pub));
|
||||
nano::open_block open2 (send4.hash (), nano::genesis_account, key2.pub, key2.prv, key2.pub, *system.work.generate (key2.pub));
|
||||
|
||||
nano::open_block open3 (send5.hash (), nano::genesis_account, key3.pub, key3.prv, key3.pub, system.work.generate (key3.pub));
|
||||
nano::send_block send8 (open3.hash (), nano::test_genesis_key.pub, 500, key3.prv, key3.pub, system.work.generate (open3.hash ()));
|
||||
nano::send_block send9 (send8.hash (), nano::test_genesis_key.pub, 200, key3.prv, key3.pub, system.work.generate (send8.hash ()));
|
||||
nano::open_block open3 (send5.hash (), nano::genesis_account, key3.pub, key3.prv, key3.pub, *system.work.generate (key3.pub));
|
||||
nano::send_block send8 (open3.hash (), nano::test_genesis_key.pub, 500, key3.prv, key3.pub, *system.work.generate (open3.hash ()));
|
||||
nano::send_block send9 (send8.hash (), nano::test_genesis_key.pub, 200, key3.prv, key3.pub, *system.work.generate (send8.hash ()));
|
||||
|
||||
nano::open_block open4 (send6.hash (), nano::genesis_account, key4.pub, key4.prv, key4.pub, system.work.generate (key4.pub));
|
||||
nano::send_block send10 (open4.hash (), nano::test_genesis_key.pub, 500, key4.prv, key4.pub, system.work.generate (open4.hash ()));
|
||||
nano::send_block send11 (send10.hash (), nano::test_genesis_key.pub, 200, key4.prv, key4.pub, system.work.generate (send10.hash ()));
|
||||
nano::open_block open4 (send6.hash (), nano::genesis_account, key4.pub, key4.prv, key4.pub, *system.work.generate (key4.pub));
|
||||
nano::send_block send10 (open4.hash (), nano::test_genesis_key.pub, 500, key4.prv, key4.pub, *system.work.generate (open4.hash ()));
|
||||
nano::send_block send11 (send10.hash (), nano::test_genesis_key.pub, 200, key4.prv, key4.pub, *system.work.generate (send10.hash ()));
|
||||
|
||||
{
|
||||
auto transaction = node->store.tx_begin_write ();
|
||||
|
@ -877,12 +877,12 @@ TEST (confirmation_height, prioritize_frontiers)
|
|||
}
|
||||
|
||||
// Check that accounts which already exist have their order modified when the uncemented count changes.
|
||||
nano::send_block send12 (send9.hash (), nano::test_genesis_key.pub, 100, key3.prv, key3.pub, system.work.generate (send9.hash ()));
|
||||
nano::send_block send13 (send12.hash (), nano::test_genesis_key.pub, 90, key3.prv, key3.pub, system.work.generate (send12.hash ()));
|
||||
nano::send_block send14 (send13.hash (), nano::test_genesis_key.pub, 80, key3.prv, key3.pub, system.work.generate (send13.hash ()));
|
||||
nano::send_block send15 (send14.hash (), nano::test_genesis_key.pub, 70, key3.prv, key3.pub, system.work.generate (send14.hash ()));
|
||||
nano::send_block send16 (send15.hash (), nano::test_genesis_key.pub, 60, key3.prv, key3.pub, system.work.generate (send15.hash ()));
|
||||
nano::send_block send17 (send16.hash (), nano::test_genesis_key.pub, 50, key3.prv, key3.pub, system.work.generate (send16.hash ()));
|
||||
nano::send_block send12 (send9.hash (), nano::test_genesis_key.pub, 100, key3.prv, key3.pub, *system.work.generate (send9.hash ()));
|
||||
nano::send_block send13 (send12.hash (), nano::test_genesis_key.pub, 90, key3.prv, key3.pub, *system.work.generate (send12.hash ()));
|
||||
nano::send_block send14 (send13.hash (), nano::test_genesis_key.pub, 80, key3.prv, key3.pub, *system.work.generate (send13.hash ()));
|
||||
nano::send_block send15 (send14.hash (), nano::test_genesis_key.pub, 70, key3.prv, key3.pub, *system.work.generate (send14.hash ()));
|
||||
nano::send_block send16 (send15.hash (), nano::test_genesis_key.pub, 60, key3.prv, key3.pub, *system.work.generate (send15.hash ()));
|
||||
nano::send_block send17 (send16.hash (), nano::test_genesis_key.pub, 50, key3.prv, key3.pub, *system.work.generate (send16.hash ()));
|
||||
{
|
||||
auto transaction = node->store.tx_begin_write ();
|
||||
ASSERT_EQ (nano::process_result::progress, node->ledger.process (transaction, send12).code);
|
||||
|
@ -980,13 +980,13 @@ TEST (confirmation_height, callback_confirmed_history)
|
|||
|
||||
nano::keypair key1;
|
||||
auto & store = node->store;
|
||||
auto send = std::make_shared<nano::send_block> (latest, key1.pub, nano::genesis_amount - nano::Gxrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (latest));
|
||||
auto send = std::make_shared<nano::send_block> (latest, key1.pub, nano::genesis_amount - nano::Gxrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (latest));
|
||||
{
|
||||
auto transaction = node->store.tx_begin_write ();
|
||||
ASSERT_EQ (nano::process_result::progress, node->ledger.process (transaction, *send).code);
|
||||
}
|
||||
|
||||
auto send1 = std::make_shared<nano::send_block> (send->hash (), key1.pub, nano::genesis_amount - nano::Gxrb_ratio * 2, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send->hash ()));
|
||||
auto send1 = std::make_shared<nano::send_block> (send->hash (), key1.pub, nano::genesis_amount - nano::Gxrb_ratio * 2, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send->hash ()));
|
||||
|
||||
add_callback_stats (*node);
|
||||
|
||||
|
@ -1059,9 +1059,9 @@ TEST (confirmation_height, dependent_election)
|
|||
|
||||
nano::keypair key1;
|
||||
auto & store = node->store;
|
||||
auto send = std::make_shared<nano::send_block> (latest, key1.pub, nano::genesis_amount - nano::Gxrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (latest));
|
||||
auto send1 = std::make_shared<nano::send_block> (send->hash (), key1.pub, nano::genesis_amount - nano::Gxrb_ratio * 2, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send->hash ()));
|
||||
auto send2 = std::make_shared<nano::send_block> (send1->hash (), key1.pub, nano::genesis_amount - nano::Gxrb_ratio * 3, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send1->hash ()));
|
||||
auto send = std::make_shared<nano::send_block> (latest, key1.pub, nano::genesis_amount - nano::Gxrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (latest));
|
||||
auto send1 = std::make_shared<nano::send_block> (send->hash (), key1.pub, nano::genesis_amount - nano::Gxrb_ratio * 2, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send->hash ()));
|
||||
auto send2 = std::make_shared<nano::send_block> (send1->hash (), key1.pub, nano::genesis_amount - nano::Gxrb_ratio * 3, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send1->hash ()));
|
||||
{
|
||||
auto transaction = node->store.tx_begin_write ();
|
||||
ASSERT_EQ (nano::process_result::progress, node->ledger.process (transaction, *send).code);
|
||||
|
@ -1123,8 +1123,8 @@ TEST (confirmation_height, dependent_election_after_already_cemented)
|
|||
|
||||
nano::keypair key1;
|
||||
auto & store = node->store;
|
||||
auto send = std::make_shared<nano::send_block> (latest, key1.pub, nano::genesis_amount - nano::Gxrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (latest));
|
||||
auto send1 = std::make_shared<nano::send_block> (send->hash (), key1.pub, nano::genesis_amount - nano::Gxrb_ratio * 2, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send->hash ()));
|
||||
auto send = std::make_shared<nano::send_block> (latest, key1.pub, nano::genesis_amount - nano::Gxrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (latest));
|
||||
auto send1 = std::make_shared<nano::send_block> (send->hash (), key1.pub, nano::genesis_amount - nano::Gxrb_ratio * 2, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send->hash ()));
|
||||
|
||||
{
|
||||
auto transaction = node->store.tx_begin_write ();
|
||||
|
|
|
@ -229,26 +229,26 @@ TEST (conflicts, adjusted_difficulty)
|
|||
nano::keypair key2;
|
||||
nano::keypair key3;
|
||||
ASSERT_EQ (0, node1.active.size ());
|
||||
auto send1 (std::make_shared<nano::send_block> (genesis.hash (), key1.pub, nano::genesis_amount - 2 * nano::xrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (genesis.hash ())));
|
||||
auto send1 (std::make_shared<nano::send_block> (genesis.hash (), key1.pub, nano::genesis_amount - 2 * nano::xrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (genesis.hash ())));
|
||||
node1.process_active (send1);
|
||||
auto send2 (std::make_shared<nano::send_block> (send1->hash (), nano::test_genesis_key.pub, nano::genesis_amount - 3 * nano::xrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send1->hash ())));
|
||||
auto send2 (std::make_shared<nano::send_block> (send1->hash (), nano::test_genesis_key.pub, nano::genesis_amount - 3 * nano::xrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send1->hash ())));
|
||||
node1.process_active (send2);
|
||||
auto receive1 (std::make_shared<nano::receive_block> (send2->hash (), send2->hash (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send2->hash ())));
|
||||
auto receive1 (std::make_shared<nano::receive_block> (send2->hash (), send2->hash (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send2->hash ())));
|
||||
node1.process_active (receive1);
|
||||
auto open1 (std::make_shared<nano::open_block> (send1->hash (), key1.pub, key1.pub, key1.prv, key1.pub, system.work.generate (key1.pub)));
|
||||
auto open1 (std::make_shared<nano::open_block> (send1->hash (), key1.pub, key1.pub, key1.prv, key1.pub, *system.work.generate (key1.pub)));
|
||||
node1.process_active (open1);
|
||||
auto send3 (std::make_shared<nano::state_block> (key1.pub, open1->hash (), key1.pub, nano::xrb_ratio, key2.pub, key1.prv, key1.pub, system.work.generate (open1->hash ())));
|
||||
auto send3 (std::make_shared<nano::state_block> (key1.pub, open1->hash (), key1.pub, nano::xrb_ratio, key2.pub, key1.prv, key1.pub, *system.work.generate (open1->hash ())));
|
||||
node1.process_active (send3);
|
||||
auto send4 (std::make_shared<nano::state_block> (key1.pub, send3->hash (), key1.pub, 0, key3.pub, key1.prv, key1.pub, system.work.generate (send3->hash ())));
|
||||
auto send4 (std::make_shared<nano::state_block> (key1.pub, send3->hash (), key1.pub, 0, key3.pub, key1.prv, key1.pub, *system.work.generate (send3->hash ())));
|
||||
node1.process_active (send4);
|
||||
ASSERT_EQ (node1.ledger.signer (node1.ledger.link (nano::epoch::epoch_1)), nano::test_genesis_key.pub);
|
||||
auto open_epoch1 (std::make_shared<nano::state_block> (key2.pub, 0, 0, 0, node1.ledger.link (nano::epoch::epoch_1), nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (key2.pub)));
|
||||
auto open_epoch1 (std::make_shared<nano::state_block> (key2.pub, 0, 0, 0, node1.ledger.link (nano::epoch::epoch_1), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (key2.pub)));
|
||||
node1.process_active (open_epoch1);
|
||||
auto receive2 (std::make_shared<nano::state_block> (key2.pub, open_epoch1->hash (), 0, nano::xrb_ratio, send3->hash (), key2.prv, key2.pub, system.work.generate (open_epoch1->hash ())));
|
||||
auto receive2 (std::make_shared<nano::state_block> (key2.pub, open_epoch1->hash (), 0, nano::xrb_ratio, send3->hash (), key2.prv, key2.pub, *system.work.generate (open_epoch1->hash ())));
|
||||
node1.process_active (receive2);
|
||||
auto open2 (std::make_shared<nano::state_block> (key3.pub, 0, key3.pub, nano::xrb_ratio, send4->hash (), key3.prv, key3.pub, system.work.generate (key3.pub)));
|
||||
auto open2 (std::make_shared<nano::state_block> (key3.pub, 0, key3.pub, nano::xrb_ratio, send4->hash (), key3.prv, key3.pub, *system.work.generate (key3.pub)));
|
||||
node1.process_active (open2);
|
||||
auto change1 (std::make_shared<nano::state_block> (key3.pub, open2->hash (), nano::test_genesis_key.pub, nano::xrb_ratio, 0, key3.prv, key3.pub, system.work.generate (open2->hash ())));
|
||||
auto change1 (std::make_shared<nano::state_block> (key3.pub, open2->hash (), nano::test_genesis_key.pub, nano::xrb_ratio, 0, key3.prv, key3.pub, *system.work.generate (open2->hash ())));
|
||||
node1.process_active (change1);
|
||||
node1.block_processor.flush ();
|
||||
system.deadline_set (3s);
|
||||
|
@ -280,7 +280,7 @@ TEST (conflicts, adjusted_difficulty)
|
|||
ASSERT_GT (adjusted_difficulties.find (open2->hash ())->second, adjusted_difficulties.find (change1->hash ())->second);
|
||||
// Independent elections can have higher difficulty than adjusted tree
|
||||
nano::keypair key4;
|
||||
auto open_epoch2 (std::make_shared<nano::state_block> (key4.pub, 0, 0, 0, node1.ledger.link (nano::epoch::epoch_1), nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (key4.pub, adjusted_difficulties.find (send1->hash ())->second)));
|
||||
auto open_epoch2 (std::make_shared<nano::state_block> (key4.pub, 0, 0, 0, node1.ledger.link (nano::epoch::epoch_1), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (key4.pub, adjusted_difficulties.find (send1->hash ())->second)));
|
||||
uint64_t difficulty;
|
||||
ASSERT_FALSE (nano::work_validate (*open_epoch2, &difficulty));
|
||||
ASSERT_GT (difficulty, adjusted_difficulties.find (send1->hash ())->second);
|
||||
|
|
|
@ -33,6 +33,24 @@ TEST (distributed_work, no_peers)
|
|||
}
|
||||
}
|
||||
|
||||
TEST (distributed_work, no_peers_disabled)
|
||||
{
|
||||
nano::system system (24000, 0);
|
||||
nano::node_config node_config (24000, system.logging);
|
||||
node_config.work_threads = 0;
|
||||
auto & node = *system.add_node (node_config);
|
||||
bool done{ false };
|
||||
auto callback_failure = [&done](boost::optional<uint64_t> work_a) {
|
||||
ASSERT_FALSE (work_a.is_initialized ());
|
||||
done = true;
|
||||
};
|
||||
node.distributed_work.make (nano::block_hash (), callback_failure, nano::network_constants::publish_test_threshold);
|
||||
while (!done)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
}
|
||||
|
||||
TEST (distributed_work, no_peers_cancel)
|
||||
{
|
||||
nano::system system (24000, 0);
|
||||
|
|
|
@ -68,7 +68,7 @@ TEST (gap_cache, gap_bootstrap)
|
|||
nano::system system (24000, 2);
|
||||
nano::block_hash latest (system.nodes[0]->latest (nano::test_genesis_key.pub));
|
||||
nano::keypair key;
|
||||
auto send (std::make_shared<nano::send_block> (latest, key.pub, nano::genesis_amount - 100, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (latest)));
|
||||
auto send (std::make_shared<nano::send_block> (latest, key.pub, nano::genesis_amount - 100, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (latest)));
|
||||
{
|
||||
auto transaction (system.nodes[0]->store.tx_begin_write ());
|
||||
ASSERT_EQ (nano::process_result::progress, system.nodes[0]->block_processor.process_one (transaction, send).code);
|
||||
|
@ -99,9 +99,9 @@ TEST (gap_cache, two_dependencies)
|
|||
nano::system system (24000, 1);
|
||||
nano::keypair key;
|
||||
nano::genesis genesis;
|
||||
auto send1 (std::make_shared<nano::send_block> (genesis.hash (), key.pub, 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (genesis.hash ())));
|
||||
auto send2 (std::make_shared<nano::send_block> (send1->hash (), key.pub, 0, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send1->hash ())));
|
||||
auto open (std::make_shared<nano::open_block> (send1->hash (), key.pub, key.pub, key.prv, key.pub, system.work.generate (key.pub)));
|
||||
auto send1 (std::make_shared<nano::send_block> (genesis.hash (), key.pub, 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (genesis.hash ())));
|
||||
auto send2 (std::make_shared<nano::send_block> (send1->hash (), key.pub, 0, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send1->hash ())));
|
||||
auto open (std::make_shared<nano::open_block> (send1->hash (), key.pub, key.pub, key.prv, key.pub, *system.work.generate (key.pub)));
|
||||
ASSERT_EQ (0, system.nodes[0]->gap_cache.size ());
|
||||
system.nodes[0]->block_processor.add (send2, nano::seconds_since_epoch ());
|
||||
system.nodes[0]->block_processor.flush ();
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -62,7 +62,7 @@ TEST (message_parser, exact_confirm_ack_size)
|
|||
nano::block_uniquer block_uniquer;
|
||||
nano::vote_uniquer vote_uniquer (block_uniquer);
|
||||
nano::message_parser parser (block_uniquer, vote_uniquer, visitor, system.work);
|
||||
auto block (std::make_shared<nano::send_block> (1, 1, 2, nano::keypair ().prv, 4, system.work.generate (nano::root (1))));
|
||||
auto block (std::make_shared<nano::send_block> (1, 1, 2, nano::keypair ().prv, 4, *system.work.generate (nano::root (1))));
|
||||
auto vote (std::make_shared<nano::vote> (0, nano::keypair ().prv, 0, std::move (block)));
|
||||
nano::confirm_ack message (vote);
|
||||
std::vector<uint8_t> bytes;
|
||||
|
@ -95,7 +95,7 @@ TEST (message_parser, exact_confirm_req_size)
|
|||
nano::block_uniquer block_uniquer;
|
||||
nano::vote_uniquer vote_uniquer (block_uniquer);
|
||||
nano::message_parser parser (block_uniquer, vote_uniquer, visitor, system.work);
|
||||
auto block (std::make_shared<nano::send_block> (1, 1, 2, nano::keypair ().prv, 4, system.work.generate (nano::root (1))));
|
||||
auto block (std::make_shared<nano::send_block> (1, 1, 2, nano::keypair ().prv, 4, *system.work.generate (nano::root (1))));
|
||||
nano::confirm_req message (std::move (block));
|
||||
std::vector<uint8_t> bytes;
|
||||
{
|
||||
|
@ -127,7 +127,7 @@ TEST (message_parser, exact_confirm_req_hash_size)
|
|||
nano::block_uniquer block_uniquer;
|
||||
nano::vote_uniquer vote_uniquer (block_uniquer);
|
||||
nano::message_parser parser (block_uniquer, vote_uniquer, visitor, system.work);
|
||||
nano::send_block block (1, 1, 2, nano::keypair ().prv, 4, system.work.generate (nano::root (1)));
|
||||
nano::send_block block (1, 1, 2, nano::keypair ().prv, 4, *system.work.generate (nano::root (1)));
|
||||
nano::confirm_req message (block.hash (), block.root ());
|
||||
std::vector<uint8_t> bytes;
|
||||
{
|
||||
|
@ -159,7 +159,7 @@ TEST (message_parser, exact_publish_size)
|
|||
nano::block_uniquer block_uniquer;
|
||||
nano::vote_uniquer vote_uniquer (block_uniquer);
|
||||
nano::message_parser parser (block_uniquer, vote_uniquer, visitor, system.work);
|
||||
auto block (std::make_shared<nano::send_block> (1, 1, 2, nano::keypair ().prv, 4, system.work.generate (nano::root (1))));
|
||||
auto block (std::make_shared<nano::send_block> (1, 1, 2, nano::keypair ().prv, 4, *system.work.generate (nano::root (1))));
|
||||
nano::publish message (std::move (block));
|
||||
std::vector<uint8_t> bytes;
|
||||
{
|
||||
|
|
|
@ -220,7 +220,7 @@ TEST (network, multi_keepalive)
|
|||
TEST (network, send_discarded_publish)
|
||||
{
|
||||
nano::system system (24000, 2);
|
||||
auto block (std::make_shared<nano::send_block> (1, 1, 2, nano::keypair ().prv, 4, system.work.generate (nano::root (1))));
|
||||
auto block (std::make_shared<nano::send_block> (1, 1, 2, nano::keypair ().prv, 4, *system.work.generate (nano::root (1))));
|
||||
nano::genesis genesis;
|
||||
{
|
||||
auto transaction (system.nodes[0]->store.tx_begin_read ());
|
||||
|
@ -242,7 +242,7 @@ TEST (network, send_invalid_publish)
|
|||
{
|
||||
nano::system system (24000, 2);
|
||||
nano::genesis genesis;
|
||||
auto block (std::make_shared<nano::send_block> (1, 1, 20, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (nano::root (1))));
|
||||
auto block (std::make_shared<nano::send_block> (1, 1, 20, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (nano::root (1))));
|
||||
{
|
||||
auto transaction (system.nodes[0]->store.tx_begin_read ());
|
||||
system.nodes[0]->network.flood_block (block);
|
||||
|
@ -269,7 +269,7 @@ TEST (network, send_valid_confirm_ack)
|
|||
system.wallet (0)->insert_adhoc (nano::test_genesis_key.prv);
|
||||
system.wallet (1)->insert_adhoc (key2.prv);
|
||||
nano::block_hash latest1 (system.nodes[0]->latest (nano::test_genesis_key.pub));
|
||||
nano::send_block block2 (latest1, key2.pub, 50, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (latest1));
|
||||
nano::send_block block2 (latest1, key2.pub, 50, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (latest1));
|
||||
nano::block_hash latest2 (system.nodes[1]->latest (nano::test_genesis_key.pub));
|
||||
system.nodes[0]->process_active (std::make_shared<nano::send_block> (block2));
|
||||
system.deadline_set (10s);
|
||||
|
@ -295,7 +295,7 @@ TEST (network, send_valid_publish)
|
|||
nano::keypair key2;
|
||||
system.wallet (1)->insert_adhoc (key2.prv);
|
||||
nano::block_hash latest1 (system.nodes[0]->latest (nano::test_genesis_key.pub));
|
||||
nano::send_block block2 (latest1, key2.pub, 50, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (latest1));
|
||||
nano::send_block block2 (latest1, key2.pub, 50, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (latest1));
|
||||
auto hash2 (block2.hash ());
|
||||
nano::block_hash latest2 (system.nodes[1]->latest (nano::test_genesis_key.pub));
|
||||
system.nodes[1]->process_active (std::make_shared<nano::send_block> (block2));
|
||||
|
@ -373,7 +373,7 @@ TEST (receivable_processor, send_with_receive)
|
|||
system.wallet (0)->insert_adhoc (nano::test_genesis_key.prv);
|
||||
nano::block_hash latest1 (system.nodes[0]->latest (nano::test_genesis_key.pub));
|
||||
system.wallet (1)->insert_adhoc (key2.prv);
|
||||
auto block1 (std::make_shared<nano::send_block> (latest1, key2.pub, amount - system.nodes[0]->config.receive_minimum.number (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (latest1)));
|
||||
auto block1 (std::make_shared<nano::send_block> (latest1, key2.pub, amount - system.nodes[0]->config.receive_minimum.number (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (latest1)));
|
||||
ASSERT_EQ (amount, system.nodes[0]->balance (nano::test_genesis_key.pub));
|
||||
ASSERT_EQ (0, system.nodes[0]->balance (key2.pub));
|
||||
ASSERT_EQ (amount, system.nodes[1]->balance (nano::test_genesis_key.pub));
|
||||
|
@ -596,9 +596,9 @@ TEST (bulk_pull, count_limit)
|
|||
nano::system system (24000, 1);
|
||||
nano::genesis genesis;
|
||||
|
||||
auto send1 (std::make_shared<nano::send_block> (system.nodes[0]->latest (nano::test_genesis_key.pub), nano::test_genesis_key.pub, 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (system.nodes[0]->latest (nano::test_genesis_key.pub))));
|
||||
auto send1 (std::make_shared<nano::send_block> (system.nodes[0]->latest (nano::test_genesis_key.pub), nano::test_genesis_key.pub, 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (system.nodes[0]->latest (nano::test_genesis_key.pub))));
|
||||
ASSERT_EQ (nano::process_result::progress, system.nodes[0]->process (*send1).code);
|
||||
auto receive1 (std::make_shared<nano::receive_block> (send1->hash (), send1->hash (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send1->hash ())));
|
||||
auto receive1 (std::make_shared<nano::receive_block> (send1->hash (), send1->hash (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send1->hash ())));
|
||||
ASSERT_EQ (nano::process_result::progress, system.nodes[0]->process (*receive1).code);
|
||||
|
||||
auto connection (std::make_shared<nano::bootstrap_server> (nullptr, system.nodes[0]));
|
||||
|
@ -738,13 +738,13 @@ TEST (bootstrap_processor, pull_diamond)
|
|||
{
|
||||
nano::system system (24000, 1);
|
||||
nano::keypair key;
|
||||
auto send1 (std::make_shared<nano::send_block> (system.nodes[0]->latest (nano::test_genesis_key.pub), key.pub, 0, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (system.nodes[0]->latest (nano::test_genesis_key.pub))));
|
||||
auto send1 (std::make_shared<nano::send_block> (system.nodes[0]->latest (nano::test_genesis_key.pub), key.pub, 0, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (system.nodes[0]->latest (nano::test_genesis_key.pub))));
|
||||
ASSERT_EQ (nano::process_result::progress, system.nodes[0]->process (*send1).code);
|
||||
auto open (std::make_shared<nano::open_block> (send1->hash (), 1, key.pub, key.prv, key.pub, system.work.generate (key.pub)));
|
||||
auto open (std::make_shared<nano::open_block> (send1->hash (), 1, key.pub, key.prv, key.pub, *system.work.generate (key.pub)));
|
||||
ASSERT_EQ (nano::process_result::progress, system.nodes[0]->process (*open).code);
|
||||
auto send2 (std::make_shared<nano::send_block> (open->hash (), nano::test_genesis_key.pub, std::numeric_limits<nano::uint128_t>::max () - 100, key.prv, key.pub, system.work.generate (open->hash ())));
|
||||
auto send2 (std::make_shared<nano::send_block> (open->hash (), nano::test_genesis_key.pub, std::numeric_limits<nano::uint128_t>::max () - 100, key.prv, key.pub, *system.work.generate (open->hash ())));
|
||||
ASSERT_EQ (nano::process_result::progress, system.nodes[0]->process (*send2).code);
|
||||
auto receive (std::make_shared<nano::receive_block> (send1->hash (), send2->hash (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send1->hash ())));
|
||||
auto receive (std::make_shared<nano::receive_block> (send1->hash (), send2->hash (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send1->hash ())));
|
||||
ASSERT_EQ (nano::process_result::progress, system.nodes[0]->process (*receive).code);
|
||||
auto node1 (std::make_shared<nano::node> (system.io_ctx, 24002, nano::unique_path (), system.alarm, system.logging, system.work));
|
||||
ASSERT_FALSE (node1->init_error ());
|
||||
|
@ -767,13 +767,13 @@ TEST (bootstrap_processor, push_diamond)
|
|||
auto wallet1 (node1->wallets.create (100));
|
||||
wallet1->insert_adhoc (nano::test_genesis_key.prv);
|
||||
wallet1->insert_adhoc (key.prv);
|
||||
auto send1 (std::make_shared<nano::send_block> (system.nodes[0]->latest (nano::test_genesis_key.pub), key.pub, 0, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (system.nodes[0]->latest (nano::test_genesis_key.pub))));
|
||||
auto send1 (std::make_shared<nano::send_block> (system.nodes[0]->latest (nano::test_genesis_key.pub), key.pub, 0, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (system.nodes[0]->latest (nano::test_genesis_key.pub))));
|
||||
ASSERT_EQ (nano::process_result::progress, node1->process (*send1).code);
|
||||
auto open (std::make_shared<nano::open_block> (send1->hash (), 1, key.pub, key.prv, key.pub, system.work.generate (key.pub)));
|
||||
auto open (std::make_shared<nano::open_block> (send1->hash (), 1, key.pub, key.prv, key.pub, *system.work.generate (key.pub)));
|
||||
ASSERT_EQ (nano::process_result::progress, node1->process (*open).code);
|
||||
auto send2 (std::make_shared<nano::send_block> (open->hash (), nano::test_genesis_key.pub, std::numeric_limits<nano::uint128_t>::max () - 100, key.prv, key.pub, system.work.generate (open->hash ())));
|
||||
auto send2 (std::make_shared<nano::send_block> (open->hash (), nano::test_genesis_key.pub, std::numeric_limits<nano::uint128_t>::max () - 100, key.prv, key.pub, *system.work.generate (open->hash ())));
|
||||
ASSERT_EQ (nano::process_result::progress, node1->process (*send2).code);
|
||||
auto receive (std::make_shared<nano::receive_block> (send1->hash (), send2->hash (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send1->hash ())));
|
||||
auto receive (std::make_shared<nano::receive_block> (send1->hash (), send2->hash (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send1->hash ())));
|
||||
ASSERT_EQ (nano::process_result::progress, node1->process (*receive).code);
|
||||
node1->bootstrap_initiator.bootstrap (system.nodes[0]->network.endpoint ());
|
||||
system.deadline_set (10s);
|
||||
|
|
|
@ -153,9 +153,9 @@ TEST (node, send_out_of_order)
|
|||
nano::system system (24000, 2);
|
||||
nano::keypair key2;
|
||||
nano::genesis genesis;
|
||||
nano::send_block send1 (genesis.hash (), key2.pub, std::numeric_limits<nano::uint128_t>::max () - system.nodes[0]->config.receive_minimum.number (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (genesis.hash ()));
|
||||
nano::send_block send2 (send1.hash (), key2.pub, std::numeric_limits<nano::uint128_t>::max () - system.nodes[0]->config.receive_minimum.number () * 2, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send1.hash ()));
|
||||
nano::send_block send3 (send2.hash (), key2.pub, std::numeric_limits<nano::uint128_t>::max () - system.nodes[0]->config.receive_minimum.number () * 3, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send2.hash ()));
|
||||
nano::send_block send1 (genesis.hash (), key2.pub, std::numeric_limits<nano::uint128_t>::max () - system.nodes[0]->config.receive_minimum.number (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (genesis.hash ()));
|
||||
nano::send_block send2 (send1.hash (), key2.pub, std::numeric_limits<nano::uint128_t>::max () - system.nodes[0]->config.receive_minimum.number () * 2, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send1.hash ()));
|
||||
nano::send_block send3 (send2.hash (), key2.pub, std::numeric_limits<nano::uint128_t>::max () - system.nodes[0]->config.receive_minimum.number () * 3, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send2.hash ()));
|
||||
system.nodes[0]->process_active (std::make_shared<nano::send_block> (send3));
|
||||
system.nodes[0]->process_active (std::make_shared<nano::send_block> (send2));
|
||||
system.nodes[0]->process_active (std::make_shared<nano::send_block> (send1));
|
||||
|
@ -174,7 +174,7 @@ TEST (node, quick_confirm)
|
|||
auto genesis_start_balance (system.nodes[0]->balance (nano::test_genesis_key.pub));
|
||||
system.wallet (0)->insert_adhoc (key.prv);
|
||||
system.wallet (0)->insert_adhoc (nano::test_genesis_key.prv);
|
||||
auto send (std::make_shared<nano::send_block> (previous, key.pub, system.nodes[0]->config.online_weight_minimum.number () + 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (previous)));
|
||||
auto send (std::make_shared<nano::send_block> (previous, key.pub, system.nodes[0]->config.online_weight_minimum.number () + 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (previous)));
|
||||
system.nodes[0]->process_active (send);
|
||||
system.deadline_set (10s);
|
||||
while (system.nodes[0]->balance (key.pub).is_zero ())
|
||||
|
@ -191,7 +191,7 @@ TEST (node, node_receive_quorum)
|
|||
nano::keypair key;
|
||||
nano::block_hash previous (system.nodes[0]->latest (nano::test_genesis_key.pub));
|
||||
system.wallet (0)->insert_adhoc (key.prv);
|
||||
auto send (std::make_shared<nano::send_block> (previous, key.pub, nano::genesis_amount - nano::Gxrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (previous)));
|
||||
auto send (std::make_shared<nano::send_block> (previous, key.pub, nano::genesis_amount - nano::Gxrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (previous)));
|
||||
system.nodes[0]->process_active (send);
|
||||
system.deadline_set (10s);
|
||||
while (!system.nodes[0]->ledger.block_exists (send->hash ()))
|
||||
|
@ -1165,8 +1165,8 @@ TEST (node, fork_keep)
|
|||
nano::keypair key2;
|
||||
nano::genesis genesis;
|
||||
// send1 and send2 fork to different accounts
|
||||
auto send1 (std::make_shared<nano::send_block> (genesis.hash (), key1.pub, nano::genesis_amount - 100, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (genesis.hash ())));
|
||||
auto send2 (std::make_shared<nano::send_block> (genesis.hash (), key2.pub, nano::genesis_amount - 100, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (genesis.hash ())));
|
||||
auto send1 (std::make_shared<nano::send_block> (genesis.hash (), key1.pub, nano::genesis_amount - 100, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (genesis.hash ())));
|
||||
auto send2 (std::make_shared<nano::send_block> (genesis.hash (), key2.pub, nano::genesis_amount - 100, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (genesis.hash ())));
|
||||
node1.process_active (send1);
|
||||
node1.block_processor.flush ();
|
||||
node2.process_active (send1);
|
||||
|
@ -1216,10 +1216,10 @@ TEST (node, fork_flip)
|
|||
ASSERT_EQ (1, node1.network.size ());
|
||||
nano::keypair key1;
|
||||
nano::genesis genesis;
|
||||
auto send1 (std::make_shared<nano::send_block> (genesis.hash (), key1.pub, nano::genesis_amount - 100, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (genesis.hash ())));
|
||||
auto send1 (std::make_shared<nano::send_block> (genesis.hash (), key1.pub, nano::genesis_amount - 100, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (genesis.hash ())));
|
||||
nano::publish publish1 (send1);
|
||||
nano::keypair key2;
|
||||
auto send2 (std::make_shared<nano::send_block> (genesis.hash (), key2.pub, nano::genesis_amount - 100, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (genesis.hash ())));
|
||||
auto send2 (std::make_shared<nano::send_block> (genesis.hash (), key2.pub, nano::genesis_amount - 100, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (genesis.hash ())));
|
||||
nano::publish publish2 (send2);
|
||||
auto channel1 (node1.network.udp_channels.create (node1.network.endpoint ()));
|
||||
node1.network.process_message (publish1, channel1);
|
||||
|
@ -1275,12 +1275,12 @@ TEST (node, fork_multi_flip)
|
|||
ASSERT_EQ (1, node1.network.size ());
|
||||
nano::keypair key1;
|
||||
nano::genesis genesis;
|
||||
auto send1 (std::make_shared<nano::send_block> (genesis.hash (), key1.pub, nano::genesis_amount - 100, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (genesis.hash ())));
|
||||
auto send1 (std::make_shared<nano::send_block> (genesis.hash (), key1.pub, nano::genesis_amount - 100, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (genesis.hash ())));
|
||||
nano::publish publish1 (send1);
|
||||
nano::keypair key2;
|
||||
auto send2 (std::make_shared<nano::send_block> (genesis.hash (), key2.pub, nano::genesis_amount - 100, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (genesis.hash ())));
|
||||
auto send2 (std::make_shared<nano::send_block> (genesis.hash (), key2.pub, nano::genesis_amount - 100, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (genesis.hash ())));
|
||||
nano::publish publish2 (send2);
|
||||
auto send3 (std::make_shared<nano::send_block> (publish2.block->hash (), key2.pub, nano::genesis_amount - 100, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (publish2.block->hash ())));
|
||||
auto send3 (std::make_shared<nano::send_block> (publish2.block->hash (), key2.pub, nano::genesis_amount - 100, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (publish2.block->hash ())));
|
||||
nano::publish publish3 (send3);
|
||||
node1.network.process_message (publish1, node1.network.udp_channels.create (node1.network.endpoint ()));
|
||||
node1.block_processor.flush ();
|
||||
|
@ -1341,9 +1341,9 @@ TEST (node, fork_bootstrap_flip)
|
|||
system0.wallet (0)->insert_adhoc (nano::test_genesis_key.prv);
|
||||
nano::block_hash latest (system0.nodes[0]->latest (nano::test_genesis_key.pub));
|
||||
nano::keypair key1;
|
||||
auto send1 (std::make_shared<nano::send_block> (latest, key1.pub, nano::genesis_amount - nano::Gxrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system0.work.generate (latest)));
|
||||
auto send1 (std::make_shared<nano::send_block> (latest, key1.pub, nano::genesis_amount - nano::Gxrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system0.work.generate (latest)));
|
||||
nano::keypair key2;
|
||||
auto send2 (std::make_shared<nano::send_block> (latest, key2.pub, nano::genesis_amount - nano::Gxrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system0.work.generate (latest)));
|
||||
auto send2 (std::make_shared<nano::send_block> (latest, key2.pub, nano::genesis_amount - nano::Gxrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system0.work.generate (latest)));
|
||||
// Insert but don't rebroadcast, simulating settled blocks
|
||||
node1.block_processor.add (send1, nano::seconds_since_epoch ());
|
||||
node1.block_processor.flush ();
|
||||
|
@ -1379,16 +1379,16 @@ TEST (node, fork_open)
|
|||
auto & node1 (*system.nodes[0]);
|
||||
nano::keypair key1;
|
||||
nano::genesis genesis;
|
||||
auto send1 (std::make_shared<nano::send_block> (genesis.hash (), key1.pub, 0, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (genesis.hash ())));
|
||||
auto send1 (std::make_shared<nano::send_block> (genesis.hash (), key1.pub, 0, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (genesis.hash ())));
|
||||
nano::publish publish1 (send1);
|
||||
auto channel1 (node1.network.udp_channels.create (node1.network.endpoint ()));
|
||||
node1.network.process_message (publish1, channel1);
|
||||
node1.block_processor.flush ();
|
||||
auto open1 (std::make_shared<nano::open_block> (publish1.block->hash (), 1, key1.pub, key1.prv, key1.pub, system.work.generate (key1.pub)));
|
||||
auto open1 (std::make_shared<nano::open_block> (publish1.block->hash (), 1, key1.pub, key1.prv, key1.pub, *system.work.generate (key1.pub)));
|
||||
nano::publish publish2 (open1);
|
||||
node1.network.process_message (publish2, channel1);
|
||||
node1.block_processor.flush ();
|
||||
auto open2 (std::make_shared<nano::open_block> (publish1.block->hash (), 2, key1.pub, key1.prv, key1.pub, system.work.generate (key1.pub)));
|
||||
auto open2 (std::make_shared<nano::open_block> (publish1.block->hash (), 2, key1.pub, key1.prv, key1.pub, *system.work.generate (key1.pub)));
|
||||
nano::publish publish3 (open2);
|
||||
ASSERT_EQ (2, node1.active.size ());
|
||||
system.wallet (0)->insert_adhoc (nano::test_genesis_key.prv);
|
||||
|
@ -1406,13 +1406,13 @@ TEST (node, fork_open_flip)
|
|||
nano::genesis genesis;
|
||||
nano::keypair rep1;
|
||||
nano::keypair rep2;
|
||||
auto send1 (std::make_shared<nano::send_block> (genesis.hash (), key1.pub, nano::genesis_amount - 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (genesis.hash ())));
|
||||
auto send1 (std::make_shared<nano::send_block> (genesis.hash (), key1.pub, nano::genesis_amount - 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (genesis.hash ())));
|
||||
node1.process_active (send1);
|
||||
node2.process_active (send1);
|
||||
// We should be keeping this block
|
||||
auto open1 (std::make_shared<nano::open_block> (send1->hash (), rep1.pub, key1.pub, key1.prv, key1.pub, system.work.generate (key1.pub)));
|
||||
auto open1 (std::make_shared<nano::open_block> (send1->hash (), rep1.pub, key1.pub, key1.prv, key1.pub, *system.work.generate (key1.pub)));
|
||||
// This block should be evicted
|
||||
auto open2 (std::make_shared<nano::open_block> (send1->hash (), rep2.pub, key1.pub, key1.prv, key1.pub, system.work.generate (key1.pub)));
|
||||
auto open2 (std::make_shared<nano::open_block> (send1->hash (), rep2.pub, key1.pub, key1.prv, key1.pub, *system.work.generate (key1.pub)));
|
||||
ASSERT_FALSE (*open1 == *open2);
|
||||
// node1 gets copy that will remain
|
||||
node1.process_active (open1);
|
||||
|
@ -1492,12 +1492,12 @@ TEST (node, fork_no_vote_quorum)
|
|||
ASSERT_EQ (node1.config.receive_minimum.number (), node1.weight (key1));
|
||||
ASSERT_EQ (node1.config.receive_minimum.number (), node2.weight (key1));
|
||||
ASSERT_EQ (node1.config.receive_minimum.number (), node3.weight (key1));
|
||||
nano::state_block send1 (nano::test_genesis_key.pub, block->hash (), nano::test_genesis_key.pub, (nano::genesis_amount / 4) - (node1.config.receive_minimum.number () * 2), key1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (block->hash ()));
|
||||
nano::state_block send1 (nano::test_genesis_key.pub, block->hash (), nano::test_genesis_key.pub, (nano::genesis_amount / 4) - (node1.config.receive_minimum.number () * 2), key1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (block->hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, node1.process (send1).code);
|
||||
ASSERT_EQ (nano::process_result::progress, node2.process (send1).code);
|
||||
ASSERT_EQ (nano::process_result::progress, node3.process (send1).code);
|
||||
auto key2 (system.wallet (2)->deterministic_insert ());
|
||||
auto send2 (std::make_shared<nano::send_block> (block->hash (), key2, (nano::genesis_amount / 4) - (node1.config.receive_minimum.number () * 2), nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (block->hash ())));
|
||||
auto send2 (std::make_shared<nano::send_block> (block->hash (), key2, (nano::genesis_amount / 4) - (node1.config.receive_minimum.number () * 2), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (block->hash ())));
|
||||
nano::raw_key key3;
|
||||
auto transaction (system.wallet (1)->wallets.tx_begin_read ());
|
||||
ASSERT_FALSE (system.wallet (1)->store.fetch (transaction, key1, key3));
|
||||
|
@ -2436,8 +2436,8 @@ TEST (node, vote_republish)
|
|||
nano::keypair key2;
|
||||
system.wallet (1)->insert_adhoc (key2.prv);
|
||||
nano::genesis genesis;
|
||||
auto send1 (std::make_shared<nano::send_block> (genesis.hash (), key2.pub, std::numeric_limits<nano::uint128_t>::max () - system.nodes[0]->config.receive_minimum.number (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (genesis.hash ())));
|
||||
auto send2 (std::make_shared<nano::send_block> (genesis.hash (), key2.pub, std::numeric_limits<nano::uint128_t>::max () - system.nodes[0]->config.receive_minimum.number () * 2, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (genesis.hash ())));
|
||||
auto send1 (std::make_shared<nano::send_block> (genesis.hash (), key2.pub, std::numeric_limits<nano::uint128_t>::max () - system.nodes[0]->config.receive_minimum.number (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (genesis.hash ())));
|
||||
auto send2 (std::make_shared<nano::send_block> (genesis.hash (), key2.pub, std::numeric_limits<nano::uint128_t>::max () - system.nodes[0]->config.receive_minimum.number () * 2, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (genesis.hash ())));
|
||||
system.nodes[0]->process_active (send1);
|
||||
system.deadline_set (5s);
|
||||
while (!system.nodes[1]->block (send1->hash ()))
|
||||
|
@ -2488,7 +2488,7 @@ TEST (node, vote_by_hash_bundle)
|
|||
nano::genesis genesis;
|
||||
for (int i = 1; i <= 200; i++)
|
||||
{
|
||||
auto send (std::make_shared<nano::send_block> (genesis.hash (), key1.pub, std::numeric_limits<nano::uint128_t>::max () - (system.nodes[0]->config.receive_minimum.number () * i), nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (genesis.hash ())));
|
||||
auto send (std::make_shared<nano::send_block> (genesis.hash (), key1.pub, std::numeric_limits<nano::uint128_t>::max () - (system.nodes[0]->config.receive_minimum.number () * i), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (genesis.hash ())));
|
||||
system.nodes[0]->block_confirm (send);
|
||||
}
|
||||
|
||||
|
@ -2510,8 +2510,8 @@ TEST (node, vote_by_hash_republish)
|
|||
nano::keypair key2;
|
||||
system.wallet (1)->insert_adhoc (key2.prv);
|
||||
nano::genesis genesis;
|
||||
auto send1 (std::make_shared<nano::send_block> (genesis.hash (), key2.pub, std::numeric_limits<nano::uint128_t>::max () - system.nodes[0]->config.receive_minimum.number (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (genesis.hash ())));
|
||||
auto send2 (std::make_shared<nano::send_block> (genesis.hash (), key2.pub, std::numeric_limits<nano::uint128_t>::max () - system.nodes[0]->config.receive_minimum.number () * 2, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (genesis.hash ())));
|
||||
auto send1 (std::make_shared<nano::send_block> (genesis.hash (), key2.pub, std::numeric_limits<nano::uint128_t>::max () - system.nodes[0]->config.receive_minimum.number (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (genesis.hash ())));
|
||||
auto send2 (std::make_shared<nano::send_block> (genesis.hash (), key2.pub, std::numeric_limits<nano::uint128_t>::max () - system.nodes[0]->config.receive_minimum.number () * 2, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (genesis.hash ())));
|
||||
system.nodes[0]->process_active (send1);
|
||||
system.deadline_set (5s);
|
||||
while (!system.nodes[1]->block (send1->hash ()))
|
||||
|
@ -2553,8 +2553,8 @@ TEST (node, vote_by_hash_epoch_block_republish)
|
|||
nano::keypair key2;
|
||||
system.wallet (1)->insert_adhoc (key2.prv);
|
||||
nano::genesis genesis;
|
||||
auto send1 (std::make_shared<nano::send_block> (genesis.hash (), key2.pub, std::numeric_limits<nano::uint128_t>::max () - system.nodes[0]->config.receive_minimum.number (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (genesis.hash ())));
|
||||
auto epoch1 (std::make_shared<nano::state_block> (nano::genesis_account, genesis.hash (), nano::genesis_account, nano::genesis_amount, system.nodes[0]->ledger.link (nano::epoch::epoch_1), nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (genesis.hash ())));
|
||||
auto send1 (std::make_shared<nano::send_block> (genesis.hash (), key2.pub, std::numeric_limits<nano::uint128_t>::max () - system.nodes[0]->config.receive_minimum.number (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (genesis.hash ())));
|
||||
auto epoch1 (std::make_shared<nano::state_block> (nano::genesis_account, genesis.hash (), nano::genesis_account, nano::genesis_amount, system.nodes[0]->ledger.link (nano::epoch::epoch_1), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (genesis.hash ())));
|
||||
system.nodes[0]->process_active (send1);
|
||||
system.deadline_set (5s);
|
||||
while (!system.nodes[1]->block (send1->hash ()))
|
||||
|
@ -2591,10 +2591,10 @@ TEST (node, epoch_conflict_confirm)
|
|||
nano::keypair key;
|
||||
nano::genesis genesis;
|
||||
nano::keypair epoch_signer (nano::test_genesis_key);
|
||||
auto send (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, genesis.hash (), nano::test_genesis_key.pub, nano::genesis_amount - 1, key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (genesis.hash ())));
|
||||
auto open (std::make_shared<nano::state_block> (key.pub, 0, key.pub, 1, send->hash (), key.prv, key.pub, system.work.generate (key.pub)));
|
||||
auto change (std::make_shared<nano::state_block> (key.pub, open->hash (), key.pub, 1, 0, key.prv, key.pub, system.work.generate (open->hash ())));
|
||||
auto epoch (std::make_shared<nano::state_block> (change->root (), 0, 0, 0, node0->ledger.link (nano::epoch::epoch_1), epoch_signer.prv, epoch_signer.pub, system.work.generate (open->hash ())));
|
||||
auto send (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, genesis.hash (), nano::test_genesis_key.pub, nano::genesis_amount - 1, key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (genesis.hash ())));
|
||||
auto open (std::make_shared<nano::state_block> (key.pub, 0, key.pub, 1, send->hash (), key.prv, key.pub, *system.work.generate (key.pub)));
|
||||
auto change (std::make_shared<nano::state_block> (key.pub, open->hash (), key.pub, 1, 0, key.prv, key.pub, *system.work.generate (open->hash ())));
|
||||
auto epoch (std::make_shared<nano::state_block> (change->root (), 0, 0, 0, node0->ledger.link (nano::epoch::epoch_1), epoch_signer.prv, epoch_signer.pub, *system.work.generate (open->hash ())));
|
||||
{
|
||||
auto transaction (node0->store.tx_begin_write ());
|
||||
ASSERT_EQ (nano::process_result::progress, node0->block_processor.process_one (transaction, send).code);
|
||||
|
@ -2641,8 +2641,8 @@ TEST (node, fork_invalid_block_signature)
|
|||
nano::system system (24000, 2);
|
||||
nano::keypair key2;
|
||||
nano::genesis genesis;
|
||||
auto send1 (std::make_shared<nano::send_block> (genesis.hash (), key2.pub, std::numeric_limits<nano::uint128_t>::max () - system.nodes[0]->config.receive_minimum.number (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (genesis.hash ())));
|
||||
auto send2 (std::make_shared<nano::send_block> (genesis.hash (), key2.pub, std::numeric_limits<nano::uint128_t>::max () - system.nodes[0]->config.receive_minimum.number () * 2, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (genesis.hash ())));
|
||||
auto send1 (std::make_shared<nano::send_block> (genesis.hash (), key2.pub, std::numeric_limits<nano::uint128_t>::max () - system.nodes[0]->config.receive_minimum.number (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (genesis.hash ())));
|
||||
auto send2 (std::make_shared<nano::send_block> (genesis.hash (), key2.pub, std::numeric_limits<nano::uint128_t>::max () - system.nodes[0]->config.receive_minimum.number () * 2, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (genesis.hash ())));
|
||||
auto send2_corrupt (std::make_shared<nano::send_block> (*send2));
|
||||
send2_corrupt->signature = nano::signature (123);
|
||||
system.nodes[0]->process_active (send1);
|
||||
|
@ -2672,8 +2672,8 @@ TEST (node, fork_invalid_block_signature_vote_by_hash)
|
|||
nano::system system (24000, 1);
|
||||
nano::keypair key2;
|
||||
nano::genesis genesis;
|
||||
auto send1 (std::make_shared<nano::send_block> (genesis.hash (), key2.pub, std::numeric_limits<nano::uint128_t>::max () - system.nodes[0]->config.receive_minimum.number (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (genesis.hash ())));
|
||||
auto send2 (std::make_shared<nano::send_block> (genesis.hash (), key2.pub, std::numeric_limits<nano::uint128_t>::max () - system.nodes[0]->config.receive_minimum.number () * 2, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (genesis.hash ())));
|
||||
auto send1 (std::make_shared<nano::send_block> (genesis.hash (), key2.pub, std::numeric_limits<nano::uint128_t>::max () - system.nodes[0]->config.receive_minimum.number (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (genesis.hash ())));
|
||||
auto send2 (std::make_shared<nano::send_block> (genesis.hash (), key2.pub, std::numeric_limits<nano::uint128_t>::max () - system.nodes[0]->config.receive_minimum.number () * 2, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (genesis.hash ())));
|
||||
auto send2_corrupt (std::make_shared<nano::send_block> (*send2));
|
||||
send2_corrupt->signature = nano::signature (123);
|
||||
system.nodes[0]->process_active (send1);
|
||||
|
@ -2873,9 +2873,9 @@ TEST (node, confirm_back)
|
|||
auto & node (*system.nodes[0]);
|
||||
nano::genesis genesis;
|
||||
auto genesis_start_balance (node.balance (nano::test_genesis_key.pub));
|
||||
auto send1 (std::make_shared<nano::send_block> (genesis.hash (), key.pub, genesis_start_balance - 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (genesis.hash ())));
|
||||
auto open (std::make_shared<nano::state_block> (key.pub, 0, key.pub, 1, send1->hash (), key.prv, key.pub, system.work.generate (key.pub)));
|
||||
auto send2 (std::make_shared<nano::state_block> (key.pub, open->hash (), key.pub, 0, nano::test_genesis_key.pub, key.prv, key.pub, system.work.generate (open->hash ())));
|
||||
auto send1 (std::make_shared<nano::send_block> (genesis.hash (), key.pub, genesis_start_balance - 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (genesis.hash ())));
|
||||
auto open (std::make_shared<nano::state_block> (key.pub, 0, key.pub, 1, send1->hash (), key.prv, key.pub, *system.work.generate (key.pub)));
|
||||
auto send2 (std::make_shared<nano::state_block> (key.pub, open->hash (), key.pub, 0, nano::test_genesis_key.pub, key.prv, key.pub, *system.work.generate (open->hash ())));
|
||||
node.process_active (send1);
|
||||
node.process_active (open);
|
||||
node.process_active (send2);
|
||||
|
@ -3018,7 +3018,7 @@ TEST (node, unchecked_cleanup)
|
|||
nano::system system (24000, 1);
|
||||
nano::keypair key;
|
||||
auto & node (*system.nodes[0]);
|
||||
auto open (std::make_shared<nano::state_block> (key.pub, 0, key.pub, 1, key.pub, key.prv, key.pub, system.work.generate (key.pub)));
|
||||
auto open (std::make_shared<nano::state_block> (key.pub, 0, key.pub, 1, key.pub, key.prv, key.pub, *system.work.generate (key.pub)));
|
||||
node.process_active (open);
|
||||
node.block_processor.flush ();
|
||||
node.config.unchecked_cutoff_time = std::chrono::seconds (2);
|
||||
|
|
|
@ -22,7 +22,7 @@ TEST (processor_service, bad_send_signature)
|
|||
nano::account_info info1;
|
||||
ASSERT_FALSE (store->account_get (transaction, nano::test_genesis_key.pub, info1));
|
||||
nano::keypair key2;
|
||||
nano::send_block send (info1.head, nano::test_genesis_key.pub, 50, nano::test_genesis_key.prv, nano::test_genesis_key.pub, pool.generate (info1.head));
|
||||
nano::send_block send (info1.head, nano::test_genesis_key.pub, 50, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (info1.head));
|
||||
send.signature.bytes[32] ^= 0x1;
|
||||
ASSERT_EQ (nano::process_result::bad_signature, ledger.process (transaction, send).code);
|
||||
}
|
||||
|
@ -40,12 +40,12 @@ TEST (processor_service, bad_receive_signature)
|
|||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::account_info info1;
|
||||
ASSERT_FALSE (store->account_get (transaction, nano::test_genesis_key.pub, info1));
|
||||
nano::send_block send (info1.head, nano::test_genesis_key.pub, 50, nano::test_genesis_key.prv, nano::test_genesis_key.pub, pool.generate (info1.head));
|
||||
nano::send_block send (info1.head, nano::test_genesis_key.pub, 50, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (info1.head));
|
||||
nano::block_hash hash1 (send.hash ());
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send).code);
|
||||
nano::account_info info2;
|
||||
ASSERT_FALSE (store->account_get (transaction, nano::test_genesis_key.pub, info2));
|
||||
nano::receive_block receive (hash1, hash1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, pool.generate (hash1));
|
||||
nano::receive_block receive (hash1, hash1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (hash1));
|
||||
receive.signature.bytes[32] ^= 0x1;
|
||||
ASSERT_EQ (nano::process_result::bad_signature, ledger.process (transaction, receive).code);
|
||||
}
|
||||
|
|
|
@ -1174,6 +1174,49 @@ TEST (wallet, work_watcher_update)
|
|||
ASSERT_GT (updated_difficulty2, difficulty2);
|
||||
}
|
||||
|
||||
TEST (wallet, work_watcher_generation_disabled)
|
||||
{
|
||||
nano::system system;
|
||||
nano::node_config node_config (24000, system.logging);
|
||||
node_config.enable_voting = false;
|
||||
node_config.work_watcher_period = 1s;
|
||||
node_config.work_threads = 0;
|
||||
auto & node = *system.add_node (node_config);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::genesis genesis;
|
||||
nano::keypair key;
|
||||
auto block (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, genesis.hash (), nano::test_genesis_key.pub, nano::genesis_amount - nano::Mxrb_ratio, key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ())));
|
||||
uint64_t difficulty (0);
|
||||
ASSERT_FALSE (nano::work_validate (*block, &difficulty));
|
||||
node.wallets.watcher->add (block);
|
||||
ASSERT_FALSE (node.process_local (block).code != nano::process_result::progress);
|
||||
ASSERT_TRUE (node.wallets.watcher->is_watched (block->qualified_root ()));
|
||||
auto multiplier = nano::difficulty::to_multiplier (difficulty, node.network_params.network.publish_threshold);
|
||||
uint64_t updated_difficulty{ difficulty };
|
||||
{
|
||||
nano::unique_lock<std::mutex> lock (node.active.mutex);
|
||||
// Prevent active difficulty repopulating multipliers
|
||||
node.network_params.network.request_interval_ms = 10000;
|
||||
//fill multipliers_cb and update active difficulty;
|
||||
for (auto i (0); i < node.active.multipliers_cb.size (); i++)
|
||||
{
|
||||
node.active.multipliers_cb.push_back (multiplier * (1.5 + i / 100.));
|
||||
}
|
||||
node.active.update_active_difficulty (lock);
|
||||
}
|
||||
std::this_thread::sleep_for (5s);
|
||||
|
||||
nano::lock_guard<std::mutex> guard (node.active.mutex);
|
||||
{
|
||||
auto const existing (node.active.roots.find (block->qualified_root ()));
|
||||
//if existing is junk the block has been confirmed already
|
||||
ASSERT_NE (existing, node.active.roots.end ());
|
||||
updated_difficulty = existing->difficulty;
|
||||
}
|
||||
ASSERT_EQ (updated_difficulty, difficulty);
|
||||
ASSERT_TRUE (node.distributed_work.work.empty ());
|
||||
}
|
||||
|
||||
TEST (wallet, work_watcher_removed)
|
||||
{
|
||||
nano::system system;
|
||||
|
|
|
@ -181,14 +181,14 @@ TEST (wallets, vote_minimum)
|
|||
nano::keypair key1;
|
||||
nano::keypair key2;
|
||||
nano::genesis genesis;
|
||||
nano::state_block send1 (nano::test_genesis_key.pub, genesis.hash (), nano::test_genesis_key.pub, std::numeric_limits<nano::uint128_t>::max () - node1.config.vote_minimum.number (), key1.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (genesis.hash ()));
|
||||
nano::state_block send1 (nano::test_genesis_key.pub, genesis.hash (), nano::test_genesis_key.pub, std::numeric_limits<nano::uint128_t>::max () - node1.config.vote_minimum.number (), key1.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (genesis.hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, node1.process (send1).code);
|
||||
nano::state_block open1 (key1.pub, 0, key1.pub, node1.config.vote_minimum.number (), send1.hash (), key1.prv, key1.pub, system.work.generate (key1.pub));
|
||||
nano::state_block open1 (key1.pub, 0, key1.pub, node1.config.vote_minimum.number (), send1.hash (), key1.prv, key1.pub, *system.work.generate (key1.pub));
|
||||
ASSERT_EQ (nano::process_result::progress, node1.process (open1).code);
|
||||
// send2 with amount vote_minimum - 1 (not voting representative)
|
||||
nano::state_block send2 (nano::test_genesis_key.pub, send1.hash (), nano::test_genesis_key.pub, std::numeric_limits<nano::uint128_t>::max () - 2 * node1.config.vote_minimum.number () + 1, key2.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send1.hash ()));
|
||||
nano::state_block send2 (nano::test_genesis_key.pub, send1.hash (), nano::test_genesis_key.pub, std::numeric_limits<nano::uint128_t>::max () - 2 * node1.config.vote_minimum.number () + 1, key2.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send1.hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, node1.process (send2).code);
|
||||
nano::state_block open2 (key2.pub, 0, key2.pub, node1.config.vote_minimum.number () - 1, send2.hash (), key2.prv, key2.pub, system.work.generate (key2.pub));
|
||||
nano::state_block open2 (key2.pub, 0, key2.pub, node1.config.vote_minimum.number () - 1, send2.hash (), key2.prv, key2.pub, *system.work.generate (key2.pub));
|
||||
ASSERT_EQ (nano::process_result::progress, node1.process (open2).code);
|
||||
auto wallet (node1.wallets.items.begin ()->second);
|
||||
ASSERT_EQ (0, wallet->representatives.size ());
|
||||
|
|
|
@ -274,7 +274,7 @@ TEST (websocket, confirmation)
|
|||
{
|
||||
nano::block_hash previous (node1->latest (nano::test_genesis_key.pub));
|
||||
balance -= send_amount;
|
||||
auto send (std::make_shared<nano::send_block> (previous, key.pub, balance, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (previous)));
|
||||
auto send (std::make_shared<nano::send_block> (previous, key.pub, balance, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (previous)));
|
||||
node1->process_active (send);
|
||||
}
|
||||
|
||||
|
@ -316,7 +316,7 @@ TEST (websocket, confirmation)
|
|||
{
|
||||
nano::block_hash previous (node1->latest (nano::test_genesis_key.pub));
|
||||
balance -= send_amount;
|
||||
auto send (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, previous, nano::test_genesis_key.pub, balance, key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (previous)));
|
||||
auto send (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, previous, nano::test_genesis_key.pub, balance, key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (previous)));
|
||||
node1->process_active (send);
|
||||
}
|
||||
|
||||
|
@ -374,7 +374,7 @@ TEST (websocket, stopped_election)
|
|||
// Create election, then erase it, causing a websocket message to be emitted
|
||||
nano::keypair key1;
|
||||
nano::genesis genesis;
|
||||
auto send1 (std::make_shared<nano::send_block> (genesis.hash (), key1.pub, 0, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (genesis.hash ())));
|
||||
auto send1 (std::make_shared<nano::send_block> (genesis.hash (), key1.pub, 0, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (genesis.hash ())));
|
||||
nano::publish publish1 (send1);
|
||||
auto channel1 (node1->network.udp_channels.create (node1->network.endpoint ()));
|
||||
node1->network.process_message (publish1, channel1);
|
||||
|
@ -435,7 +435,7 @@ TEST (websocket, confirmation_options)
|
|||
nano::block_hash previous (node1->latest (nano::test_genesis_key.pub));
|
||||
{
|
||||
balance -= send_amount;
|
||||
auto send (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, previous, nano::test_genesis_key.pub, balance, key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (previous)));
|
||||
auto send (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, previous, nano::test_genesis_key.pub, balance, key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (previous)));
|
||||
node1->process_active (send);
|
||||
previous = send->hash ();
|
||||
}
|
||||
|
@ -494,7 +494,7 @@ TEST (websocket, confirmation_options)
|
|||
// Quick-confirm another block
|
||||
{
|
||||
balance -= send_amount;
|
||||
auto send (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, previous, nano::test_genesis_key.pub, balance, key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (previous)));
|
||||
auto send (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, previous, nano::test_genesis_key.pub, balance, key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (previous)));
|
||||
node1->process_active (send);
|
||||
previous = send->hash ();
|
||||
}
|
||||
|
@ -521,7 +521,7 @@ TEST (websocket, confirmation_options)
|
|||
// When filtering options are enabled, legacy blocks are always filtered
|
||||
{
|
||||
balance -= send_amount;
|
||||
auto send (std::make_shared<nano::send_block> (previous, key.pub, balance, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (previous)));
|
||||
auto send (std::make_shared<nano::send_block> (previous, key.pub, balance, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (previous)));
|
||||
node1->process_active (send);
|
||||
previous = send->hash ();
|
||||
}
|
||||
|
@ -588,7 +588,7 @@ TEST (websocket, vote)
|
|||
nano::keypair key;
|
||||
system.wallet (1)->insert_adhoc (nano::test_genesis_key.prv);
|
||||
nano::block_hash previous (node1->latest (nano::test_genesis_key.pub));
|
||||
auto send (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, previous, nano::test_genesis_key.pub, nano::genesis_amount - (node1->config.online_weight_minimum.number () + 1), key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (previous)));
|
||||
auto send (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, previous, nano::test_genesis_key.pub, nano::genesis_amount - (node1->config.online_weight_minimum.number () + 1), key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (previous)));
|
||||
node1->process_active (send);
|
||||
|
||||
// Wait for the websocket client to receive the vote message
|
||||
|
@ -654,7 +654,7 @@ TEST (websocket, vote_options)
|
|||
auto confirm_block = [&]() {
|
||||
nano::block_hash previous (node1->latest (nano::test_genesis_key.pub));
|
||||
balance -= send_amount;
|
||||
auto send (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, previous, nano::test_genesis_key.pub, balance, key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (previous)));
|
||||
auto send (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, previous, nano::test_genesis_key.pub, balance, key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (previous)));
|
||||
node1->process_active (send);
|
||||
};
|
||||
confirm_block ();
|
||||
|
|
|
@ -11,12 +11,20 @@ TEST (work, one)
|
|||
nano::network_constants network_constants;
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::change_block block (1, 1, nano::keypair ().prv, 3, 4);
|
||||
block.block_work_set (pool.generate (block.root ()));
|
||||
block.block_work_set (*pool.generate (block.root ()));
|
||||
uint64_t difficulty;
|
||||
ASSERT_FALSE (nano::work_validate (block, &difficulty));
|
||||
ASSERT_LT (network_constants.publish_threshold, difficulty);
|
||||
}
|
||||
|
||||
TEST (work, disabled)
|
||||
{
|
||||
nano::network_constants network_constants;
|
||||
nano::work_pool pool (0);
|
||||
auto result (pool.generate (nano::block_hash ()));
|
||||
ASSERT_FALSE (result.is_initialized ());
|
||||
}
|
||||
|
||||
TEST (work, validate)
|
||||
{
|
||||
nano::network_constants network_constants;
|
||||
|
@ -25,7 +33,7 @@ TEST (work, validate)
|
|||
uint64_t difficulty;
|
||||
ASSERT_TRUE (nano::work_validate (send_block, &difficulty));
|
||||
ASSERT_LT (difficulty, network_constants.publish_threshold);
|
||||
send_block.block_work_set (pool.generate (send_block.root ()));
|
||||
send_block.block_work_set (*pool.generate (send_block.root ()));
|
||||
ASSERT_FALSE (nano::work_validate (send_block, &difficulty));
|
||||
ASSERT_LT (network_constants.publish_threshold, difficulty);
|
||||
}
|
||||
|
@ -78,10 +86,11 @@ TEST (work, opencl)
|
|||
auto opencl (nano::opencl_work::create (true, { 0, 0, 16 * 1024 }, logger));
|
||||
if (opencl != nullptr)
|
||||
{
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max (), std::chrono::nanoseconds (0), opencl ? [&opencl](nano::root const & root_a, uint64_t difficulty_a, std::atomic<int> & ticket_a) {
|
||||
// 0 threads, should add 1 for managing OpenCL
|
||||
nano::work_pool pool (0, std::chrono::nanoseconds (0), opencl ? [&opencl](nano::root const & root_a, uint64_t difficulty_a, std::atomic<int> & ticket_a) {
|
||||
return opencl->generate_work (root_a, difficulty_a);
|
||||
}
|
||||
: std::function<boost::optional<uint64_t> (nano::root const &, uint64_t, std::atomic<int> & ticket_a)> (nullptr));
|
||||
: std::function<boost::optional<uint64_t> (nano::root const &, uint64_t, std::atomic<int> & ticket_a)> (nullptr));
|
||||
ASSERT_NE (nullptr, pool.opencl);
|
||||
nano::root root;
|
||||
uint64_t difficulty (0xff00000000000000);
|
||||
|
@ -89,7 +98,7 @@ TEST (work, opencl)
|
|||
for (auto i (0); i < 16; ++i)
|
||||
{
|
||||
nano::random_pool::generate_block (root.bytes.data (), root.bytes.size ());
|
||||
auto result (pool.generate (root, difficulty));
|
||||
auto result (*pool.generate (root, difficulty));
|
||||
uint64_t result_difficulty (0);
|
||||
ASSERT_FALSE (nano::work_validate (root, result, &result_difficulty));
|
||||
ASSERT_GE (result_difficulty, difficulty);
|
||||
|
@ -132,14 +141,14 @@ TEST (work, difficulty)
|
|||
uint64_t nonce1 (0);
|
||||
do
|
||||
{
|
||||
auto work1 = pool.generate (root, difficulty1);
|
||||
auto work1 = *pool.generate (root, difficulty1);
|
||||
nano::work_validate (root, work1, &nonce1);
|
||||
} while (nonce1 > difficulty2);
|
||||
ASSERT_GT (nonce1, difficulty1);
|
||||
uint64_t nonce2 (0);
|
||||
do
|
||||
{
|
||||
auto work2 = pool.generate (root, difficulty2);
|
||||
auto work2 = *pool.generate (root, difficulty2);
|
||||
nano::work_validate (root, work2, &nonce2);
|
||||
} while (nonce2 > difficulty3);
|
||||
ASSERT_GT (nonce2, difficulty2);
|
||||
|
@ -161,7 +170,7 @@ TEST (work, eco_pow)
|
|||
uint64_t nonce (0);
|
||||
do
|
||||
{
|
||||
auto work = pool.generate (root, difficulty1);
|
||||
auto work = *pool.generate (root, difficulty1);
|
||||
nano::work_validate (root, work, &nonce);
|
||||
} while (nonce > difficulty2);
|
||||
ASSERT_GT (nonce, difficulty1);
|
||||
|
|
|
@ -54,6 +54,10 @@ std::string nano::error_common_messages::message (int ev) const
|
|||
return "Bad wallet number";
|
||||
case nano::error_common::bad_work_format:
|
||||
return "Bad work";
|
||||
case nano::error_common::disabled_local_work_generation:
|
||||
return "Local work generation is disabled";
|
||||
case nano::error_common::disabled_work_generation:
|
||||
return "Work generation is disabled";
|
||||
case nano::error_common::failure_work_generation:
|
||||
return "Work generation cancellation or failure";
|
||||
case nano::error_common::insufficient_balance:
|
||||
|
|
|
@ -32,6 +32,8 @@ enum class error_common
|
|||
bad_threshold,
|
||||
bad_wallet_number,
|
||||
bad_work_format,
|
||||
disabled_local_work_generation,
|
||||
disabled_work_generation,
|
||||
failure_work_generation,
|
||||
missing_account,
|
||||
missing_balance,
|
||||
|
|
|
@ -41,7 +41,7 @@ opencl (opencl_a)
|
|||
static_assert (ATOMIC_INT_LOCK_FREE == 2, "Atomic int needed");
|
||||
boost::thread::attributes attrs;
|
||||
nano::thread_attributes::set (attrs);
|
||||
auto count (network_constants.is_test_network () ? 1 : std::min (max_threads_a, std::max (1u, boost::thread::hardware_concurrency ())));
|
||||
auto count (network_constants.is_test_network () ? std::min (max_threads_a, 1u) : std::min (max_threads_a, std::max (1u, boost::thread::hardware_concurrency ())));
|
||||
if (opencl)
|
||||
{
|
||||
// One thread to handle OpenCL
|
||||
|
@ -203,31 +203,41 @@ void nano::work_pool::generate (nano::root const & root_a, std::function<void(bo
|
|||
void nano::work_pool::generate (nano::root const & root_a, std::function<void(boost::optional<uint64_t> const &)> callback_a, uint64_t difficulty_a)
|
||||
{
|
||||
assert (!root_a.is_zero ());
|
||||
boost::optional<uint64_t> result;
|
||||
if (!threads.empty ())
|
||||
{
|
||||
nano::lock_guard<std::mutex> lock (mutex);
|
||||
pending.emplace_back (root_a, callback_a, difficulty_a);
|
||||
{
|
||||
nano::lock_guard<std::mutex> lock (mutex);
|
||||
pending.push_back ({ root_a, callback_a, difficulty_a });
|
||||
}
|
||||
producer_condition.notify_all ();
|
||||
}
|
||||
else if (callback_a)
|
||||
{
|
||||
callback_a (boost::none);
|
||||
}
|
||||
producer_condition.notify_all ();
|
||||
}
|
||||
|
||||
uint64_t nano::work_pool::generate (nano::root const & root_a)
|
||||
boost::optional<uint64_t> nano::work_pool::generate (nano::root const & root_a)
|
||||
{
|
||||
return generate (root_a, network_constants.publish_threshold);
|
||||
}
|
||||
|
||||
uint64_t nano::work_pool::generate (nano::root const & root_a, uint64_t difficulty_a)
|
||||
boost::optional<uint64_t> nano::work_pool::generate (nano::root const & root_a, uint64_t difficulty_a)
|
||||
{
|
||||
std::promise<boost::optional<uint64_t>> work;
|
||||
std::future<boost::optional<uint64_t>> future = work.get_future ();
|
||||
// clang-format off
|
||||
generate (root_a, [&work](boost::optional<uint64_t> work_a) {
|
||||
work.set_value (work_a);
|
||||
},
|
||||
difficulty_a);
|
||||
// clang-format on
|
||||
auto result (future.get ());
|
||||
return result.value ();
|
||||
boost::optional<uint64_t> result;
|
||||
if (!threads.empty ())
|
||||
{
|
||||
std::promise<boost::optional<uint64_t>> work;
|
||||
std::future<boost::optional<uint64_t>> future = work.get_future ();
|
||||
// clang-format off
|
||||
generate (root_a, [&work](boost::optional<uint64_t> work_a) {
|
||||
work.set_value (work_a);
|
||||
},
|
||||
difficulty_a);
|
||||
// clang-format on
|
||||
result = future.get ().value ();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
size_t nano::work_pool::size ()
|
||||
|
|
|
@ -41,8 +41,8 @@ public:
|
|||
void cancel (nano::root const &);
|
||||
void generate (nano::root const &, std::function<void(boost::optional<uint64_t> const &)>);
|
||||
void generate (nano::root const &, std::function<void(boost::optional<uint64_t> const &)>, uint64_t);
|
||||
uint64_t generate (nano::root const &);
|
||||
uint64_t generate (nano::root const &, uint64_t);
|
||||
boost::optional<uint64_t> generate (nano::root const &);
|
||||
boost::optional<uint64_t> generate (nano::root const &, uint64_t);
|
||||
size_t size ();
|
||||
nano::network_constants network_constants;
|
||||
std::atomic<int> ticket;
|
||||
|
|
|
@ -225,7 +225,7 @@ int main (int argc, char * const * argv)
|
|||
<< "Account: " << rep.pub.to_account () << "\n";
|
||||
}
|
||||
nano::uint128_t balance (std::numeric_limits<nano::uint128_t>::max ());
|
||||
nano::open_block genesis_block (reinterpret_cast<const nano::block_hash &> (genesis.pub), genesis.pub, genesis.pub, genesis.prv, genesis.pub, work.generate (genesis.pub));
|
||||
nano::open_block genesis_block (reinterpret_cast<const nano::block_hash &> (genesis.pub), genesis.pub, genesis.pub, genesis.prv, genesis.pub, *work.generate (genesis.pub));
|
||||
std::cout << genesis_block.to_json ();
|
||||
std::cout.flush ();
|
||||
nano::block_hash previous (genesis_block.hash ());
|
||||
|
@ -237,7 +237,7 @@ int main (int argc, char * const * argv)
|
|||
{
|
||||
assert (balance > weekly_distribution);
|
||||
balance = balance < (weekly_distribution * 2) ? 0 : balance - weekly_distribution;
|
||||
nano::send_block send (previous, landing.pub, balance, genesis.prv, genesis.pub, work.generate (previous));
|
||||
nano::send_block send (previous, landing.pub, balance, genesis.prv, genesis.pub, *work.generate (previous));
|
||||
previous = send.hash ();
|
||||
std::cout << send.to_json ();
|
||||
std::cout.flush ();
|
||||
|
@ -353,7 +353,7 @@ int main (int argc, char * const * argv)
|
|||
{
|
||||
block.hashables.previous.qwords[0] += 1;
|
||||
auto begin1 (std::chrono::high_resolution_clock::now ());
|
||||
block.block_work_set (work.generate (block.root ()));
|
||||
block.block_work_set (*work.generate (block.root ()));
|
||||
auto end1 (std::chrono::high_resolution_clock::now ());
|
||||
std::cerr << boost::str (boost::format ("%|1$ 12d|\n") % std::chrono::duration_cast<std::chrono::microseconds> (end1 - begin1).count ());
|
||||
}
|
||||
|
@ -442,7 +442,7 @@ int main (int argc, char * const * argv)
|
|||
{
|
||||
block.hashables.previous.qwords[0] += 1;
|
||||
auto begin1 (std::chrono::high_resolution_clock::now ());
|
||||
block.block_work_set (work_pool.generate (block.root (), difficulty));
|
||||
block.block_work_set (*work_pool.generate (block.root (), difficulty));
|
||||
auto end1 (std::chrono::high_resolution_clock::now ());
|
||||
std::cerr << boost::str (boost::format ("%|1$ 12d|\n") % std::chrono::duration_cast<std::chrono::microseconds> (end1 - begin1).count ());
|
||||
}
|
||||
|
@ -580,7 +580,7 @@ int main (int argc, char * const * argv)
|
|||
.balance (genesis_balance)
|
||||
.link (keys[i].pub)
|
||||
.sign (keys[i].prv, keys[i].pub)
|
||||
.work (work.generate (genesis_latest))
|
||||
.work (*work.generate (genesis_latest))
|
||||
.build ();
|
||||
|
||||
genesis_latest = send->hash ();
|
||||
|
@ -593,7 +593,7 @@ int main (int argc, char * const * argv)
|
|||
.balance (balances[i])
|
||||
.link (genesis_latest)
|
||||
.sign (test_params.ledger.test_genesis_key.prv, test_params.ledger.test_genesis_key.pub)
|
||||
.work (work.generate (keys[i].pub))
|
||||
.work (*work.generate (keys[i].pub))
|
||||
.build ();
|
||||
|
||||
frontiers[i] = open->hash ();
|
||||
|
@ -614,7 +614,7 @@ int main (int argc, char * const * argv)
|
|||
.balance (balances[j])
|
||||
.link (keys[other].pub)
|
||||
.sign (keys[j].prv, keys[j].pub)
|
||||
.work (work.generate (frontiers[j]))
|
||||
.work (*work.generate (frontiers[j]))
|
||||
.build ();
|
||||
|
||||
frontiers[j] = send->hash ();
|
||||
|
@ -629,7 +629,7 @@ int main (int argc, char * const * argv)
|
|||
.balance (balances[other])
|
||||
.link (static_cast<nano::block_hash const &> (frontiers[j]))
|
||||
.sign (keys[other].prv, keys[other].pub)
|
||||
.work (work.generate (frontiers[other]))
|
||||
.work (*work.generate (frontiers[other]))
|
||||
.build ();
|
||||
|
||||
frontiers[other] = receive->hash ();
|
||||
|
@ -689,7 +689,7 @@ int main (int argc, char * const * argv)
|
|||
.balance (genesis_balance)
|
||||
.link (keys[i].pub)
|
||||
.sign (test_params.ledger.test_genesis_key.prv, test_params.ledger.test_genesis_key.pub)
|
||||
.work (work.generate (genesis_latest))
|
||||
.work (*work.generate (genesis_latest))
|
||||
.build ();
|
||||
|
||||
genesis_latest = send->hash ();
|
||||
|
@ -702,7 +702,7 @@ int main (int argc, char * const * argv)
|
|||
.balance (balance)
|
||||
.link (genesis_latest)
|
||||
.sign (keys[i].prv, keys[i].pub)
|
||||
.work (work.generate (keys[i].pub))
|
||||
.work (*work.generate (keys[i].pub))
|
||||
.build ();
|
||||
|
||||
node->ledger.process (transaction, *open);
|
||||
|
@ -721,7 +721,7 @@ int main (int argc, char * const * argv)
|
|||
.balance (genesis_balance)
|
||||
.link (destination.pub)
|
||||
.sign (test_params.ledger.test_genesis_key.prv, test_params.ledger.test_genesis_key.pub)
|
||||
.work (work.generate (genesis_latest))
|
||||
.work (*work.generate (genesis_latest))
|
||||
.build ();
|
||||
|
||||
genesis_latest = send->hash ();
|
||||
|
|
|
@ -92,7 +92,7 @@ void nano::distributed_work::start_work ()
|
|||
auto this_l (shared_from_this ());
|
||||
|
||||
// Start work generation if peers are not acting correctly, or if there are no peers configured
|
||||
if ((outstanding.empty () || node.unresponsive_work_peers) && (node.config.work_threads != 0 || node.work.opencl))
|
||||
if ((outstanding.empty () || node.unresponsive_work_peers) && node.local_work_generation_enabled ())
|
||||
{
|
||||
local_generation_started = true;
|
||||
node.work.generate (
|
||||
|
@ -260,7 +260,7 @@ void nano::distributed_work::stop_once (bool const local_stop_a)
|
|||
if (!stopped.exchange (true))
|
||||
{
|
||||
nano::lock_guard<std::mutex> guard (mutex);
|
||||
if (local_stop_a && (node.config.work_threads != 0 || node.work.opencl))
|
||||
if (local_stop_a && node.local_work_generation_enabled ())
|
||||
{
|
||||
node.work.cancel (root);
|
||||
}
|
||||
|
@ -382,12 +382,19 @@ void nano::distributed_work_factory::make (nano::root const & root_a, std::funct
|
|||
void nano::distributed_work_factory::make (unsigned int backoff_a, nano::root const & root_a, std::function<void(boost::optional<uint64_t>)> const & callback_a, uint64_t difficulty_a, boost::optional<nano::account> const & account_a)
|
||||
{
|
||||
cleanup_finished ();
|
||||
auto distributed (std::make_shared<nano::distributed_work> (backoff_a, node, root_a, callback_a, difficulty_a, account_a));
|
||||
if (node.work_generation_enabled ())
|
||||
{
|
||||
nano::lock_guard<std::mutex> guard (mutex);
|
||||
work[root_a].emplace_back (distributed);
|
||||
auto distributed (std::make_shared<nano::distributed_work> (backoff_a, node, root_a, callback_a, difficulty_a, account_a));
|
||||
{
|
||||
nano::lock_guard<std::mutex> guard (mutex);
|
||||
work[root_a].emplace_back (distributed);
|
||||
}
|
||||
distributed->start ();
|
||||
}
|
||||
else if (callback_a)
|
||||
{
|
||||
callback_a (boost::none);
|
||||
}
|
||||
distributed->start ();
|
||||
}
|
||||
|
||||
void nano::distributed_work_factory::cancel (nano::root const & root_a, bool const local_stop)
|
||||
|
|
|
@ -671,7 +671,9 @@ void nano::json_handler::account_representative ()
|
|||
void nano::json_handler::account_representative_set ()
|
||||
{
|
||||
auto rpc_l (shared_from_this ());
|
||||
node.worker.push_task ([rpc_l]() {
|
||||
// clang-format off
|
||||
node.worker.push_task ([ rpc_l, work_generation_enabled = node.work_generation_enabled () ]() {
|
||||
// clang-format on
|
||||
auto wallet (rpc_l->wallet_impl ());
|
||||
auto account (rpc_l->account_impl ());
|
||||
std::string representative_text (rpc_l->request.get<std::string> ("representative"));
|
||||
|
@ -701,6 +703,13 @@ void nano::json_handler::account_representative_set ()
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (!rpc_l->ec) // work == 0
|
||||
{
|
||||
if (!work_generation_enabled)
|
||||
{
|
||||
rpc_l->ec = nano::error_common::disabled_work_generation;
|
||||
}
|
||||
}
|
||||
if (!rpc_l->ec)
|
||||
{
|
||||
bool generate_work (work == 0); // Disable work generation if "work" option is provided
|
||||
|
@ -1274,6 +1283,10 @@ void nano::json_handler::block_create ()
|
|||
prv.data.clear ();
|
||||
nano::block_hash previous (0);
|
||||
nano::amount balance (0);
|
||||
if (work == 0 && !node.work_generation_enabled ())
|
||||
{
|
||||
ec = nano::error_common::disabled_work_generation;
|
||||
}
|
||||
if (!ec && wallet != 0 && account != 0)
|
||||
{
|
||||
auto existing (node.wallets.items.find (wallet));
|
||||
|
@ -3106,6 +3119,13 @@ void nano::json_handler::receive ()
|
|||
ec = nano::error_common::invalid_work;
|
||||
}
|
||||
}
|
||||
else if (!ec) // && work == 0
|
||||
{
|
||||
if (!node.work_generation_enabled ())
|
||||
{
|
||||
ec = nano::error_common::disabled_work_generation;
|
||||
}
|
||||
}
|
||||
if (!ec)
|
||||
{
|
||||
bool generate_work (work == 0); // Disable work generation if "work" option is provided
|
||||
|
@ -3418,6 +3438,10 @@ void nano::json_handler::send ()
|
|||
{
|
||||
auto work (work_optional_impl ());
|
||||
nano::uint128_t balance (0);
|
||||
if (!ec && work == 0 && !node.work_generation_enabled ())
|
||||
{
|
||||
ec = nano::error_common::disabled_work_generation;
|
||||
}
|
||||
if (!ec)
|
||||
{
|
||||
auto transaction (node.wallets.tx_begin_read ());
|
||||
|
@ -4531,11 +4555,25 @@ void nano::json_handler::work_generate ()
|
|||
};
|
||||
if (!use_peers)
|
||||
{
|
||||
node.work.generate (hash, callback, difficulty);
|
||||
if (node.local_work_generation_enabled ())
|
||||
{
|
||||
node.work.generate (hash, callback, difficulty);
|
||||
}
|
||||
else
|
||||
{
|
||||
ec = nano::error_common::disabled_local_work_generation;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
node.work_generate (hash, callback, difficulty, account);
|
||||
if (node.work_generation_enabled ())
|
||||
{
|
||||
node.work_generate (hash, callback, difficulty, account);
|
||||
}
|
||||
else
|
||||
{
|
||||
ec = nano::error_common::disabled_work_generation;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -372,7 +372,7 @@ startup_time (std::chrono::steady_clock::now ())
|
|||
|
||||
logger.always_log (boost::str (boost::format ("Work pool running %1% threads %2%") % work.threads.size () % (work.opencl ? "(1 for OpenCL)" : "")));
|
||||
logger.always_log (boost::str (boost::format ("%1% work peers configured") % config.work_peers.size ()));
|
||||
if (config.work_peers.empty () && config.work_threads == 0 && !work.opencl)
|
||||
if (!work_generation_enabled ())
|
||||
{
|
||||
logger.always_log ("Work generation is disabled");
|
||||
}
|
||||
|
@ -960,6 +960,16 @@ int nano::node::price (nano::uint128_t const & balance_a, int amount_a)
|
|||
return static_cast<int> (result * 100.0);
|
||||
}
|
||||
|
||||
bool nano::node::local_work_generation_enabled () const
|
||||
{
|
||||
return config.work_threads > 0 || work.opencl;
|
||||
}
|
||||
|
||||
bool nano::node::work_generation_enabled () const
|
||||
{
|
||||
return !config.work_peers.empty () || local_work_generation_enabled ();
|
||||
}
|
||||
|
||||
boost::optional<uint64_t> nano::node::work_generate_blocking (nano::block & block_a)
|
||||
{
|
||||
return work_generate_blocking (block_a, network_params.network.publish_threshold);
|
||||
|
|
|
@ -123,6 +123,8 @@ public:
|
|||
void bootstrap_wallet ();
|
||||
void unchecked_cleanup ();
|
||||
int price (nano::uint128_t const &, int);
|
||||
bool local_work_generation_enabled () const;
|
||||
bool work_generation_enabled () const;
|
||||
boost::optional<uint64_t> work_generate_blocking (nano::block &, uint64_t);
|
||||
boost::optional<uint64_t> work_generate_blocking (nano::block &);
|
||||
boost::optional<uint64_t> work_generate_blocking (nano::root const &, uint64_t, boost::optional<nano::account> const & = boost::none);
|
||||
|
|
|
@ -816,7 +816,7 @@ nano::frontiers_confirmation_mode nano::node_config::deserialize_frontiers_confi
|
|||
}
|
||||
}
|
||||
|
||||
nano::account nano::node_config::random_representative ()
|
||||
nano::account nano::node_config::random_representative () const
|
||||
{
|
||||
assert (!preconfigured_representatives.empty ());
|
||||
size_t index (nano::random_pool::generate_word32 (0, static_cast<CryptoPP::word32> (preconfigured_representatives.size () - 1)));
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
nano::error serialize_toml (nano::tomlconfig &) const;
|
||||
nano::error deserialize_toml (nano::tomlconfig &);
|
||||
bool upgrade_json (unsigned, nano::jsonconfig &);
|
||||
nano::account random_representative ();
|
||||
nano::account random_representative () const;
|
||||
nano::network_params network_params;
|
||||
uint16_t peering_port{ 0 };
|
||||
nano::logging logging;
|
||||
|
|
|
@ -1365,18 +1365,21 @@ bool nano::wallet::live ()
|
|||
|
||||
void nano::wallet::work_cache_blocking (nano::account const & account_a, nano::root const & root_a)
|
||||
{
|
||||
auto opt_work_l (wallets.node.work_generate_blocking (root_a, account_a));
|
||||
if (opt_work_l.is_initialized ())
|
||||
if (wallets.node.work_generation_enabled ())
|
||||
{
|
||||
auto transaction_l (wallets.tx_begin_write ());
|
||||
if (live () && store.exists (transaction_l, account_a))
|
||||
auto opt_work_l (wallets.node.work_generate_blocking (root_a, account_a));
|
||||
if (opt_work_l.is_initialized ())
|
||||
{
|
||||
work_update (transaction_l, account_a, root_a, *opt_work_l);
|
||||
auto transaction_l (wallets.tx_begin_write ());
|
||||
if (live () && store.exists (transaction_l, account_a))
|
||||
{
|
||||
work_update (transaction_l, account_a, root_a, *opt_work_l);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
wallets.node.logger.try_log (boost::str (boost::format ("Could not precache work for root %1 due to work generation failure") % root_a.to_string ()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
wallets.node.logger.try_log (boost::str (boost::format ("Could not precache work for root %1 due to work generation failure") % root_a.to_string ()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1435,7 +1438,11 @@ void nano::work_watcher::watching (nano::qualified_root const & root_a, std::sha
|
|||
auto root_l (block_a->root ());
|
||||
nano::work_validate (root_l, block_a->block_work (), &difficulty);
|
||||
auto active_difficulty (watcher_l->node.active.limited_active_difficulty ());
|
||||
if (active_difficulty > difficulty)
|
||||
/*
|
||||
* Work watcher should still watch blocks even without work generation, although no rework is done
|
||||
* Functionality may be added in the future that does not require updating work
|
||||
*/
|
||||
if (active_difficulty > difficulty && watcher_l->node.work_generation_enabled ())
|
||||
{
|
||||
watcher_l->node.work_generate (
|
||||
root_l, [watcher_l, block_a, root_a](boost::optional<uint64_t> work_a) {
|
||||
|
|
|
@ -2241,7 +2241,14 @@ void nano_qt::block_creation::create_send ()
|
|||
else
|
||||
{
|
||||
show_label_error (*status);
|
||||
status->setText ("Work generation failure");
|
||||
if (wallet.node.work_generation_enabled ())
|
||||
{
|
||||
status->setText ("Work generation failure");
|
||||
}
|
||||
else
|
||||
{
|
||||
status->setText ("Work generation is disabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -2313,7 +2320,14 @@ void nano_qt::block_creation::create_receive ()
|
|||
else
|
||||
{
|
||||
show_label_error (*status);
|
||||
status->setText ("Work generation failure");
|
||||
if (wallet.node.work_generation_enabled ())
|
||||
{
|
||||
status->setText ("Work generation failure");
|
||||
}
|
||||
else
|
||||
{
|
||||
status->setText ("Work generation is disabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -2385,7 +2399,14 @@ void nano_qt::block_creation::create_change ()
|
|||
else
|
||||
{
|
||||
show_label_error (*status);
|
||||
status->setText ("Work generation failure");
|
||||
if (wallet.node.work_generation_enabled ())
|
||||
{
|
||||
status->setText ("Work generation failure");
|
||||
}
|
||||
else
|
||||
{
|
||||
status->setText ("Work generation is disabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -2455,7 +2476,14 @@ void nano_qt::block_creation::create_open ()
|
|||
else
|
||||
{
|
||||
show_label_error (*status);
|
||||
status->setText ("Work generation failure");
|
||||
if (wallet.node.work_generation_enabled ())
|
||||
{
|
||||
status->setText ("Work generation failure");
|
||||
}
|
||||
else
|
||||
{
|
||||
status->setText ("Work generation is disabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -332,7 +332,7 @@ TEST (wallet, process_block)
|
|||
QTest::mouseClick (wallet->show_advanced, Qt::LeftButton);
|
||||
QTest::mouseClick (wallet->advanced.enter_block, Qt::LeftButton);
|
||||
ASSERT_EQ (wallet->block_entry.window, wallet->main_stack->currentWidget ());
|
||||
nano::send_block send (latest, key1.pub, 0, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (latest));
|
||||
nano::send_block send (latest, key1.pub, 0, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (latest));
|
||||
std::string previous;
|
||||
send.hashables.previous.encode_hex (previous);
|
||||
std::string balance;
|
||||
|
@ -484,11 +484,11 @@ TEST (history, short_text)
|
|||
store.initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
nano::keypair key;
|
||||
auto latest (ledger.latest (transaction, nano::test_genesis_key.pub));
|
||||
nano::send_block send (latest, nano::test_genesis_key.pub, 0, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (latest));
|
||||
nano::send_block send (latest, nano::test_genesis_key.pub, 0, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (latest));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send).code);
|
||||
nano::receive_block receive (send.hash (), send.hash (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send.hash ()));
|
||||
nano::receive_block receive (send.hash (), send.hash (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send.hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, receive).code);
|
||||
nano::change_block change (receive.hash (), key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (receive.hash ()));
|
||||
nano::change_block change (receive.hash (), key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (receive.hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, change).code);
|
||||
}
|
||||
nano_qt::history history (ledger, nano::test_genesis_key.pub, *wallet);
|
||||
|
@ -597,7 +597,7 @@ TEST (wallet, republish)
|
|||
{
|
||||
auto transaction (system.nodes[0]->store.tx_begin_write ());
|
||||
auto latest (system.nodes[0]->ledger.latest (transaction, nano::test_genesis_key.pub));
|
||||
nano::send_block block (latest, key.pub, 0, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (latest));
|
||||
nano::send_block block (latest, key.pub, 0, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (latest));
|
||||
hash = block.hash ();
|
||||
ASSERT_EQ (nano::process_result::progress, system.nodes[0]->ledger.process (transaction, block).code);
|
||||
}
|
||||
|
@ -797,7 +797,7 @@ TEST (wallet, DISABLED_synchronizing)
|
|||
{
|
||||
auto transaction (system1.nodes[0]->store.tx_begin_write ());
|
||||
auto latest (system1.nodes[0]->ledger.latest (transaction, nano::genesis_account));
|
||||
nano::send_block send (latest, key1, 0, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system1.work.generate (latest));
|
||||
nano::send_block send (latest, key1, 0, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system1.work.generate (latest));
|
||||
system1.nodes[0]->ledger.process (transaction, send);
|
||||
}
|
||||
ASSERT_EQ (0, wallet->active_status.active.count (nano_qt::status_types::synchronizing));
|
||||
|
|
|
@ -523,6 +523,41 @@ TEST (rpc, send_work)
|
|||
ASSERT_EQ (system.nodes[0]->latest (nano::test_genesis_key.pub), block);
|
||||
}
|
||||
|
||||
TEST (rpc, send_work_disabled)
|
||||
{
|
||||
nano::system system (24000, 0);
|
||||
nano::node_config node_config (24000, system.logging);
|
||||
node_config.work_threads = 0;
|
||||
auto & node = *system.add_node (node_config);
|
||||
system.wallet (0)->insert_adhoc (nano::test_genesis_key.prv);
|
||||
scoped_io_thread_name_change scoped_thread_name_io;
|
||||
enable_ipc_transport_tcp (node.config.ipc_config.transport_tcp);
|
||||
nano::node_rpc_config node_rpc_config;
|
||||
nano::ipc::ipc_server ipc_server (node, node_rpc_config);
|
||||
nano::rpc_config rpc_config (true);
|
||||
nano::ipc_rpc_processor ipc_rpc_processor (system.io_ctx, rpc_config);
|
||||
nano::rpc rpc (system.io_ctx, rpc_config, ipc_rpc_processor);
|
||||
rpc.start ();
|
||||
boost::property_tree::ptree request;
|
||||
std::string wallet;
|
||||
system.nodes[0]->wallets.items.begin ()->first.encode_hex (wallet);
|
||||
request.put ("wallet", wallet);
|
||||
request.put ("action", "send");
|
||||
request.put ("source", nano::test_genesis_key.pub.to_account ());
|
||||
request.put ("destination", nano::test_genesis_key.pub.to_account ());
|
||||
request.put ("amount", "100");
|
||||
{
|
||||
test_response response (request, rpc.config.port, system.io_ctx);
|
||||
system.deadline_set (10s);
|
||||
while (response.status == 0)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_EQ (200, response.status);
|
||||
ASSERT_EQ (std::error_code (nano::error_common::disabled_work_generation).message (), response.json.get<std::string> ("error"));
|
||||
}
|
||||
}
|
||||
|
||||
TEST (rpc, send_idempotent)
|
||||
{
|
||||
nano::system system (24000, 1);
|
||||
|
@ -1681,7 +1716,7 @@ TEST (rpc, process_block_with_work_watcher)
|
|||
auto & node1 = *system.add_node (node_config);
|
||||
nano::keypair key;
|
||||
auto latest (system.nodes[0]->latest (nano::test_genesis_key.pub));
|
||||
auto send (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, latest, nano::test_genesis_key.pub, nano::genesis_amount - 100, nano::test_genesis_key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (latest)));
|
||||
auto send (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, latest, nano::test_genesis_key.pub, nano::genesis_amount - 100, nano::test_genesis_key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (latest)));
|
||||
uint64_t difficulty1 (0);
|
||||
nano::work_validate (*send, &difficulty1);
|
||||
auto multiplier1 = nano::difficulty::to_multiplier (difficulty1, node1.network_params.network.publish_threshold);
|
||||
|
@ -3311,6 +3346,39 @@ TEST (rpc, account_representative_set)
|
|||
ASSERT_EQ (rep.pub, system.nodes[0]->store.block_get (transaction, hash)->representative ());
|
||||
}
|
||||
|
||||
TEST (rpc, account_representative_set_work_disabled)
|
||||
{
|
||||
nano::system system (24000, 0);
|
||||
nano::node_config node_config (24000, system.logging);
|
||||
node_config.work_threads = 0;
|
||||
auto & node = *system.add_node (node_config);
|
||||
system.wallet (0)->insert_adhoc (nano::test_genesis_key.prv);
|
||||
scoped_io_thread_name_change scoped_thread_name_io;
|
||||
enable_ipc_transport_tcp (node.config.ipc_config.transport_tcp);
|
||||
nano::node_rpc_config node_rpc_config;
|
||||
nano::ipc::ipc_server ipc_server (node, node_rpc_config);
|
||||
nano::rpc_config rpc_config (true);
|
||||
nano::ipc_rpc_processor ipc_rpc_processor (system.io_ctx, rpc_config);
|
||||
nano::rpc rpc (system.io_ctx, rpc_config, ipc_rpc_processor);
|
||||
rpc.start ();
|
||||
boost::property_tree::ptree request;
|
||||
nano::keypair rep;
|
||||
request.put ("account", nano::genesis_account.to_account ());
|
||||
request.put ("representative", rep.pub.to_account ());
|
||||
request.put ("wallet", system.nodes[0]->wallets.items.begin ()->first.to_string ());
|
||||
request.put ("action", "account_representative_set");
|
||||
{
|
||||
test_response response (request, rpc.config.port, system.io_ctx);
|
||||
system.deadline_set (10s);
|
||||
while (response.status == 0)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_EQ (200, response.status);
|
||||
ASSERT_EQ (std::error_code (nano::error_common::disabled_work_generation).message (), response.json.get<std::string> ("error"));
|
||||
}
|
||||
}
|
||||
|
||||
TEST (rpc, bootstrap)
|
||||
{
|
||||
nano::system system0 (24000, 1);
|
||||
|
@ -5888,13 +5956,13 @@ TEST (rpc, confirmation_height_currently_processing)
|
|||
auto transaction = node->store.tx_begin_write ();
|
||||
for (auto i = num_blocks; i > 0; --i)
|
||||
{
|
||||
nano::send_block send (previous_genesis_chain_hash, nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio + i + 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (previous_genesis_chain_hash));
|
||||
nano::send_block send (previous_genesis_chain_hash, nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio + i + 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (previous_genesis_chain_hash));
|
||||
ASSERT_EQ (nano::process_result::progress, node->ledger.process (transaction, send).code);
|
||||
previous_genesis_chain_hash = send.hash ();
|
||||
}
|
||||
|
||||
nano::keypair key1;
|
||||
nano::send_block send (previous_genesis_chain_hash, key1.pub, nano::genesis_amount - nano::Gxrb_ratio - 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (previous_genesis_chain_hash));
|
||||
nano::send_block send (previous_genesis_chain_hash, key1.pub, nano::genesis_amount - nano::Gxrb_ratio - 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (previous_genesis_chain_hash));
|
||||
ASSERT_EQ (nano::process_result::progress, node->ledger.process (transaction, send).code);
|
||||
previous_genesis_chain_hash = send.hash ();
|
||||
}
|
||||
|
@ -6633,10 +6701,10 @@ TEST (rpc, block_confirmed)
|
|||
{
|
||||
auto transaction = node->store.tx_begin_write ();
|
||||
nano::block_hash latest (node->latest (nano::test_genesis_key.pub));
|
||||
nano::send_block send1 (latest, key.pub, 300, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (latest));
|
||||
nano::send_block send1 (latest, key.pub, 300, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (latest));
|
||||
ASSERT_EQ (nano::process_result::progress, node->ledger.process (transaction, send1).code);
|
||||
|
||||
nano::open_block open1 (send1.hash (), nano::genesis_account, key.pub, key.prv, key.pub, system.work.generate (key.pub));
|
||||
nano::open_block open1 (send1.hash (), nano::genesis_account, key.pub, key.prv, key.pub, *system.work.generate (key.pub));
|
||||
ASSERT_EQ (nano::process_result::progress, node->ledger.process (transaction, open1).code);
|
||||
}
|
||||
scoped_thread_name_io.renew ();
|
||||
|
@ -6655,7 +6723,7 @@ TEST (rpc, block_confirmed)
|
|||
ASSERT_FALSE (response2.json.get<bool> ("confirmed"));
|
||||
|
||||
// Create and process a new send block
|
||||
auto send = std::make_shared<nano::send_block> (latest, key.pub, 10, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (latest));
|
||||
auto send = std::make_shared<nano::send_block> (latest, key.pub, 10, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (latest));
|
||||
node->process_active (send);
|
||||
node->block_processor.flush ();
|
||||
|
||||
|
|
|
@ -99,19 +99,19 @@ TEST (ledger, deep_account_compute)
|
|||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair key;
|
||||
auto balance (nano::genesis_amount - 1);
|
||||
nano::send_block send (genesis.hash (), key.pub, balance, nano::test_genesis_key.prv, nano::test_genesis_key.pub, pool.generate (genesis.hash ()));
|
||||
nano::send_block send (genesis.hash (), key.pub, balance, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send).code);
|
||||
nano::open_block open (send.hash (), nano::test_genesis_key.pub, key.pub, key.prv, key.pub, pool.generate (key.pub));
|
||||
nano::open_block open (send.hash (), nano::test_genesis_key.pub, key.pub, key.prv, key.pub, *pool.generate (key.pub));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, open).code);
|
||||
auto sprevious (send.hash ());
|
||||
auto rprevious (open.hash ());
|
||||
for (auto i (0), n (100000); i != n; ++i)
|
||||
{
|
||||
balance -= 1;
|
||||
nano::send_block send (sprevious, key.pub, balance, nano::test_genesis_key.prv, nano::test_genesis_key.pub, pool.generate (sprevious));
|
||||
nano::send_block send (sprevious, key.pub, balance, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (sprevious));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send).code);
|
||||
sprevious = send.hash ();
|
||||
nano::receive_block receive (rprevious, send.hash (), key.prv, key.pub, pool.generate (rprevious));
|
||||
nano::receive_block receive (rprevious, send.hash (), key.prv, key.pub, *pool.generate (rprevious));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, receive).code);
|
||||
rprevious = receive.hash ();
|
||||
if (i % 100 == 0)
|
||||
|
@ -442,7 +442,7 @@ TEST (node, mass_vote_by_hash)
|
|||
std::vector<std::shared_ptr<nano::state_block>> blocks;
|
||||
for (auto i (0); i < 10000; ++i)
|
||||
{
|
||||
auto block (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, previous, nano::test_genesis_key.pub, nano::genesis_amount - (i + 1) * nano::Gxrb_ratio, key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (previous)));
|
||||
auto block (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, previous, nano::test_genesis_key.pub, nano::genesis_amount - (i + 1) * nano::Gxrb_ratio, key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (previous)));
|
||||
previous = block->hash ();
|
||||
blocks.push_back (block);
|
||||
}
|
||||
|
@ -480,9 +480,9 @@ TEST (confirmation_height, many_accounts_single_confirmation)
|
|||
nano::keypair key;
|
||||
system.wallet (0)->insert_adhoc (key.prv);
|
||||
|
||||
nano::send_block send (last_open_hash, key.pub, node->config.online_weight_minimum.number (), last_keypair.prv, last_keypair.pub, system.work.generate (last_open_hash));
|
||||
nano::send_block send (last_open_hash, key.pub, node->config.online_weight_minimum.number (), last_keypair.prv, last_keypair.pub, *system.work.generate (last_open_hash));
|
||||
ASSERT_EQ (nano::process_result::progress, node->ledger.process (transaction, send).code);
|
||||
nano::open_block open (send.hash (), last_keypair.pub, key.pub, key.prv, key.pub, system.work.generate (key.pub));
|
||||
nano::open_block open (send.hash (), last_keypair.pub, key.pub, key.prv, key.pub, *system.work.generate (key.pub));
|
||||
ASSERT_EQ (nano::process_result::progress, node->ledger.process (transaction, open).code);
|
||||
last_open_hash = open.hash ();
|
||||
last_keypair = key;
|
||||
|
@ -550,9 +550,9 @@ TEST (confirmation_height, many_accounts_many_confirmations)
|
|||
nano::keypair key;
|
||||
system.wallet (0)->insert_adhoc (key.prv);
|
||||
|
||||
nano::send_block send (latest_genesis, key.pub, node->config.online_weight_minimum.number (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (latest_genesis));
|
||||
nano::send_block send (latest_genesis, key.pub, node->config.online_weight_minimum.number (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (latest_genesis));
|
||||
ASSERT_EQ (nano::process_result::progress, node->ledger.process (transaction, send).code);
|
||||
auto open = std::make_shared<nano::open_block> (send.hash (), nano::test_genesis_key.pub, key.pub, key.prv, key.pub, system.work.generate (key.pub));
|
||||
auto open = std::make_shared<nano::open_block> (send.hash (), nano::test_genesis_key.pub, key.pub, key.prv, key.pub, *system.work.generate (key.pub));
|
||||
ASSERT_EQ (nano::process_result::progress, node->ledger.process (transaction, *open).code);
|
||||
open_blocks.push_back (std::move (open));
|
||||
latest_genesis = send.hash ();
|
||||
|
@ -592,8 +592,8 @@ TEST (confirmation_height, long_chains)
|
|||
constexpr auto num_blocks = 10000;
|
||||
|
||||
// First open the other account
|
||||
nano::send_block send (latest, key1.pub, nano::genesis_amount - nano::Gxrb_ratio + num_blocks + 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (latest));
|
||||
nano::open_block open (send.hash (), nano::genesis_account, key1.pub, key1.prv, key1.pub, system.work.generate (key1.pub));
|
||||
nano::send_block send (latest, key1.pub, nano::genesis_amount - nano::Gxrb_ratio + num_blocks + 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (latest));
|
||||
nano::open_block open (send.hash (), nano::genesis_account, key1.pub, key1.prv, key1.pub, *system.work.generate (key1.pub));
|
||||
{
|
||||
auto transaction = node->store.tx_begin_write ();
|
||||
ASSERT_EQ (nano::process_result::progress, node->ledger.process (transaction, send).code);
|
||||
|
@ -607,9 +607,9 @@ TEST (confirmation_height, long_chains)
|
|||
auto transaction = node->store.tx_begin_write ();
|
||||
for (auto i = num_blocks - 1; i > 0; --i)
|
||||
{
|
||||
nano::send_block send (previous_genesis_chain_hash, key1.pub, nano::genesis_amount - nano::Gxrb_ratio + i + 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (previous_genesis_chain_hash));
|
||||
nano::send_block send (previous_genesis_chain_hash, key1.pub, nano::genesis_amount - nano::Gxrb_ratio + i + 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (previous_genesis_chain_hash));
|
||||
ASSERT_EQ (nano::process_result::progress, node->ledger.process (transaction, send).code);
|
||||
nano::receive_block receive (previous_destination_chain_hash, send.hash (), key1.prv, key1.pub, system.work.generate (previous_destination_chain_hash));
|
||||
nano::receive_block receive (previous_destination_chain_hash, send.hash (), key1.prv, key1.pub, *system.work.generate (previous_destination_chain_hash));
|
||||
ASSERT_EQ (nano::process_result::progress, node->ledger.process (transaction, receive).code);
|
||||
|
||||
previous_genesis_chain_hash = send.hash ();
|
||||
|
@ -618,12 +618,12 @@ TEST (confirmation_height, long_chains)
|
|||
}
|
||||
|
||||
// Send one from destination to genesis and pocket it
|
||||
nano::send_block send1 (previous_destination_chain_hash, nano::test_genesis_key.pub, nano::Gxrb_ratio - 2, key1.prv, key1.pub, system.work.generate (previous_destination_chain_hash));
|
||||
auto receive1 (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, previous_genesis_chain_hash, nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio + 1, send1.hash (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (previous_genesis_chain_hash)));
|
||||
nano::send_block send1 (previous_destination_chain_hash, nano::test_genesis_key.pub, nano::Gxrb_ratio - 2, key1.prv, key1.pub, *system.work.generate (previous_destination_chain_hash));
|
||||
auto receive1 (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, previous_genesis_chain_hash, nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio + 1, send1.hash (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (previous_genesis_chain_hash)));
|
||||
|
||||
// Unpocketed. Send to a non-existing account to prevent auto receives from the wallet adjusting expected confirmation height
|
||||
nano::keypair key2;
|
||||
nano::state_block send2 (nano::genesis_account, receive1->hash (), nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio, key2.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (receive1->hash ()));
|
||||
nano::state_block send2 (nano::genesis_account, receive1->hash (), nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio, key2.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (receive1->hash ()));
|
||||
|
||||
{
|
||||
auto transaction = node->store.tx_begin_write ();
|
||||
|
@ -694,9 +694,9 @@ TEST (confirmation_height, prioritize_frontiers_overwrite)
|
|||
nano::keypair key;
|
||||
system.wallet (0)->insert_adhoc (key.prv);
|
||||
|
||||
nano::send_block send (last_open_hash, key.pub, nano::Gxrb_ratio - 1, last_keypair.prv, last_keypair.pub, system.work.generate (last_open_hash));
|
||||
nano::send_block send (last_open_hash, key.pub, nano::Gxrb_ratio - 1, last_keypair.prv, last_keypair.pub, *system.work.generate (last_open_hash));
|
||||
ASSERT_EQ (nano::process_result::progress, node->ledger.process (transaction, send).code);
|
||||
nano::open_block open (send.hash (), last_keypair.pub, key.pub, key.prv, key.pub, system.work.generate (key.pub));
|
||||
nano::open_block open (send.hash (), last_keypair.pub, key.pub, key.prv, key.pub, *system.work.generate (key.pub));
|
||||
ASSERT_EQ (nano::process_result::progress, node->ledger.process (transaction, open).code);
|
||||
last_open_hash = open.hash ();
|
||||
last_keypair = key;
|
||||
|
@ -719,8 +719,8 @@ TEST (confirmation_height, prioritize_frontiers_overwrite)
|
|||
// Add a new frontier with 1 block, it should not be added to the frontier container because it is not higher than any already in the maxed out container
|
||||
nano::keypair key;
|
||||
auto latest_genesis = node->latest (nano::test_genesis_key.pub);
|
||||
nano::send_block send (latest_genesis, key.pub, nano::Gxrb_ratio - 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (latest_genesis));
|
||||
nano::open_block open (send.hash (), nano::test_genesis_key.pub, key.pub, key.prv, key.pub, system.work.generate (key.pub));
|
||||
nano::send_block send (latest_genesis, key.pub, nano::Gxrb_ratio - 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (latest_genesis));
|
||||
nano::open_block open (send.hash (), nano::test_genesis_key.pub, key.pub, key.prv, key.pub, *system.work.generate (key.pub));
|
||||
{
|
||||
auto transaction = node->store.tx_begin_write ();
|
||||
ASSERT_EQ (nano::process_result::progress, node->ledger.process (transaction, send).code);
|
||||
|
@ -732,8 +732,8 @@ TEST (confirmation_height, prioritize_frontiers_overwrite)
|
|||
ASSERT_EQ (node->active.priority_wallet_cementable_frontiers_size (), num_accounts / 2);
|
||||
|
||||
// The account now has an extra block (2 in total) so has 1 more uncemented block than the next smallest frontier in the collection.
|
||||
nano::send_block send1 (send.hash (), key.pub, nano::Gxrb_ratio - 2, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send.hash ()));
|
||||
nano::receive_block receive (open.hash (), send1.hash (), key.prv, key.pub, system.work.generate (open.hash ()));
|
||||
nano::send_block send1 (send.hash (), key.pub, nano::Gxrb_ratio - 2, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send.hash ()));
|
||||
nano::receive_block receive (open.hash (), send1.hash (), key.prv, key.pub, *system.work.generate (open.hash ()));
|
||||
{
|
||||
auto transaction = node->store.tx_begin_write ();
|
||||
ASSERT_EQ (nano::process_result::progress, node->ledger.process (transaction, send1).code);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue