Skip to content
Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ All notable changes to this project will be documented in this file.

### Changes

- Smartcontract
- Migrate read callers in the CLI, sentinel, client, controlplane admin, and Rust SDK topology helper to read interfaces from `Device::new_interfaces` instead of the legacy `interfaces` enum vec, and adopt the `Device::find_interface` signature that returns `&NewInterface`. The legacy `interfaces` slot is still written on-disk via the per-write V2 projection from #3667; this PR only migrates reads. The temporary `Device::find_interface_legacy` helper is retained for the smartcontract program processors, which migrate in a later issue. Activator is intentionally excluded — it is deprecated ([#3659](https://github.com/malbeclabs/doublezero/issues/3659))
- Activator
- Delete the `activator/` crate from the workspace; onchain allocation (RFC-11) supersedes it. The deployed activator was frozen in Phase 1 ([#3608](https://github.com/malbeclabs/doublezero/pull/3608), [#3628](https://github.com/malbeclabs/doublezero/pull/3628)) and removed from e2e in Phase 2 ([#3609](https://github.com/malbeclabs/doublezero/pull/3609), [#3610](https://github.com/malbeclabs/doublezero/pull/3610), [#3611](https://github.com/malbeclabs/doublezero/pull/3611), [#3629](https://github.com/malbeclabs/doublezero/pull/3629)). The `*/activate`, `*/reject`, and `*/closeaccount` onchain instructions and their SDK command modules remain in place for older CLIs until the min-version gate ([#3612](https://github.com/malbeclabs/doublezero/issues/3612))
- Smartcontract
Expand Down
3 changes: 1 addition & 2 deletions client/doublezero/src/dzd_latency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ pub(crate) fn get_device_tunnel_endpoints(device: &Device) -> Vec<Ipv4Addr> {
let mut endpoints = vec![device.public_ip];

// Add all UserTunnelEndpoint interfaces
for iface in &device.interfaces {
let iface = iface.into_current_version();
for iface in &device.new_interfaces {
if iface.user_tunnel_endpoint && iface.ip_net != Default::default() {
endpoints.push(iface.ip_net.ip());
}
Expand Down
7 changes: 3 additions & 4 deletions controlplane/doublezero-admin/src/cli/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,9 @@ impl FlexAlgoMigrateCliCommand {
let mut devices_needing_backfill: Vec<Pubkey> = Vec::new();

for (device_pubkey, device) in &device_entries {
let needs_backfill = device.interfaces.iter().any(|iface| {
let current = iface.into_v3();
current.loopback_type == LoopbackType::Vpnv4
&& !current
let needs_backfill = device.new_interfaces.iter().any(|iface| {
iface.loopback_type == LoopbackType::Vpnv4
&& !iface
.flex_algo_node_segments
.iter()
.any(|s| s.topology == *topology_pubkey)
Expand Down
3 changes: 1 addition & 2 deletions crates/sentinel/src/dz_ledger_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,9 @@ pub fn fetch_device_infos(
.copied()
.unwrap_or((0.0, 0.0));
let user_tunnel_endpoints = device
.interfaces
.new_interfaces
.iter()
.filter_map(|iface| {
let iface = iface.into_current_version();
if iface.user_tunnel_endpoint && iface.ip_net != Default::default() {
Some(iface.ip_net.ip())
} else {
Expand Down
3 changes: 1 addition & 2 deletions crates/sentinel/src/multicast_publisher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,10 +468,9 @@ impl MulticastDzLedgerClient for RpcMulticastDzLedgerClient {
continue;
}
let user_tunnel_endpoints = device
.interfaces
.new_interfaces
.iter()
.filter_map(|iface| {
let iface = iface.into_current_version();
if iface.user_tunnel_endpoint && iface.ip_net != Default::default() {
Some(iface.ip_net.ip())
} else {
Expand Down
14 changes: 5 additions & 9 deletions smartcontract/cli/src/device/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use doublezero_sdk::{
contributor::get::GetContributorCommand, device::get::GetDeviceCommand,
exchange::get::GetExchangeCommand,
},
GetLocationCommand, Interface,
GetLocationCommand, NewInterface,
};
use serde::Serialize;
use solana_sdk::pubkey::Pubkey;
Expand Down Expand Up @@ -45,11 +45,8 @@ struct InterfaceDisplay {
pub tunnel_endpoint: bool,
}

impl From<&Interface> for InterfaceDisplay {
fn from(iface: &Interface) -> Self {
// Convert to current version to ensure all fields are populated, even if the stored version is older
let iface = iface.into_current_version();

impl From<&NewInterface> for InterfaceDisplay {
fn from(iface: &NewInterface) -> Self {
Self {
name: iface.name.clone(),
status: iface.status.to_string(),
Expand Down Expand Up @@ -145,16 +142,15 @@ impl GetDeviceCliCommand {
public_ip: device.public_ip.to_string(),
dz_prefixes: device.dz_prefixes.to_string(),
cyoa_ips: device
.interfaces
.new_interfaces
.iter()
.map(|iface| iface.into_current_version())
.filter(|iface| iface.user_tunnel_endpoint)
.map(|iface| iface.ip_net.to_string())
.collect(),
metrics_publisher: device.metrics_publisher_pk.to_string(),
mgmt_vrf: device.mgmt_vrf,
interfaces: device
.interfaces
.new_interfaces
.iter()
.map(InterfaceDisplay::from)
.collect(),
Expand Down
16 changes: 8 additions & 8 deletions smartcontract/cli/src/device/interface/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ impl CreateDeviceInterfaceCliCommand {
.map_err(|_| eyre::eyre!("Device with pubkey/code '{}' not found", self.device))?;

device
.interfaces
.new_interfaces
.iter()
.find(|i| i.into_current_version().name == self.name)
.find(|i| i.name == self.name)
.map_or(Ok(()), |_| {
Err(eyre::eyre!(
"Interface with name '{}' already exists",
Expand Down Expand Up @@ -101,8 +101,7 @@ impl CreateDeviceInterfaceCliCommand {
if dev.contributor_pk != device.contributor_pk {
continue;
}
for iface in &dev.interfaces {
let iface = iface.into_current_version();
for iface in &dev.new_interfaces {
if iface.ip_net == *ip_net {
eyre::bail!(
"IP {} is already assigned to interface {} on device {}",
Expand Down Expand Up @@ -209,7 +208,8 @@ mod tests {
metrics_publisher_pk: Pubkey::default(),
owner: device2_pubkey,
mgmt_vrf: "default".to_string(),
interfaces: vec![CurrentInterfaceVersion {
interfaces: vec![],
new_interfaces: vec![(&CurrentInterfaceVersion {
status: InterfaceStatus::Activated,
name: "Loopback100".to_string(),
interface_type: InterfaceType::Loopback,
Expand All @@ -224,9 +224,9 @@ mod tests {
ip_net: "185.189.47.80/32".parse().unwrap(),
node_segment_idx: 0,
user_tunnel_endpoint: false,
}
.to_interface()],
new_interfaces: vec![],
})
.try_into()
.unwrap()],
max_users: 255,
users_count: 0,
device_health: doublezero_serviceability::state::device::DeviceHealth::ReadyForUsers,
Expand Down
20 changes: 11 additions & 9 deletions smartcontract/cli/src/device/interface/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl DeleteDeviceInterfaceCliCommand {
.map_err(|_| eyre::eyre!("Device not found"))?;

let (_, iface) = device
.find_interface_legacy(&self.name)
.find_interface(&self.name)
.map_err(|err| eyre::eyre!(err))?;

// if a physical interface is Activated, it's part of a link and shouldn't be deleted.
Expand Down Expand Up @@ -93,8 +93,9 @@ mod tests {
metrics_publisher_pk: Pubkey::default(),
owner: Pubkey::default(),
mgmt_vrf: "default".to_string(),
interfaces: vec![
CurrentInterfaceVersion {
interfaces: vec![],
new_interfaces: vec![
(&CurrentInterfaceVersion {
status: InterfaceStatus::Unlinked,
name: "Ethernet0".to_string(),
interface_type: InterfaceType::Physical,
Expand All @@ -109,9 +110,10 @@ mod tests {
ip_net: "10.0.0.1/24".parse().unwrap(),
node_segment_idx: 12,
user_tunnel_endpoint: true,
}
.to_interface(),
CurrentInterfaceVersion {
})
.try_into()
.unwrap(),
(&CurrentInterfaceVersion {
status: InterfaceStatus::Activated,
name: "Loopback0".to_string(),
interface_type: InterfaceType::Loopback,
Expand All @@ -126,10 +128,10 @@ mod tests {
ip_net: "10.0.1.1/24".parse().unwrap(),
node_segment_idx: 13,
user_tunnel_endpoint: false,
}
.to_interface(),
})
.try_into()
.unwrap(),
],
new_interfaces: vec![],
max_users: 255,
users_count: 0,
device_health: doublezero_serviceability::state::device::DeviceHealth::ReadyForUsers,
Expand Down
14 changes: 7 additions & 7 deletions smartcontract/cli/src/device/interface/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,13 @@ impl GetDeviceInterfaceCliCommand {
})?;

let interface = device
.interfaces
.new_interfaces
.iter()
.map(|i| i.into_current_version())
.find(|i| i.name.to_lowercase() == self.name.to_lowercase())
.ok_or_else(|| eyre::eyre!("Interface '{}' not found", self.name))?;

let display = InterfaceDisplay {
name: interface.name,
name: interface.name.clone(),
status: interface.status.to_string(),
loopback_type: interface.loopback_type.to_string(),
interface_cyoa: interface.interface_cyoa.to_string(),
Expand Down Expand Up @@ -121,7 +120,8 @@ mod tests {
),
owner: device1_pubkey,
mgmt_vrf: "default".to_string(),
interfaces: vec![CurrentInterfaceVersion {
interfaces: vec![],
new_interfaces: vec![(&CurrentInterfaceVersion {
status: InterfaceStatus::Activated,
name: "eth0".to_string(),
interface_type: InterfaceType::Physical,
Expand All @@ -136,9 +136,9 @@ mod tests {
ip_net: "10.0.0.1/24".parse().unwrap(),
node_segment_idx: 42,
user_tunnel_endpoint: true,
}
.to_interface()],
new_interfaces: vec![],
})
.try_into()
.unwrap()],
max_users: 255,
users_count: 0,
device_health: doublezero_serviceability::state::device::DeviceHealth::ReadyForUsers,
Expand Down
30 changes: 16 additions & 14 deletions smartcontract/cli/src/device/interface/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use clap::Args;
use doublezero_program_common::types::NetworkV4;
use doublezero_sdk::{
commands::device::{get::GetDeviceCommand, list::ListDeviceCommand},
CurrentInterfaceVersion, InterfaceType,
InterfaceType, NewInterface,
};
use doublezero_serviceability::state::interface::{
InterfaceCYOA, InterfaceDIA, LoopbackType, RoutingMode,
Expand Down Expand Up @@ -56,9 +56,9 @@ impl ListDeviceInterfaceCliCommand {
.map_err(|_| eyre::eyre!("Device not found"))?;

device
.interfaces
.new_interfaces
.iter()
.map(|iface| build_display(&iface.into_current_version(), &device.code))
.map(|iface| build_display(iface, &device.code))
.collect()
} else {
let devices = client.list_device(ListDeviceCommand {})?;
Expand All @@ -67,9 +67,9 @@ impl ListDeviceInterfaceCliCommand {
.iter()
.flat_map(|(_, device)| {
device
.interfaces
.new_interfaces
.iter()
.map(|iface| build_display(&iface.into_current_version(), &device.code))
.map(|iface| build_display(iface, &device.code))
})
.collect()
};
Expand All @@ -90,7 +90,7 @@ impl ListDeviceInterfaceCliCommand {
}
}

fn build_display(iface: &CurrentInterfaceVersion, device_code: &str) -> DeviceInterfaceDisplay {
fn build_display(iface: &NewInterface, device_code: &str) -> DeviceInterfaceDisplay {
DeviceInterfaceDisplay {
device: device_code.to_string(),
name: iface.name.clone(),
Expand Down Expand Up @@ -147,8 +147,9 @@ mod tests {
metrics_publisher_pk: Pubkey::default(),
owner: Pubkey::from_str_const("1111111FVAiSujNZVgYSc27t6zUTWoKfAGxbRzzPB"),
mgmt_vrf: "default".to_string(),
interfaces: vec![
CurrentInterfaceVersion {
interfaces: vec![],
new_interfaces: vec![
(&CurrentInterfaceVersion {
status: InterfaceStatus::Activated,
name: "eth0".to_string(),
interface_type: InterfaceType::Physical,
Expand All @@ -164,9 +165,10 @@ mod tests {
ip_net: "10.0.0.1/24".parse().unwrap(),
node_segment_idx: 12,
user_tunnel_endpoint: true,
}
.to_interface(),
CurrentInterfaceVersion {
})
.try_into()
.unwrap(),
(&CurrentInterfaceVersion {
status: InterfaceStatus::Activated,
name: "lo0".to_string(),
interface_type: InterfaceType::Loopback,
Expand All @@ -182,10 +184,10 @@ mod tests {
ip_net: "10.0.1.1/24".parse().unwrap(),
node_segment_idx: 13,
user_tunnel_endpoint: false,
}
.to_interface(),
})
.try_into()
.unwrap(),
],
new_interfaces: vec![],
max_users: 255,
users_count: 0,
device_health: doublezero_serviceability::state::device::DeviceHealth::ReadyForUsers,
Expand Down
Loading
Loading