Merge sole-store context change into the next-side

Bring the immutable-state single-store change onto the Noise XX line.
The shared NodeContext is now the sole store; this merge applies the
next-only adaptations the master-side change couldn't carry:

- Remove node_profile from the Node struct (next-only field) so it lives
  solely in NodeContext; migrate its readers (tree/bloom/discovery/
  handshake negotiation) onto the node_profile() accessor. The two FMP
  negotiation sites hoist node_profile() into a local to avoid borrowing
  &self while a connection is mutably borrowed.
- leaf_only sets both is_leaf_only and node_profile via the context swap.
- Preserve the XX handshake/rekey structure (no identity-in-msg1; XX/XK
  initiator/responder constructors) while applying the startup_epoch()
  accessor migration.
- Tests: route profile selection through a make_test_node_with_profile
  helper (profile is immutable, set via Config flags) instead of poking
  the removed field.

cargo test --lib 1369/0; clippy -D warnings and release build clean.
This commit is contained in:
Johnathan Corgan
2026-06-02 17:30:15 +00:00
19 changed files with 250 additions and 253 deletions
+21 -2
View File
@@ -30,10 +30,29 @@ pub(super) async fn make_test_node() -> TestNode {
/// Create a test node with a specific transport MTU.
pub(super) async fn make_test_node_with_mtu(mtu: u16) -> TestNode {
make_test_node_inner(Config::new(), mtu).await
}
/// Create a test node with a specific routing profile. Profile is immutable
/// (lives in the shared context), so it is set via the `Config` flags that
/// `Config::node_profile()` reads rather than poked post-construction.
pub(super) async fn make_test_node_with_profile(profile: crate::protocol::NodeProfile) -> TestNode {
use crate::protocol::NodeProfile;
let mut config = Config::new();
match profile {
NodeProfile::Leaf => config.node.leaf_only = true,
NodeProfile::NonRouting => config.node.disable_routing = true,
NodeProfile::Full => {}
}
make_test_node_inner(config, 1280).await
}
/// Shared builder: a test node from an explicit `Config` and transport MTU.
async fn make_test_node_inner(config: Config, mtu: u16) -> TestNode {
use crate::config::UdpConfig;
use crate::transport::udp::UdpTransport;
let mut node = make_node();
let mut node = make_node_with(config);
let transport_id = TransportId::new(1);
// recv_buf_size and packet_channel are sized for large-network harness
@@ -90,7 +109,7 @@ pub(super) async fn initiate_handshake(nodes: &mut [TestNode], i: usize, j: usiz
let our_index = initiator.node.index_allocator.allocate().unwrap();
let our_keypair = initiator.node.identity().keypair();
let noise_msg1 = conn
.start_handshake(our_keypair, initiator.node.startup_epoch, 1000)
.start_handshake(our_keypair, initiator.node.startup_epoch(), 1000)
.unwrap();
conn.set_our_index(our_index);
conn.set_transport_id(transport_id);