Skip to content

Commit 00e51df

Browse files
authored
Merge pull request #102 from IntersectMBO/remove_legacy_networking
refactor: remove legacy networking support and configs
2 parents aef2038 + ba355d0 commit 00e51df

File tree

12 files changed

+25
-101
lines changed

12 files changed

+25
-101
lines changed

src/cardonnay/inspect_instance.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,6 @@ def get_config(statedir: pl.Path) -> structs.CombinedConfig:
254254
open(statedir / "config-pool1.json", encoding="utf-8") as fp_in,
255255
):
256256
data = json.load(fp_in)
257-
config.EnableP2P = data.get("EnableP2P")
258257
config.ledgerdb_backend = (
259258
data.get("LedgerDB", {}).get("Backend", "default") if "LedgerDB" in data else "default"
260259
)

src/cardonnay/local_scripts.py

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -154,21 +154,8 @@ def _replace_instance_files(
154154
new_content = new_content.replace("%%WEBSERVER_PORT%%", str(instance_ports.webserver))
155155
return new_content
156156

157-
def _gen_legacy_topology(self, addr: str, ports: tp.Iterable[int]) -> dict:
158-
"""Generate legacy topology for given ports."""
159-
producers = [
160-
{
161-
"addr": addr,
162-
"port": port,
163-
"valency": 1,
164-
}
165-
for port in ports
166-
]
167-
topology = {"Producers": producers}
168-
return topology
169-
170157
def _gen_p2p_topology(self, addr: str, ports: list[int], fixed_ports: list[int]) -> dict:
171-
"""Generate p2p topology for given ports."""
158+
"""Generate topology for given ports."""
172159
# Select fixed ports and several randomly selected ports
173160
rand_threshold = 3
174161
sample_ports = random.sample(ports, 3) if len(ports) > rand_threshold else ports
@@ -234,23 +221,14 @@ def _gen_topology_files(
234221
all_except = all_nodes[:]
235222
all_except.remove(node_rec.node)
236223
node_name = "bft1" if node_rec.num == 0 else f"pool{node_rec.num}"
237-
238-
# Legacy topology
239-
240-
topology = self._gen_legacy_topology(addr=addr, ports=all_except)
241-
helpers.write_json(out_file=destdir / f"topology-{node_name}.json", content=topology)
242-
243-
# P2P topology
244-
245224
# Bft1 and first three pools
246225
fixed_ports = all_except[:4]
247226

248-
p2p_topology = self._gen_p2p_topology(
227+
topology_content = self._gen_p2p_topology(
249228
addr=addr, ports=all_except, fixed_ports=fixed_ports
250229
)
251-
252230
helpers.write_json(
253-
out_file=destdir / f"p2p-topology-{node_name}.json", content=p2p_topology
231+
out_file=destdir / f"topology-{node_name}.json", content=topology_content
254232
)
255233

256234
def _reconfigure_local(self, indir: pl.Path, destdir: pl.Path, instance_num: int) -> None:

src/cardonnay/structs.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ class CombinedConfig(pydantic.BaseModel):
8686
govActionLifetime: int | None = None # noqa: N815
8787

8888
# Pool1 config-pool1.json
89-
EnableP2P: bool | None = None
9089
ledgerdb_backend: str = "default"
9190

9291
# Derived

src/cardonnay_scripts/scripts/common/common-start-fast

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -269,34 +269,6 @@ edit_node_configs() {
269269
end
270270
| if (.LedgerDB? // {}) == {} then del(.LedgerDB) else . end
271271
' "$conf" > "${STATE_CLUSTER}/${fname}"
272-
273-
if ! is_truthy "${ENABLE_LEGACY:-}"; then
274-
if is_truthy "${MIXED_P2P:-}"; then
275-
if [ -z "$pool_num" ]; then
276-
cp -f "$SCRIPT_DIR"/topology-bft1.json "$STATE_CLUSTER"
277-
continue
278-
fi
279-
280-
if [ "$((pool_num % 2))" != 0 ]; then
281-
cp -f "${SCRIPT_DIR}/topology-pool${pool_num}.json" "$STATE_CLUSTER"
282-
continue
283-
fi
284-
fi
285-
286-
jq \
287-
'.EnableP2P = true
288-
| .MaxConcurrencyBulkSync = 2
289-
| .MaxConcurrencyDeadline = 4
290-
| .TargetNumberOfRootPeers = 100
291-
| .TargetNumberOfKnownPeers = 100
292-
| .TargetNumberOfEstablishedPeers = 50
293-
| .TargetNumberOfActivePeers = 20
294-
| .TraceBlockFetchClient = true
295-
| .TraceChainSyncClient = true' \
296-
"${STATE_CLUSTER}/${fname}" > "${STATE_CLUSTER}/${fname}_jq"
297-
cat "${STATE_CLUSTER}/${fname}_jq" > "${STATE_CLUSTER}/${fname}"
298-
rm -f "${STATE_CLUSTER}/${fname}_jq"
299-
fi
300272
done
301273
}
302274

src/cardonnay_scripts/scripts/common/common-start-slow

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ edit_node_configs() {
229229
utxo_backend=""
230230
fi
231231

232-
233232
jq \
234233
--arg byron_hash "$BYRON_GENESIS_HASH" \
235234
--arg shelley_hash "$SHELLEY_GENESIS_HASH" \
@@ -266,34 +265,6 @@ edit_node_configs() {
266265
end
267266
| if (.LedgerDB? // {}) == {} then del(.LedgerDB) else . end
268267
' "$conf" > "${STATE_CLUSTER}/${fname}"
269-
270-
if ! is_truthy "${ENABLE_LEGACY:-}"; then
271-
if is_truthy "${MIXED_P2P:-}"; then
272-
if [ -z "$pool_num" ]; then
273-
cp -f "$SCRIPT_DIR"/topology-bft1.json "$STATE_CLUSTER"
274-
continue
275-
fi
276-
277-
if [ "$((pool_num % 2))" != 0 ]; then
278-
cp -f "${SCRIPT_DIR}/topology-pool${pool_num}.json" "$STATE_CLUSTER"
279-
continue
280-
fi
281-
fi
282-
283-
jq \
284-
'.EnableP2P = true
285-
| .MaxConcurrencyBulkSync = 2
286-
| .MaxConcurrencyDeadline = 4
287-
| .TargetNumberOfRootPeers = 100
288-
| .TargetNumberOfKnownPeers = 100
289-
| .TargetNumberOfEstablishedPeers = 50
290-
| .TargetNumberOfActivePeers = 20
291-
| .TraceBlockFetchClient = true
292-
| .TraceChainSyncClient = true' \
293-
"${STATE_CLUSTER}/${fname}" > "${STATE_CLUSTER}/${fname}_jq"
294-
cat "${STATE_CLUSTER}/${fname}_jq" > "${STATE_CLUSTER}/${fname}"
295-
rm -f "${STATE_CLUSTER}/${fname}_jq"
296-
fi
297268
done
298269
}
299270

src/cardonnay_scripts/scripts/common/common.sh

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -410,17 +410,7 @@ setup_state_cluster() {
410410
cp "$SCRIPT_DIR/testnet.json" "$STATE_CLUSTER"
411411
cp "$SCRIPT_DIR"/*genesis*.spec.json "$genesis_init_dir"
412412
cp "$SCRIPT_DIR"/cost_models*.json "$genesis_init_dir" 2>/dev/null || true
413-
414-
if ! is_truthy "${ENABLE_LEGACY:-}"; then
415-
local tconf tfname
416-
for tconf in "$SCRIPT_DIR"/p2p-topology-*.json; do
417-
[ -e "$tconf" ] || { echo "No p2p topology files found in ${SCRIPT_DIR}, line $LINENO in ${BASH_SOURCE[0]}" >&2; exit 1; }
418-
tfname="${tconf##*/p2p-}"
419-
cp "$tconf" "${STATE_CLUSTER}/${tfname}"
420-
done
421-
else
422-
cp "$SCRIPT_DIR"/topology-*.json "$STATE_CLUSTER"
423-
fi
413+
cp "$SCRIPT_DIR"/topology-*.json "$STATE_CLUSTER"
424414
}
425415

426416
create_dreps_files() {

src/cardonnay_scripts/scripts/conway_fast/template-config.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,13 @@
179179
"scRotation": null
180180
}
181181
],
182+
"EnableP2P": true,
183+
"MaxConcurrencyBulkSync": 2,
184+
"MaxConcurrencyDeadline": 4,
185+
"TargetNumberOfRootPeers": 100,
186+
"TargetNumberOfKnownPeers": 100,
187+
"TargetNumberOfEstablishedPeers": 50,
188+
"TargetNumberOfActivePeers": 20,
182189
"TestShelleyHardForkAtEpoch": 0,
183190
"TestAllegraHardForkAtEpoch": 0,
184191
"TestMaryHardForkAtEpoch": 0,

src/cardonnay_scripts/scripts/conway_fast/testnet.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
"control_env": {
55
"DBSYNC_SCHEMA_DIR": "will start and configure db-sync if the value is path to db-sync schema directory",
66
"SMASH": "if set, will start and configure smash",
7-
"ENABLE_LEGACY": "if set, local cluster will use legacy networking",
8-
"MIXED_P2P": "if set, local cluster will use P2P for some nodes and legacy topology for others",
97
"ENABLE_EXPERIMENTAL": "if set, experimental features will be enabled in the local cluster",
108
"UTXO_BACKEND": "'mem', 'disk', 'disklmdb' or `empty`, default is `empty` (mem without configuration) if unset",
119
"NO_CC": "if set, will not create committee",

src/cardonnay_scripts/scripts/conway_slow/template-config.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@
5353
"TracingVerbosity": "NormalVerbosity",
5454
"TurnOnLogMetrics": true,
5555
"TurnOnLogging": true,
56+
"EnableP2P": true,
57+
"MaxConcurrencyBulkSync": 2,
58+
"MaxConcurrencyDeadline": 4,
59+
"TargetNumberOfRootPeers": 100,
60+
"TargetNumberOfKnownPeers": 100,
61+
"TargetNumberOfEstablishedPeers": 50,
62+
"TargetNumberOfActivePeers": 20,
5663
"defaultBackends": [
5764
"KatipBK"
5865
],

src/cardonnay_scripts/scripts/conway_slow/testnet.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
"control_env": {
55
"DBSYNC_SCHEMA_DIR": "will start and configure db-sync if the value is path to db-sync schema directory",
66
"SMASH": "if set, will start and configure smash",
7-
"ENABLE_LEGACY": "if set, local cluster will use legacy networking",
8-
"MIXED_P2P": "if set, local cluster will use P2P for some nodes and legacy topology for others",
97
"ENABLE_EXPERIMENTAL": "if set, experimental features will be enabled in the local cluster",
108
"UTXO_BACKEND": "'mem', 'disk', 'disklmdb' or `empty`, default is `empty` (mem without configuration) if unset",
119
"NO_CC": "if set, will not create committee",

0 commit comments

Comments
 (0)