Skip to content

Commit 7340cb3

Browse files
Release 0.15.6 (#1506)
Fix for Resource temporarily unavailable error for CLN channel alias list Security fix for npm vulnerabilities
1 parent 8479235 commit 7340cb3

29 files changed

+5595
-5066
lines changed

.github/README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,17 @@ To download from master (*not recommended*):
5555
```
5656
$ git clone https://github.com/Ride-The-Lightning/RTL.git
5757
$ cd RTL
58-
$ npm install --omit=dev --legacy-peer-deps
58+
$ npm ci --omit=dev --legacy-peer-deps
5959
```
6060
#### Or: Update existing dependencies
6161
```
6262
$ cd RTL
6363
$ git reset --hard HEAD
6464
$ git clean -f -d
6565
$ git pull
66-
$ npm install --omit=dev --legacy-peer-deps
66+
$ npm ci --omit=dev --legacy-peer-deps
6767
```
6868

69-
#### Error on npm install
70-
If there is an error with `upstream dependency conflict` message then replace `npm install --omit=dev` with `npm install --omit=dev --legacy-peer-deps`.
71-
7269
### <a name="prep"></a>Prep for Execution
7370
RTL requires its own config file `RTL-Config.json`, to start the server and provide user authentication on the app.
7471

.github/docs/Core_lightning_setup.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ To download from master (*not recommended*):
3333
```
3434
$ git clone https://github.com/Ride-The-Lightning/RTL.git
3535
$ cd RTL
36-
$ npm install --omit=dev --legacy-peer-deps
36+
$ npm ci --omit=dev --legacy-peer-deps
3737
```
3838

3939
#### Or: Update existing build
@@ -42,12 +42,9 @@ $ cd RTL
4242
$ git reset --hard HEAD
4343
$ git clean -f -d
4444
$ git pull
45-
$ npm install --omit=dev --legacy-peer-deps
45+
$ npm ci --omit=dev --legacy-peer-deps
4646
```
4747

48-
#### Error on npm install
49-
If there is an error with `upstream dependency conflict` message then replace `npm install --omit=dev` with `npm install --omit=dev --legacy-peer-deps`.
50-
5148
### <a name="prep"></a>Prep for Execution
5249
RTL requires its own config file `RTL-Config.json`, to start the server and provide user authentication on the app
5350
* Rename the file `Sample-RTL-Config.json` to `RTL-Config.json` located at`./RTL`

.github/docs/Eclair_setup.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,17 @@ To download from master (*not recommended*) follow the below instructions:
2828
```
2929
$ git clone https://github.com/Ride-The-Lightning/RTL.git
3030
$ cd RTL
31-
$ npm install --omit=dev --legacy-peer-deps
31+
$ npm ci --omit=dev --legacy-peer-deps
3232
```
3333
#### Or: Update existing build
3434
```
3535
$ cd RTL
3636
$ git reset --hard HEAD
3737
$ git clean -f -d
3838
$ git pull
39-
$ npm install --omit=dev --legacy-peer-deps
39+
$ npm ci --omit=dev --legacy-peer-deps
4040
```
4141

42-
#### Error on npm install
43-
If there is an error with `upstream dependency conflict` message then replace `npm install --omit=dev` with `npm install --omit=dev --legacy-peer-deps`.
44-
4542
### <a name="prep"></a>Prep for Execution
4643
RTL requires its own config file `RTL-Config.json`, to start the server and provide user authentication on the app.
4744
* Rename the file `Sample-RTL-Config.json` to `RTL-Config.json` located at`./RTL`..

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ Contributions via code is the most sought after contribution and something we en
4343
* Pull the code from the release (current eg Release-0.12.2) branch into your local workspace via github commandline/GUI.
4444

4545
##### Install Dependencies
46-
* Assuming that nodejs (v14 & above) and npm are already installed on your local machine. Go into your RTL root folder and run `npm install`.
47-
* Use `npm install --legacy-peer-deps` if there is any dependency conflict.
46+
* Assuming that nodejs (v14 & above) and npm are already installed on your local machine. Go into your RTL root folder and run `npm ci`.
47+
* Use `npm ci --legacy-peer-deps` if there is any dependency conflict.
4848
* Sometimes after installation, user receives a message from npm to fix dependency vulnerability by running `npm audit fix`. Please do not follow this step as it can break some of the working RTL code on your machine. We audit and fix these vulnerabilities as soon as possible at our end.
4949

5050
##### Node Backend Server for Development

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ WORKDIR /RTL
77
COPY package.json /RTL/package.json
88
COPY package-lock.json /RTL/package-lock.json
99

10-
RUN npm install --legacy-peer-deps
10+
RUN npm ci --legacy-peer-deps
1111

1212
COPY . .
1313

backend/controllers/cln/channels.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ export const listPeerChannels = (req, res, next) => {
1414
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/listpeerchannels';
1515
request.post(options).then((body) => {
1616
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Peer Channels List Received', data: body.channels });
17-
return Promise.all(body.channels?.map((channel) => {
17+
const getPeerAliasesTasks = body.channels.map((channel) => () => {
1818
channel.to_them_msat = channel.total_msat - channel.to_us_msat;
19-
channel.balancedness = (channel.total_msat === 0) ? 1 : (1 - Math.abs((channel.to_us_msat - (channel.total_msat - channel.to_us_msat)) / channel.total_msat)).toFixed(3);
19+
channel.balancedness = (channel.total_msat === 0) ? 1 : (1 - Math.abs((channel.to_us_msat - channel.to_them_msat) / channel.total_msat)).toFixed(3);
2020
return getAlias(req.session.selectedNode, channel, 'peer_id');
21-
})).then((values) => {
21+
});
22+
common.runWithConcurrencyLimit(getPeerAliasesTasks, 20, () => {
2223
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Peer Channels List With Aliases Received', data: body.channels });
2324
return res.status(200).json(body.channels || []);
2425
});

backend/controllers/cln/network.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Common } from '../../utils/common.js';
44
let options = null;
55
const logger = Logger;
66
const common = Common;
7+
const aliasCache = new Map();
78
export const getRoute = (req, res, next) => {
89
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Network', msg: 'Getting Network Routes..' });
910
options = common.getOptions(req);
@@ -80,20 +81,28 @@ export const listNodes = (req, res, next) => {
8081
});
8182
};
8283
export const getAlias = (selNode, peer, id) => {
83-
options.url = selNode.settings.lnServerUrl + '/v1/listnodes';
84-
if (!peer[id]) {
84+
const peerId = peer[id];
85+
if (!peerId) {
8586
logger.log({ selectedNode: selNode, level: 'ERROR', fileName: 'Network', msg: 'Empty Peer ID' });
8687
peer.alias = '';
87-
return peer;
88+
return Promise.resolve(peer);
8889
}
89-
options.body = { id: peer[id] };
90+
if (aliasCache.has(peerId)) {
91+
peer.alias = aliasCache.get(peerId);
92+
return Promise.resolve(peer);
93+
}
94+
options.url = selNode.settings.lnServerUrl + '/v1/listnodes';
95+
options.body = { id: peerId };
9096
return request.post(options).then((body) => {
9197
logger.log({ selectedNode: selNode, level: 'DEBUG', fileName: 'Network', msg: 'Peer Alias Finished', data: body });
92-
peer.alias = body.nodes[0] && body.nodes[0].alias ? body.nodes[0].alias : peer[id].substring(0, 20);
98+
const alias = body.nodes?.[0]?.alias || peerId.substring(0, 20);
99+
aliasCache.set(peerId, alias);
100+
peer.alias = alias;
93101
return peer;
94102
}).catch((errRes) => {
95103
common.handleError(errRes, 'Network', 'Peer Alias Error', selNode);
96-
peer.alias = peer[id].substring(0, 20);
104+
const alias = peerId.substring(0, 20);
105+
peer.alias = alias;
97106
return peer;
98107
});
99108
};

backend/utils/common.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,39 @@ export class CommonService {
608608
const dataStr = foundDataLine ? foundDataLine.substring((foundDataLine.indexOf(search_string)) + search_string.length) : '{}';
609609
return JSON.parse(dataStr);
610610
};
611+
this.runWithConcurrencyLimit = (tasks, limit, done) => {
612+
const results = new Array(tasks.length);
613+
let nextIndex = 0;
614+
let activeCount = 0;
615+
const runNext = () => {
616+
if (nextIndex >= tasks.length) {
617+
if (activeCount === 0) {
618+
done(results); // all tasks are finished
619+
}
620+
return;
621+
}
622+
const currentIndex = nextIndex++;
623+
activeCount++;
624+
const task = tasks[currentIndex];
625+
if (typeof task !== 'function') {
626+
results[currentIndex] = { error: new Error('Invalid task at index ' + currentIndex) };
627+
activeCount--;
628+
runNext();
629+
return;
630+
}
631+
Promise.resolve().then(() => task()).then((result) => {
632+
results[currentIndex] = result;
633+
}).catch((err) => {
634+
results[currentIndex] = { error: err };
635+
}).finally(() => {
636+
activeCount--;
637+
runNext();
638+
});
639+
};
640+
for (let i = 0; i < limit && i < tasks.length; i++) {
641+
runNext();
642+
}
643+
};
611644
}
612645
}
613646
export const Common = new CommonService();

frontend/193.0e1a81316bbc29da.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

frontend/193.398f8f87a3703825.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)