Skip to content

Commit

Permalink
Merge pull request #209 from nemtech/dev
Browse files Browse the repository at this point in the history
Dev -> Main
  • Loading branch information
fboucquez committed Mar 24, 2021
2 parents 56e7018 + 2f86910 commit d38463f
Show file tree
Hide file tree
Showing 42 changed files with 2,274 additions and 171 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file.

The changelog format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [1.0.2] - Mar-24-2021

**Milestone**: Mainnet(1.0.0.0)

| Package | Version | Link |
| ---------------- | ------- | ------------------------------------------------------------------ |
| Symbol Bootstrap | v1.0.2 | [symbol-bootstrap](https://www.npmjs.com/package/symbol-bootstrap) |

- Fixed link (--unlink) command when voting properties changes.
- Broker ports (7902) are closed by default in compose.
- Peer role is selected based on `syncsource` configuration and not on the `harvesting` flag.

## [1.0.1] - Mar-22-2021

**Milestone**: Mainnet(1.0.0.0)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ $ npm install -g symbol-bootstrap
$ symbol-bootstrap COMMAND
running command...
$ symbol-bootstrap (-v|--version|version)
symbol-bootstrap/1.0.1 linux-x64 node-v10.24.0
symbol-bootstrap/1.0.2 linux-x64 node-v12.18.4
$ symbol-bootstrap --help [COMMAND]
USAGE
$ symbol-bootstrap COMMAND
Expand Down
2 changes: 1 addition & 1 deletion cmds/link-testnet-supernode-external-node.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
symbol-bootstrap link -t target/testnet-supernode --useKnownRestGateways $1 $2 $3 $4
symbol-bootstrap link -t target/testnet-supernode --useKnownRestGateways $1 $2 $3 $4 $5 $6 $7
2 changes: 1 addition & 1 deletion docs/clean.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ EXAMPLE
$ symbol-bootstrap clean
```

_See code: [src/commands/clean.ts](https://github.com/nemtech/symbol-bootstrap/blob/v1.0.1/src/commands/clean.ts)_
_See code: [src/commands/clean.ts](https://github.com/nemtech/symbol-bootstrap/blob/v1.0.2/src/commands/clean.ts)_
2 changes: 1 addition & 1 deletion docs/compose.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ EXAMPLE
$ symbol-bootstrap compose
```

_See code: [src/commands/compose.ts](https://github.com/nemtech/symbol-bootstrap/blob/v1.0.1/src/commands/compose.ts)_
_See code: [src/commands/compose.ts](https://github.com/nemtech/symbol-bootstrap/blob/v1.0.2/src/commands/compose.ts)_
2 changes: 1 addition & 1 deletion docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ EXAMPLES
$ echo "$MY_ENV_VAR_PASSWORD" | symbol-bootstrap config -p testnet -a dual
```

_See code: [src/commands/config.ts](https://github.com/nemtech/symbol-bootstrap/blob/v1.0.1/src/commands/config.ts)_
_See code: [src/commands/config.ts](https://github.com/nemtech/symbol-bootstrap/blob/v1.0.2/src/commands/config.ts)_
2 changes: 1 addition & 1 deletion docs/decrypt.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ EXAMPLES
plain-addresses.yml
```

_See code: [src/commands/decrypt.ts](https://github.com/nemtech/symbol-bootstrap/blob/v1.0.1/src/commands/decrypt.ts)_
_See code: [src/commands/decrypt.ts](https://github.com/nemtech/symbol-bootstrap/blob/v1.0.2/src/commands/decrypt.ts)_
2 changes: 1 addition & 1 deletion docs/encrypt.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ EXAMPLES
encrypted-custom-preset.yml
```

_See code: [src/commands/encrypt.ts](https://github.com/nemtech/symbol-bootstrap/blob/v1.0.1/src/commands/encrypt.ts)_
_See code: [src/commands/encrypt.ts](https://github.com/nemtech/symbol-bootstrap/blob/v1.0.2/src/commands/encrypt.ts)_
2 changes: 1 addition & 1 deletion docs/enrolRewardProgram.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ EXAMPLES
$ echo "$MY_ENV_VAR_PASSWORD" | symbol-bootstrap enrolRewardProgram --url http://external-rest:3000
```

_See code: [src/commands/enrolRewardProgram.ts](https://github.com/nemtech/symbol-bootstrap/blob/v1.0.1/src/commands/enrolRewardProgram.ts)_
_See code: [src/commands/enrolRewardProgram.ts](https://github.com/nemtech/symbol-bootstrap/blob/v1.0.2/src/commands/enrolRewardProgram.ts)_
2 changes: 1 addition & 1 deletion docs/healthCheck.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ EXAMPLE
$ symbol-bootstrap healthCheck
```

_See code: [src/commands/healthCheck.ts](https://github.com/nemtech/symbol-bootstrap/blob/v1.0.1/src/commands/healthCheck.ts)_
_See code: [src/commands/healthCheck.ts](https://github.com/nemtech/symbol-bootstrap/blob/v1.0.2/src/commands/healthCheck.ts)_
2 changes: 1 addition & 1 deletion docs/link.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ EXAMPLES
$ echo "$MY_ENV_VAR_PASSWORD" | symbol-bootstrap link --unlink --useKnownRestGateways
```

_See code: [src/commands/link.ts](https://github.com/nemtech/symbol-bootstrap/blob/v1.0.1/src/commands/link.ts)_
_See code: [src/commands/link.ts](https://github.com/nemtech/symbol-bootstrap/blob/v1.0.2/src/commands/link.ts)_
2 changes: 1 addition & 1 deletion docs/report.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ EXAMPLE
$ symbol-bootstrap report
```

_See code: [src/commands/report.ts](https://github.com/nemtech/symbol-bootstrap/blob/v1.0.1/src/commands/report.ts)_
_See code: [src/commands/report.ts](https://github.com/nemtech/symbol-bootstrap/blob/v1.0.2/src/commands/report.ts)_
2 changes: 1 addition & 1 deletion docs/resetData.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ EXAMPLE
$ symbol-bootstrap resetData
```

_See code: [src/commands/resetData.ts](https://github.com/nemtech/symbol-bootstrap/blob/v1.0.1/src/commands/resetData.ts)_
_See code: [src/commands/resetData.ts](https://github.com/nemtech/symbol-bootstrap/blob/v1.0.2/src/commands/resetData.ts)_
2 changes: 1 addition & 1 deletion docs/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ EXAMPLE
$ symbol-bootstrap run
```

_See code: [src/commands/run.ts](https://github.com/nemtech/symbol-bootstrap/blob/v1.0.1/src/commands/run.ts)_
_See code: [src/commands/run.ts](https://github.com/nemtech/symbol-bootstrap/blob/v1.0.2/src/commands/run.ts)_
2 changes: 1 addition & 1 deletion docs/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@ EXAMPLES
$ echo "$MY_ENV_VAR_PASSWORD" | symbol-bootstrap start -p testnet -a dual
```

_See code: [src/commands/start.ts](https://github.com/nemtech/symbol-bootstrap/blob/v1.0.1/src/commands/start.ts)_
_See code: [src/commands/start.ts](https://github.com/nemtech/symbol-bootstrap/blob/v1.0.2/src/commands/start.ts)_
2 changes: 1 addition & 1 deletion docs/stop.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ EXAMPLE
$ symbol-bootstrap stop
```

_See code: [src/commands/stop.ts](https://github.com/nemtech/symbol-bootstrap/blob/v1.0.1/src/commands/stop.ts)_
_See code: [src/commands/stop.ts](https://github.com/nemtech/symbol-bootstrap/blob/v1.0.2/src/commands/stop.ts)_
2 changes: 1 addition & 1 deletion presets/mainnet/assembly-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ nodes:
databaseHost: 'db'
brokerName: 'broker'
openPort: true
brokerOpenPort: true
brokerOpenPort: false
trustedHosts: 127.0.0.1, 172.20.0.25
localNetworks: 127.0.0.1, 172.20.0.25
gateways:
Expand Down
2 changes: 1 addition & 1 deletion presets/mainnet/assembly-dual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ nodes:
databaseHost: 'db'
brokerName: 'broker'
openPort: true
brokerOpenPort: true
brokerOpenPort: false
trustedHosts: 127.0.0.1, 172.20.0.25
localNetworks: 127.0.0.1, 172.20.0.25
gateways:
Expand Down
2 changes: 1 addition & 1 deletion presets/testnet/assembly-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ nodes:
databaseHost: 'db'
brokerName: 'api-broker'
openPort: true
brokerOpenPort: true
brokerOpenPort: false
trustedHosts: 127.0.0.1, 172.20.0.25
localNetworks: 127.0.0.1, 172.20.0.25
gateways:
Expand Down
2 changes: 1 addition & 1 deletion presets/testnet/assembly-dual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ nodes:
databaseHost: 'db'
brokerName: 'api-broker'
openPort: true
brokerOpenPort: true
brokerOpenPort: false
trustedHosts: 127.0.0.1, 172.20.0.25
localNetworks: 127.0.0.1, 172.20.0.25
gateways:
Expand Down
14 changes: 14 additions & 0 deletions src/model/ConfigPreset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export enum PrivateKeySecurityMode {
PROMPT_ALL = 'PROMPT_ALL',
}

export type DeepPartial<T> = {
[P in keyof T]?: DeepPartial<T[P]>;
};

export interface DockerServicePreset {
ipv4_address?: string;
openPort?: boolean | number | string;
Expand Down Expand Up @@ -71,6 +75,16 @@ export interface NodePreset extends DockerServicePreset {
api: boolean;
voting: boolean;

syncsource: boolean;
filespooling: boolean;
partialtransaction: boolean;
sinkType: 'Async' | 'Sync';
enableSingleThreadPool: boolean;
addressextraction: boolean;
mongo: boolean;
zeromq: boolean;
enableAutoSyncCleanup: boolean;

// At least these properties.
// If true, harvesterSigningPrivateKey != mainPrivateKey and harvesterSigningPrivateKey will be linked to mainPrivateKey
serverVersion?: string;
Expand Down
6 changes: 3 additions & 3 deletions src/service/BootstrapService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* limitations under the License.
*/

import { Addresses, ConfigPreset } from '../model';
import { DockerCompose } from '../model/DockerCompose';
import { Addresses, ConfigPreset, DockerCompose } from '../model';
import { BootstrapUtils } from './BootstrapUtils';
import { ComposeParams, ComposeService } from './ComposeService';
import { ConfigParams, ConfigResult, ConfigService } from './ConfigService';
import { LinkParams, LinkService } from './LinkService';
Expand All @@ -29,7 +29,7 @@ export type StartParams = ConfigParams & ComposeParams & RunParams;
* Main entry point for API integration.
*/
export class BootstrapService {
public constructor(private readonly root: string = './node_modules/symbol-bootstrap') {}
public constructor(private readonly root: string = BootstrapUtils.DEFAULT_ROOT_FOLDER) {}

/**
* It generates the configuration and nemesis for the provided preset
Expand Down
1 change: 1 addition & 0 deletions src/service/BootstrapUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export class BootstrapUtils {
private static readonly pulledImages: string[] = [];

public static readonly VERSION = version;
public static readonly DEFAULT_ROOT_FOLDER = BootstrapUtils.resolveRootFolder();

public static stopProcess = false;

Expand Down
100 changes: 53 additions & 47 deletions src/service/ConfigLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,16 @@ import { Account, Address, Convert, Crypto, MosaicId, MosaicNonce, NetworkType,
import { LogType } from '../logger';
import Logger from '../logger/Logger';
import LoggerFactory from '../logger/LoggerFactory';
import { Addresses, ConfigAccount, ConfigPreset, MosaicAccounts, NodeAccount, NodePreset, PrivateKeySecurityMode } from '../model';
import {
Addresses,
ConfigAccount,
ConfigPreset,
DeepPartial,
MosaicAccounts,
NodeAccount,
NodePreset,
PrivateKeySecurityMode,
} from '../model';
import { BootstrapUtils, KnownError, Migration, Password } from './BootstrapUtils';
import { CommandUtils } from './CommandUtils';
import { KeyName, Preset } from './ConfigService';
Expand Down Expand Up @@ -371,63 +380,60 @@ export class ConfigLoader {

public dynamicDefaultNodeConfiguration(nodes?: NodePreset[]): NodePreset[] {
return _.map(nodes || [], (node) => {
const roles = this.resolveRoles(node);
if (node.harvesting && node.api) {
return {
syncsource: true,
filespooling: true,
partialtransaction: true,
openPort: true,
sinkType: 'Async',
enableSingleThreadPool: false,
brokerOpenPort: true,
addressextraction: true,
enableAutoSyncCleanup: false,
mongo: true,
zeromq: true,
...node,
roles,
};
}
if (node.api) {
return {
sinkType: 'Async',
syncsource: false,
filespooling: true,
partialtransaction: true,
enableSingleThreadPool: false,
addressextraction: true,
mongo: true,
zeromq: true,
enableAutoSyncCleanup: false,
...node,
roles,
};
}
const expandedNodeConfiguration = { ...this.getDefaultConfiguration(node), ...node };
const roles = this.resolveRoles(expandedNodeConfiguration);
return { ...expandedNodeConfiguration, roles };
});
}

//peer only (harvesting or not).
private getDefaultConfiguration(node: NodePreset): DeepPartial<NodePreset> {
if (node.harvesting && node.api) {
return {
sinkType: 'Sync',
enableSingleThreadPool: true,
addressextraction: false,
mongo: false,
zeromq: false,
syncsource: true,
filespooling: false,
enableAutoSyncCleanup: true,
partialtransaction: false,
...node,
roles,
filespooling: true,
partialtransaction: true,
openPort: true,
sinkType: 'Async',
enableSingleThreadPool: false,
addressextraction: true,
enableAutoSyncCleanup: false,
mongo: true,
zeromq: true,
};
});
}
if (node.api) {
return {
sinkType: 'Async',
syncsource: false,
filespooling: true,
partialtransaction: true,
enableSingleThreadPool: false,
addressextraction: true,
mongo: true,
zeromq: true,
enableAutoSyncCleanup: false,
};
}
//peer only (harvesting or not).
return {
sinkType: 'Sync',
enableSingleThreadPool: true,
addressextraction: false,
mongo: false,
zeromq: false,
syncsource: true,
filespooling: false,
enableAutoSyncCleanup: true,
partialtransaction: false,
};
}

private resolveRoles(nodePreset: NodePreset): string {
if (nodePreset.roles) {
return nodePreset.roles;
}
const roles: string[] = [];
if (nodePreset.harvesting) {
if (nodePreset.syncsource) {
roles.push('Peer');
}
if (nodePreset.api) {
Expand Down
2 changes: 1 addition & 1 deletion src/service/ConfigService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ export class ConfigService {
presetData.peersP2PListLimit,
serverConfig,
NodeType.PEER_NODE,
(nodePresetData) => nodePresetData.harvesting && nodePresetData != nodePreset,
(nodePresetData) => nodePresetData.syncsource && nodePresetData != nodePreset,
'peers-p2p.json',
);
const peersApiFile = await this.generateP2PFile(
Expand Down
Loading

0 comments on commit d38463f

Please sign in to comment.