Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix node.fork_invalid_block_signature intermittent failures, re-enable on windows CI #2743

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions nano/core_test/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3087,32 +3087,38 @@ TEST (node, epoch_conflict_confirm)
}
}

// Test is unstable on github actions for windows, disable if CI detected and windows
#if (defined(_WIN32) && CI)
TEST (node, DISABLED_fork_invalid_block_signature)
#else
TEST (node, fork_invalid_block_signature)
#endif
{
nano::system system (2);
auto & node1 (*system.nodes[0]);
auto & node2 (*system.nodes[1]);
nano::system system;
nano::node_flags node_flags;
// Disabling republishing + waiting for a rollback before sending the correct vote below fixes an intermittent failure in this test
// If these are taken out, one of two things may cause the test two fail often:
// - Block *send2* might get processed before the rollback happens, simply due to timings, with code "fork", and not be processed again. Waiting for the rollback fixes this issue.
// - Block *send1* might get processed again after the rollback happens, which causes *send2* to be processed with code "fork". Disabling block republishing ensures "send1" is not processed again.
// An alternative would be to repeatedly flood the correct vote
node_flags.disable_block_processor_republishing = true;
auto & node1 (*system.add_node (node_flags));
auto & node2 (*system.add_node (node_flags));
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 () - node1.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 () - node1.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);
auto vote (std::make_shared<nano::vote> (nano::test_genesis_key.pub, nano::test_genesis_key.prv, 0, send2));
auto vote_corrupt (std::make_shared<nano::vote> (nano::test_genesis_key.pub, nano::test_genesis_key.prv, 0, send2_corrupt));

node1.process_active (send1);
system.deadline_set (5s);
while (!node1.block (send1->hash ()))
{
ASSERT_NO_ERROR (system.poll ());
}
auto vote (std::make_shared<nano::vote> (nano::test_genesis_key.pub, nano::test_genesis_key.prv, 0, send2));
auto vote_corrupt (std::make_shared<nano::vote> (nano::test_genesis_key.pub, nano::test_genesis_key.prv, 0, send2_corrupt));
// Send the vote with the corrupt block signature
node2.network.flood_vote (vote_corrupt, 1.0f);
ASSERT_NO_ERROR (system.poll ());
// Wait for the rollback
ASSERT_TIMELY (5s, node1.stats.count (nano::stat::type::rollback, nano::stat::detail::all));
// Send the vote with the correct block
node2.network.flood_vote (vote, 1.0f);
while (node1.block (send1->hash ()))
{
Expand Down