Skip to content

Commit

Permalink
Fix --port and --listen-addr CLI-args handling (#1494)
Browse files Browse the repository at this point in the history
* feature: don't remove non-finalized block at FastWithoutState end
* fix: port and listen-addr CLI-args handling

Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
  • Loading branch information
xDimon authored Feb 20, 2023
1 parent 4416329 commit 7b52db1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
9 changes: 7 additions & 2 deletions core/application/impl/app_configuration_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,9 @@ namespace kagome::application {
}

fs::path AppConfigurationImpl::keystorePath(std::string chain_id) const {
if (keystore_path_) return *keystore_path_ / chain_id / "keystore";
if (keystore_path_) {
return *keystore_path_ / chain_id / "keystore";
}
return chainPath(chain_id) / "keystore";
}

Expand Down Expand Up @@ -1036,6 +1038,7 @@ namespace kagome::application {
return false; // just proxy erroneous case to the top level
}

// Check of possible address ambiguity
if (p2p_port_explicitly_defined_ and not listen_addresses_.empty()) {
SL_ERROR(logger_,
"Port and listen address must not be defined simultaneously; "
Expand All @@ -1058,7 +1061,9 @@ namespace kagome::application {
public_addresses_ = listen_addresses_;
}

if (p2p_port_explicitly_defined_ and listen_addresses_.empty()) {
// If listen address has not defined, listen P2P TCP-port on all
// accessible interfaces
if (listen_addresses_.empty()) {
// IPv6
{
auto ma_res = libp2p::multi::Multiaddress::create(
Expand Down
24 changes: 13 additions & 11 deletions core/consensus/babe/impl/babe_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,19 @@ namespace kagome::consensus::babe {

current_state_ = Babe::State::STATE_LOADING;

if (app_config_.syncMethod() == SyncMethod::FastWithoutState) {
if (app_state_manager_->state()
!= application::AppStateManager::State::ShuttingDown) {
SL_INFO(log_,
"Stateless fast sync is finished on block {}; "
"Application is stopping",
block_tree_->bestLeaf());
log_->flush();
app_state_manager_->shutdown();
}
return;
}

// Switch to last finalized to have a state on it
auto block_at_state = block_tree_->getLastFinalized();

Expand Down Expand Up @@ -572,17 +585,6 @@ namespace kagome::consensus::babe {
}
} while (affected);

if (app_config_.syncMethod() == SyncMethod::FastWithoutState) {
if (app_state_manager_->state()
!= application::AppStateManager::State::ShuttingDown) {
SL_INFO(log_,
"Stateless fast sync is finished; Application is stopping");
log_->flush();
app_state_manager_->shutdown();
}
return;
}

SL_TRACE(log_,
"Trying to sync state on block {} from {}",
block_at_state,
Expand Down

0 comments on commit 7b52db1

Please sign in to comment.