Skip to content

feat: add peer transport preference modes#7851

Open
caozhengming wants to merge 2 commits into
tari-project:developmentfrom
caozhengming:bounty-7830-transport-preferences
Open

feat: add peer transport preference modes#7851
caozhengming wants to merge 2 commits into
tari-project:developmentfrom
caozhengming:bounty-7830-transport-preferences

Conversation

@caozhengming
Copy link
Copy Markdown

Fixes #7830

Summary

  • add TorTcp and TcpTor peer transport modes, with TcpTor as the default
  • restrict peer protocol availability per mode and apply transport preference order before dialing addresses
  • add unit coverage for mode protocol order and dial address ordering
  • add a Cucumber feature covering all four peer transport modes

Validation

  • git diff --check
  • cargo fmt/test not run locally because this Windows environment does not have cargo/rustfmt installed

@github-actions
Copy link
Copy Markdown

⚠️ This PR contains unsigned commits. To get your PR merged, please sign those commits (git rebase --exec 'git commit -S --amend --no-edit -n' @{upstream}) and force push them to this branch (git push --force-with-lease).

If you're new to commit signing, there are different ways to set it up:

Sign commits with gpg

Follow the steps below to set up commit signing with gpg:

  1. Generate a GPG key
  2. Add the GPG key to your GitHub account
  3. Configure git to use your GPG key for commit signing
Sign commits with ssh-agent

Follow the steps below to set up commit signing with ssh-agent:

  1. Generate an SSH key and add it to ssh-agent
  2. Add the SSH key to your GitHub account
  3. Configure git to use your SSH key for commit signing
Sign commits with 1Password

You can also sign commits using 1Password, which lets you sign commits with biometrics without the signing key leaving the local 1Password process.

Learn how to use 1Password to sign your commits.

Watch the demo

@caozhengming caozhengming force-pushed the bounty-7830-transport-preferences branch from f2f5dbe to 691bcb2 Compare May 25, 2026 16:24
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces new transport types, TorTcp and TcpTor, and updates the default transport configuration to TcpTor. It implements logic to prioritize and sort dial addresses based on the selected transport's protocol preferences. Additionally, it refines protocol support for existing transport types, such as restricting the Tor transport to the Onion protocol, and includes comprehensive unit and integration tests to verify these changes. I have no feedback to provide.

proxy_bypass_predicate: Arc::new(FalsePredicate::new()),
});
}
transport.set_supported_protocols(TransportType::Tcp.get_supported_protocols());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this above needs updating as well

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this part is still not correct

# This setting is optional however, if it is not specified, this node will not be able to connect to nodes that
# only advertise an onion address. (default = )
# Configures a tor proxy available to the TCP transport. Peer selection only includes onion addresses when using
# type = "tor", "tor_tcp" or "tcp_tor". (default = )
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fill in the default here

use tari_integration_tests::TariWorld;
use tari_p2p::TransportType;

#[then(expr = "peer transport mode {word} supports protocols {string}")]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is simply unit tests parading as cucumber tests, cucumber tests will test connectivity and the dailed addresses between actual running nodes

@caozhengming caozhengming force-pushed the bounty-7830-transport-preferences branch from 691bcb2 to dd9a84f Compare May 28, 2026 01:39
@caozhengming
Copy link
Copy Markdown
Author

Thanks for the review. I pushed dd9a84f addressing the requested changes:

  • updated the TCP initialization path so the explicit TCP mode is logged and kept TCP-only even if legacy tor_socks_address config is present; mixed TCP/Tor modes continue through the hidden-service variants
  • filled the config default wording for tcp.tor_socks_address as none in the base node and wallet presets
  • removed the cucumber feature/steps that were only unit-style assertions, leaving the protocol/preference behavior covered by unit tests instead of presenting them as integration connectivity coverage

The commit is SSH-signed and the signed-commit check is green. I could not run the Rust test suite locally in this environment because cargo is not installed.

@SWvheerden
Copy link
Copy Markdown
Collaborator

there is that missing part in initi thats not correct

@caozhengming
Copy link
Copy Markdown
Author

Thanks, I found the remaining initialization issue and pushed 8b38730. The explicit Tcp transport branch no longer configures the legacy tor_socks_address proxy path, so Tcp stays TCP-only. The mixed TcpTor/TorTcp modes continue through the Tor hidden-service transport branch where the protocol availability/order is set from the selected TransportType.\n\nVerification: git diff --check. I still cannot run the Rust tests locally because cargo is not installed in this environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Connection types

2 participants