Skip to content

Commit ad55139

Browse files
sdk/ts: fix deserializeInterface to read flex_algo_node_segments for V2 (version 1); rustfmt
1 parent e898519 commit ad55139

4 files changed

Lines changed: 19 additions & 19 deletions

File tree

sdk/serviceability/typescript/serviceability/state.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -534,18 +534,16 @@ function deserializeInterface(r: DefensiveReader): DeviceInterface {
534534
iface.ipNet = r.readNetworkV4();
535535
iface.nodeSegmentIdx = r.readU16();
536536
iface.userTunnelEndpoint = r.readBool();
537-
if (iface.version === 2) {
538-
// V3
539-
const segCount = r.readU32();
540-
const flexAlgoNodeSegments: FlexAlgoNodeSegment[] = [];
541-
for (let i = 0; i < segCount; i++) {
542-
flexAlgoNodeSegments.push({
543-
topology: readPubkey(r),
544-
nodeSegmentIdx: r.readU16(),
545-
});
546-
}
547-
iface.flexAlgoNodeSegments = flexAlgoNodeSegments;
537+
// flex_algo_node_segments is part of V2 (version byte 1) and later
538+
const segCount = r.readU32();
539+
const flexAlgoNodeSegments: FlexAlgoNodeSegment[] = [];
540+
for (let i = 0; i < segCount; i++) {
541+
flexAlgoNodeSegments.push({
542+
topology: readPubkey(r),
543+
nodeSegmentIdx: r.readU16(),
544+
});
548545
}
546+
iface.flexAlgoNodeSegments = flexAlgoNodeSegments;
549547
}
550548

551549
return iface;

smartcontract/programs/doublezero-serviceability/src/instructions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ impl DoubleZeroInstruction {
510510
Self::SetUserBGPStatus(_) => "SetUserBGPStatus".to_string(), // variant 106
511511
Self::CreateTopology(_) => "CreateTopology".to_string(), // variant 107
512512
Self::DeleteTopology(_) => "DeleteTopology".to_string(), // variant 108
513-
Self::ClearTopology(_) => "ClearTopology".to_string(), // variant 109
513+
Self::ClearTopology(_) => "ClearTopology".to_string(), // variant 109
514514
Self::BackfillTopology(_) => "BackfillTopology".to_string(), // variant 110
515515
}
516516
}
@@ -644,7 +644,7 @@ impl DoubleZeroInstruction {
644644
Self::SetUserBGPStatus(args) => format!("{args:?}"), // variant 106
645645
Self::CreateTopology(args) => format!("{args:?}"), // variant 107
646646
Self::DeleteTopology(args) => format!("{args:?}"), // variant 108
647-
Self::ClearTopology(args) => format!("{args:?}"), // variant 109
647+
Self::ClearTopology(args) => format!("{args:?}"), // variant 109
648648
Self::BackfillTopology(args) => format!("{args:?}"), // variant 110
649649
}
650650
}

smartcontract/programs/doublezero-serviceability/src/pda.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ use crate::{
66
seeds::{
77
SEED_ACCESS_PASS, SEED_ADMIN_GROUP_BITS, SEED_CONFIG, SEED_CONTRIBUTOR, SEED_DEVICE,
88
SEED_DEVICE_TUNNEL_BLOCK, SEED_DZ_PREFIX_BLOCK, SEED_EXCHANGE, SEED_GLOBALSTATE,
9-
SEED_INDEX, SEED_LINK,
10-
SEED_LINK_IDS, SEED_LOCATION, SEED_MULTICASTGROUP_BLOCK, SEED_MULTICAST_GROUP,
11-
SEED_MULTICAST_PUBLISHER_BLOCK, SEED_PERMISSION, SEED_PREFIX, SEED_PROGRAM_CONFIG,
12-
SEED_SEGMENT_ROUTING_IDS, SEED_TENANT, SEED_TOPOLOGY, SEED_TUNNEL_IDS, SEED_USER,
13-
SEED_USER_TUNNEL_BLOCK, SEED_VRF_IDS,
9+
SEED_INDEX, SEED_LINK, SEED_LINK_IDS, SEED_LOCATION, SEED_MULTICASTGROUP_BLOCK,
10+
SEED_MULTICAST_GROUP, SEED_MULTICAST_PUBLISHER_BLOCK, SEED_PERMISSION, SEED_PREFIX,
11+
SEED_PROGRAM_CONFIG, SEED_SEGMENT_ROUTING_IDS, SEED_TENANT, SEED_TOPOLOGY, SEED_TUNNEL_IDS,
12+
SEED_USER, SEED_USER_TUNNEL_BLOCK, SEED_VRF_IDS,
1413
},
1514
state::user::UserType,
1615
};

smartcontract/programs/doublezero-serviceability/tests/delete_cyoa_interface_test.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,10 @@ async fn test_update_cyoa_interface_with_invalid_sibling() {
438438
.unwrap();
439439

440440
let updated_iface = device.find_interface("Ethernet1").unwrap().1;
441-
assert_eq!(updated_iface.mtu, 1500, "MTU should remain 1500 for CYOA interface");
441+
assert_eq!(
442+
updated_iface.mtu, 1500,
443+
"MTU should remain 1500 for CYOA interface"
444+
);
442445
assert_eq!(
443446
updated_iface.ip_net,
444447
"63.243.225.62/30".parse().unwrap(),

0 commit comments

Comments
 (0)