Skip to content

Commit

Permalink
Merge pull request #269 from luguslabs/multi-srv
Browse files Browse the repository at this point in the history
#268 add trustlines and centrifuge nodes support
  • Loading branch information
branciard authored Jan 2, 2021
2 parents 5f27502 + fb83fd1 commit 6bfc8cc
Show file tree
Hide file tree
Showing 8 changed files with 948 additions and 6 deletions.
53 changes: 53 additions & 0 deletions cli/src/centrifuge.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const {
validateSeed
} = require('./substrate');

// Necessary fields for polkadot service
const centrifugeFields = [
{
type: 'text',
name: 'granKey',
label: 'Gran Key',
env: 'CENTRIFUGE_KEY_GRAN',
},
{
type: 'text',
name: 'babeKey',
label: 'Babe Key',
env: 'CENTRIFUGE_KEY_BABE',
},
{
type: 'text',
name: 'imonKey',
label: 'Imon Key',
env: 'CENTRIFUGE_KEY_IMON',
},
{
type: 'text',
name: 'audiKey',
label: 'Audi Key',
env: 'CENTRIFUGE_KEY_AUDI',
},
];

// Validate CENTRIFUGE service configuration
const validateCentrifugeConfig = async fieldData => {
// Validate seeds
if (!await validateSeed(fieldData.granKey)) {
throw Error('granKey seed is not valid.');
}
if (!await validateSeed(fieldData.babeKey)) {
throw Error('babeKey seed is not valid.');
}
if (!await validateSeed(fieldData.imonKey)) {
throw Error('imonKey seed is not valid.');
}
if (!await validateSeed(fieldData.audiKey)) {
throw Error('audiKey seed is not valid.');
}
};

module.exports = {
centrifugeFields,
validateCentrifugeConfig
};
38 changes: 38 additions & 0 deletions cli/src/service.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { generateNodeIds } = require('./substrate');

const { validatePolkadotConfig, polkadotFields } = require('./polkadot');
const { validateCentrifugeConfig, centrifugeFields } = require('./centrifuge');

// Validate service config
const validateServicesConfig = async (configData) => {
Expand All @@ -13,6 +14,10 @@ const validateServicesConfig = async (configData) => {
for (const fields of service.fields) {
await validatePolkadotConfig(fields);
}
} else if(serviceName === 'centrifuge'){
for (const fields of service.fields) {
await validateCentrifugeConfig(fields);
}
} else {
throw Error(`Service ${configData.service} is not supported yet.`);
}
Expand Down Expand Up @@ -41,6 +46,22 @@ const generateServicesTemplate = (servicesName, instances) => {
}
service = { ...service, ...fieldsList };
template.services.push(service);
} else if(value === 'centrifuge'){
let service = {};
service.name = value;
let fieldsList = {};
fieldsList.fields = [];
var i;
for (i = 0; i < instances; i++) {
const fields = centrifugeFields.map((el) => el.name);
const fieldsObject = fields.reduce((result, item) => {
result[item] = '';
return result;
}, {});
fieldsList.fields.push(fieldsObject);
}
service = { ...service, ...fieldsList };
template.services.push(service);
} else {
throw Error(`Service ${value} is not supported yet.`);
}
Expand Down Expand Up @@ -73,6 +94,23 @@ const generateServicesConfig = async (configData, federationSize) => {
);
}, '')
.slice(0, -1);
} else if(serviceData.name === 'centrifuge'){
service.fields = await generateServiceFieldsConfig(
serviceData,
centrifugeFields
);
// Generate Service Node Ids
service.nodeIds = await generateNodeIds(serviceData.name, federationSize);
// Create reserved peers list
service.reservedPeersList = await service.nodeIds
.reduce((listArray, currentValue, currentIndex) => {
return listArray.concat(
`/ip4/10.0.1.${currentIndex + 1}/tcp/30333/p2p/${
currentValue.peerId
},`
);
}, '')
.slice(0, -1);
} else {
throw Error(`Service ${service.name} is not supported yet.`);
}
Expand Down
5 changes: 5 additions & 0 deletions deployer/archipel/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ RUN apt-get -y update && \
apt install -y resolvconf && \
apt clean

#installl a static curl
RUN wget https://github.com/moparisthebest/static-curl/releases/download/v7.74.0/curl-amd64
RUN mv curl-amd64 /usr/local/bin/curl-static
RUN chmod +x /usr/local/bin/curl-static

####################################
# import orchestrator
####################################
Expand Down
25 changes: 22 additions & 3 deletions doc/polkadot-keys-initialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Those keys will be used for the node identities in the federation and use for au

## Subkey Tool

