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

Disable p2p network when delayed_node plugin is enabled #2393

Merged
merged 33 commits into from
Apr 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
9da846c
Disable p2p network when delayed_node plugin is enabled
pmconrad Nov 3, 2019
6eb5b22
Fail in network_broadcast_api when not connected to P2P network
pmconrad Nov 4, 2019
359af02
Refactored database_fixture for better customization
pmconrad Nov 6, 2019
3a582f3
Merge pull request #2040 from pmconrad/104_delayed_node_p2p
abitmore Mar 24, 2021
e05c7f1
Merge branch 'develop'
abitmore Mar 24, 2021
afd64de
Update database_fixture_base destructor
abitmore Mar 26, 2021
00d8c7b
Move db_fixture_base member init to constructor
abitmore Mar 26, 2021
1db9905
Remove Extra initialization of db_fixture.app
abitmore Mar 26, 2021
10b64a2
Fix typo in logging
abitmore Mar 27, 2021
8ed1ce2
Refactor application and plugin framework
abitmore Mar 28, 2021
8120839
Update tests to adapt the plugin framework changes
abitmore Mar 28, 2021
5db63f5
Remove application::shutdown()
abitmore Mar 29, 2021
d4441b0
Add option in app to enable or disable P2P network
abitmore Mar 29, 2021
290b3d0
Refactor application_impl::startup()
abitmore Mar 29, 2021
c19a676
Fix a compiler warning
abitmore Mar 29, 2021
3d68030
Remove redundant 'virtual' declarations
abitmore Mar 29, 2021
d135a9c
Pass a shared_ptr of node_delegate to node
abitmore Mar 29, 2021
c147536
Manage node_impl object with shared_ptr
abitmore Apr 6, 2021
24f424d
Add try catch in _terminate_inactive_conn_loop
abitmore Apr 6, 2021
197adf7
Explicitly shutdown witness plugin in unit test
abitmore Apr 6, 2021
2384ecb
Cleanup socket after app in CLI tests for windows
abitmore Apr 6, 2021
1476bc6
Add tests for enable-p2p-network option
abitmore Apr 6, 2021
e659a63
Update order of includes in es_test
abitmore Apr 6, 2021
b013559
Refuse to broadcast sooner if no P2P network
abitmore Apr 7, 2021
67026f6
Rename long variable names
abitmore Apr 7, 2021
628f93b
Replace duplicate constructors with using clauses
abitmore Apr 7, 2021
aac5f43
Rename long variable names and function names
abitmore Apr 7, 2021
52ebad4
Fix code smells
abitmore Apr 7, 2021
e2aa835
Rename long function names
abitmore Apr 7, 2021
6a5f576
Fix code smells
abitmore Apr 7, 2021
670f70d
Change functions to const, fix code smells
abitmore Apr 7, 2021
c3b0849
Replace usage of std::cout and std::cerr by logger
abitmore Apr 8, 2021
6efa4c4
Add tests for program arguments in Github Actions
abitmore Apr 8, 2021
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
27 changes: 27 additions & 0 deletions .github/workflows/build-and-test.mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,33 @@ jobs:
libraries/fc/tests/run-parallel-tests.sh _build/tests/chain_test -l test_suite
_build/tests/cli_test -l test_suite
df -h
- name: Quick test for program arguments
run: |
_build/programs/witness_node/witness_node --version
_build/programs/witness_node/witness_node --help
if _build/programs/witness_node/witness_node --bad-arg ; then \
echo "Fail: did not get expected error."; false; \
else \
echo "Pass: got expected error."; \
fi
if _build/programs/witness_node/witness_node --plugins "account_history elasticsearch" ; then \
echo "Fail: did not get expected error."; false; \
else \
echo "Pass: got expected error."; \
fi
if _build/programs/witness_node/witness_node --rpc-endpoint --plugins "witness"; then \
echo "Fail: did not get expected error."; false; \
else \
echo "Pass: got expected error."; \
fi
_build/programs/cli_wallet/cli_wallet --version
_build/programs/cli_wallet/cli_wallet --help
_build/programs/cli_wallet/cli_wallet --suggest-brain-key
if _build/programs/cli_wallet/cli_wallet --bad-arg ; then \
echo "Fail: did not get expected error."; false; \
else \
echo "Pass: got expected error."; \
fi
- name: Node-Test
run: |
df -h
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/build-and-test.ubuntu-debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,33 @@ jobs:
libraries/fc/tests/run-parallel-tests.sh _build/tests/chain_test -l test_suite
_build/tests/cli_test -l test_suite
df -h
- name: Quick test for program arguments
run: |
_build/programs/witness_node/witness_node --version
_build/programs/witness_node/witness_node --help
if _build/programs/witness_node/witness_node --bad-arg ; then \
echo "Fail: did not get expected error."; false; \
else \
echo "Pass: got expected error."; \
fi
if _build/programs/witness_node/witness_node --plugins "account_history elasticsearch" ; then \
echo "Fail: did not get expected error."; false; \
else \
echo "Pass: got expected error."; \
fi
if _build/programs/witness_node/witness_node --rpc-endpoint --plugins "witness"; then \
echo "Fail: did not get expected error."; false; \
else \
echo "Pass: got expected error."; \
fi
_build/programs/cli_wallet/cli_wallet --version
_build/programs/cli_wallet/cli_wallet --help
_build/programs/cli_wallet/cli_wallet --suggest-brain-key
if _build/programs/cli_wallet/cli_wallet --bad-arg ; then \
echo "Fail: did not get expected error."; false; \
else \
echo "Pass: got expected error."; \
fi
- name: Node-Test
run: |
df -h
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/build-and-test.ubuntu-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,33 @@ jobs:
libraries/fc/tests/run-parallel-tests.sh _build/tests/chain_test -l test_suite
_build/tests/cli_test -l test_suite
df -h
- name: Quick test for program arguments
run: |
_build/programs/witness_node/witness_node --version
_build/programs/witness_node/witness_node --help
if _build/programs/witness_node/witness_node --bad-arg ; then \
echo "Fail: did not get expected error."; false; \
else \
echo "Pass: got expected error."; \
fi
if _build/programs/witness_node/witness_node --plugins "account_history elasticsearch" ; then \
echo "Fail: did not get expected error."; false; \
else \
echo "Pass: got expected error."; \
fi
if _build/programs/witness_node/witness_node --rpc-endpoint --plugins "witness"; then \
echo "Fail: did not get expected error."; false; \
else \
echo "Pass: got expected error."; \
fi
_build/programs/cli_wallet/cli_wallet --version
_build/programs/cli_wallet/cli_wallet --help
_build/programs/cli_wallet/cli_wallet --suggest-brain-key
if _build/programs/cli_wallet/cli_wallet --bad-arg ; then \
echo "Fail: did not get expected error."; false; \
else \
echo "Pass: got expected error."; \
fi
- name: Node-Test
run: |
df -h
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/sonar-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,33 @@ jobs:
echo "Cleanup"
rm -rf /tmp/graphene*
df -h
- name: Quick test for program arguments
run: |
_build/programs/witness_node/witness_node --version
_build/programs/witness_node/witness_node --help
if _build/programs/witness_node/witness_node --bad-arg ; then \
echo "Fail: did not get expected error."; false; \
else \
echo "Pass: got expected error."; \
fi
if _build/programs/witness_node/witness_node --plugins "account_history elasticsearch" ; then \
echo "Fail: did not get expected error."; false; \
else \
echo "Pass: got expected error."; \
fi
if _build/programs/witness_node/witness_node --rpc-endpoint --plugins "witness"; then \
echo "Fail: did not get expected error."; false; \
else \
echo "Pass: got expected error."; \
fi
_build/programs/cli_wallet/cli_wallet --version
_build/programs/cli_wallet/cli_wallet --help
_build/programs/cli_wallet/cli_wallet --suggest-brain-key
if _build/programs/cli_wallet/cli_wallet --bad-arg ; then \
echo "Fail: did not get expected error."; false; \
else \
echo "Pass: got expected error."; \
fi
- name: Prepare for scanning with SonarScanner
run: |
mkdir -p sonar_cache
Expand Down
26 changes: 17 additions & 9 deletions libraries/app/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,10 @@ namespace graphene { namespace app {

void network_broadcast_api::broadcast_transaction(const precomputable_transaction& trx)
{
FC_ASSERT( _app.p2p_node() != nullptr, "Not connected to P2P network, can't broadcast!" );
_app.chain_database()->precompute_parallel( trx ).wait();
_app.chain_database()->push_transaction(trx);
if( _app.p2p_node() != nullptr )
_app.p2p_node()->broadcast_transaction(trx);
_app.p2p_node()->broadcast_transaction(trx);
}

fc::variant network_broadcast_api::broadcast_transaction_synchronous(const precomputable_transaction& trx)
Expand All @@ -197,19 +197,19 @@ namespace graphene { namespace app {

void network_broadcast_api::broadcast_block( const signed_block& b )
{
FC_ASSERT( _app.p2p_node() != nullptr, "Not connected to P2P network, can't broadcast!" );
_app.chain_database()->precompute_parallel( b ).wait();
_app.chain_database()->push_block(b);
if( _app.p2p_node() != nullptr )
_app.p2p_node()->broadcast( net::block_message( b ));
_app.p2p_node()->broadcast( net::block_message( b ));
}

void network_broadcast_api::broadcast_transaction_with_callback(confirmation_callback cb, const precomputable_transaction& trx)
{
FC_ASSERT( _app.p2p_node() != nullptr, "Not connected to P2P network, can't broadcast!" );
_app.chain_database()->precompute_parallel( trx ).wait();
_callbacks[trx.id()] = cb;
_app.chain_database()->push_transaction(trx);
if( _app.p2p_node() != nullptr )
_app.p2p_node()->broadcast_transaction(trx);
_app.p2p_node()->broadcast_transaction(trx);
}

network_node_api::network_node_api( application& a ) : _app( a )
Expand All @@ -218,33 +218,41 @@ namespace graphene { namespace app {

fc::variant_object network_node_api::get_info() const
{
FC_ASSERT( _app.p2p_node() != nullptr, "No P2P network!" );
fc::mutable_variant_object result = _app.p2p_node()->network_get_info();
result["connection_count"] = _app.p2p_node()->get_connection_count();
return result;
}

void network_node_api::add_node(const fc::ip::endpoint& ep)
{
_app.p2p_node()->add_node(ep);
if( _app.p2p_node() != nullptr )
_app.p2p_node()->add_node(ep);
}

std::vector<net::peer_status> network_node_api::get_connected_peers() const
{
return _app.p2p_node()->get_connected_peers();
if( _app.p2p_node() != nullptr )
return _app.p2p_node()->get_connected_peers();
return {};
}

std::vector<net::potential_peer_record> network_node_api::get_potential_peers() const
{
return _app.p2p_node()->get_potential_peers();
if( _app.p2p_node() != nullptr )
return _app.p2p_node()->get_potential_peers();
return {};
}

fc::variant_object network_node_api::get_advanced_node_parameters() const
{
FC_ASSERT( _app.p2p_node() != nullptr, "No P2P network!" );
return _app.p2p_node()->get_advanced_node_parameters();
}

void network_node_api::set_advanced_node_parameters(const fc::variant_object& params)
{
FC_ASSERT( _app.p2p_node() != nullptr, "No P2P network!" );
return _app.p2p_node()->set_advanced_node_parameters(params);
}

Expand Down
Loading