Skip to content

Commit

Permalink
beneficiaryAddress set to use the node's main account (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
fboucquez authored Mar 22, 2021
1 parent faab54f commit 82d51b7
Show file tree
Hide file tree
Showing 17 changed files with 40 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ The changelog format is based on [Keep a Changelog](https://keepachangelog.com/e
- Random and limited peer/api list.
- Custom `votingUnfinalizedBlocksDuration` and `nonVotingUnfinalizedBlocksDuration` preset properties.
- Agent service is disabled until supernode program resumes.
- The default `beneficiaryAddress` is the node's main address. Use `beneficiaryAddress: ''` in a custom preset to override the new default.

## [1.0.0] - Mar-16-2021

Expand Down
1 change: 1 addition & 0 deletions presets/bootstrap/network.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ currencyName: 'currency'
harvestingName: 'harvest'
explorerUrl: http://localhost:90/
faucetUrl: http://localhost:100/
beneficiaryAddress: ''
nemesis:
mosaics:
- name: '{{currencyName}}'
Expand Down
1 change: 0 additions & 1 deletion presets/shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ transactionElementTraceInterval: 10
enableDispatcherAbortWhenFull: false
enableDispatcherInputAuditing: false
maxTrackedNodes: 5'000
beneficiaryAddress: ''
enableAutoHarvesting: true
fileDatabaseBatchSize: 1
maxUnlockedAccounts: 10
Expand Down
2 changes: 2 additions & 0 deletions src/model/ConfigPreset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export interface NodePreset extends DockerServicePreset {
host?: string;
roles?: string;
friendlyName?: string;
beneficiaryAddress?: string;

// Optional private keys. If not provided, bootstrap will generate random ones.
mainPrivateKey?: string;
Expand Down Expand Up @@ -175,6 +176,7 @@ export interface ConfigPreset {
harvestNetworkFeeSinkAddress?: string;
mosaicRentalFeeSinkAddress?: string;
namespaceRentalFeeSinkAddress?: string;
beneficiaryAddress?: string;
nodeUseRemoteAccount: boolean;
networkheight: boolean;
dockerComposeVersion: number | string;
Expand Down
2 changes: 2 additions & 0 deletions src/service/ConfigService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ export class ConfigService {
'storing the harvesterVrfPrivateKey in the server properties',
);

const beneficiaryAddress = nodePreset.beneficiaryAddress || presetData.beneficiaryAddress;
const generatedContext = {
name: name,
friendlyName: nodePreset?.friendlyName || account.friendlyName,
Expand All @@ -314,6 +315,7 @@ export class ConfigService {
unfinalizedBlocksDuration: nodePreset.voting
? presetData.votingUnfinalizedBlocksDuration
: presetData.nonVotingUnfinalizedBlocksDuration,
beneficiaryAddress: beneficiaryAddress == undefined ? account.main.address : beneficiaryAddress,
};
const templateContext: any = { ...presetData, ...generatedContext, ...nodePreset };
const excludeFiles: string[] = [];
Expand Down
2 changes: 1 addition & 1 deletion test/reports/mainnet-dual-voting/node-config.csv
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ harvesterVrfPrivateKey; ********************************************************
enableAutoHarvesting; true; bool; Set to true if auto harvesting is enabled.
maxUnlockedAccounts; 10; uint32_t; Maximum number of unlocked accounts.
delegatePrioritizationPolicy; Importance; harvesting::DelegatePrioritizationPolicy; Delegate harvester prioritization policy.
beneficiaryAddress; ; Address; Address of the account receiving part of the harvested fee.
beneficiaryAddress; NDQ32MTJICEPJDU45KVN7BAM4A4GI7OARNBUUFY; Address; Address of the account receiving part of the harvested fee.


config-inflation.properties
Expand Down
2 changes: 1 addition & 1 deletion test/reports/mainnet-dual-voting/node-config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ config-harvesting.properties
enableAutoHarvesting; true; bool; Set to true if auto harvesting is enabled.
maxUnlockedAccounts; 10; uint32_t; Maximum number of unlocked accounts.
delegatePrioritizationPolicy; Importance; harvesting::DelegatePrioritizationPolicy; Delegate harvester prioritization policy.
beneficiaryAddress; ; Address; Address of the account receiving part of the harvested fee.
beneficiaryAddress; NDQ32MTJICEPJDU45KVN7BAM4A4GI7OARNBUUFY; Address; Address of the account receiving part of the harvested fee.

config-inflation.properties
===========================
Expand Down
2 changes: 1 addition & 1 deletion test/reports/mainnet-dual/node-config.csv
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ harvesterVrfPrivateKey; ********************************************************
enableAutoHarvesting; true; bool; Set to true if auto harvesting is enabled.
maxUnlockedAccounts; 10; uint32_t; Maximum number of unlocked accounts.
delegatePrioritizationPolicy; Importance; harvesting::DelegatePrioritizationPolicy; Delegate harvester prioritization policy.
beneficiaryAddress; ; Address; Address of the account receiving part of the harvested fee.
beneficiaryAddress; NDQ32MTJICEPJDU45KVN7BAM4A4GI7OARNBUUFY; Address; Address of the account receiving part of the harvested fee.


config-inflation.properties
Expand Down
2 changes: 1 addition & 1 deletion test/reports/mainnet-dual/node-config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ config-harvesting.properties
enableAutoHarvesting; true; bool; Set to true if auto harvesting is enabled.
maxUnlockedAccounts; 10; uint32_t; Maximum number of unlocked accounts.
delegatePrioritizationPolicy; Importance; harvesting::DelegatePrioritizationPolicy; Delegate harvester prioritization policy.
beneficiaryAddress; ; Address; Address of the account receiving part of the harvested fee.
beneficiaryAddress; NDQ32MTJICEPJDU45KVN7BAM4A4GI7OARNBUUFY; Address; Address of the account receiving part of the harvested fee.

config-inflation.properties
===========================
Expand Down
2 changes: 1 addition & 1 deletion test/reports/mainnet-peer/node-config.csv
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ harvesterVrfPrivateKey; ********************************************************
enableAutoHarvesting; true; bool; Set to true if auto harvesting is enabled.
maxUnlockedAccounts; 10; uint32_t; Maximum number of unlocked accounts.
delegatePrioritizationPolicy; Importance; harvesting::DelegatePrioritizationPolicy; Delegate harvester prioritization policy.
beneficiaryAddress; ; Address; Address of the account receiving part of the harvested fee.
beneficiaryAddress; NDQ32MTJICEPJDU45KVN7BAM4A4GI7OARNBUUFY; Address; Address of the account receiving part of the harvested fee.


config-inflation.properties
Expand Down
2 changes: 1 addition & 1 deletion test/reports/mainnet-peer/node-config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ config-harvesting.properties
enableAutoHarvesting; true; bool; Set to true if auto harvesting is enabled.
maxUnlockedAccounts; 10; uint32_t; Maximum number of unlocked accounts.
delegatePrioritizationPolicy; Importance; harvesting::DelegatePrioritizationPolicy; Delegate harvester prioritization policy.
beneficiaryAddress; ; Address; Address of the account receiving part of the harvested fee.
beneficiaryAddress; NDQ32MTJICEPJDU45KVN7BAM4A4GI7OARNBUUFY; Address; Address of the account receiving part of the harvested fee.

config-inflation.properties
===========================
Expand Down
2 changes: 1 addition & 1 deletion test/reports/testnet-dual-voting/api-node-config.csv
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ harvesterVrfPrivateKey; ********************************************************
enableAutoHarvesting; true; bool; Set to true if auto harvesting is enabled.
maxUnlockedAccounts; 10; uint32_t; Maximum number of unlocked accounts.
delegatePrioritizationPolicy; Importance; harvesting::DelegatePrioritizationPolicy; Delegate harvester prioritization policy.
beneficiaryAddress; ; Address; Address of the account receiving part of the harvested fee.
beneficiaryAddress; TDQ32MTJICEPJDU45KVN7BAM4A4GI7OARMLVSXQ; Address; Address of the account receiving part of the harvested fee.


config-inflation.properties
Expand Down
2 changes: 1 addition & 1 deletion test/reports/testnet-dual-voting/api-node-config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ config-harvesting.properties
enableAutoHarvesting; true; bool; Set to true if auto harvesting is enabled.
maxUnlockedAccounts; 10; uint32_t; Maximum number of unlocked accounts.
delegatePrioritizationPolicy; Importance; harvesting::DelegatePrioritizationPolicy; Delegate harvester prioritization policy.
beneficiaryAddress; ; Address; Address of the account receiving part of the harvested fee.
beneficiaryAddress; TDQ32MTJICEPJDU45KVN7BAM4A4GI7OARMLVSXQ; Address; Address of the account receiving part of the harvested fee.

config-inflation.properties
===========================
Expand Down
2 changes: 1 addition & 1 deletion test/reports/testnet-peer-voting/peer-node-config.csv
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ harvesterVrfPrivateKey; ********************************************************
enableAutoHarvesting; true; bool; Set to true if auto harvesting is enabled.
maxUnlockedAccounts; 10; uint32_t; Maximum number of unlocked accounts.
delegatePrioritizationPolicy; Importance; harvesting::DelegatePrioritizationPolicy; Delegate harvester prioritization policy.
beneficiaryAddress; ; Address; Address of the account receiving part of the harvested fee.
beneficiaryAddress; TDQ32MTJICEPJDU45KVN7BAM4A4GI7OARMLVSXQ; Address; Address of the account receiving part of the harvested fee.


config-inflation.properties
Expand Down
2 changes: 1 addition & 1 deletion test/reports/testnet-peer-voting/peer-node-config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ config-harvesting.properties
enableAutoHarvesting; true; bool; Set to true if auto harvesting is enabled.
maxUnlockedAccounts; 10; uint32_t; Maximum number of unlocked accounts.
delegatePrioritizationPolicy; Importance; harvesting::DelegatePrioritizationPolicy; Delegate harvester prioritization policy.
beneficiaryAddress; ; Address; Address of the account receiving part of the harvested fee.
beneficiaryAddress; TDQ32MTJICEPJDU45KVN7BAM4A4GI7OARMLVSXQ; Address; Address of the account receiving part of the harvested fee.

config-inflation.properties
===========================
Expand Down
20 changes: 18 additions & 2 deletions test/service/BootstrapUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@

import { expect } from '@oclif/test';
import { statSync } from 'fs';
import * as _ from 'lodash';
import 'mocha';
import { it } from 'mocha';
import { totalmem } from 'os';
import { Account, Deadline, LinkAction, NetworkType, UInt64, VotingKeyLinkTransaction } from 'symbol-sdk';
import { BootstrapUtils } from '../../src/service';
import { CryptoUtils } from '../../src/service/CryptoUtils';
import { BootstrapUtils, CryptoUtils } from '../../src/service';
import assert = require('assert');

describe('BootstrapUtils', () => {
Expand Down Expand Up @@ -142,6 +142,22 @@ describe('BootstrapUtils', () => {
expect(CryptoUtils.encryptedCount(BootstrapUtils.loadYaml('test/encrypted.yml', false))).to.be.eq(6);
});

it('mergeTest', async () => {
const a = { a: 1, list: ['1', '1', '3'], c: 'A', beneficiaryAddress: 'abc' };
const b = { a: undefined, c: 'B' };
const c = { list: ['a', 'b'], a: undefined, c: 'C', beneficiaryAddress: '' };
const expected = {
a: 1,
beneficiaryAddress: '',
c: 'C',
list: ['a', 'b', '3'],
};

expect(_.merge(a, b, c)).deep.equals(expected);

expect(_.merge(a, b, c)).deep.equals(expected);
});

it('createVotingKeyTransaction v1 short key', async () => {
const networkType = NetworkType.PRIVATE;
const deadline = Deadline.createFromDTO('1');
Expand Down
6 changes: 6 additions & 0 deletions test/service/ReportService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ describe('ReportService', () => {
const customPresetObject = {
nodes: [
{
mainPrivateKey: 'CA82E7ADAF7AB729A5462A1BD5AA78632390634904A64EB1BB22295E2E1A1BDD',
voting: true,
friendlyName: 'myFriendlyName',
},
Expand All @@ -74,6 +75,7 @@ describe('ReportService', () => {
const customPresetObject = {
nodes: [
{
mainPrivateKey: 'CA82E7ADAF7AB729A5462A1BD5AA78632390634904A64EB1BB22295E2E1A1BDD',
voting: true,
friendlyName: 'myFriendlyName',
},
Expand All @@ -97,6 +99,7 @@ describe('ReportService', () => {
const customPresetObject = {
nodes: [
{
mainPrivateKey: 'CA82E7ADAF7AB729A5462A1BD5AA78632390634904A64EB1BB22295E2E1A1BDD',
voting: false,
friendlyName: 'myFriendlyName',
},
Expand All @@ -120,6 +123,7 @@ describe('ReportService', () => {
const customPresetObject = {
nodes: [
{
mainPrivateKey: 'CA82E7ADAF7AB729A5462A1BD5AA78632390634904A64EB1BB22295E2E1A1BDD',
voting: false,
friendlyName: 'myFriendlyName',
},
Expand All @@ -143,6 +147,7 @@ describe('ReportService', () => {
const customPresetObject = {
nodes: [
{
mainPrivateKey: 'CA82E7ADAF7AB729A5462A1BD5AA78632390634904A64EB1BB22295E2E1A1BDD',
voting: false,
friendlyName: 'myFriendlyName',
},
Expand All @@ -166,6 +171,7 @@ describe('ReportService', () => {
const customPresetObject = {
nodes: [
{
mainPrivateKey: 'CA82E7ADAF7AB729A5462A1BD5AA78632390634904A64EB1BB22295E2E1A1BDD',
voting: true,
friendlyName: 'myFriendlyName',
},
Expand Down

0 comments on commit 82d51b7

Please sign in to comment.