Archipel and polkadot use [Substrate](https://substrate.dev/) framework. This framwork has a utility tool to generate keys. You will use it to facilitate the keys generation. The first step is to [download and install subkey](https://substrate.dev/docs/en/ecosystem/subkey#installation). Then check subkey installation and options available :
Archipel and polkadot use [Substrate](https://substrate.dev/) framework. This framwork has a utility tool to generate keys. You will use it to facilitate the keys generation. The first step is to [download and install subkey](https://substrate.dev/docs/en/knowledgebase/integrate/subkey). Then check subkey installation and options available :

```bash
subkey --version
Expand Down Expand Up @@ -134,6 +134,19 @@ subkey generate --network polkadot --scheme Sr25519 > polkadot-session-audi-sr25
cat polkadot-session-audi-sr25519.keys | grep phrase | cut -d"\`" -f2 > polkadot-session-audi.seed
```

#### Centrifuge Full steps session keys creation

```bash
subkey generate --network centrifuge --scheme Ed25519 > centrifuge-session-gran-ed25519.keys
cat centrifuge-session-gran-ed25519.keys | grep phrase | cut -d"\`" -f2 > centrifuge-session-gran.seed
subkey generate --network centrifuge --scheme Sr25519 > centrifuge-session-babe-sr25519.keys
cat centrifuge-session-babe-sr25519.keys | grep phrase | cut -d"\`" -f2 > centrifuge-session-babe.seed
subkey generate --network centrifuge --scheme Sr25519 > centrifuge-session-imon-sr25519.keys
cat centrifuge-session-imon-sr25519.keys | grep phrase | cut -d"\`" -f2 > centrifuge-session-imon.seed
subkey generate --network centrifuge --scheme Sr25519 > centrifuge-session-audi-sr25519.keys
cat centrifuge-session-audi-sr25519.keys | grep phrase | cut -d"\`" -f2 > centrifuge-session-audi.seed
```

### Matching Polkadot sessions files keys with Archipel env variables

```bash
Expand All @@ -159,13 +172,19 @@ Here how to extract the value from env varibale :
- KUSAMA

```bash
export ROTATE_KEY=$(cat kusama-session-gran-ed25519.keys | grep Public | cut -d":" -f2 | cut -c 4-)$(cat kusama-session-babe-sr25519.keys | grep Public | cut -d":" -f2 | cut -c 6-)$(cat kusama-session-imon-sr25519.keys | grep Public | cut -d":" -f2 | cut -c 6-)$(cat kusama-session-para-sr25519.keys | grep Public | cut -d":" -f2 | cut -c 6-)$(cat kusama-session-audi-sr25519.keys | grep Public | cut -d":" -f2 | cut -c 6-)
export ROTATE_KEY=$(cat kusama-session-gran-ed25519.keys | grep Public | cut -d":" -f2 | cut -c 4-)$(cat kusama-session-babe-sr25519.keys | grep Public | cut -d":" -f2 | cut -c 4-)$(cat kusama-session-imon-sr25519.keys | grep Public | cut -d":" -f2 | cut -c 4-)$(cat kusama-session-para-sr25519.keys | grep Public | cut -d":" -f2 | cut -c 4-)$(cat kusama-session-audi-sr25519.keys | grep Public | cut -d":" -f2 | cut -c 4-)
```

- POLKADOT

```bash
export ROTATE_KEY=$(cat polkadot-session-gran-ed25519.keys | grep Public | cut -d":" -f2 | cut -c 4-)$(cat polkadot-session-babe-sr25519.keys | grep Public | cut -d":" -f2 | cut -c 6-)$(cat polkadot-session-imon-sr25519.keys | grep Public | cut -d":" -f2 | cut -c 6-)$(cat polkadot-session-para-sr25519.keys | grep Public | cut -d":" -f2 | cut -c 6-)$(cat polkadot-session-audi-sr25519.keys | grep Public | cut -d":" -f2 | cut -c 6-)
export ROTATE_KEY=$(cat polkadot-session-gran-ed25519.keys | grep Public | cut -d":" -f2 | cut -c 4-)$(cat polkadot-session-babe-sr25519.keys | grep Public | cut -d":" -f2 | cut -c 4-)$(cat polkadot-session-imon-sr25519.keys | grep Public | cut -d":" -f2 | cut -c 4-)$(cat polkadot-session-para-sr25519.keys | grep Public | cut -d":" -f2 | cut -c 4-)$(cat polkadot-session-audi-sr25519.keys | grep Public | cut -d":" -f2 | cut -c 4-)
```

- CENTRIFUGE

```bash
export ROTATE_KEY=$(cat centrifuge-session-gran-ed25519.keys | grep Public | cut -d":" -f2 | cut -c 4-)$(cat centrifuge-session-babe-sr25519.keys | grep Public | cut -d":" -f2 | cut -c 4-)$(cat centrifuge-session-imon-sr25519.keys | grep Public | cut -d":" -f2 | cut -c 4-)$(cat centrifuge-session-audi-sr25519.keys | grep Public | cut -d":" -f2 | cut -c 4-)
```

### Check 5 sesssion keys correctly installed on your node with ROTATE_KEY value check
Expand Down
Loading

0 comments on commit 6bfc8cc

Please sign in to comment.