Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions overlay/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ stellar-xdr = { version = "=26.0.0", default-features = true }
libp2p = { version = "0.54", features = ["tokio", "macros", "identify", "quic"] }
libp2p-stream = "0.2.0-alpha"
futures = "0.3"
hickory-resolver = "0.24.4"

# Logging
tracing = "0.1"
Expand Down
8 changes: 7 additions & 1 deletion overlay/src/libp2p_overlay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ impl StellarOverlay {
}
OverlayCommand::DialPeer { peer_id, addr } => {
let opts = DialOpts::peer_id(peer_id)
.condition(PeerCondition::Disconnected)
.condition(PeerCondition::DisconnectedAndNotDialing)
.addresses(vec![addr.clone()])
.build();
self.state.metrics.outbound_attempt.fetch_add(1, Ordering::Relaxed);
Expand Down Expand Up @@ -4628,6 +4628,7 @@ async fn test_dial_peer_skips_when_connected() {

// Record outbound_attempt before the PeerId-based dial
let attempts_before = m1.outbound_attempt.load(Ordering::Relaxed);
let pending_before = m1.connection_pending.load(Ordering::Relaxed);

// PeerId-based dial should be a no-op (already connected)
handle1.dial_peer(peer_id2, addr2.clone()).await;
Expand All @@ -4638,11 +4639,16 @@ async fn test_dial_peer_skips_when_connected() {
// outbound_attempt increments (we submitted the command), but connection_pending
// should NOT have changed (DialPeer was rejected by libp2p before handshake)
let attempts_after = m1.outbound_attempt.load(Ordering::Relaxed);
let pending_after = m1.connection_pending.load(Ordering::Relaxed);
assert_eq!(
attempts_after,
attempts_before + 1,
"outbound_attempt should increment by 1"
);
assert_eq!(
pending_after, pending_before,
"connection_pending should not change for an already-connected peer"
);

handle1.shutdown().await;
handle2.shutdown().await;
Expand Down
261 changes: 201 additions & 60 deletions overlay/src/main.rs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/main/AppConnector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ AppConnector::getNetworkID() const
}

void
AppConnector::postOnMainThread(std::function<void()>&& f, std::string&& message,
Scheduler::ActionType type)
AppConnector::postOnMainThread(std::function<void()>&& f,
std::string&& message)
{
mApp.postOnMainThread(std::move(f), std::move(message), type);
mApp.postOnMainThread(std::move(f), std::move(message));
}

void
Expand Down
4 changes: 1 addition & 3 deletions src/main/AppConnector.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ class AppConnector

// Thread-safe methods
SorobanMetrics& getSorobanMetrics() const;
void postOnMainThread(
std::function<void()>&& f, std::string&& message,
Scheduler::ActionType type = Scheduler::ActionType::NORMAL_ACTION);
void postOnMainThread(std::function<void()>&& f, std::string&& message);
void postOnOverlayThread(std::function<void()>&& f,
std::string const& message);
void postOnBackgroundThread(std::function<void()>&& f,
Expand Down
5 changes: 2 additions & 3 deletions src/main/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,8 @@ class Application
virtual asio::io_context& getOverlayIOContext() = 0;
virtual asio::io_context& getLedgerCloseIOContext() = 0;

virtual void postOnMainThread(
std::function<void()>&& f, std::string&& name,
Scheduler::ActionType type = Scheduler::ActionType::NORMAL_ACTION) = 0;
virtual void postOnMainThread(std::function<void()>&& f,
std::string&& name) = 0;

// While both are lower priority than the main thread, eviction threads have
// more priority than regular worker background threads
Expand Down
6 changes: 2 additions & 4 deletions src/main/ApplicationImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1536,8 +1536,7 @@ ApplicationImpl::getLedgerCloseIOContext()
}

void
ApplicationImpl::postOnMainThread(std::function<void()>&& f, std::string&& name,
Scheduler::ActionType type)
ApplicationImpl::postOnMainThread(std::function<void()>&& f, std::string&& name)
{
JITTER_INJECT_DELAY();
LogSlowExecution isSlow{name, LogSlowExecution::Mode::MANUAL,
Expand All @@ -1554,8 +1553,7 @@ ApplicationImpl::postOnMainThread(std::function<void()>&& f, std::string&& name,
std::this_thread::sleep_for(sleepFor);
}
f();
},
std::move(name), type);
});
}

void
Expand Down
4 changes: 2 additions & 2 deletions src/main/ApplicationImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ class ApplicationImpl : public Application
virtual asio::io_context& getOverlayIOContext() override;
virtual asio::io_context& getLedgerCloseIOContext() override;

virtual void postOnMainThread(std::function<void()>&& f, std::string&& name,
Scheduler::ActionType type) override;
virtual void postOnMainThread(std::function<void()>&& f,
std::string&& name) override;
virtual void postOnBackgroundThread(std::function<void()>&& f,
std::string jobName) override;
virtual void postOnEvictionBackgroundThread(std::function<void()>&& f,
Expand Down
2 changes: 2 additions & 0 deletions src/main/CommandHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,8 @@ CommandHandler::info(std::string const& params, std::string& retStr)
std::map<std::string, std::string> retMap;
http::server::server::parseParams(params, retMap);

mApp.syncAllMetrics();

retStr = mApp.getJsonInfo(retMap["compact"] == "false").toStyledString();
}

Expand Down
1 change: 1 addition & 0 deletions src/process/ProcessManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <deque>
#include <mutex>
#include <vector>
#include <map>

namespace stellar
{
Expand Down
Loading
Loading