Skip to content

Commit bfafb44

Browse files
committed
feat: update simulation activity logic and volumes configuration
1 parent 98ed68d commit bfafb44

File tree

4 files changed

+34
-15
lines changed

4 files changed

+34
-15
lines changed

docker/nodes.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@
5959
"0.3.3-alpha": "0.16.0-beta",
6060
"0.3.2-alpha": "0.16.0-beta"
6161
}
62-
},
63-
"simln": {
64-
"latest": "0.2.0",
65-
"versions": ["0.2.0"]
6662
}
6763
}
6864
}

src/components/designer/default/cards/ActivityDesignerCard.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,10 @@ const ActivityDesignerCard: React.FC<Props> = ({ visible, network }) => {
186186

187187
useEffect(() => {
188188
isSimulationContainerRunning().then(isRunning => {
189+
console.log('isRunning', isRunning);
189190
setIsStartSimulationActive(isRunning);
190191
});
191-
}, []);
192+
}, [isSimulationContainerRunning]);
192193

193194
const startSimulationActivity = () => {
194195
if (network.status !== Status.Started) {

src/lib/docker/dockerService.ts

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,30 @@ class DockerService implements DockerLibrary {
178178
const nodes = new Set();
179179
const activities = new Set();
180180
network.simulationActivities.map(activity => {
181+
const { source, destination } = activity;
182+
// split the macaroon and cert path at "volumes/" to get the relative path
183+
// to the docker volume. This is necessary because the docker volumes are
184+
// mounted as a different path in the container
185+
const sourceMacaroon = source.macaroon.split('volumes/').pop();
186+
const sourceCert = source?.tlsCert
187+
? source.tlsCert?.split('volumes/').pop()
188+
: source?.clientKey?.split('volumes/').pop();
189+
const destMacaroon = destination.macaroon.split('volumes/').pop();
190+
const destCert = destination.tlsCert
191+
? destination.tlsCert?.split('volumes/').pop()
192+
: destination?.clientKey?.split('volumes/').pop();
193+
info({ sourceMacaroon, sourceCert, destMacaroon, destCert });
181194
nodes.add({
182195
id: activity.source.id,
183196
address: activity.source.address,
184-
macaroon: activity.source.macaroon,
185-
cert: activity.source.clientCert ?? activity.source.clientKey,
197+
macaroon: `/home/simln/.${sourceMacaroon}`,
198+
cert: `/home/simln/.${sourceCert}`,
186199
});
187200
nodes.add({
188201
id: activity.destination.id,
189202
address: activity.destination.address,
190-
macaroon: activity.destination.macaroon,
191-
cert: activity.destination.clientCert ?? activity.destination.clientKey,
203+
macaroon: `/home/simln/.${destMacaroon}`,
204+
cert: `/home/simln/.${destCert}`,
192205
});
193206

194207
activities.add({
@@ -200,7 +213,7 @@ class DockerService implements DockerLibrary {
200213
});
201214
return {
202215
nodes: Array.from(nodes),
203-
activities: Array.from(activities) as SimulationActivity[],
216+
activity: Array.from(activities) as SimulationActivity[],
204217
};
205218
}
206219

@@ -210,8 +223,9 @@ class DockerService implements DockerLibrary {
210223
*/
211224
async startSimulationActivity(network: Network) {
212225
const simJson = await this.constructSimJson(network);
213-
console.log('simJson', simJson);
214-
info(`simJson: ${simJson}`);
226+
info(
227+
`simJson: ${simJson} simJson.nodes: ${simJson.nodes} simJson.activities: ${simJson.activity}`,
228+
);
215229
await this.ensureDirs(network, [
216230
...network.nodes.bitcoin,
217231
...network.nodes.lightning,
@@ -234,8 +248,12 @@ class DockerService implements DockerLibrary {
234248
info(`Simulation activity stopped:\n ${result.out || result.err}`);
235249

236250
// remove container to avoid conflicts when starting the network again
237-
await this.execute(compose.rm as any, this.getArgs(network), 'simln');
238-
info(`Removed simln container`);
251+
const removedContainer = await this.execute(
252+
compose.rm as any,
253+
this.getArgs(network),
254+
'simln',
255+
);
256+
info(`Removed simln container ${removedContainer.out || removedContainer.err}`);
239257
}
240258

241259
/**

src/lib/docker/nodeTemplates.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ export const simln = (
1818
command: trimInside(command),
1919
environment,
2020
restart: 'always',
21-
volumes: [`./volumes/${name}:/home/simln/.simln`],
21+
volumes: [
22+
`./volumes/${name}:/home/simln/.simln`,
23+
`./volumes/${dockerConfigs.LND.volumeDirName}:/home/simln/.lnd`,
24+
`./volumes/${dockerConfigs['c-lightning'].volumeDirName}:/home/simln/.clightning`,
25+
],
2226
expose: [],
2327
ports: [],
2428
});

0 commit comments

Comments
 (0)