Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Blox SSV config formatting #586

Merged
merged 1 commit into from
Jul 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion launcher/src/backend/NodeConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ export class NodeConnection {
*/
async playbookStatus(playbookRunRef) {
return new Promise(async (resolve, reject) => {
log.info("playbook status of ref ", playbookRunRef);
log.debug("playbook status of ref ", playbookRunRef);

let statusResult;
try {
Expand Down
5 changes: 1 addition & 4 deletions launcher/src/backend/OneClickInstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,10 @@ export class OneClickInstall {
await this.nodeConnection.runPlaybook('ssv-key-generator', { stereum_role: 'ssv-key-generator', ssv_key_service: this.validatorService.id })
const config = await this.nodeConnection.readServiceConfiguration(this.validatorService.id)
let ssvConfig = this.validatorService.getServiceConfiguration(this.networkHandler(false), [this.executionClient], [this.beaconService])
ssvConfig.OperatorPrivateKey = config.ssv_sk

// prepare service's config file
const dataDir = (this.validatorService.volumes.find(vol => vol.servicePath === '/data')).destinationPath
const configFile = new YAML.Document()
configFile.contents = ssvConfig
const escapedConfigFile = StringUtils.escapeStringForShell(configFile.toString())
const escapedConfigFile = StringUtils.escapeStringForShell(ssvConfig.replace(/^OperatorPrivateKey.*/gm,"OperatorPrivateKey: \"" + config.ssv_sk + "\""))
this.nodeConnection.sshService.exec(`mkdir -p ${dataDir} && echo ${escapedConfigFile} > ${dataDir}/config.yaml`)
}

Expand Down
7 changes: 2 additions & 5 deletions launcher/src/backend/ValidatorAccountManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,9 @@ export class ValidatorAccountManager {
return new Promise(async (resolve, reject) => {
try {
const dataDir = (service.config.volumes.find(vol => vol.servicePath === '/data')).destinationPath
let bloxConfig = YAML.parse((await this.nodeConnection.sshService.exec(`cat ${dataDir}/config.yaml`)).stdout)
let bloxConfig = (await this.nodeConnection.sshService.exec(`cat ${dataDir}/config.yaml`)).stdout
if (bloxConfig) {
bloxConfig.OperatorPrivateKey = sk
const newConfig = new YAML.Document()
newConfig.contents = bloxConfig
const escapedConfigFile = StringUtils.escapeStringForShell(newConfig.toString())
const escapedConfigFile = StringUtils.escapeStringForShell(bloxConfig.replace(/^OperatorPrivateKey.*/gm,"OperatorPrivateKey: \"" + sk + "\""))
await this.nodeConnection.sshService.exec(`echo ${escapedConfigFile} > ${dataDir}/config.yaml`)

await this.serviceManager.manageServiceState(service.config.serviceID, 'stopped')
Expand Down
25 changes: 10 additions & 15 deletions launcher/src/backend/ethereum-services/BloxSSVService.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,16 @@ global:
LogLevel: "debug"
MetricsAPIPort: 15000
*/
return {
eth2: {
Network: network,
BeaconNodeAddr: consensusClients.map(client => client.buildConsensusClientHttpEndpointUrl())[0]
},
eth1: {
ETH1Addr: executionClients.map(client => client.buildExecutionClientHttpEndpointUrl())[0],
RegistryContractAddr: ''
},
OperatorPrivateKey: '', // somehow generate them?
global: {
LogLevel: 'info'
},
MetricsAPIPort: 15000
}
return `eth2:
Network: "${network}"
BeaconNodeAddr: "${consensusClients.map(client => client.buildConsensusClientHttpEndpointUrl())[0]}"
eth1:
ETH1Addr: "${executionClients.map(client => client.buildExecutionClientWsEndpointUrl())[0]}"
RegistryContractAddr: "0x687fb596F3892904F879118e2113e1EEe8746C2E"
OperatorPrivateKey: ""
global:
LogLevel: info
MetricsAPIPort: 15000`
}

static buildByUserInput (network, ports, dir, executionClients, consensusClients) {
Expand Down
17 changes: 8 additions & 9 deletions launcher/src/backend/ethereum-services/BloxSSVService.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ test('buildConfiguration', () => {

jest.mock('./GethService')
const GethService = require('./GethService')
const mMock = jest.fn(() => { return 'http-endpoint-string' })
const mMock = jest.fn(() => { return 'ws-endpoint-string' })
GethService.GethService.mockImplementation(() => {
return {
buildExecutionClientHttpEndpointUrl: mMock,
buildExecutionClientWsEndpointUrl: mMock,
buildMinimalConfiguration: jest.fn(() => {
return {
id: 'geth-id',
Expand Down Expand Up @@ -56,10 +56,10 @@ test('buildConfiguration', () => {
test('getServiceConfiguration', () => {
jest.mock('./GethService')
const GethService = require('./GethService')
const mMock = jest.fn(() => { return 'http-endpoint-string' })
const mMock = jest.fn(() => { return 'ws-endpoint-string' })
GethService.GethService.mockImplementation(() => {
return {
buildExecutionClientHttpEndpointUrl: mMock
buildExecutionClientWsEndpointUrl: mMock
}
})

Expand All @@ -74,11 +74,10 @@ test('getServiceConfiguration', () => {

const bloxService = BloxSSVService.buildByUserInput(networks.prater, null, '/opt/stereum/ssv', [new GethService.GethService()], [new LighthouseBeaconService.LighthouseBeaconService()]).getServiceConfiguration(networks.prater, [new GethService.GethService()], [new LighthouseBeaconService.LighthouseBeaconService()])

expect(bloxService.MetricsAPIPort).toBeDefined()
expect(bloxService.eth2.Network).toMatch(/prater/)
expect(bloxService.eth2.BeaconNodeAddr).toMatch(/http-lh-endpoint-string/)
expect(bloxService.eth1.ETH1Addr).toMatch(/http-endpoint-string/)
expect(bloxService.OperatorPrivateKey).toBeDefined()
expect(bloxService).toBeDefined()
expect(bloxService).toMatch(/prater/)
expect(bloxService).toMatch(/http-lh-endpoint-string/)
expect(bloxService).toMatch(/ws-endpoint-string/)
})

test('getAvailablePorts', () => {
Expand Down
2 changes: 1 addition & 1 deletion launcher/src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import promiseIpc from "electron-promise-ipc";
import path from "path";
import { readFileSync } from "fs";
import url from "url";
import { captureRejectionSymbol } from "events";
const isDevelopment = process.env.NODE_ENV !== "production";
const stereumService = new StereumService();
const storageService = new StorageService();
Expand All @@ -31,6 +30,7 @@ const validatorAccountManager = new ValidatorAccountManager(

const log = require("electron-log");
log.transports.console.level = "info"
log.transports.file.level = "info"

let remoteHost = {};

Expand Down